• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

JuliaLang / julia / #37591

pending completion
#37591

push

local

web-flow
Allocation Profiler: Types for all allocations (#50337)

Pass the types to the allocator functions.

-------

Before this PR, we were missing the types for allocations in two cases:

1. allocations from codegen
2. allocations in `gc_managed_realloc_`

The second one is easy: those are always used for buffers, right?

For the first one: we extend the allocation functions called from
codegen, to take the type as a parameter, and set the tag there.

I kept the old interfaces around, since I think that they cannot be
removed due to supporting legacy code?

------

An example of the generated code:
```julia
  %ptls_field6 = getelementptr inbounds {}**, {}*** %4, i64 2
  %13 = bitcast {}*** %ptls_field6 to i8**
  %ptls_load78 = load i8*, i8** %13, align 8
  %box = call noalias nonnull dereferenceable(32) {}* @ijl_gc_pool_alloc_typed(i8* %ptls_load78, i32 1184, i32 32, i64 4366152144) #7
```

Fixes #43688.
Fixes #45268.

Co-authored-by: Valentin Churavy <vchuravy@users.noreply.github.com>

72755 of 84117 relevant lines covered (86.49%)

22738368.36 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

64.0
/base/docs/utils.jl
1
# This file is a part of Julia. License is MIT: https://julialang.org/license
2

3
# Text / HTML objects
4

5
import .Base: print, show, ==, hash
6

7
export HTML, @html_str
8

9
export HTML, Text
10

11
"""
12
`HTML(s)`: Create an object that renders `s` as html.
13

14
    HTML("<div>foo</div>")
15

16
You can also use a stream for large amounts of data:
17

18
    HTML() do io
19
      println(io, "<div>foo</div>")
20
    end
21

22
!!! warning
23
    `HTML` is currently exported to maintain
24
    backwards compatibility, but this export
25
    is deprecated. It is recommended to use
26
    this type as `Docs.HTML` or to explicitly
27
    import it from `Docs`.
28
"""
29
mutable struct HTML{T}
30
    content::T
2✔
31
end
32

33
function HTML(xs...)
×
34
    HTML() do io
×
35
        for x in xs
×
36
            print(io, x)
×
37
        end
×
38
    end
39
end
40

41
show(io::IO, ::MIME"text/html", h::HTML) = print(io, h.content)
×
42
show(io::IO, ::MIME"text/html", h::HTML{<:Function}) = h.content(io)
×
43

44
"""
45
    @html_str -> Docs.HTML
46

47
Create an `HTML` object from a literal string.
48

49
# Examples
50
```jldoctest
51
julia> html"Julia"
52
HTML{String}("Julia")
53
```
54
"""
55
macro html_str(s)
1✔
56
    :(HTML($s))
1✔
57
end
58

59
function catdoc(xs::HTML...)
1✔
60
    HTML() do io
1✔
61
        for x in xs
62
            show(io, MIME"text/html"(), x)
63
        end
64
    end
65
end
66

67
export Text, @text_str
68

69
"""
70
`Text(s)`: Create an object that renders `s` as plain text.
71

72
    Text("foo")
73

74
You can also use a stream for large amounts of data:
75

76
    Text() do io
77
      println(io, "foo")
78
    end
79

80
!!! warning
81
    `Text` is currently exported to maintain
82
    backwards compatibility, but this export
83
    is deprecated. It is recommended to use
84
    this type as `Docs.Text` or to explicitly
85
    import it from `Docs`.
86
"""
87
mutable struct Text{T}
88
    content::T
3✔
89
end
90

91
print(io::IO, t::Text) = print(io, t.content)
1✔
92
print(io::IO, t::Text{<:Function}) = t.content(io)
1✔
93
show(io::IO, t::Text) = print(io, t)
2✔
94

95
==(t1::T, t2::T) where {T<:Union{HTML,Text}} = t1.content == t2.content
×
96
hash(t::T, h::UInt) where {T<:Union{HTML,Text}} = hash(T, hash(t.content, h))
×
97

98
"""
99
    @text_str -> Docs.Text
100

101
Create a `Text` object from a literal string.
102

103
# Examples
104
```jldoctest
105
julia> text"Julia"
106
Julia
107
```
108
"""
109
macro text_str(s)
1✔
110
    :(Text($s))
1✔
111
end
112

113
function catdoc(xs::Text...)
1✔
114
    Text() do io
1✔
115
        for x in xs
1✔
116
            show(io, MIME"text/plain"(), x)
1✔
117
        end
1✔
118
    end
119
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc