Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typemap: improve quality of leaf split #48925

Merged
merged 1 commit into from
Mar 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1070,29 +1070,31 @@ function visit(f, mt::Core.MethodTable)
nothing
end
function visit(f, mc::Core.TypeMapLevel)
if mc.targ !== nothing
e = mc.targ::Vector{Any}
function avisit(f, e::Array{Any,1})
for i in 2:2:length(e)
isassigned(e, i) && visit(f, e[i])
isassigned(e, i) || continue
ei = e[i]
if ei isa Vector{Any}
for j in 2:2:length(ei)
isassigned(ei, j) || continue
visit(f, ei[j])
end
else
visit(f, ei)
end
end
end
if mc.targ !== nothing
avisit(f, mc.targ::Vector{Any})
end
if mc.arg1 !== nothing
e = mc.arg1::Vector{Any}
for i in 2:2:length(e)
isassigned(e, i) && visit(f, e[i])
end
avisit(f, mc.arg1::Vector{Any})
end
if mc.tname !== nothing
e = mc.tname::Vector{Any}
for i in 2:2:length(e)
isassigned(e, i) && visit(f, e[i])
end
avisit(f, mc.tname::Vector{Any})
end
if mc.name1 !== nothing
e = mc.name1::Vector{Any}
for i in 2:2:length(e)
isassigned(e, i) && visit(f, e[i])
end
avisit(f, mc.name1::Vector{Any})
end
mc.list !== nothing && visit(f, mc.list)
mc.any !== nothing && visit(f, mc.any)
Expand Down
8 changes: 4 additions & 4 deletions src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -639,10 +639,10 @@ typedef struct _jl_typemap_level_t {
// next split may be on Type{T} as LeafTypes then TypeName's parents up to Any
// next split may be on LeafType
// next split may be on TypeName
_Atomic(jl_array_t*) arg1; // contains LeafType
_Atomic(jl_array_t*) targ; // contains Type{LeafType}
_Atomic(jl_array_t*) name1; // contains non-abstract TypeName, for parents up to (excluding) Any
_Atomic(jl_array_t*) tname; // contains a dict of Type{TypeName}, for parents up to Any
_Atomic(jl_array_t*) arg1; // contains LeafType (in a map of non-abstract TypeName)
_Atomic(jl_array_t*) targ; // contains Type{LeafType} (in a map of non-abstract TypeName)
_Atomic(jl_array_t*) name1; // a map for a map for TypeName, for parents up to (excluding) Any
_Atomic(jl_array_t*) tname; // a map for Type{TypeName}, for parents up to (including) Any
// next a linear list of things too complicated at this level for analysis (no more levels)
_Atomic(jl_typemap_entry_t*) linear;
// finally, start a new level if the type at offs is Any
Expand Down
Loading