From 21c5d646865e7b0da26767869930be964e8ac134 Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Tue, 5 Mar 2019 05:41:16 -0600 Subject: [PATCH 1/2] Run `objectid` in Compiled mode (fixes #92) --- src/JuliaInterpreter.jl | 4 +++- test/interpret.jl | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/JuliaInterpreter.jl b/src/JuliaInterpreter.jl index f857425f49f4c9..4a16dcdaa6e0e8 100644 --- a/src/JuliaInterpreter.jl +++ b/src/JuliaInterpreter.jl @@ -174,7 +174,7 @@ struct Variable isparam::Bool end Base.show(io::IO, var::Variable) = print(io, var.name, " = ", var.value) -Base.isequal(var1::Variable, var2::Variable) = +Base.isequal(var1::Variable, var2::Variable) = var1.value == var2.value && var1.name == var2.name && var1.isparam == var2.isparam """ @@ -1148,6 +1148,8 @@ function set_compiled_methods() # issue #76 push!(compiled_methods, which(unsafe_store!, (Ptr{Any}, Any, Int))) push!(compiled_methods, which(unsafe_store!, (Ptr, Any, Int))) + # issue #92 + push!(compiled_methods, which(objectid, Tuple{Any})) end function __init__() diff --git a/test/interpret.jl b/test/interpret.jl index eb92b747bc3253..bb1e2cfaa2cfe1 100644 --- a/test/interpret.jl +++ b/test/interpret.jl @@ -271,6 +271,12 @@ let TT = Union{UInt8, Int8} @interpret unsafe_store!(pa, 0x1, 2) end +# issue #92 +let x = Core.TypedSlot(1, Any) + f(x) = objectid(x) + @test isa(@interpret(f(x)), UInt) +end + # Some expression can appear nontrivial but lower to nothing @test isa(JuliaInterpreter.prepare_thunk(Main, :(@static if ccall(:jl_get_UNAME, Any, ()) == :NoOS 1+1 end)), Nothing) @test isa(JuliaInterpreter.prepare_thunk(Main, :(Base.BaseDocs.@kw_str "using")), Nothing) From fd45431be336d1cd0bf79d1e9e9186c508dc2100 Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Tue, 5 Mar 2019 05:41:32 -0600 Subject: [PATCH 2/2] Update `handle_err` in utils.jl to new API --- test/utils.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/utils.jl b/test/utils.jl index fce319a61885b5..da631aa9658e39 100644 --- a/test/utils.jl +++ b/test/utils.jl @@ -58,7 +58,7 @@ function evaluate_limited!(stack, frame::JuliaStackFrame, nstmts::Int, pc::Julia do_assignment!(frame, lhs, rhs) new_pc = pc + 1 catch err - new_pc = handle_err(frame, err) + new_pc = handle_err(stack, frame, pc, err) end nstmts = refnstmts[] elseif stmt.head == :(=) && isexpr(stmt.args[2], :call) && !isa(stack, Compiled) @@ -69,7 +69,7 @@ function evaluate_limited!(stack, frame::JuliaStackFrame, nstmts::Int, pc::Julia do_assignment!(frame, stmt.args[1], rhs) new_pc = pc + 1 catch err - new_pc = handle_err(frame, err) + new_pc = handle_err(stack, frame, pc, err) end nstmts = refnstmts[] elseif stmt.head == :thunk