diff --git a/base/compiler/abstractinterpretation.jl b/base/compiler/abstractinterpretation.jl index 2dfd67629c30d6..2c7e26428c7b64 100644 --- a/base/compiler/abstractinterpretation.jl +++ b/base/compiler/abstractinterpretation.jl @@ -685,7 +685,7 @@ function force_const_prop(interp::AbstractInterpreter, @nospecialize(f), method: end function const_prop_function_heuristic( - interp::AbstractInterpreter, @nospecialize(f), (; argtypes)::ArgInfo, + _::AbstractInterpreter, @nospecialize(f), (; argtypes)::ArgInfo, nargs::Int, all_overridden::Bool, _::InferenceState) if nargs > 1 if istopfunction(f, :getindex) || istopfunction(f, :setindex!) @@ -704,9 +704,9 @@ function const_prop_function_heuristic( end end if !all_overridden && (istopfunction(f, :+) || istopfunction(f, :-) || istopfunction(f, :*) || - istopfunction(f, :(==)) || istopfunction(f, :!=) || - istopfunction(f, :<=) || istopfunction(f, :>=) || istopfunction(f, :<) || istopfunction(f, :>) || - istopfunction(f, :<<) || istopfunction(f, :>>)) + istopfunction(f, :(==)) || istopfunction(f, :!=) || + istopfunction(f, :<=) || istopfunction(f, :>=) || istopfunction(f, :<) || istopfunction(f, :>) || + istopfunction(f, :<<) || istopfunction(f, :>>)) # it is almost useless to inline the op when all the same type, # but highly worthwhile to inline promote of a constant length(argtypes) > 2 || return false diff --git a/base/compiler/optimize.jl b/base/compiler/optimize.jl index ba6846ae683cbe..eb80c336fc7d43 100644 --- a/base/compiler/optimize.jl +++ b/base/compiler/optimize.jl @@ -579,7 +579,7 @@ function statement_costs!(cost::Vector{Int}, body::Vector{Any}, src::Union{CodeI return maxcost end -function is_known_call(e::Expr, @nospecialize(func), src, sptypes::Vector{Any}, slottypes::Vector{Any} = empty_slottypes) +function is_known_call(e::Expr, @nospecialize(func), src, sptypes::Vector{Any}, slottypes::Vector{Any} = EMPTY_SLOTTYPES) if e.head !== :call return false end diff --git a/base/compiler/ssair/inlining.jl b/base/compiler/ssair/inlining.jl index 5142f7ad562a93..77bc6b43604f78 100644 --- a/base/compiler/ssair/inlining.jl +++ b/base/compiler/ssair/inlining.jl @@ -446,7 +446,7 @@ function ir_inline_item!(compact::IncrementalCompact, idx::Int, argexprs::Vector return_value end -const fatal_type_bound_error = ErrorException("fatal error in type inference (type bound)") +const FATAL_TYPE_BOUND_ERROR = ErrorException("fatal error in type inference (type bound)") function ir_inline_unionsplit!(compact::IncrementalCompact, idx::Int, argexprs::Vector{Any}, linetable::Vector{LineInfoNode}, @@ -516,7 +516,7 @@ function ir_inline_unionsplit!(compact::IncrementalCompact, idx::Int, bb += 1 # We're now in the fall through block, decide what to do if item.fully_covered - e = Expr(:call, GlobalRef(Core, :throw), fatal_type_bound_error) + e = Expr(:call, GlobalRef(Core, :throw), FATAL_TYPE_BOUND_ERROR) insert_node_here!(compact, NewInstruction(e, Union{}, line)) insert_node_here!(compact, NewInstruction(ReturnNode(), Union{}, line)) finish_current_bb!(compact, 0) diff --git a/base/compiler/typeinfer.jl b/base/compiler/typeinfer.jl index 5b7708f4526301..49722a8ab30907 100644 --- a/base/compiler/typeinfer.jl +++ b/base/compiler/typeinfer.jl @@ -335,9 +335,11 @@ function maybe_compress_codeinfo(interp::AbstractInterpreter, linfo::MethodInsta if toplevel return ci end - cache_the_tree = !may_discard_trees(interp) || (ci.inferred && - (ci.inlineable || - ccall(:jl_isa_compileable_sig, Int32, (Any, Any), linfo.specTypes, def) != 0)) + if may_discard_trees(interp) + cache_the_tree = ci.inferred && (ci.inlineable || isa_compileable_sig(linfo.specTypes, def)) + else + cache_the_tree = true + end if cache_the_tree if may_compress(interp) nslots = length(ci.slotflags) diff --git a/base/compiler/utilities.jl b/base/compiler/utilities.jl index 1da32ebd7b386c..107bc163218641 100644 --- a/base/compiler/utilities.jl +++ b/base/compiler/utilities.jl @@ -137,9 +137,6 @@ function retrieve_code_info(linfo::MethodInstance) return nothing end -# Get at the nonfunction_mt, which happens to be the mt of SimpleVector -const nonfunction_mt = typename(SimpleVector).mt - function get_compileable_sig(method::Method, @nospecialize(atypes), sparams::SimpleVector) isa(atypes, DataType) || return nothing mt = ccall(:jl_method_table_for, Any, (Any,), atypes) @@ -148,6 +145,9 @@ function get_compileable_sig(method::Method, @nospecialize(atypes), sparams::Sim mt, atypes, sparams, method) end +isa_compileable_sig(@nospecialize(atype), method::Method) = + !iszero(ccall(:jl_isa_compileable_sig, Int32, (Any, Any), atype, method)) + # eliminate UnionAll vars that might be degenerate due to having identical bounds, # or a concrete upper bound and appearing covariantly. function subst_trivial_bounds(@nospecialize(atypes)) @@ -228,9 +228,9 @@ end argextype(@nospecialize(x), state) = argextype(x, state.src, state.sptypes, state.slottypes) -const empty_slottypes = Any[] +const EMPTY_SLOTTYPES = Any[] -function argextype(@nospecialize(x), src, sptypes::Vector{Any}, slottypes::Vector{Any} = empty_slottypes) +function argextype(@nospecialize(x), src, sptypes::Vector{Any}, slottypes::Vector{Any} = EMPTY_SLOTTYPES) if isa(x, Expr) if x.head === :static_parameter return sptypes[x.args[1]::Int]