From 9179728ea9bcb7c3ec27dffea3373220b7625b2d Mon Sep 17 00:00:00 2001 From: Shuhei Kadowaki Date: Sat, 30 Dec 2023 16:01:11 +0900 Subject: [PATCH] drop support for v1.9 --- .github/workflows/ci.yml | 4 +- Project.toml | 16 +-- docs/src/jetanalysis.md | 5 +- src/JET.jl | 86 +----------- src/abstractinterpret/abstractanalyzer.jl | 52 +------ src/abstractinterpret/inferenceerrorreport.jl | 15 +- src/abstractinterpret/typeinfer.jl | 108 +++------------ src/analyzers/jetanalyzer.jl | 130 ++---------------- src/analyzers/optanalyzer.jl | 8 +- src/toplevel/virtualprocess.jl | 8 +- src/ui/print.jl | 35 +---- test/analyzers/test_jetanalyzer.jl | 2 +- test/analyzers/test_optanalyzer.jl | 6 +- test/self_check.jl | 2 +- test/test_misc.jl | 4 - 15 files changed, 62 insertions(+), 419 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c27883909..da1daafb3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,9 +14,9 @@ jobs: fail-fast: false # don't stop CI even when one of them fails matrix: version: - - '1.9.0' # lowest version supported + - '1.10.0' # lowest version supported - '1' # current stable - - '1.10-nightly' # next stable + - '1.11-nightly' # next stable - 'nightly' os: - ubuntu-latest diff --git a/Project.toml b/Project.toml index cef6fd2c5..f9bbcef6d 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "JET" uuid = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" authors = ["Shuhei Kadowaki "] -version = "0.8.21" +version = "0.8.22" [deps] InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" @@ -18,20 +18,20 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" Aqua = "0.8.2" BenchmarkTools = "1.3.2" Example = "0.5.3" -InteractiveUtils = "1.9" +InteractiveUtils = "1.10" JuliaInterpreter = "0.9" -Libdl = "1.9" -Logging = "1.9" +Libdl = "1.10" +Logging = "1.10" LoweredCodeUtils = "2.2" MacroTools = "0.5.6" -Pkg = "1.9" +Pkg = "1.10" PrecompileTools = "1" Preferences = "1.4" -Random = "1.9" +Random = "1.10" Revise = "3.3" StaticArrays = "1.7.0" -Test = "1.9" -julia = "1.9" +Test = "1.10" +julia = "1.10" [extras] Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" diff --git a/docs/src/jetanalysis.md b/docs/src/jetanalysis.md index 8a8a27421..a104c6530 100644 --- a/docs/src/jetanalysis.md +++ b/docs/src/jetanalysis.md @@ -289,7 +289,7 @@ using JET # hide @report_call f(Foo(1)) ``` -We might reasonably expect the compiler to know that in the `else` branch, `x.x` must be an `Int`, since it just checked that it is not `nothing`. However, the compiler does not know that the value obtained from loading the `x` field in the expression `x.x` on the like with the if statement in this case is the same value as the value obtained when loading the `x` field in the `x.x + 1` statement[^3]. +We might reasonably expect the compiler to know that in the `else` branch, `x.x` must be an `Int`, since it just checked that it is not `nothing`. However, the compiler does not know that the value obtained from loading the `x` field in the expression `x.x` on the like with the if statement in this case is the same value as the value obtained when loading the `x` field in the `x.x + 1` statement. You can solve this issue by assigning `x.x` to a variable: ```@repl union3 @@ -305,9 +305,6 @@ end; @report_call f(Foo(1)) ``` -[^3]: For immutable structs, the Julia compiler can figure out type constraints imposed on - aliased field loads if you're using Julia version higher than `v"1.10.0-DEV.25"`. - ### `X is not defined` #### Description This happens when a name `X` is used in a function, but no object named `X` can be found. diff --git a/src/JET.jl b/src/JET.jl index 5e746f188..66d13e321 100644 --- a/src/JET.jl +++ b/src/JET.jl @@ -65,7 +65,7 @@ using Core: IntrinsicFunction, Intrinsics, LineInfoNode, MethodInstance, MethodMatch, MethodTable, ReturnNode, SSAValue, SimpleVector, SlotNumber, svec -using .CC: βŠ‘, +using .CC: @nospecs, βŠ‘, AbstractInterpreter, ArgInfo, BasicBlock, Bottom, CFG, CachedMethodTable, CallMeta, ConstCallInfo, InferenceResult, InternalMethodTable, InvokeCallInfo, LimitedAccuracy, MethodCallResult, MethodLookupResult, MethodMatchInfo, MethodMatches, NOT_FOUND, @@ -125,29 +125,6 @@ __init__() = foreach(@nospecialize(f)->f(), INIT_HOOKS) # compat # ------ -@static if VERSION β‰₯ v"1.10.0-DEV.96" - using Base: _which -else - function _which(@nospecialize(tt::Type); - method_table::Union{Nothing,MethodTable,Core.Compiler.MethodTableView}=nothing, - world::UInt=get_world_counter(), - raise::Bool=false) - if method_table === nothing - table = Core.Compiler.InternalMethodTable(world) - elseif isa(method_table, MethodTable) - table = Core.Compiler.OverlayMethodTable(world, method_table) - else - table = method_table - end - match, = Core.Compiler.findsup(tt, table) - if match === nothing - raise && error("no unique matching method found for the specified argument types") - return nothing - end - return match - end -end - # macros # ------ @@ -240,61 +217,6 @@ struct JETConfigError <: Exception end Base.showerror(io::IO, err::JETConfigError) = print(io, "JETConfigError: ", err.msg) -@static if VERSION β‰₯ v"1.10.0-DEV.117" - using .CC: @nospecs -else - using Base: is_function_def - - @doc """ - @nospecs def - - Adds `@nospecialize` annotation to non-annotated arguments of `def`. - ```julia - (Core.Compiler) julia> @macroexpand @nospecs function tfunc(𝕃::AbstractLattice, x, y::Bool, zs...) - x, ys - end - :(function tfunc(\$(Expr(:meta, :specialize, :(𝕃::AbstractLattice))), x, y::Bool, zs...) - #= REPL[3]:1 =# - \$(Expr(:meta, :nospecialize, :x, :zs)) - #= REPL[3]:2 =# - (x, ys) - end) - ``` - """ - macro nospecs(ex) - is_function_def(ex) || throw(ArgumentError("expected function definition")) - args, body = ex.args - while isexpr(args, :where) - args = args.args[1] - end - if isexpr(args, :call) - args = args.args[2:end] # skip marking `@nospecialize` on the function itself - else - @assert isexpr(args, :tuple) # anonymous function - args = args.args - end - names = Symbol[] - for arg in args - isexpr(arg, :macrocall) && continue - if isexpr(arg, :...) - arg = arg.args[1] - elseif isexpr(arg, :kw) - arg = arg.args[1] - end - isexpr(arg, :(::)) && continue - @assert arg isa Symbol - push!(names, arg) - end - @assert isexpr(body, :block) - if !isempty(names) - lin = first(body.args)::LineNumberNode - nospec = Expr(:macrocall, Symbol("@nospecialize"), lin, names...) - insert!(body.args, 2, nospec) - end - return esc(ex) - end -end - # utils # ----- @@ -407,9 +329,7 @@ function print_report end include("toplevel/graph.jl") -const JULIA_SYNTAX_ENABLED = - VERSION β‰₯ v"1.11.0-DEV.123" || VERSION β‰₯ v"1.10.0-beta1.1" ? !(Base.get_bool_env("JULIA_USE_FLISP_PARSER", false) === true) : - VERSION β‰₯ v"1.10.0-DEV.1520" && Base.get_bool_env("JULIA_USE_NEW_PARSER", true) === true +const JULIA_SYNTAX_ENABLED = !(Base.get_bool_env("JULIA_USE_FLISP_PARSER", false)) include("toplevel/virtualprocess.jl") @@ -716,7 +636,7 @@ function analyze_gf_by_type!(analyzer::AbstractAnalyzer, @nospecialize(tt::Type{ end function find_single_match(@nospecialize(tt), analyzer::AbstractAnalyzer) - match = _which(tt; method_table=method_table(analyzer), world=get_world_counter(analyzer), raise=false) + match = Base._which(tt; method_table=method_table(analyzer), world=get_world_counter(analyzer), raise=false) match === nothing && single_match_error(tt) return match end diff --git a/src/abstractinterpret/abstractanalyzer.jl b/src/abstractinterpret/abstractanalyzer.jl index 640cb7784..ec031e0be 100644 --- a/src/abstractinterpret/abstractanalyzer.jl +++ b/src/abstractinterpret/abstractanalyzer.jl @@ -253,7 +253,6 @@ function JETInferenceParams end function JETOptimizationParams end # define wrappers of `InferenceParams(...)` and `OptimizationParams(...)` that can accept JET configurations -@static if hasfield(InferenceParams, :max_methods) # VERSION β‰₯ v"1.10.0-DEV.105" for (Params, Func) = ((InferenceParams, JETInferenceParams), (OptimizationParams, JETOptimizationParams)) params = Params() @@ -273,61 +272,14 @@ for (Params, Func) = ((InferenceParams, JETInferenceParams), def = Expr(:(=), sig, body) Core.eval(@__MODULE__, def) end -else -function JETInferenceParams( - params::InferenceParams = InferenceParams(); - ipo_constant_propagation::Bool = params.ipo_constant_propagation, - aggressive_constant_propagation::Bool = params.aggressive_constant_propagation, - unoptimize_throw_blocks::Bool = params.unoptimize_throw_blocks, - max_methods::Int = params.MAX_METHODS, - union_splitting::Int = params.MAX_UNION_SPLITTING, - apply_union_enum::Int = params.MAX_APPLY_UNION_ENUM, - tupletype_depth::Int = params.TUPLE_COMPLEXITY_LIMIT_DEPTH, - tuple_splat::Int = params.MAX_TUPLE_SPLAT, - __jetconfigs...) - return InferenceParams(; ipo_constant_propagation, - aggressive_constant_propagation, - unoptimize_throw_blocks, - max_methods, - union_splitting, - apply_union_enum, - tupletype_depth, - tuple_splat) -end -function JETOptimizationParams( - params::OptimizationParams=OptimizationParams(); - inlining::Bool = params.inlining, - inline_cost_threshold::Int = params.inline_cost_threshold, - inline_nonleaf_penalty::Int = params.inline_nonleaf_penalty, - inline_tupleret_bonus::Int = params.inline_tupleret_bonus, - inline_error_path_cost::Int = params.inline_error_path_cost, - tuple_splat::Int = params.MAX_TUPLE_SPLAT, - compilesig_invokes::Bool = params.compilesig_invokes, - trust_inference::Bool = params.trust_inference, - assume_fatal_throw::Bool = params.assume_fatal_throw, - __jetconfigs...) - return OptimizationParams(; inlining, - inline_cost_threshold, - inline_nonleaf_penalty, - inline_tupleret_bonus, - inline_error_path_cost, - tuple_splat, - compilesig_invokes, - trust_inference, - assume_fatal_throw) -end -end # hasfield(InferenceParams, :max_methods) # VERSION β‰₯ v"1.10.0-DEV.105" # assert that the wrappers create same objects as the original constructors for (Params, Func) = ((InferenceParams, JETInferenceParams), (OptimizationParams, JETOptimizationParams)) @assert Params() == Func() end -@static if hasfield(InferenceParams, :max_methods) # VERSION β‰₯ v"1.10.0-DEV.105" - # assert that `Effects(::Effects; ...)`-like constructors work as expected - @assert JETInferenceParams(InferenceParams(); max_methods=1).max_methods == 1 - @assert !JETOptimizationParams(OptimizationParams(); inlining=false).inlining -end +@assert JETInferenceParams(InferenceParams(); max_methods=1).max_methods == 1 +@assert !JETOptimizationParams(OptimizationParams(); inlining=false).inlining Base.show(io::IO, state::AnalyzerState) = print(io, typeof(state), "(...)") diff --git a/src/abstractinterpret/inferenceerrorreport.jl b/src/abstractinterpret/inferenceerrorreport.jl index 8950b8b33..07882184d 100644 --- a/src/abstractinterpret/inferenceerrorreport.jl +++ b/src/abstractinterpret/inferenceerrorreport.jl @@ -300,11 +300,7 @@ function handle_sig_static_parameter!(sig::Vector{Any}, s::StateAtPC, expr::Expr i = first(expr.args)::Int sv = first(s) name = sparam_name((sv.linfo.def::Method).sig::UnionAll, i) - @static if VERSION β‰₯ v"1.10.0-DEV.556" - typ = widenconst(sv.sptypes[i].typ) - else - typ = widenconst(CC.unwrap_maybeundefsp(sv.sptypes[i])) - end + typ = widenconst(sv.sptypes[i].typ) push!(sig, String(name), typ) return sig end @@ -346,13 +342,8 @@ function handle_sig!(sig::Vector{Any}, s::StateAtPC, slot::SlotNumber) repr = String(name) end # we can use per-program counter type after inference - @static if VERSION β‰₯ v"1.10.0-DEV.750" - typ = safewidenconst((sv isa InferenceState && CC.is_inferred(sv)) ? - get_slottype(sv, slot) : get_slottype(s, slot)) - else - typ = safewidenconst((sv isa InferenceState && sv.inferred) ? - get_slottype(sv, slot) : get_slottype(s, slot)) - end + typ = safewidenconst((sv isa InferenceState && CC.is_inferred(sv)) ? + get_slottype(sv, slot) : get_slottype(s, slot)) push!(sig, repr, typ) return sig end diff --git a/src/abstractinterpret/typeinfer.jl b/src/abstractinterpret/typeinfer.jl index 58de9f8b6..e0f91b870 100644 --- a/src/abstractinterpret/typeinfer.jl +++ b/src/abstractinterpret/typeinfer.jl @@ -23,76 +23,33 @@ function CC.abstract_call_method(analyzer::AbstractAnalyzer, return ret end -@static if VERSION β‰₯ v"1.10.0-DEV.1345" -let # overload `const_prop_call` - @static if VERSION β‰₯ v"1.11.0-DEV.233" || v"1.11.0-DEV" > VERSION β‰₯ v"1.10.0-beta1.11" - sigs_ex = :(analyzer::AbstractAnalyzer, - mi::MethodInstance, result::MethodCallResult, arginfo::ArgInfo, sv::InferenceState, - concrete_eval_result::Union{Nothing,CC.ConstCallResults}) - args_ex = :(analyzer::AbstractInterpreter, - mi::MethodInstance, result::MethodCallResult, arginfo::ArgInfo, sv::InferenceState, - concrete_eval_result::Union{Nothing,CC.ConstCallResults}) - else - sigs_ex = :(analyzer::AbstractAnalyzer, - mi::MethodInstance, result::MethodCallResult, arginfo::ArgInfo, sv::InferenceState) - args_ex = :(analyzer::AbstractInterpreter, - mi::MethodInstance, result::MethodCallResult, arginfo::ArgInfo, sv::InferenceState) - end - @eval function CC.const_prop_call($(sigs_ex.args...)) - set_cache_target!(analyzer, :const_prop_call => sv.result) - const_result = @invoke CC.const_prop_call($(args_ex.args...)) - @assert get_cache_target(analyzer) === nothing "invalid JET analysis state" - if const_result !== nothing - # successful constant prop', we need to update reports - collect_callee_reports!(analyzer, sv) - end - return const_result - end -end -else -function CC.abstract_call_method_with_const_args(analyzer::AbstractAnalyzer, - result::MethodCallResult, @nospecialize(f), arginfo::ArgInfo, si::StmtInfo, match::MethodMatch, - sv::InferenceState, invokecall::Union{Nothing,CC.InvokeCall}=nothing) - set_cache_target!(analyzer, :abstract_call_method_with_const_args => sv.result) - const_result = @invoke CC.abstract_call_method_with_const_args(analyzer::AbstractInterpreter, - result::MethodCallResult, f::Any, arginfo::ArgInfo, si::StmtInfo, match::MethodMatch, - sv::InferenceState, invokecall::Union{Nothing,CC.InvokeCall}) - # make sure we reset the cache target because at this point we may have not hit - # `CC.cache_lookup(linfo::MethodInstance, given_argtypes::Argtypes, view::AbstractAnalyzerView)` - set_cache_target!(analyzer, nothing) +@eval function CC.const_prop_call(analyzer::AbstractAnalyzer, + mi::MethodInstance, result::MethodCallResult, arginfo::ArgInfo, sv::InferenceState, + concrete_eval_result::Union{Nothing,CC.ConstCallResults}) + set_cache_target!(analyzer, :const_prop_call => sv.result) + const_result = @invoke CC.const_prop_call(analyzer::AbstractInterpreter, + mi::MethodInstance, result::MethodCallResult, arginfo::ArgInfo, sv::InferenceState, + concrete_eval_result::Union{Nothing,CC.ConstCallResults}) + @assert get_cache_target(analyzer) === nothing "invalid JET analysis state" if const_result !== nothing # successful constant prop', we need to update reports collect_callee_reports!(analyzer, sv) end return const_result end -end # @static if VERSION β‰₯ v"1.10.0-DEV.1345" -let # overload `concrete_eval_call` - @static if VERSION β‰₯ v"1.10.0-DEV.1345" - sigs_ex = :(analyzer::AbstractAnalyzer, - @nospecialize(f), result::MethodCallResult, arginfo::ArgInfo, - sv::InferenceState, invokecall::Union{Nothing,CC.InvokeCall}) - args_ex = :(analyzer::AbstractInterpreter, - f::Any, result::MethodCallResult, arginfo::ArgInfo, - sv::InferenceState, invokecall::Union{Nothing,CC.InvokeCall}) - else - sigs_ex = :(analyzer::AbstractAnalyzer, - @nospecialize(f), result::MethodCallResult, arginfo::ArgInfo, si::StmtInfo, - sv::InferenceState, invokecall::Union{Nothing,CC.InvokeCall}) - args_ex = :(analyzer::AbstractInterpreter, - f::Any, result::MethodCallResult, arginfo::ArgInfo, si::StmtInfo, - sv::InferenceState, invokecall::Union{Nothing,CC.InvokeCall}) - end - @eval function CC.concrete_eval_call($(sigs_ex.args...)) - ret = @invoke CC.concrete_eval_call($(args_ex.args...)) - if ret isa CC.ConstCallResults - # this frame has been concretized, now we throw away reports collected - # during the previous non-constant, abstract-interpretation - filter_lineages!(analyzer, sv.result, result.edge::MethodInstance) - end - return ret +function CC.concrete_eval_call(analyzer::AbstractAnalyzer, + @nospecialize(f), result::MethodCallResult, arginfo::ArgInfo, + sv::InferenceState, invokecall::Union{Nothing,CC.InvokeCall}) + ret = @invoke CC.concrete_eval_call(analyzer::AbstractInterpreter, + f::Any, result::MethodCallResult, arginfo::ArgInfo, + sv::InferenceState, invokecall::Union{Nothing,CC.InvokeCall}) + if ret isa CC.ConstCallResults + # this frame has been concretized, now we throw away reports collected + # during the previous non-constant, abstract-interpretation + filter_lineages!(analyzer, sv.result, result.edge::MethodInstance) end + return ret end function CC.abstract_call_known(analyzer::AbstractAnalyzer, @@ -280,7 +237,6 @@ struct JETCallback end @static if VERSION β‰₯ v"1.11.0-DEV.798" - function add_jet_callback!(mi::MethodInstance, analysis_cache::AnalysisCache) callback = JETCallback(analysis_cache) CC.add_invalidation_callback!(callback, mi) @@ -288,9 +244,7 @@ end function (callback::JETCallback)(replaced::MethodInstance, max_world::UInt32) delete!(callback.analysis_cache, replaced) end - else - function add_jet_callback!(mi::MethodInstance, analysis_cache::AnalysisCache) callback = JETCallback(analysis_cache) if !isdefined(mi, :callbacks) @@ -303,7 +257,6 @@ function add_jet_callback!(mi::MethodInstance, analysis_cache::AnalysisCache) end return nothing end - function (callback::JETCallback)(replaced::MethodInstance, max_world::UInt32, seen::IdSet{MethodInstance} = IdSet{MethodInstance}()) push!(seen, replaced) @@ -318,7 +271,6 @@ function (callback::JETCallback)(replaced::MethodInstance, max_world::UInt32, end return nothing end - end # local @@ -339,21 +291,13 @@ function CC.cache_lookup(𝕃ᡒ::CC.AbstractLattice, mi::MethodInstance, given_ isa(inf_result, InferenceResult) || return inf_result # constant prop' hits a cycle (recur into same non-constant analysis), we just bail out - @static if VERSION β‰₯ v"1.10.0-DEV.750" - inf_result.result === nothing && return inf_result - else - isa(inf_result.result, InferenceState) && return inf_result - end + inf_result.result === nothing && return inf_result # cache hit, restore reports from the local report cache if cache_target !== nothing context, caller = cache_target - @static if VERSION β‰₯ v"1.10.0-DEV.1345" - @assert context === :const_prop_call "invalid JET analysis state" - else - @assert context === :abstract_call_method_with_const_args "invalid JET analysis state" - end + @assert context === :const_prop_call "invalid JET analysis state" # as the analyzer uses the reports that are cached by the abstract-interpretation # with the extended lattice elements, here we should throw-away the error reports @@ -520,20 +464,12 @@ function CC._typeinf(analyzer::AbstractAnalyzer, frame::InferenceState) for caller in frames caller.valid_worlds = valid_worlds CC.finish(caller, analyzer) - @static if !(VERSION β‰₯ v"1.10.0-DEV.750") - # finalize and record the linfo result - caller.inferred = true - end end for frame in frames caller = frame.result opt = caller.src if opt isa OptimizationState{typeof(analyzer)} - @static if VERSION β‰₯ v"1.10.0-DEV.757" - CC.optimize(analyzer, opt, caller) - else - CC.optimize(analyzer, opt, OptimizationParams(analyzer), caller) - end + CC.optimize(analyzer, opt, caller) end end for frame in frames diff --git a/src/analyzers/jetanalyzer.jl b/src/analyzers/jetanalyzer.jl index ab2a15a12..af34b32bd 100644 --- a/src/analyzers/jetanalyzer.jl +++ b/src/analyzers/jetanalyzer.jl @@ -86,15 +86,13 @@ CC.may_optimize(::JETAnalyzer) = false CC.method_table(analyzer::JETAnalyzer) = analyzer.method_table -@static if VERSION β‰₯ v"1.10.0-DEV.25" -import .CC: typeinf_lattice, ipo_lattice +import .CC: + typeinf_lattice, ipo_lattice, widenlattice, is_valid_lattice_norec, + βŠ‘, tmerge, tmeet, _getfield_tfunc using .CC: AbstractLattice, InferenceLattice, MustAliasesLattice, InterMustAliasesLattice, BaseInferenceLattice, IPOResultLattice -@static if VERSION β‰₯ v"1.10.0-DEV.197" -import .CC: widenlattice, is_valid_lattice_norec, βŠ‘, tmerge, tmeet, _getfield_tfunc - @doc """ IntrinsicErrorCheckLattice <: AbstractLattice @@ -111,17 +109,9 @@ CC.is_valid_lattice_norec(::IntrinsicErrorCheckLattice, @nospecialize(elem)) = f @nospecs CC.tmerge(𝕃::IntrinsicErrorCheckLattice, x, y) = tmerge(widenlattice(𝕃), x, y) @nospecs CC.tmeet(𝕃::IntrinsicErrorCheckLattice, x, t::Type) = tmeet(widenlattice(𝕃), x, t) @nospecs CC._getfield_tfunc(𝕃::IntrinsicErrorCheckLattice, xs...) = _getfield_tfunc(widenlattice(𝕃), xs...) - CC.typeinf_lattice(::JETAnalyzer) = InferenceLattice(IntrinsicErrorCheckLattice(MustAliasesLattice(BaseInferenceLattice.instance))) CC.ipo_lattice(::JETAnalyzer) = InferenceLattice(IntrinsicErrorCheckLattice(InterMustAliasesLattice(IPOResultLattice.instance))) -else # @static if VERSION β‰₯ v"1.10.0-DEV.197" -CC.typeinf_lattice(::JETAnalyzer) = InferenceLattice(MustAliasesLattice(BaseInferenceLattice.instance)) -CC.ipo_lattice(::JETAnalyzer) = InferenceLattice(InterMustAliasesLattice(IPOResultLattice.instance)) - -end # @static if VERSION β‰₯ v"1.10.0-DEV.197" -end # @static if VERSION β‰₯ v"1.10.0-DEV.25" - # AbstractAnalyzer API # ==================== @@ -190,55 +180,6 @@ a package, or improve the accuracy of base abstract interpretation analysis. # getting rid of the false positive error from `getindex((), i)`. @overlay JET_METHOD_TABLE Base.iterate(::Tuple{}, ::Int) = nothing -# take the effects of https://github.com/JuliaLang/julia/pull/49801 for release versions -@static if VERSION < v"1.10.0-DEV.1289" -@overlay JET_METHOD_TABLE Base.@assume_effects :foldable function Base.aligned_sizeof(@nospecialize T::Type) - if isa(T, Union) - if Base.allocatedinline(T) - # NOTE this check is equivalent to `isbitsunion(T)`, we can improve type - # inference in the second branch with the outer `isa(T, Union)` check - _, sz, al = Base.uniontype_layout(T) - return Base.LLT_ALIGN(sz, al) - end - elseif Base.allocatedinline(T) - al = Base.datatype_alignment(T) - return Base.LLT_ALIGN(Core.sizeof(T), al) - end - return Core.sizeof(Ptr{Cvoid}) -end -end - -# take the effects of https://github.com/JuliaLang/julia/pull/48136 for release versions -@static if VERSION < v"1.10.0-DEV.286" # || VERSION β‰₯ v"1.9" -@overlay JET_METHOD_TABLE Base.@assume_effects :total function Base.array_subpadding(S, T) - lcm_size = lcm(sizeof(S), sizeof(T)) - s, t = Base.CyclePadding(S), Base.CyclePadding(T) - checked_size = 0 - # use of Stateful harms inference and makes this vulnerable to invalidation - (pad, tstate) = let - it = iterate(t) - it === nothing && return true - it - end - (ps, sstate) = let - it = iterate(s) - it === nothing && return false - it - end - while checked_size < lcm_size - while true - # See if there's corresponding padding in S - ps.offset > pad.offset && return false - intersect(ps, pad) == pad && break - ps, sstate = iterate(s, sstate) - end - checked_size = pad.offset + pad.size - pad, tstate = iterate(t, tstate) - end - return true -end -end # @static if VERSION < v"1.10.0-DEV.286" - # overloads # ========= @@ -285,15 +226,6 @@ function CC.abstract_call_gf_by_type(analyzer::JETAnalyzer, f::Any, arginfo::ArgInfo, si::StmtInfo, atype::Any, sv::InferenceState, max_methods::Int) ReportPass(analyzer)(MethodErrorReport, analyzer, sv, ret, arginfo.argtypes, atype) ReportPass(analyzer)(UnanalyzedCallReport, analyzer, sv, ret, atype) - @static if !hasmethod(CC.from_interprocedural!, (AbstractInterpreter, - Any, InferenceState, ArgInfo, Any)) - # For v1.9 compatibility (see the `CC.from_interprocedural!` overload below) - if JETAnalyzerConfig(analyzer).ignore_missing_comparison - if ret.rt === Union{Bool,Missing} - ret = CallMeta(Any, ret.effects, ret.info) - end - end - end return ret end @@ -374,30 +306,16 @@ function CC.concrete_eval_eligible(analyzer::JETAnalyzer, end res = @invoke CC.concrete_eval_eligible(analyzer::AbstractAnalyzer, f::Any, newresult::MethodCallResult, arginfo::ArgInfo, sv::InferenceState) - @static if VERSION β‰₯ v"1.10.0-DEV.1345" - if res === :concrete_eval - return :concrete_eval - end - else - if res === true - return true - end + if res === :concrete_eval + return :concrete_eval end elseif istopfunction(f, :fieldindex) if concrete_eval_eligible_ignoring_overlay(result, arginfo) - @static if VERSION β‰₯ v"1.10.0-DEV.1345" - return :concrete_eval - else - return true - end + return :concrete_eval end end # disables both concrete evaluation and semi-concrete interpretation - @static if VERSION β‰₯ v"1.10.0-DEV.1345" - return :none - else - return nothing - end + return :none end function concrete_eval_eligible_ignoring_overlay(result::MethodCallResult, arginfo::ArgInfo) @@ -520,7 +438,7 @@ function CC.builtin_tfunction(analyzer::JETAnalyzer, # `IntrinsicError` is a special marker object that JET uses to indicate an erroneous # intrinsic function call, so fix it up here to `Bottom` - if @static VERSION β‰₯ v"1.10.0-DEV.197" ? (ret isa IntrinsicError) : false + if ret isa IntrinsicError ret = Bottom end @@ -768,11 +686,7 @@ function report_method_error_for_union_split!(analyzer::JETAnalyzer, for (i, matchinfo) in enumerate(info.matches) if is_empty_match(matchinfo) if isnothing(split_argtypes) - @static if VERSION β‰₯ v"1.10.0-DEV.833" - split_argtypes = switchtupleunion(typeinf_lattice(analyzer), argtypes) - else - split_argtypes = switchtupleunion(argtypes) - end + split_argtypes = switchtupleunion(typeinf_lattice(analyzer), argtypes) end argtypesβ€² = split_argtypes[i]::Vector{Any} if !sound && report_reduce_empty_error!(analyzer, sv, argtypesβ€²) @@ -786,11 +700,7 @@ function report_method_error_for_union_split!(analyzer::JETAnalyzer, push!(empty_matches[1], sig_n) elseif sound && !is_fully_covered(matchinfo) if isnothing(split_argtypes) - @static if VERSION β‰₯ v"1.10.0-DEV.833" - split_argtypes = switchtupleunion(typeinf_lattice(analyzer), argtypes) - else - split_argtypes = switchtupleunion(argtypes) - end + split_argtypes = switchtupleunion(typeinf_lattice(analyzer), argtypes) end argtypesβ€² = split_argtypes[i]::Vector{Any} if uncovered_matches === nothing @@ -929,11 +839,7 @@ function report_undef_global_var!(analyzer::JETAnalyzer, sv::InferenceState, gr: is_corecompiler_undefglobal(gr) && return false # if this global var is explicitly type-declared, it will be likely get assigned somewhere # TODO give this permission only to top-level analysis - @static if VERSION β‰₯ v"1.10.0-DEV.145" - ccall(:jl_get_binding_type, Any, (Any, Any), gr.mod, gr.name) !== nothing && return false - else - ccall(:jl_binding_type, Any, (Any, Any), gr.mod, gr.name) !== nothing && return false - end + ccall(:jl_get_binding_type, Any, (Any, Any), gr.mod, gr.name) !== nothing && return false begin @label report add_new_report!(analyzer, sv.result, UndefVarErrorReport(sv, gr)) return true @@ -961,7 +867,7 @@ end report_undef_static_parameter!(analyzer, sv, n) function report_undef_static_parameter!(analyzer::JETAnalyzer, sv::InferenceState, n::Int) if 1 ≀ n ≀ length(sv.sptypes) - if (@static VERSION β‰₯ v"1.10.0-DEV.556" ? sv.sptypes[n].typ : sv.sptypes[n]) === Any + if sv.sptypes[n].typ === Any tv = sv.linfo.sparam_vals[n] add_new_report!(analyzer, sv.result, UndefVarErrorReport(sv, tv)) return true @@ -1023,11 +929,7 @@ end report_global_assignment!(analyzer, sv, mod, name, vtyp, #=sound=#false) function report_global_assignment!(analyzer::JETAnalyzer, sv::InferenceState, mod::Module, name::Symbol, @nospecialize(vtyp), sound::Bool) - @static if VERSION β‰₯ v"1.10.0-DEV.145" - btyp = ccall(:jl_get_binding_type, Any, (Any, Any), mod, name) - else - btyp = ccall(:jl_binding_type, Any, (Any, Any), mod, name) - end + btyp = ccall(:jl_get_binding_type, Any, (Any, Any), mod, name) if btyp !== nothing vtyp = widenconst(ignorelimited(vtyp)) if !(sound ? vtyp βŠ‘ btyp : hasintersect(vtyp, btyp)) @@ -1183,8 +1085,6 @@ end print_report_message(io::IO, r::BuiltinErrorReport) = print(io, r.msg) const GENERAL_BUILTIN_ERROR_MSG = "invalid builtin function call" -@static if VERSION β‰₯ v"1.10.0-DEV.197" - # report erroneous intrinsic function calls @doc """ @@ -1271,8 +1171,6 @@ import .CC: bitcast_tfunc, conversion_tfunc, math_tfunc, shift_tfunc, cmp_tfunc, @nospecs CC.cmp_tfunc(𝕃::IntrinsicErrorCheckLattice, a, b) = with_intrinsic_errorcheck(Bool, a, b, #=shift=#true) @nospecs CC.chk_tfunc(𝕃::IntrinsicErrorCheckLattice, a, b) = with_intrinsic_errorcheck(Tuple{widenconst(a),Bool}, a, b, #=shift=#true) -end # @static if VERSION >= v"1.10.0-DEV.197" - function (::BasicPass)(::Type{AbstractBuiltinErrorReport}, analyzer::JETAnalyzer, sv::InferenceState, @nospecialize(f), argtypes::Argtypes, @nospecialize(ret)) @assert !(f === throw) "`throw` calls should be handled either by the report pass of `SeriousExceptionReport` or `UncaughtExceptionReport`" if f === getfield @@ -1288,7 +1186,7 @@ function (::BasicPass)(::Type{AbstractBuiltinErrorReport}, analyzer::JETAnalyzer elseif length(argtypes) == 2 && is_division_func(f) report_divide_error!(analyzer, sv, f, argtypes) && return true end - if @static VERSION >= v"1.10.0-DEV.197" ? (ret isa IntrinsicError) : false + if ret isa IntrinsicError msg = LazyString(f, ": ", ret.reason) report = BuiltinErrorReport(sv, f, msg) add_new_report!(analyzer, sv.result, report) diff --git a/src/analyzers/optanalyzer.jl b/src/analyzers/optanalyzer.jl index 38c319ff3..ddd94c301 100644 --- a/src/analyzers/optanalyzer.jl +++ b/src/analyzers/optanalyzer.jl @@ -225,7 +225,6 @@ struct OptAnalysisPass <: ReportPass end optanalyzer_function_filter(@nospecialize f) = true -@static if VERSION β‰₯ v"1.11.0-DEV.233" || VERSION β‰₯ v"1.10.0-beta1.11" function CC.const_prop_call(analyzer::OptAnalyzer, mi::MethodInstance, result::MethodCallResult, arginfo::ArgInfo, sv::InferenceState, concrete_eval_result::Union{Nothing,CC.ConstCallResults}) @@ -239,7 +238,6 @@ function CC.const_prop_call(analyzer::OptAnalyzer, end return ret end - function CC.const_prop_call(analyzer::OptAnalyzer, mi::MethodInstance, result::MethodCallResult, arginfo::ArgInfo, sv::CC.IRInterpretationState, concrete_eval_result::Union{Nothing,CC.ConstCallResults}) @@ -252,7 +250,6 @@ function CC.const_prop_call(analyzer::OptAnalyzer, mi::MethodInstance, result::MethodCallResult, arginfo::ArgInfo, sv::CC.IRInterpretationState, nothing::Nothing) end -end # TODO better to work only `finish!` function CC.finish(frame::InferenceState, analyzer::OptAnalyzer) @@ -339,10 +336,7 @@ function CC.finish!(analyzer::OptAnalyzer, frame::InferenceState) if src isa OptimizationState{typeof(analyzer)} ReportPass(analyzer)(RuntimeDispatchReport, analyzer, caller, src) elseif (@static JET_DEV_MODE ? true : false) - if (@static VERSION < v"1.10.0-DEV.551" && true) && isa(src, CC.ConstAPI) - # the optimization was very successful (i.e. fully constant folded), - # nothing to report - elseif src === nothing # the optimization didn't happen + if src === nothing # the optimization didn't happen else # and this pass should never happen # NOTE `src` never be `CodeInfo` since `CC.may_discard_trees(::OptAnalyzer) === false` Core.eval(@__MODULE__, :(src = $src)) diff --git a/src/toplevel/virtualprocess.jl b/src/toplevel/virtualprocess.jl index df54ac79c..928b137e4 100644 --- a/src/toplevel/virtualprocess.jl +++ b/src/toplevel/virtualprocess.jl @@ -531,7 +531,7 @@ function analyze_from_definitions!(analyzer::AbstractAnalyzer, res::VirtualProce analyzer = AbstractAnalyzer(analyzer, state) end for (i, tt) in enumerate(res.toplevel_signatures) - match = _which(tt; + match = Base._which(tt; # NOTE use the latest world counter with `method_table(analyzer)` unwrapped, # otherwise it may use a world counter when this method isn't defined yet method_table=unwrap_method_table(method_table(analyzer)), @@ -1469,11 +1469,7 @@ function analyze_toplevel!(analyzer::AbstractAnalyzer, src::CodeInfo) mi.def = mod = get_toplevelmod(analyzer) transform_abstract_global_symbols!(src, analyzer) resolve_toplevel_symbols!(src, mod) - @static if VERSION β‰₯ v"1.10.0-DEV.112" - @atomic mi.uninferred = src - else - mi.uninferred = src - end + @atomic mi.uninferred = src result = InferenceResult(mi); init_result!(analyzer, result) diff --git a/src/ui/print.jl b/src/ui/print.jl index db547fc82..e661e6eb9 100644 --- a/src/ui/print.jl +++ b/src/ui/print.jl @@ -203,7 +203,7 @@ function print_frame_sig(io, frame) if m isa Module Base.show_mi(io, mi, #=from_stackframe=#true) else - show_spec_sig(IOContext(io, :backtrace=>true), m, mi.specTypes) + Base.StackTraces.show_spec_sig(IOContext(io, :backtrace=>true), m, mi.specTypes) end end @@ -226,39 +226,6 @@ function print_frame_loc(io, frame, config, color) printstyled(io, ' ', path, ':', frame.line; color) end -@static if VERSION β‰₯ v"1.10.0-DEV.1394" -using Base.StackTraces: show_spec_sig -else -function show_spec_sig(io::IO, m::Method, @nospecialize(sig::Type)) - if get(io, :limit, :false)::Bool - if !haskey(io, :displaysize) - io = IOContext(io, :displaysize => displaysize(io)) - end - end - argnames = Base.method_argnames(m) - argnames = replace(argnames, :var"#unused#" => :var"") - if m.nkw > 0 - # rearrange call kw_impl(kw_args..., func, pos_args...) to func(pos_args...; kw_args) - kwarg_types = Any[ fieldtype(sig, i) for i = 2:(1+m.nkw) ] - uw = Base.unwrap_unionall(sig)::DataType - pos_sig = Base.rewrap_unionall(Tuple{uw.parameters[(m.nkw+2):end]...}, sig) - kwnames = argnames[2:(m.nkw+1)] - for i = 1:length(kwnames) - str = string(kwnames[i])::String - if endswith(str, "...") - kwnames[i] = Symbol(str[1:end-3]) - end - end - Base.show_tuple_as_call(io, m.name, pos_sig; - demangle=true, - kwargs=zip(kwnames, kwarg_types), - argnames=argnames[m.nkw+2:end]) - else - Base.show_tuple_as_call(io, m.name, sig; demangle=true, argnames) - end -end -end # @static if VERSION β‰₯ v"1.10.0-DEV.1394" - function print_error_frame(io, report, config, depth) frame = report.vst[depth] color = report_color(report) diff --git a/test/analyzers/test_jetanalyzer.jl b/test/analyzers/test_jetanalyzer.jl index 3980f9c05..e116e23f5 100644 --- a/test/analyzers/test_jetanalyzer.jl +++ b/test/analyzers/test_jetanalyzer.jl @@ -1032,7 +1032,7 @@ function issue_404(c::Bool) end test_call(issue_404, (Bool,)) -@static VERSION β‰₯ v"1.10.0-DEV.197" && @testset "intrinsic errors" begin +@testset "intrinsic errors" begin let result = report_call((Int32,Int64)) do x, y return Core.Intrinsics.add_int(x, y) end diff --git a/test/analyzers/test_optanalyzer.jl b/test/analyzers/test_optanalyzer.jl index b02a4c6ae..23b36bac9 100644 --- a/test/analyzers/test_optanalyzer.jl +++ b/test/analyzers/test_optanalyzer.jl @@ -188,11 +188,7 @@ end @testset "OptAnalyzer configurations" begin @testset "function_filter" begin - @static if hasfield(Core.Compiler.InferenceParams, :max_methods) # VERSION β‰₯ v"1.10.0-DEV.105" - @assert JET.InferenceParams(JET.OptAnalyzer()).max_union_splitting < 5 - else - @assert JET.InferenceParams(JET.OptAnalyzer()).MAX_UNION_SPLITTING < 5 - end + @assert JET.InferenceParams(JET.OptAnalyzer()).max_union_splitting < 5 let result = report_opt((Vector{Any},)) do xs with_runtime_dispatch(xs[1]) diff --git a/test/self_check.jl b/test/self_check.jl index 54f3dce60..420abd63a 100644 --- a/test/self_check.jl +++ b/test/self_check.jl @@ -36,7 +36,7 @@ let target_modules = (JET,) f === zero || f === JET.copy_report || f === JET.handle_sig! || - f === JET._which || + f === Base._which || f === Base.rewrap_unionall || f === JET.nameof || false) diff --git a/test/test_misc.jl b/test/test_misc.jl index 47dcf89a9..62a20c504 100644 --- a/test/test_misc.jl +++ b/test/test_misc.jl @@ -10,8 +10,6 @@ using JET, Test test_call(getproperty, (Any,Symbol)) end -@static if isdefined(Base, :specializations) - f_method_instance(s::AbstractString) = sum(s) try f_method_instance("throws") @@ -24,8 +22,6 @@ end @test !isempty(JET.get_reports(report_opt(mi))) end -end # @static - @testset "`find_pkg`" begin using Pkg, JET using JET: find_pkg