Skip to content

Commit 2def71f

Browse files
authored
compiler: minor cosmetic changes (JuliaLang#42789)
1 parent ec906ce commit 2def71f

File tree

5 files changed

+17
-15
lines changed

5 files changed

+17
-15
lines changed

base/compiler/abstractinterpretation.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ function force_const_prop(interp::AbstractInterpreter, @nospecialize(f), method:
685685
end
686686

687687
function const_prop_function_heuristic(
688-
interp::AbstractInterpreter, @nospecialize(f), (; argtypes)::ArgInfo,
688+
_::AbstractInterpreter, @nospecialize(f), (; argtypes)::ArgInfo,
689689
nargs::Int, all_overridden::Bool, _::InferenceState)
690690
if nargs > 1
691691
if istopfunction(f, :getindex) || istopfunction(f, :setindex!)
@@ -704,9 +704,9 @@ function const_prop_function_heuristic(
704704
end
705705
end
706706
if !all_overridden && (istopfunction(f, :+) || istopfunction(f, :-) || istopfunction(f, :*) ||
707-
istopfunction(f, :(==)) || istopfunction(f, :!=) ||
708-
istopfunction(f, :<=) || istopfunction(f, :>=) || istopfunction(f, :<) || istopfunction(f, :>) ||
709-
istopfunction(f, :<<) || istopfunction(f, :>>))
707+
istopfunction(f, :(==)) || istopfunction(f, :!=) ||
708+
istopfunction(f, :<=) || istopfunction(f, :>=) || istopfunction(f, :<) || istopfunction(f, :>) ||
709+
istopfunction(f, :<<) || istopfunction(f, :>>))
710710
# it is almost useless to inline the op when all the same type,
711711
# but highly worthwhile to inline promote of a constant
712712
length(argtypes) > 2 || return false

base/compiler/optimize.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ function statement_costs!(cost::Vector{Int}, body::Vector{Any}, src::Union{CodeI
579579
return maxcost
580580
end
581581

582-
function is_known_call(e::Expr, @nospecialize(func), src, sptypes::Vector{Any}, slottypes::Vector{Any} = empty_slottypes)
582+
function is_known_call(e::Expr, @nospecialize(func), src, sptypes::Vector{Any}, slottypes::Vector{Any} = EMPTY_SLOTTYPES)
583583
if e.head !== :call
584584
return false
585585
end

base/compiler/ssair/inlining.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ function ir_inline_item!(compact::IncrementalCompact, idx::Int, argexprs::Vector
446446
return_value
447447
end
448448

449-
const fatal_type_bound_error = ErrorException("fatal error in type inference (type bound)")
449+
const FATAL_TYPE_BOUND_ERROR = ErrorException("fatal error in type inference (type bound)")
450450

451451
function ir_inline_unionsplit!(compact::IncrementalCompact, idx::Int,
452452
argexprs::Vector{Any}, linetable::Vector{LineInfoNode},
@@ -516,7 +516,7 @@ function ir_inline_unionsplit!(compact::IncrementalCompact, idx::Int,
516516
bb += 1
517517
# We're now in the fall through block, decide what to do
518518
if item.fully_covered
519-
e = Expr(:call, GlobalRef(Core, :throw), fatal_type_bound_error)
519+
e = Expr(:call, GlobalRef(Core, :throw), FATAL_TYPE_BOUND_ERROR)
520520
insert_node_here!(compact, NewInstruction(e, Union{}, line))
521521
insert_node_here!(compact, NewInstruction(ReturnNode(), Union{}, line))
522522
finish_current_bb!(compact, 0)

base/compiler/typeinfer.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,11 @@ function maybe_compress_codeinfo(interp::AbstractInterpreter, linfo::MethodInsta
335335
if toplevel
336336
return ci
337337
end
338-
cache_the_tree = !may_discard_trees(interp) || (ci.inferred &&
339-
(ci.inlineable ||
340-
ccall(:jl_isa_compileable_sig, Int32, (Any, Any), linfo.specTypes, def) != 0))
338+
if may_discard_trees(interp)
339+
cache_the_tree = ci.inferred && (ci.inlineable || isa_compileable_sig(linfo.specTypes, def))
340+
else
341+
cache_the_tree = true
342+
end
341343
if cache_the_tree
342344
if may_compress(interp)
343345
nslots = length(ci.slotflags)

base/compiler/utilities.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,6 @@ function retrieve_code_info(linfo::MethodInstance)
137137
return nothing
138138
end
139139

140-
# Get at the nonfunction_mt, which happens to be the mt of SimpleVector
141-
const nonfunction_mt = typename(SimpleVector).mt
142-
143140
function get_compileable_sig(method::Method, @nospecialize(atypes), sparams::SimpleVector)
144141
isa(atypes, DataType) || return nothing
145142
mt = ccall(:jl_method_table_for, Any, (Any,), atypes)
@@ -148,6 +145,9 @@ function get_compileable_sig(method::Method, @nospecialize(atypes), sparams::Sim
148145
mt, atypes, sparams, method)
149146
end
150147

148+
isa_compileable_sig(@nospecialize(atype), method::Method) =
149+
!iszero(ccall(:jl_isa_compileable_sig, Int32, (Any, Any), atype, method))
150+
151151
# eliminate UnionAll vars that might be degenerate due to having identical bounds,
152152
# or a concrete upper bound and appearing covariantly.
153153
function subst_trivial_bounds(@nospecialize(atypes))
@@ -228,9 +228,9 @@ end
228228

229229
argextype(@nospecialize(x), state) = argextype(x, state.src, state.sptypes, state.slottypes)
230230

231-
const empty_slottypes = Any[]
231+
const EMPTY_SLOTTYPES = Any[]
232232

233-
function argextype(@nospecialize(x), src, sptypes::Vector{Any}, slottypes::Vector{Any} = empty_slottypes)
233+
function argextype(@nospecialize(x), src, sptypes::Vector{Any}, slottypes::Vector{Any} = EMPTY_SLOTTYPES)
234234
if isa(x, Expr)
235235
if x.head === :static_parameter
236236
return sptypes[x.args[1]::Int]

0 commit comments

Comments
 (0)