Skip to content

Commit

Permalink
use invoke even if we failed to compute the ABI for it
Browse files Browse the repository at this point in the history
Inference (notably IRInterp) relies upon having this use an invoke not a
call, and it still does generate slightly better runtime code even
though inference failed here.
  • Loading branch information
vtjnash committed Nov 1, 2024
1 parent a7c8401 commit c21b1f7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 9 additions & 8 deletions base/compiler/ssair/inlining.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct SomeCase
end

struct InvokeCase
invoke::CodeInstance
invoke::Union{CodeInstance,MethodInstance}
effects::Effects
info::CallInfo
end
Expand Down Expand Up @@ -809,14 +809,15 @@ function compileable_specialization(mi::MethodInstance, effects::Effects,
end
end
code = get(code_cache(et.state), mi_invoke, nothing)
if code isa CodeInstance
add_inlining_edge!(et, mi) # to the dispatch lookup
if mi_invoke !== mi
add_invoke_edge!(et.state.edges, method.sig, mi_invoke) # add_inlining_edge to the invoke call, if that is different
end
return InvokeCase(code, effects, info)
if !(code isa CodeInstance)
#println("missing code for ", mi_invoke, " for ", mi)
code = mi_invoke
end
return nothing
add_inlining_edge!(et, mi) # to the dispatch lookup
if mi_invoke !== mi
add_invoke_edge!(et.state.edges, method.sig, mi_invoke) # add_inlining_edge to the invoke call, if that is different
end
return InvokeCase(code, effects, info)
end

struct InferredResult
Expand Down
2 changes: 2 additions & 0 deletions base/essentials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,7 @@ call obsolete versions of a function `f`.
Prior to Julia 1.9, this function was not exported, and was called as `Base.invokelatest`.
"""
function invokelatest(@nospecialize(f), @nospecialize args...; kwargs...)
@inline
kwargs = merge(NamedTuple(), kwargs)
if isempty(kwargs)
return Core._call_latest(f, args...)
Expand Down Expand Up @@ -1078,6 +1079,7 @@ of [`invokelatest`](@ref).
world age refers to system state unrelated to the main Julia session.
"""
function invoke_in_world(world::UInt, @nospecialize(f), @nospecialize args...; kwargs...)
@inline
kwargs = Base.merge(NamedTuple(), kwargs)
if isempty(kwargs)
return Core._call_in_world(world, f, args...)
Expand Down

0 comments on commit c21b1f7

Please sign in to comment.