Skip to content

Commit

Permalink
Merge pull request #93 from JuliaDebug/teh/fix_92
Browse files Browse the repository at this point in the history
 Run `objectid` in Compiled mode (fixes #92)
  • Loading branch information
timholy authored Mar 5, 2019
2 parents 5855707 + fd45431 commit 6d582e3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/JuliaInterpreter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

"""
Expand Down Expand Up @@ -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__()
Expand Down
6 changes: 6 additions & 0 deletions test/interpret.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions test/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 6d582e3

Please sign in to comment.