diff --git a/src/interpret.jl b/src/interpret.jl index 56578942..ff8248dc 100644 --- a/src/interpret.jl +++ b/src/interpret.jl @@ -370,7 +370,6 @@ function maybe_assign!(frame, @nospecialize(stmt), @nospecialize(val)) end maybe_assign!(frame, @nospecialize(val)) = maybe_assign!(frame, pc_expr(frame), val) - function eval_rhs(@nospecialize(recurse), frame, node::Expr) head = node.head if head === :new @@ -399,6 +398,7 @@ function eval_rhs(@nospecialize(recurse), frame, node::Expr) val = (node.args[1]::QuoteNode).value return isa(val, Expr) ? copy(val) : val elseif head === :enter + # XXX This seems to be dead code return length(frame.framedata.exception_frames) elseif head === :boundscheck return true @@ -565,6 +565,9 @@ function step_expr!(@nospecialize(recurse), frame, @nospecialize(node), istoplev elseif istoplevel && isa(node, LineNumberNode) elseif istoplevel && isa(node, Symbol) rhs = getfield(moduleof(frame), node) + elseif @static (isdefined(Core.IR, :EnterNode) && true) && isa(node, Core.IR.EnterNode) + rhs = node.catch_dest + push!(data.exception_frames, rhs) else rhs = @lookup(frame, node) end diff --git a/src/optimize.jl b/src/optimize.jl index f5ac4bec..5d879470 100644 --- a/src/optimize.jl +++ b/src/optimize.jl @@ -54,12 +54,10 @@ function renumber_ssa!(stmts::Vector{Any}, ssalookup) stmts[i] = SSAValue(ssalookup[stmt.id]) elseif isa(stmt, NewSSAValue) stmts[i] = SSAValue(stmt.id) + elseif isexpr(stmt, :enter) + stmt.args[end] = jumplookup(ssalookup, stmt.args[1]::Int) elseif isa(stmt, Expr) - stmt = replace_ssa(stmt, ssalookup) - if stmt.head === :enter - stmt.args[end] = jumplookup(ssalookup, stmt.args[1]::Int) - end - stmts[i] = stmt + stmts[i] = replace_ssa(stmt, ssalookup) elseif isa(stmt, GotoIfNot) cond = stmt.cond if isa(cond, SSAValue) @@ -71,6 +69,8 @@ function renumber_ssa!(stmts::Vector{Any}, ssalookup) if isa(val, SSAValue) stmts[i] = ReturnNode(SSAValue(ssalookup[val.id])) end + elseif @static (isdefined(Core.IR, :EnterNode) && true) && isa(stmt, Core.IR.EnterNode) + stmts[i] = Core.IR.EnterNode(jumplookup(ssalookup, stmt.catch_dest)) end end return stmts