From b799e84f4b3ed78a7b238c13614ca2bd38ce7c34 Mon Sep 17 00:00:00 2001 From: Shuhei Kadowaki Date: Sun, 7 Jan 2024 19:50:16 +0900 Subject: [PATCH] compiler: eliminate `Core.Compiler.` qualifier --- base/compiler/abstractlattice.jl | 9 ++++++--- base/compiler/ssair/ir.jl | 2 +- base/compiler/tfuncs.jl | 33 ++++++++++++++++---------------- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/base/compiler/abstractlattice.jl b/base/compiler/abstractlattice.jl index 18b6a5473abd0..0102a59667c1e 100644 --- a/base/compiler/abstractlattice.jl +++ b/base/compiler/abstractlattice.jl @@ -285,9 +285,12 @@ has_extended_unionsplit(::AnyMustAliasesLattice) = true has_extended_unionsplit(::JLTypeLattice) = false # Curried versions -⊑(lattice::AbstractLattice) = (@nospecialize(a), @nospecialize(b)) -> ⊑(lattice, a, b) -⊏(lattice::AbstractLattice) = (@nospecialize(a), @nospecialize(b)) -> ⊏(lattice, a, b) -⋤(lattice::AbstractLattice) = (@nospecialize(a), @nospecialize(b)) -> ⋤(lattice, a, b) +⊑(𝕃::AbstractLattice) = (@nospecialize(a), @nospecialize(b)) -> ⊑(𝕃, a, b) +⊏(𝕃::AbstractLattice) = (@nospecialize(a), @nospecialize(b)) -> ⊏(𝕃, a, b) +⋤(𝕃::AbstractLattice) = (@nospecialize(a), @nospecialize(b)) -> ⋤(𝕃, a, b) +partialorder(𝕃::AbstractLattice) = ⊑(𝕃) +strictpartialorder(𝕃::AbstractLattice) = ⊏(𝕃) +strictneqpartialorder(𝕃::AbstractLattice) = ⋤(𝕃) # Fallbacks for external packages using these methods const fallback_lattice = InferenceLattice(BaseInferenceLattice.instance) diff --git a/base/compiler/ssair/ir.jl b/base/compiler/ssair/ir.jl index c4086ff508773..8029f6c57fb83 100644 --- a/base/compiler/ssair/ir.jl +++ b/base/compiler/ssair/ir.jl @@ -1117,7 +1117,7 @@ function find_ssavalue_uses1(compact::IncrementalCompact) end function _oracle_check(compact::IncrementalCompact) - (observed_used_ssas, observed_used_newssas) = Core.Compiler.find_ssavalue_uses1(compact) + (observed_used_ssas, observed_used_newssas) = find_ssavalue_uses1(compact) for i = 1:length(observed_used_ssas) if observed_used_ssas[i] != compact.used_ssas[i] return (observed_used_ssas, observed_used_newssas, SSAValue(i)) diff --git a/base/compiler/tfuncs.jl b/base/compiler/tfuncs.jl index 0d15921dbc48e..1cba3e7795c47 100644 --- a/base/compiler/tfuncs.jl +++ b/base/compiler/tfuncs.jl @@ -331,7 +331,7 @@ end add_tfunc(Core.ifelse, 3, 3, ifelse_tfunc, 1) @nospecs function ifelse_nothrow(𝕃::AbstractLattice, cond, x, y) - ⊑ = Core.Compiler.:⊑(𝕃) + ⊑ = partialorder(𝕃) return cond ⊑ Bool end @@ -380,7 +380,7 @@ function isdefined_nothrow(𝕃::AbstractLattice, argtypes::Vector{Any}) return isdefined_nothrow(𝕃, argtypes[1], argtypes[2]) end @nospecs function isdefined_nothrow(𝕃::AbstractLattice, x, name) - ⊑ = Core.Compiler.:⊑(𝕃) + ⊑ = partialorder(𝕃) isvarargtype(x) && return false isvarargtype(name) && return false if hasintersect(widenconst(x), Module) @@ -600,7 +600,8 @@ add_tfunc(svec, 0, INT_INF, @nospecs((𝕃::AbstractLattice, args...)->SimpleVec end return TypeVar end -@nospecs function typebound_nothrow(b) +@nospecs function typebound_nothrow(𝕃::AbstractLattice, b) + ⊑ = partialorder(𝕃) b = widenconst(b) (b ⊑ TypeVar) && return true if isType(b) @@ -609,10 +610,10 @@ end return false end @nospecs function typevar_nothrow(𝕃::AbstractLattice, n, lb, ub) - ⊑ = Core.Compiler.:⊑(𝕃) + ⊑ = partialorder(𝕃) n ⊑ Symbol || return false - typebound_nothrow(lb) || return false - typebound_nothrow(ub) || return false + typebound_nothrow(𝕃, lb) || return false + typebound_nothrow(𝕃, ub) || return false return true end add_tfunc(Core._typevar, 3, 3, typevar_tfunc, 100) @@ -813,7 +814,7 @@ end add_tfunc(typeassert, 2, 2, typeassert_tfunc, 4) @nospecs function typeassert_nothrow(𝕃::AbstractLattice, v, t) - ⊑ = Core.Compiler.:⊑(𝕃) + ⊑ = partialorder(𝕃) # ty, exact = instanceof_tfunc(t, true) # return exact && v ⊑ ty if (isType(t) && !has_free_typevars(t) && v ⊑ t.parameters[1]) || @@ -859,7 +860,7 @@ end add_tfunc(isa, 2, 2, isa_tfunc, 1) @nospecs function isa_nothrow(𝕃::AbstractLattice, obj, typ) - ⊑ = Core.Compiler.:⊑(𝕃) + ⊑ = partialorder(𝕃) return typ ⊑ Type end @@ -882,7 +883,7 @@ end add_tfunc(<:, 2, 2, subtype_tfunc, 10) @nospecs function subtype_nothrow(𝕃::AbstractLattice, lty, rty) - ⊑ = Core.Compiler.:⊑(𝕃) + ⊑ = partialorder(𝕃) return lty ⊑ Type && rty ⊑ Type end @@ -981,7 +982,7 @@ end isa(name, Const) || return false end - ⊑ = Core.Compiler.:⊑(𝕃) + ⊑ = partialorder(𝕃) # If we have s00 being a const, we can potentially refine our type-based analysis above if isa(s00, Const) || isconstType(s00) @@ -1340,7 +1341,6 @@ end return setfield!_nothrow(𝕃, s00, name, v) end @nospecs function setfield!_nothrow(𝕃::AbstractLattice, s00, name, v) - ⊑ = Core.Compiler.:⊑(𝕃) s0 = widenconst(s00) s = unwrap_unionall(s0) if isa(s, Union) @@ -1357,6 +1357,7 @@ end isconst(s, field) && return false isfieldatomic(s, field) && return false # TODO: currently we're only testing for ordering === :not_atomic v_expected = fieldtype(s0, field) + ⊑ = partialorder(𝕃) return v ⊑ v_expected end return false @@ -1431,7 +1432,7 @@ add_tfunc(replacefield!, 4, 6, replacefield!_tfunc, 3) @nospecs function fieldtype_nothrow(𝕃::AbstractLattice, s0, name) s0 === Bottom && return true # unreachable - ⊑ = Core.Compiler.:⊑(𝕃) + ⊑ = partialorder(𝕃) if s0 === Any || s0 === Type || DataType ⊑ s0 || UnionAll ⊑ s0 # We have no idea return false @@ -2090,7 +2091,7 @@ end elemtype_expected = memoryref_elemtype(memtype) elemtype_expected === Union{} && return false # Check that the element type is compatible with the element we're assigning - ⊑ = Core.Compiler.:⊑(𝕃) + ⊑ = partialorder(𝕃) elemtype ⊑ elemtype_expected || return false return true end @@ -2149,13 +2150,13 @@ function memoryrefop_builtin_common_nothrow(𝕃::AbstractLattice, argtypes::Vec end @nospecs function memoryref_builtin_common_typecheck(𝕃::AbstractLattice, boundscheck, memtype, order) - ⊑ = Core.Compiler.:⊑(𝕃) + ⊑ = partialorder(𝕃) return boundscheck ⊑ Bool && memtype ⊑ GenericMemoryRef && order ⊑ Symbol end # Query whether the given builtin is guaranteed not to throw given the argtypes @nospecs function _builtin_nothrow(𝕃::AbstractLattice, f, argtypes::Vector{Any}, rt) - ⊑ = Core.Compiler.:⊑(𝕃) + ⊑ = partialorder(𝕃) if f === memoryref return memoryref_builtin_common_nothrow(argtypes) elseif f === memoryrefoffset @@ -3108,7 +3109,7 @@ end add_tfunc(Core.get_binding_type, 2, 2, get_binding_type_tfunc, 0) @nospecs function get_binding_type_nothrow(𝕃::AbstractLattice, M, s) - ⊑ = Core.Compiler.:⊑(𝕃) + ⊑ = partialorder(𝕃) return M ⊑ Module && s ⊑ Symbol end