Skip to content

Commit 941c86e

Browse files
committed
1 parent 30ac9f5 commit 941c86e

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/Cthulhu.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,10 @@ function do_typeinf!(interp::CthulhuInterpreter, mi::MethodInstance)
430430
# we may want to handle the case when `InferenceState(...)` returns `nothing`,
431431
# which indicates code generation of a `@generated` has been failed,
432432
# and show it in the UI in some way ?
433-
frame = InferenceState(result, true, interp)::InferenceState
433+
# branch on https://github.com/JuliaLang/julia/pull/42082
434+
frame = @static hasmethod(InferenceState, (InferenceResult,Symbol,AbstractInterpreter)) ?
435+
InferenceState(result, #=cache=# :global, interp)::InferenceState :
436+
InferenceState(result, #=cached=# true, interp)::InferenceState
434437
Core.Compiler.typeinf(interp, frame)
435438
return nothing
436439
end

src/interpreter.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,19 @@ end
8484

8585
# branch on https://github.com/JuliaLang/julia/pull/41328
8686
@static if isdefined(Compiler, :is_stmt_inline)
87-
function Compiler.inlining_policy(interp::CthulhuInterpreter, @nospecialize(src), stmt_flag::UInt8)
87+
function Compiler.inlining_policy(
88+
interp::CthulhuInterpreter, @nospecialize(src), stmt_flag::UInt8,
89+
mi::MethodInstance, argtypes::Vector{Any})
8890
@assert isa(src, OptimizedSource) || isnothing(src)
8991
if isa(src, OptimizedSource)
9092
if Compiler.is_stmt_inline(stmt_flag) || src.isinlineable
9193
return src.ir
9294
end
95+
else
96+
# the default inlining policy may try additional effor to find the source in a local cache
97+
return Base.@invoke Compiler.inlining_policy(
98+
interp::AbstractInterpreter, nothing, stmt_flag::UInt8,
99+
mi::MethodInstance, argtypes::Vector{Any})
93100
end
94101
return nothing
95102
end

0 commit comments

Comments
 (0)