Skip to content

Commit e807fdc

Browse files
authored
Lookup bindings in the latest world (#657)
Post-partitioning the executing world age matters for bindings lookup. JuliaInterpreter currently does not model world age correctly. That's a bigger issue. However, for now, just look up bindings in the latest world age, which mostly restores the unpartitioned behavior.
1 parent 443d672 commit e807fdc

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/interpret.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ isassign(frame::Frame) = isassign(frame, frame.pc)
22
isassign(frame::Frame, pc::Int) = (pc in frame.framecode.used)
33

44
lookup_var(frame::Frame, val::SSAValue) = frame.framedata.ssavalues[val.id]
5-
lookup_var(frame::Frame, ref::GlobalRef) = getfield(ref.mod, ref.name)
5+
lookup_var(frame::Frame, ref::GlobalRef) = invokelatest(getfield, ref.mod, ref.name)
66
function lookup_var(frame::Frame, slot::SlotNumber)
77
val = frame.framedata.locals[slot.id]
88
val !== nothing && return val.value
@@ -311,8 +311,8 @@ function evaluate_methoddef(frame::Frame, node::Expr)
311311
if f isa Symbol || f isa GlobalRef
312312
mod = f isa Symbol ? moduleof(frame) : f.mod
313313
name = f isa Symbol ? f : f.name
314-
if Base.isbindingresolved(mod, name) && isdefined(mod, name) # `isdefined` accesses the binding, making it impossible to create a new one
315-
f = getfield(mod, name)
314+
if Base.isbindingresolved(mod, name) && invokelatest(isdefined, mod, name) # `isdefined` accesses the binding, making it impossible to create a new one
315+
f = invokelatest(getfield, mod, name)
316316
else
317317
f = Core.eval(mod, Expr(:function, name)) # create a new function
318318
end

src/optimize.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ function smallest_ref(stmts, arg, idmin)
2424
end
2525

2626
function lookup_global_ref(a::GlobalRef)
27-
if Base.isbindingresolved(a.mod, a.name) && isdefined(a.mod, a.name) && isconst(a.mod, a.name)
28-
return QuoteNode(getfield(a.mod, a.name))
27+
if Base.isbindingresolved(a.mod, a.name) && invokelatest(isdefined, a.mod, a.name) && invokelatest(isconst, a.mod, a.name)
28+
return QuoteNode(invokelatest(getfield, a.mod, a.name))
2929
end
3030
return a
3131
end

0 commit comments

Comments
 (0)