Skip to content

get rid of no-op "plain" #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/JuliaInterpreter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -534,8 +534,6 @@ function optimize!(code::CodeInfo, mod::Module)
return code
end

plain(stmt) = stmt

function prepare_locals(framecode, argvals::Vector{Any})
if isa(framecode.scope, Method)
meth, code = framecode.scope::Method, framecode.code
Expand Down Expand Up @@ -707,7 +705,7 @@ end

function maybe_step_through_wrapper!(stack)
length(stack[1].code.code.code) < 2 && return stack
last = plain(stack[1].code.code.code[end-1])
last = stack[1].code.code.code[end-1]
isexpr(last, :(=)) && (last = last.args[2])
stack1 = stack[1]
is_kw = stack1.code.scope isa Method && startswith(String(Base.unwrap_unionall(stack1.code.scope.sig).parameters[1].name.name), "#kw")
Expand Down
10 changes: 5 additions & 5 deletions src/interpret.jl
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ Step through statements of `frame` until the next statement satifies `predicate(
"""
function next_until!(f, stack, frame, pc::JuliaProgramCounter=frame.pc[], istoplevel::Bool=false)
while (pc = _step_expr!(stack, frame, pc, istoplevel)) != nothing
f(plain(pc_expr(frame, pc))) && (frame.pc[] = pc; return pc)
f(pc_expr(frame, pc)) && (frame.pc[] = pc; return pc)
end
return nothing
end
Expand Down Expand Up @@ -554,7 +554,7 @@ function find_used(code::CodeInfo)
used = BitSet()
stmts = code.code
for stmt in stmts
Core.Compiler.scan_ssa_use!(push!, used, plain(stmt))
Core.Compiler.scan_ssa_use!(push!, used, stmt)
if isexpr(stmt, :struct_type) # this one is missed
for a in stmt.args
Core.Compiler.scan_ssa_use!(push!, used, a)
Expand All @@ -580,7 +580,7 @@ function next_line!(stack, frame, dbstack = nothing)
while location(frame, pc) == initial
# If this is a return node, interrupt execution. This is the same
# special case as in `s`.
expr = plain(pc_expr(frame, pc))
expr = pc_expr(frame, pc)
(!first && isexpr(expr, :return)) && return pc
first = false
# If this is a goto node, step it and reevaluate
Expand All @@ -592,7 +592,7 @@ function next_line!(stack, frame, dbstack = nothing)
# confuses the logic here, just step into the first call that's not a builtin
while true
dbstack[1] = JuliaStackFrame(JuliaFrameCode(frame.code; wrapper = true), frame, pc)
call_expr = plain(pc_expr(frame, pc))
call_expr = pc_expr(frame, pc)
isexpr(call_expr, :(=)) && (call_expr = call_expr.args[2])
call_expr = Expr(:call, map(x->@lookup(frame, x), call_expr.args)...)
new_frame = enter_call_expr(call_expr)
Expand All @@ -617,7 +617,7 @@ end

function maybe_next_call!(stack, frame, pc)
call_or_return(node) = is_call(node) || isexpr(node, :return)
call_or_return(plain(pc_expr(frame, pc))) ||
call_or_return(pc_expr(frame, pc)) ||
(pc = next_until!(call_or_return, stack, frame, pc, false))
pc
end
Expand Down