Skip to content

Commit f738580

Browse files
authored
use explicit keyword arguments for specialize_method (#41920)
It would be a bit easier to reason about the configurations.
1 parent 2cb8e17 commit f738580

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

base/compiler/abstractinterpretation.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ function maybe_get_const_prop_profitable(interp::AbstractInterpreter, result::Me
584584
end
585585
end
586586
force |= allconst
587-
mi = specialize_method(match, !force)
587+
mi = specialize_method(match; preexisting=!force)
588588
if mi === nothing
589589
add_remark!(interp, sv, "[constprop] Failed to specialize")
590590
return nothing
@@ -983,7 +983,7 @@ end
983983
function is_method_pure(method::Method, @nospecialize(sig), sparams::SimpleVector)
984984
if isdefined(method, :generator)
985985
method.generator.expand_early || return false
986-
mi = specialize_method(method, sig, sparams, false)
986+
mi = specialize_method(method, sig, sparams)
987987
isa(mi, MethodInstance) || return false
988988
staged = get_staged(mi)
989989
(staged isa CodeInfo && (staged::CodeInfo).pure) || return false

base/compiler/ssair/inlining.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -708,13 +708,13 @@ function singleton_type(@nospecialize(ft))
708708
end
709709

710710
function compileable_specialization(et::Union{EdgeTracker, Nothing}, match::MethodMatch)
711-
mi = specialize_method(match, false, true)
711+
mi = specialize_method(match; compilesig=true)
712712
mi !== nothing && et !== nothing && push!(et, mi::MethodInstance)
713713
return mi
714714
end
715715

716716
function compileable_specialization(et::Union{EdgeTracker, Nothing}, (; linfo)::InferenceResult)
717-
mi = specialize_method(linfo.def::Method, linfo.specTypes, linfo.sparam_vals, false, true)
717+
mi = specialize_method(linfo.def::Method, linfo.specTypes, linfo.sparam_vals; compilesig=true)
718718
mi !== nothing && et !== nothing && push!(et, mi::MethodInstance)
719719
return mi
720720
end
@@ -809,7 +809,7 @@ function analyze_method!(match::MethodMatch, atypes::Vector{Any},
809809
end
810810

811811
# See if there exists a specialization for this method signature
812-
mi = specialize_method(match, true) # Union{Nothing, MethodInstance}
812+
mi = specialize_method(match; preexisting=true) # Union{Nothing, MethodInstance}
813813
if !isa(mi, MethodInstance)
814814
return compileable_specialization(et, match)
815815
end

base/compiler/utilities.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ function normalize_typevars(method::Method, @nospecialize(atypes), sparams::Simp
176176
end
177177

178178
# get a handle to the unique specialization object representing a particular instantiation of a call
179-
function specialize_method(method::Method, @nospecialize(atypes), sparams::SimpleVector, preexisting::Bool=false, compilesig::Bool=false)
179+
function specialize_method(method::Method, @nospecialize(atypes), sparams::SimpleVector; preexisting::Bool=false, compilesig::Bool=false)
180180
if isa(atypes, UnionAll)
181181
atypes, sparams = normalize_typevars(method, atypes, sparams)
182182
end
@@ -193,14 +193,14 @@ function specialize_method(method::Method, @nospecialize(atypes), sparams::Simpl
193193
return ccall(:jl_specializations_get_linfo, Ref{MethodInstance}, (Any, Any, Any), method, atypes, sparams)
194194
end
195195

196-
function specialize_method(match::MethodMatch, preexisting::Bool=false, compilesig::Bool=false)
197-
return specialize_method(match.method, match.spec_types, match.sparams, preexisting, compilesig)
196+
function specialize_method(match::MethodMatch; kwargs...)
197+
return specialize_method(match.method, match.spec_types, match.sparams; kwargs...)
198198
end
199199

200200
# This function is used for computing alternate limit heuristics
201201
function method_for_inference_heuristics(method::Method, @nospecialize(sig), sparams::SimpleVector)
202202
if isdefined(method, :generator) && method.generator.expand_early && may_invoke_generator(method, sig, sparams)
203-
method_instance = specialize_method(method, sig, sparams, false)
203+
method_instance = specialize_method(method, sig, sparams)
204204
if isa(method_instance, MethodInstance)
205205
cinfo = get_staged(method_instance)
206206
if isa(cinfo, CodeInfo)

test/compiler/validation.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ end
2121
msig = Tuple{typeof(f22938),Int,Int,Int,Int}
2222
world = typemax(UInt)
2323
match = Base._methods_by_ftype(msig, -1, world)[]
24-
mi = Core.Compiler.specialize_method(match, false)
24+
mi = Core.Compiler.specialize_method(match)
2525
c0 = Core.Compiler.retrieve_code_info(mi)
2626

2727
@test isempty(Core.Compiler.validate_code(mi))

0 commit comments

Comments
 (0)