Skip to content

Commit

Permalink
Merge pull request #16379 from JuliaLang/jb/exprcopy
Browse files Browse the repository at this point in the history
only copy Exprs when copying IR
  • Loading branch information
vtjnash committed May 16, 2016
2 parents f76d49c + 8268ea0 commit 5d52f02
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions base/expr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ end
## expressions ##

copy(e::Expr) = (n = Expr(e.head);
n.args = astcopy(e.args);
n.args = copy_exprargs(e.args);
n.typ = e.typ;
n)

# copy parts of an AST that the compiler mutates
astcopy(x::Expr) = copy(x)
astcopy(x::Array{Any,1}) = Any[astcopy(a) for a in x]
astcopy(x) = x
copy_exprs(x::Expr) = copy(x)
copy_exprs(x::ANY) = x
copy_exprargs(x::Array{Any,1}) = Any[copy_exprs(a) for a in x]

==(x::Expr, y::Expr) = x.head === y.head && isequal(x.args, y.args)
==(x::QuoteNode, y::QuoteNode) = isequal(x.value, y.value)
Expand Down
4 changes: 2 additions & 2 deletions base/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1397,7 +1397,7 @@ function unshare_linfo!(li::LambdaInfo)
if !isa(li.code, Array{Any,1})
li.code = ccall(:jl_uncompress_ast, Any, (Any,Any), li, li.code)
else
li.code = astcopy(li.code)
li.code = copy_exprargs(li.code)
end
li.slotnames = copy(li.slotnames)
li.slotflags = copy(li.slotflags)
Expand Down Expand Up @@ -2457,7 +2457,7 @@ function inlineable(f::ANY, ft::ANY, e::Expr, atypes::Vector{Any}, sv::Inference
if !isa(ast,Array{Any,1})
ast = ccall(:jl_uncompress_ast, Any, (Any,Any), linfo, ast)
else
ast = astcopy(ast)
ast = copy_exprargs(ast)
end
ast = ast::Array{Any,1}

Expand Down

0 comments on commit 5d52f02

Please sign in to comment.