• 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

38.38
/stdlib/Markdown/src/render/html.jl
1
# This file is a part of Julia. License is MIT: https://julialang.org/license
2

3
include("rich.jl")
4

5
# Utils
6

7
function withtag(f, io::IO, tag, attrs...)
22✔
8
    print(io, "<$tag")
22✔
9
    for (attr, value) in attrs
22✔
10
        print(io, " ")
×
11
        htmlesc(io, attr)
×
12
        print(io, "=\"")
×
13
        htmlesc(io, value)
×
14
        print(io, "\"")
×
15
    end
×
16
    f === nothing && return print(io, " />")
22✔
17

18
    print(io, ">")
22✔
19
    f()
24✔
20
    print(io, "</$tag>")
22✔
21
end
22

23
tag(io::IO, tag, attrs...) = withtag(nothing, io, tag, attrs...)
×
24

25
const _htmlescape_chars = Dict('<'=>"&lt;",   '>'=>"&gt;",
26
                               '"'=>"&quot;", '&'=>"&amp;",
27
                               # ' '=>"&nbsp;",
28
                               )
29
for ch in "'`!\$%()=+{}[]"
30
    _htmlescape_chars[ch] = "&#$(Int(ch));"
31
end
32

33
function htmlesc(io::IO, s::AbstractString)
12✔
34
    # s1 = replace(s, r"&(?!(\w+|\#\d+);)" => "&amp;")
35
    for ch in s
24✔
36
        print(io, get(_htmlescape_chars, ch, ch))
120✔
37
    end
116✔
38
end
39
function htmlesc(io::IO, s::Symbol)
×
40
    htmlesc(io, string(s))
×
41
end
42
function htmlesc(io::IO, xs::Union{AbstractString,Symbol}...)
×
43
    for s in xs
×
44
        htmlesc(io, s)
×
45
    end
×
46
end
47
function htmlesc(s::Union{AbstractString,Symbol})
×
48
    sprint(htmlesc, s)
×
49
end
50

51
# Block elements
52

53
function html(io::IO, content::Vector)
10✔
54
    for md in content
10✔
55
        html(io, md)
16✔
56
        println(io)
16✔
57
    end
16✔
58
end
59

60
html(io::IO, md::MD) = html(io, md.content)
10✔
61

62
function html(io::IO, header::Header{l}) where l
10✔
63
    withtag(io, "h$l") do
10✔
64
        htmlinline(io, header.text)
10✔
65
    end
66
end
67

68
function html(io::IO, code::Code)
2✔
69
    withtag(io, :pre) do
2✔
70
        maybe_lang = !isempty(code.language) ? Any[:class=>"language-$(code.language)"] : []
4✔
71
        withtag(io, :code, maybe_lang...) do
2✔
72
            htmlesc(io, code.code)
2✔
73
            # TODO should print newline if this is longer than one line ?
74
        end
75
    end
76
end
77

78
function html(io::IO, md::Paragraph)
4✔
79
    withtag(io, :p) do
4✔
80
        htmlinline(io, md.content)
4✔
81
    end
82
end
83

84
function html(io::IO, md::BlockQuote)
×
85
    withtag(io, :blockquote) do
×
86
        println(io)
×
87
        html(io, md.content)
×
88
    end
89
end
90

91
function html(io::IO, f::Footnote)
×
92
    withtag(io, :div, :class => "footnote", :id => "footnote-$(f.id)") do
×
93
        withtag(io, :p, :class => "footnote-title") do
×
94
            print(io, f.id)
×
95
        end
96
        html(io, f.text)
×
97
    end
98
end
99

100
function html(io::IO, md::Admonition)
×
101
    withtag(io, :div, :class => "admonition $(md.category)") do
×
102
        withtag(io, :p, :class => "admonition-title") do
×
103
            print(io, md.title)
×
104
        end
105
        html(io, md.content)
×
106
    end
107
end
108

109
function html(io::IO, md::List)
×
110
    maybe_attr = md.ordered > 1 ? Any[:start => string(md.ordered)] : []
×
111
    withtag(io, isordered(md) ? :ol : :ul, maybe_attr...) do
×
112
        for item in md.items
×
113
            println(io)
×
114
            withtag(io, :li) do
×
115
                html(io, item)
×
116
            end
117
        end
×
118
        println(io)
×
119
    end
120
end
121

122
function html(io::IO, md::HorizontalRule)
×
123
    tag(io, :hr)
×
124
end
125

126
html(io::IO, x) = tohtml(io, x)
×
127

128
# Inline elements
129

130
function htmlinline(io::IO, content::Vector)
14✔
131
    for x in content
18✔
132
        htmlinline(io, x)
10✔
133
    end
10✔
134
end
135

136
function htmlinline(io::IO, code::Code)
4✔
137
    withtag(io, :code) do
4✔
138
        htmlesc(io, code.code)
4✔
139
    end
140
end
141

142
function htmlinline(io::IO, md::Union{Symbol,AbstractString})
6✔
143
    htmlesc(io, md)
6✔
144
end
145

146
function htmlinline(io::IO, md::Bold)
×
147
    withtag(io, :strong) do
×
148
        htmlinline(io, md.text)
×
149
    end
150
end
151

152
function htmlinline(io::IO, md::Italic)
×
153
    withtag(io, :em) do
×
154
        htmlinline(io, md.text)
×
155
    end
156
end
157

158
function htmlinline(io::IO, md::Image)
×
159
    tag(io, :img, :src=>md.url, :alt=>md.alt)
×
160
end
161

162

163
function htmlinline(io::IO, f::Footnote)
×
164
    withtag(io, :a, :href => "#footnote-$(f.id)", :class => "footnote") do
×
165
        print(io, "[", f.id, "]")
×
166
    end
167
end
168

169
function htmlinline(io::IO, link::Link)
×
170
    withtag(io, :a, :href=>link.url) do
×
171
        htmlinline(io, link.text)
×
172
    end
173
end
174

175
function htmlinline(io::IO, br::LineBreak)
×
176
    tag(io, :br)
×
177
end
178

179
htmlinline(io::IO, x) = tohtml(io, x)
×
180

181
# API
182

183
export html
184

185
html(md) = sprint(html, md)
10✔
186

187
function show(io::IO, ::MIME"text/html", md::MD)
×
188
    withtag(io, :div, :class=>"markdown") do
×
189
        html(io, md)
×
190
    end
191
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