Skip to content

Commit

Permalink
compiler: minor cosmetic changes (JuliaLang#42789)
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk authored and LilithHafner committed Mar 8, 2022
1 parent 1222af4 commit e25daea
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
8 changes: 4 additions & 4 deletions base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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!)
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion base/compiler/optimize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions base/compiler/ssair/inlining.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 5 additions & 3 deletions base/compiler/typeinfer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions base/compiler/utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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))
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit e25daea

Please sign in to comment.