Skip to content

Commit 96e9942

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 17aa423 commit 96e9942

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
@@ -1319,25 +1319,27 @@ function collectinvokes!(workqueue::CompilationQueue, ci::CodeInfo, sptypes::Vec
13191319
edge isa CodeInstance && isdefined(edge, :inferred) && push!(workqueue, edge)
13201320
end
13211321

1322+
invokelatest_queue === nothing && continue
13221323
if isexpr(stmt, :call)
13231324
farg = stmt.args[1]
13241325
!applicable(argextype, farg, ci, sptypes) && continue # TODO: Why is this failing during bootstrap
13251326
ftyp = widenconst(argextype(farg, ci, sptypes))
1326-
if ftyp <: Builtin
1327-
if Core.finalizer isa ftyp && length(stmt.args) == 3
1328-
finalizer = argextype(stmt.args[2], ci, sptypes)
1329-
obj = argextype(stmt.args[3], ci, sptypes)
1330-
atype = argtypes_to_type(Any[finalizer, obj])
1331-
1332-
invokelatest_queue === nothing && continue
1333-
let workqueue = invokelatest_queue
1334-
# make a best-effort attempt to enqueue the relevant code for the finalizer
1335-
mi = compileable_specialization_for_call(workqueue.interp, atype)
1336-
mi === nothing && continue
1337-
1338-
push!(workqueue, mi)
1339-
end
1340-
end
1327+
1328+
if ftyp === typeof(Core.finalizer) && length(stmt.args) == 3
1329+
finalizer = argextype(stmt.args[2], ci, sptypes)
1330+
obj = argextype(stmt.args[3], ci, sptypes)
1331+
atype = argtypes_to_type(Any[finalizer, obj])
1332+
else
1333+
# No dynamic dispatch to resolve / enqueue
1334+
continue
1335+
end
1336+
1337+
let workqueue = invokelatest_queue
1338+
# make a best-effort attempt to enqueue the relevant code for the finalizer
1339+
mi = compileable_specialization_for_call(workqueue.interp, atype)
1340+
mi === nothing && continue
1341+
1342+
push!(workqueue, mi)
13411343
end
13421344
end
13431345
# TODO: handle other StmtInfo like @cfunction and OpaqueClosure?

0 commit comments

Comments
 (0)