Skip to content

Commit 8272763

Browse files
oxinaboxvtjnash
authored andcommitted
internal: allow CodeInfo edges to be attached to MathodTable (#32779)
1 parent f928246 commit 8272763

File tree

1 file changed

+19
-22
lines changed

1 file changed

+19
-22
lines changed

base/compiler/typeinfer.jl

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -176,29 +176,26 @@ function store_backedges(frame::InferenceState)
176176
if !toplevel && (frame.cached || frame.parent !== nothing)
177177
caller = frame.result.linfo
178178
for edges in frame.stmt_edges
179-
edges === nothing && continue
180-
i = 1
181-
while i <= length(edges)
182-
to = edges[i]
183-
if isa(to, MethodInstance)
184-
ccall(:jl_method_instance_add_backedge, Cvoid, (Any, Any), to, caller)
185-
i += 1
186-
else
187-
typeassert(to, Core.MethodTable)
188-
typ = edges[i + 1]
189-
ccall(:jl_method_table_add_backedge, Cvoid, (Any, Any, Any), to, typ, caller)
190-
i += 2
191-
end
192-
end
179+
store_backedges(caller, edges)
193180
end
194-
edges = frame.src.edges
195-
if edges !== nothing
196-
edges = edges::Vector{MethodInstance}
197-
for edge in edges
198-
@assert isa(edge, MethodInstance)
199-
ccall(:jl_method_instance_add_backedge, Cvoid, (Any, Any), edge, caller)
200-
end
201-
frame.src.edges = nothing
181+
store_backedges(caller, frame.src.edges)
182+
frame.src.edges = nothing
183+
end
184+
end
185+
186+
store_backedges(caller, edges::Nothing) = nothing
187+
function store_backedges(caller, edges::Vector)
188+
i = 1
189+
while i <= length(edges)
190+
to = edges[i]
191+
if isa(to, MethodInstance)
192+
ccall(:jl_method_instance_add_backedge, Cvoid, (Any, Any), to, caller)
193+
i += 1
194+
else
195+
typeassert(to, Core.MethodTable)
196+
typ = edges[i + 1]
197+
ccall(:jl_method_table_add_backedge, Cvoid, (Any, Any, Any), to, typ, caller)
198+
i += 2
202199
end
203200
end
204201
end

0 commit comments

Comments
 (0)