Skip to content

Commit

Permalink
drop support for v1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk committed Dec 30, 2023
1 parent 928c10e commit 9179728
Show file tree
Hide file tree
Showing 15 changed files with 62 additions and 419 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "JET"
uuid = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
authors = ["Shuhei Kadowaki <[email protected]>"]
version = "0.8.21"
version = "0.8.22"

[deps]
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
Expand All @@ -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"
Expand Down
5 changes: 1 addition & 4 deletions docs/src/jetanalysis.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
86 changes: 3 additions & 83 deletions src/JET.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
# ------

Expand Down Expand Up @@ -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
# -----

Expand Down Expand Up @@ -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")

Expand Down Expand Up @@ -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
Expand Down
52 changes: 2 additions & 50 deletions src/abstractinterpret/abstractanalyzer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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), "(...)")

Expand Down
15 changes: 3 additions & 12 deletions src/abstractinterpret/inferenceerrorreport.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 9179728

Please sign in to comment.