From 25fcd5666c01fcb63f8b3bc2580b6fb404c7554e Mon Sep 17 00:00:00 2001 From: Keno Fischer Date: Thu, 14 Nov 2024 05:49:40 +0000 Subject: [PATCH 1/2] Handle `:latestworld` expr These were added in https://github.com/JuliaLang/julia/pull/56523. This simply adds tracking for the world age to the interpreter, but does not use it for anything. JuliaInterpreter's current model of world age does not match Base anyway. We should fix that eventually, but it's probably easier to do that once https://github.com/JuliaLang/julia/pull/56509 and binding partitions are merged. --- src/interpret.jl | 2 ++ src/types.jl | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/interpret.jl b/src/interpret.jl index 979997a2..119524e2 100644 --- a/src/interpret.jl +++ b/src/interpret.jl @@ -550,6 +550,8 @@ function step_expr!(@nospecialize(recurse), frame::Frame, @nospecialize(node), i error("unexpected error statement ", node) elseif node.head === :incomplete error("incomplete statement ", node) + elseif node.head === :latestworld + frame.world = Base.get_world_counter() else rhs = eval_rhs(recurse, frame, node) end diff --git a/src/types.jl b/src/types.jl index 041a5b84..30590745 100644 --- a/src/types.jl +++ b/src/types.jl @@ -253,8 +253,10 @@ mutable struct Frame caller::Union{Frame,Nothing} callee::Union{Frame,Nothing} last_codeloc::Int + # TODO: This is incompletely implemented + world::UInt end -function Frame(framecode::FrameCode, framedata::FrameData, pc=1, caller=nothing) +function Frame(framecode::FrameCode, framedata::FrameData, pc=1, caller=nothing, world=Base.tls_world_age()) if length(junk_frames) > 0 frame = pop!(junk_frames) frame.framecode = framecode @@ -264,9 +266,10 @@ function Frame(framecode::FrameCode, framedata::FrameData, pc=1, caller=nothing) frame.caller = caller frame.callee = nothing frame.last_codeloc = 0 + frame.world = world return frame else - return Frame(framecode, framedata, pc, 1, caller, nothing, 0) + return Frame(framecode, framedata, pc, 1, caller, nothing, 0, world) end end """ From 049c09b4ada6aab9fe8f21489fd3b13932af2972 Mon Sep 17 00:00:00 2001 From: Keno Fischer Date: Thu, 14 Nov 2024 05:58:57 +0000 Subject: [PATCH 2/2] 1.6 compat --- src/types.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/types.jl b/src/types.jl index 30590745..ad935213 100644 --- a/src/types.jl +++ b/src/types.jl @@ -256,7 +256,8 @@ mutable struct Frame # TODO: This is incompletely implemented world::UInt end -function Frame(framecode::FrameCode, framedata::FrameData, pc=1, caller=nothing, world=Base.tls_world_age()) +function Frame(framecode::FrameCode, framedata::FrameData, pc=1, caller=nothing, + world=isdefined(Base, :tls_world_age) ? Base.tls_world_age() : Base.get_world_counter()) if length(junk_frames) > 0 frame = pop!(junk_frames) frame.framecode = framecode