From f90856cc3440d99a418e9421bd05dd61c7680bf2 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Tue, 24 Apr 2018 18:36:41 -0400 Subject: [PATCH] some compiler performance improvements mostly due to avoiding specialization of closures in comprehensions in the compiler itself --- base/expr.jl | 2 +- base/inference.jl | 8 ++++---- base/reflection.jl | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/base/expr.jl b/base/expr.jl index fa1f6586079a4..de06264ffd586 100644 --- a/base/expr.jl +++ b/base/expr.jl @@ -40,7 +40,7 @@ copy(e::Expr) = (n = Expr(e.head); # copy parts of an AST that the compiler mutates 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] +copy_exprargs(x::Array{Any,1}) = Any[copy_exprs(x[i]) for i in 1:length(x)] ==(x::Expr, y::Expr) = x.head === y.head && isequal(x.args, y.args) ==(x::QuoteNode, y::QuoteNode) = isequal(x.value, y.value) diff --git a/base/inference.jl b/base/inference.jl index 8455889e807b5..49b29c6bf4e79 100644 --- a/base/inference.jl +++ b/base/inference.jl @@ -1453,7 +1453,7 @@ function precise_container_type(arg::ANY, typ::ANY, vtypes::VarTable, sv::Infere if isa(typ, Const) val = typ.val if isa(val, SimpleVector) || isa(val, Tuple) - return Any[ abstract_eval_constant(x) for x in val ] + return Any[ abstract_eval_constant(val[i]) for i in 1:length(val) ] end end @@ -1898,7 +1898,7 @@ function abstract_call(f::ANY, fargs::Union{Tuple{},Vector{Any}}, argtypes::Vect end function abstract_eval_call(e::Expr, vtypes::VarTable, sv::InferenceState) - argtypes = Any[abstract_eval(a, vtypes, sv) for a in e.args] + argtypes = Any[abstract_eval(e.args[i], vtypes, sv) for i in 1:length(e.args)] #print("call ", e.args[1], argtypes, "\n\n") for x in argtypes x === Bottom && return Bottom @@ -4459,12 +4459,12 @@ function inlining_pass(e::Expr, sv::InferenceState, stmts, ins) newargs[i-2] = aarg.args[2:end] elseif isa(argt,Const) && (isa(argt.val, Tuple) || isa(argt.val, SimpleVector)) && effect_free(aarg, sv.src, sv.mod, true) - newargs[i-2] = Any[ QuoteNode(x) for x in argt.val ] + newargs[i-2] = Any[ QuoteNode(argt.val[i]) for i in 1:length(argt.val) ] elseif isa(aarg, Tuple) || (isa(aarg, QuoteNode) && (isa(aarg.value, Tuple) || isa(aarg.value, SimpleVector))) if isa(aarg, QuoteNode) aarg = aarg.value end - newargs[i-2] = Any[ QuoteNode(x) for x in aarg ] + newargs[i-2] = Any[ QuoteNode(aarg[i]) for i in 1:length(aarg) ] elseif isa(t, DataType) && t.name === Tuple.name && !isvatuple(t) && length(t.parameters) <= sv.params.MAX_TUPLE_SPLAT for k = (effect_free_upto+1):(i-3) diff --git a/base/reflection.jl b/base/reflection.jl index 85ddf9cbb71bf..b4e0cdf064c79 100644 --- a/base/reflection.jl +++ b/base/reflection.jl @@ -232,7 +232,7 @@ false """ isbits(t::DataType) = (@_pure_meta; !t.mutable & (t.layout != C_NULL) && datatype_pointerfree(t)) isbits(t::Type) = (@_pure_meta; false) -isbits(x) = (@_pure_meta; isbits(typeof(x))) +isbits(x::ANY) = (@_pure_meta; isbits(typeof(x))) """ isleaftype(T)