Skip to content

Commit ce56baa

Browse files
committed
Collect invoke only for ftyp === typeof(finalizer)
Otherwise this will match `ftyp === Builtin`, which is pretty silly since that could just as well be any other built-in.
1 parent 27a8799 commit ce56baa

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

Compiler/src/typeinfer.jl

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,25 +1438,27 @@ function collectinvokes!(workqueue::CompilationQueue, ci::CodeInfo, sptypes::Vec
14381438
edge isa CodeInstance && isdefined(edge, :inferred) && push!(workqueue, edge)
14391439
end
14401440

1441+
invokelatest_queue === nothing && continue
14411442
if isexpr(stmt, :call)
14421443
farg = stmt.args[1]
14431444
!applicable(argextype, farg, ci, sptypes) && continue # TODO: Why is this failing during bootstrap
14441445
ftyp = widenconst(argextype(farg, ci, sptypes))
1445-
if ftyp <: Builtin
1446-
if Core.finalizer isa ftyp && length(stmt.args) == 3
1447-
finalizer = argextype(stmt.args[2], ci, sptypes)
1448-
obj = argextype(stmt.args[3], ci, sptypes)
1449-
atype = argtypes_to_type(Any[finalizer, obj])
1450-
1451-
invokelatest_queue === nothing && continue
1452-
let workqueue = invokelatest_queue
1453-
# make a best-effort attempt to enqueue the relevant code for the finalizer
1454-
mi = compileable_specialization_for_call(workqueue.interp, atype)
1455-
mi === nothing && continue
1456-
1457-
push!(workqueue, mi)
1458-
end
1459-
end
1446+
1447+
if ftyp === typeof(Core.finalizer) && length(stmt.args) == 3
1448+
finalizer = argextype(stmt.args[2], ci, sptypes)
1449+
obj = argextype(stmt.args[3], ci, sptypes)
1450+
atype = argtypes_to_type(Any[finalizer, obj])
1451+
else
1452+
# No dynamic dispatch to resolve / enqueue
1453+
continue
1454+
end
1455+
1456+
let workqueue = invokelatest_queue
1457+
# make a best-effort attempt to enqueue the relevant code for the finalizer
1458+
mi = compileable_specialization_for_call(workqueue.interp, atype)
1459+
mi === nothing && continue
1460+
1461+
push!(workqueue, mi)
14601462
end
14611463
end
14621464
# TODO: handle other StmtInfo like @cfunction and OpaqueClosure?

0 commit comments

Comments
 (0)