• 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

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

3
mutable struct MD
4
    content::Vector{Any}
5
    meta::Dict{Symbol, Any}
6

7
    MD(content::AbstractVector, meta::Dict = Dict()) =
17,693✔
8
        new(content, meta)
9
end
10

11
MD(xs...) = MD(vcat(xs...))
5,396✔
12

13
function MD(cfg::Config, xs...)
×
14
    md = MD(xs...)
5,299✔
15
    md.meta[:config] = cfg
5,299✔
16
    return md
5,299✔
17
end
18

19
config(md::MD) = md.meta[:config]::Config
22,644✔
20

21
# Forward some array methods
22

23
Base.push!(md::MD, x) = push!(md.content, x)
13,627✔
24
Base.getindex(md::MD, args...) = md.content[args...]
×
25
Base.setindex!(md::MD, args...) = setindex!(md.content, args...)
×
26
Base.lastindex(md::MD) = lastindex(md.content)
×
27
Base.firstindex(md::MD) = firstindex(md.content)
×
28
Base.length(md::MD) = length(md.content)
×
29
Base.isempty(md::MD) = isempty(md.content)
×
30
Base.copy(md::MD) = MD(copy(md.content), copy(md.meta))
×
31

32
==(a::MD, b::MD) = (html(a) == html(b))
5✔
33

34
# Parser functions:
35
#   md – should be modified appropriately
36
#   return – basically, true if parse was successful
37
#     false uses the next parser in the queue, true
38
#     goes back to the beginning
39
#
40
# Inner parsers:
41
#   return – element to use or nothing
42

43
# Inner parsing
44

45
function parseinline(stream::IO, md::MD, parsers::Vector{Function})
25,288✔
46
    for parser in parsers
25,288✔
47
        inner = parser(stream, md)
28,822✔
48
        inner ≡ nothing || return inner
51,985✔
49
    end
5,659✔
50
end
51

52
function parseinline(stream::IO, md::MD, config::Config)
13,079✔
53
    content = []
13,079✔
54
    buffer = IOBuffer()
13,079✔
55
    while !eof(stream)
942,291✔
56
        char = peek(stream, Char)
929,212✔
57
        if haskey(config.inner, char) &&
929,212✔
58
                (inner = parseinline(stream, md, config.inner[char])) !== nothing
59
            c = String(take!(buffer))
23,163✔
60
            !isempty(c) && push!(content, c)
23,163✔
61
            buffer = IOBuffer()
23,163✔
62
            push!(content, inner)
23,163✔
63
        else
64
            write(buffer, read(stream, Char))
906,049✔
65
        end
66
    end
929,212✔
67
    c = String(take!(buffer))
13,079✔
68
    !isempty(c) && push!(content, c)
13,079✔
69
    return content
13,079✔
70
end
71

72
parseinline(s::AbstractString, md::MD, c::Config) =
3,765✔
73
    parseinline(IOBuffer(s), md, c)
74

75
parseinline(s, md::MD) = parseinline(s, md, config(md))
13,079✔
76

77
# Block parsing
78

79
function parse(stream::IO, block::MD, config::Config; breaking = false)
58,262✔
80
    skipblank(stream)
29,131✔
81
    eof(stream) && return false
29,131✔
82
    for parser in (breaking ? config.breaking : [config.breaking; config.regular])
23,832✔
83
        parser(stream, block) && return true
182,922✔
84
    end
176,634✔
85
    return false
8,772✔
86
end
87

88
parse(stream::IO, block::MD; breaking = false) =
18,032✔
89
  parse(stream, block, config(block), breaking = breaking)
90

91
function parse(stream::IO; flavor = julia)
10,598✔
92
    isa(flavor, Symbol) && (flavor = flavors[flavor])
×
93
    markdown = MD(flavor)
5,299✔
94
    while parse(stream, markdown, flavor) end
34,931✔
95
    return markdown
5,299✔
96
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

© 2025 Coveralls, Inc