Skip to content

Commit

Permalink
bump the minimum supported Julia version to 1.10 (LTS) (#654)
Browse files Browse the repository at this point in the history
* bump the minimum supported Julia version to 1.10 (LTS)

Maintaining this package that closely depends on Julia internals across
multiple Julia versions is very cumbersome. Now that the LTS has been
updated to 1.10, let's drop compatibility with earlier versions and
simplify the code.

* use `Base._uncompressed_ir`

* use `Base.method_instances`

* remove unnecessary `@static` from `bulitins.jl`

* Update .github/workflows/CI.yml

Co-authored-by: Kristoffer Carlsson <[email protected]>

* fix comment

* make this a patch bump

---------

Co-authored-by: Kristoffer Carlsson <[email protected]>
  • Loading branch information
aviatesk and KristofferC authored Nov 21, 2024
1 parent 0421a75 commit cc89e74
Show file tree
Hide file tree
Showing 19 changed files with 166 additions and 366 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ jobs:
fail-fast: false
matrix:
include:
- version: '1.6' # old LTS
- version: '1' # current stable
os: ubuntu-latest
arch: x64
- version: '1.10' # current stable
- version: '1.10' # lowest version supported
os: ubuntu-latest
arch: x64
- version: '~1.11.0-0' # next release
- version: '1.12-nightly' # next release
os: ubuntu-latest
arch: x64
- version: 'nightly' # dev
Expand Down
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "JuliaInterpreter"
uuid = "aa1ae85d-cabe-5617-a682-6adf51b2e16a"
version = "0.9.37"
version = "0.9.38"

[deps]
CodeTracking = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2"
Expand All @@ -10,7 +10,7 @@ UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[compat]
CodeTracking = "0.5.9, 1"
julia = "1.6"
julia = "1.10"

[extras]
CassetteOverlay = "d78b62d4-37fa-4a6f-acd8-2f19986eb9ee"
Expand Down
52 changes: 30 additions & 22 deletions bin/generate_builtins.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,26 @@
# Should be run on the latest Julia nightly
using InteractiveUtils

# All builtins present in 1.6
const ALWAYS_PRESENT = Core.Builtin[
(<:), (===), Core._abstracttype, Core._apply_iterate, Core._apply_pure,
Core._call_in_world, Core._call_latest, Core._equiv_typedef, Core._expr,
Core._primitivetype, Core._setsuper!, Core._structtype, Core._typebody!,
Core._typevar, Core.apply_type, Core.ifelse, Core.sizeof, Core.svec,
applicable, fieldtype, getfield, invoke, isa, isdefined, nfields,
setfield!, throw, tuple, typeassert, typeof
# Builtins not present in 1.10 (the lowest supported version)
const RECENTLY_ADDED = Core.Builtin[
Core.current_scope,
Core.memoryref_isassigned,
Core.memoryrefget,
Core.memoryrefmodify!,
Core.memoryrefnew,
Core.memoryrefoffset,
Core.memoryrefreplace!,
Core.memoryrefset!,
Core.memoryrefsetonce!,
Core.memoryrefswap!,
Core.throw_methoderror,
modifyglobal!,
replaceglobal!,
setfieldonce!,
setglobalonce!,
swapglobal!,
]
# Builtins present from 1.6, not builtins (potentially still normal functions) anymore
# Builtins present from 1.10, not builtins (potentially still normal functions) anymore
const RECENTLY_REMOVED = GlobalRef.(Ref(Core), [
:arrayref, :arrayset, :arrayset, :const_arrayref, :memoryref, :set_binding_type!
])
Expand Down Expand Up @@ -132,9 +142,9 @@ function maybe_evaluate_builtin(frame, call_expr, expand::Bool)
f = @lookup(frame, fex)
end
if @static isdefined(Core, :OpaqueClosure) && f isa Core.OpaqueClosure
if f isa Core.OpaqueClosure
if expand
if !Core.Compiler.uncompressed_ir(f.source).inferred
if !Base.uncompressed_ir(f.source).inferred
return Expr(:call, f, args[2:end]...)
else
@debug "not interpreting opaque closure \$f since it contains inferred code"
Expand Down Expand Up @@ -235,7 +245,7 @@ function maybe_evaluate_builtin(frame, call_expr, expand::Bool)

id = findfirst(isequal(f), Core.Compiler.T_FFUNC_KEY)
fcall = generate_fcall(f, Core.Compiler.T_FFUNC_VAL, id)
if !(f in ALWAYS_PRESENT)
if f in RECENTLY_ADDED
print(io,
"""
$head @static isdefined($(ft.name.module), $(repr(nameof(f)))) && f === $fname
Expand Down Expand Up @@ -324,16 +334,14 @@ function maybe_evaluate_builtin(frame, call_expr, expand::Bool)
"""
if isa(f, Core.IntrinsicFunction)
cargs = getargs(args, frame)
@static if isdefined(Core.Intrinsics, :have_fma)
if f === Core.Intrinsics.have_fma && length(cargs) == 1
cargs1 = cargs[1]
if cargs1 == Float64
return Some{Any}(FMA_FLOAT64[])
elseif cargs1 == Float32
return Some{Any}(FMA_FLOAT32[])
elseif cargs1 == Float16
return Some{Any}(FMA_FLOAT16[])
end
if f === Core.Intrinsics.have_fma && length(cargs) == 1
cargs1 = cargs[1]
if cargs1 == Float64
return Some{Any}(FMA_FLOAT64[])
elseif cargs1 == Float32
return Some{Any}(FMA_FLOAT32[])
elseif cargs1 == Float16
return Some{Any}(FMA_FLOAT16[])
end
end
if f === Core.Intrinsics.muladd_float && length(cargs) == 3
Expand Down
7 changes: 2 additions & 5 deletions src/breakpoints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,9 @@ function framecode_matches_breakpoint(framecode::FrameCode, bp::BreakpointSignat
meth isa Method || return false
bp.f isa Method && return meth === bp.f
f = extract_function_from_method(meth)
if !(bp.f === f || @static isdefined(Core, :kwcall) ?
f === Core.kwcall && let ftype = Base.unwrap_unionall(meth.sig).parameters[3]
if !(bp.f === f || (f === Core.kwcall && let ftype = Base.unwrap_unionall(meth.sig).parameters[3]
!Base.has_free_typevars(ftype) && bp.f isa ftype
end :
Core.kwfunc(bp.f) === f
)
end))
return false
end
bp.sig === nothing && return true
Expand Down
104 changes: 29 additions & 75 deletions src/builtins.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ function maybe_evaluate_builtin(frame, call_expr, expand::Bool)
f = @lookup(frame, fex)
end

if @static isdefined(Core, :OpaqueClosure) && f isa Core.OpaqueClosure
if f isa Core.OpaqueClosure
if expand
if !Core.Compiler.uncompressed_ir(f.source).inferred
if !Base.uncompressed_ir(f.source).inferred
return Expr(:call, f, args[2:end]...)
else
@debug "not interpreting opaque closure $f since it contains inferred code"
Expand Down Expand Up @@ -86,7 +86,7 @@ function maybe_evaluate_builtin(frame, call_expr, expand::Bool)
return Some{Any}(Core._apply_pure(getargs(args, frame)...))
elseif f === Core._call_in_world
return Some{Any}(Core._call_in_world(getargs(args, frame)...))
elseif @static isdefined(Core, :_call_in_world_total) && f === Core._call_in_world_total
elseif f === Core._call_in_world_total
return Some{Any}(Core._call_in_world_total(getargs(args, frame)...))
elseif f === Core._call_latest
args = getargs(args, frame)
Expand All @@ -99,7 +99,7 @@ function maybe_evaluate_builtin(frame, call_expr, expand::Bool)
push!(new_expr.args, QuoteNode(x))
end
return maybe_recurse_expanded_builtin(frame, new_expr)
elseif @static isdefined(Core, :_compute_sparams) && f === Core._compute_sparams
elseif f === Core._compute_sparams
return Some{Any}(Core._compute_sparams(getargs(args, frame)...))
elseif f === Core._equiv_typedef
return Some{Any}(Core._equiv_typedef(getargs(args, frame)...))
Expand All @@ -111,7 +111,7 @@ function maybe_evaluate_builtin(frame, call_expr, expand::Bool)
return Some{Any}(Core._setsuper!(getargs(args, frame)...))
elseif f === Core._structtype
return Some{Any}(Core._structtype(getargs(args, frame)...))
elseif @static isdefined(Core, :_svec_ref) && f === Core._svec_ref
elseif f === Core._svec_ref
return Some{Any}(Core._svec_ref(getargs(args, frame)...))
elseif f === Core._typebody!
return Some{Any}(Core._typebody!(getargs(args, frame)...))
Expand All @@ -123,7 +123,7 @@ function maybe_evaluate_builtin(frame, call_expr, expand::Bool)
end
elseif f === Core.apply_type
return Some{Any}(Core.apply_type(getargs(args, frame)...))
elseif @static isdefined(Core, :compilerbarrier) && f === Core.compilerbarrier
elseif f === Core.compilerbarrier
if nargs == 2
return Some{Any}(Core.compilerbarrier(@lookup(frame, args[2]), @lookup(frame, args[3])))
else
Expand All @@ -139,9 +139,9 @@ function maybe_evaluate_builtin(frame, call_expr, expand::Bool)
else
return Some{Any}(Core.current_scope(getargs(args, frame)...))
end
elseif @static isdefined(Core, :donotdelete) && f === Core.donotdelete
elseif f === Core.donotdelete
return Some{Any}(Core.donotdelete(getargs(args, frame)...))
elseif @static isdefined(Core, :finalizer) && f === Core.finalizer
elseif f === Core.finalizer
if nargs == 2
return Some{Any}(Core.finalizer(@lookup(frame, args[2]), @lookup(frame, args[3])))
elseif nargs == 3
Expand All @@ -151,12 +151,8 @@ function maybe_evaluate_builtin(frame, call_expr, expand::Bool)
else
return Some{Any}(Core.finalizer(getargs(args, frame)...))
end
elseif @static isdefined(Core, :get_binding_type) && f === Core.get_binding_type
if nargs == 2
return Some{Any}(Core.get_binding_type(@lookup(frame, args[2]), @lookup(frame, args[3])))
else
return Some{Any}(Core.get_binding_type(getargs(args, frame)...))
end
elseif f === Core.get_binding_type
return Some{Any}(Core.get_binding_type(getargs(args, frame)...))
elseif f === Core.ifelse
if nargs == 3
return Some{Any}(Core.ifelse(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4])))
Expand Down Expand Up @@ -255,14 +251,8 @@ function maybe_evaluate_builtin(frame, call_expr, expand::Bool)
else
return Some{Any}(getfield(getargs(args, frame)...))
end
elseif @static isdefined(Core, :getglobal) && f === getglobal
if nargs == 2
return Some{Any}(getglobal(@lookup(frame, args[2]), @lookup(frame, args[3])))
elseif nargs == 3
return Some{Any}(getglobal(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4])))
else
return Some{Any}(getglobal(getargs(args, frame)...))
end
elseif f === getglobal
return Some{Any}(getglobal(getargs(args, frame)...))
elseif f === invoke
if !expand
argswrapped = getargs(args, frame)
Expand All @@ -285,7 +275,7 @@ function maybe_evaluate_builtin(frame, call_expr, expand::Bool)
else
return Some{Any}(isdefined(getargs(args, frame)...))
end
elseif @static isdefined(Core, :modifyfield!) && f === modifyfield!
elseif f === modifyfield!
if nargs == 4
return Some{Any}(modifyfield!(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4]), @lookup(frame, args[5])))
elseif nargs == 5
Expand All @@ -294,20 +284,14 @@ function maybe_evaluate_builtin(frame, call_expr, expand::Bool)
return Some{Any}(modifyfield!(getargs(args, frame)...))
end
elseif @static isdefined(Core, :modifyglobal!) && f === modifyglobal!
if nargs == 4
return Some{Any}(modifyglobal!(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4]), @lookup(frame, args[5])))
elseif nargs == 5
return Some{Any}(modifyglobal!(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4]), @lookup(frame, args[5]), @lookup(frame, args[6])))
else
return Some{Any}(modifyglobal!(getargs(args, frame)...))
end
return Some{Any}(modifyglobal!(getargs(args, frame)...))
elseif f === nfields
if nargs == 1
return Some{Any}(nfields(@lookup(frame, args[2])))
else
return Some{Any}(nfields(getargs(args, frame)...))
end
elseif @static isdefined(Core, :replacefield!) && f === replacefield!
elseif f === replacefield!
if nargs == 4
return Some{Any}(replacefield!(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4]), @lookup(frame, args[5])))
elseif nargs == 5
Expand All @@ -318,15 +302,7 @@ function maybe_evaluate_builtin(frame, call_expr, expand::Bool)
return Some{Any}(replacefield!(getargs(args, frame)...))
end
elseif @static isdefined(Core, :replaceglobal!) && f === replaceglobal!
if nargs == 4
return Some{Any}(replaceglobal!(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4]), @lookup(frame, args[5])))
elseif nargs == 5
return Some{Any}(replaceglobal!(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4]), @lookup(frame, args[5]), @lookup(frame, args[6])))
elseif nargs == 6
return Some{Any}(replaceglobal!(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4]), @lookup(frame, args[5]), @lookup(frame, args[6]), @lookup(frame, args[7])))
else
return Some{Any}(replaceglobal!(getargs(args, frame)...))
end
return Some{Any}(replaceglobal!(getargs(args, frame)...))
elseif f === setfield!
if nargs == 3
return Some{Any}(setfield!(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4])))
Expand All @@ -345,25 +321,11 @@ function maybe_evaluate_builtin(frame, call_expr, expand::Bool)
else
return Some{Any}(setfieldonce!(getargs(args, frame)...))
end
elseif @static isdefined(Core, :setglobal!) && f === setglobal!
if nargs == 3
return Some{Any}(setglobal!(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4])))
elseif nargs == 4
return Some{Any}(setglobal!(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4]), @lookup(frame, args[5])))
else
return Some{Any}(setglobal!(getargs(args, frame)...))
end
elseif f === setglobal!
return Some{Any}(setglobal!(getargs(args, frame)...))
elseif @static isdefined(Core, :setglobalonce!) && f === setglobalonce!
if nargs == 3
return Some{Any}(setglobalonce!(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4])))
elseif nargs == 4
return Some{Any}(setglobalonce!(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4]), @lookup(frame, args[5])))
elseif nargs == 5
return Some{Any}(setglobalonce!(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4]), @lookup(frame, args[5]), @lookup(frame, args[6])))
else
return Some{Any}(setglobalonce!(getargs(args, frame)...))
end
elseif @static isdefined(Core, :swapfield!) && f === swapfield!
return Some{Any}(setglobalonce!(getargs(args, frame)...))
elseif f === swapfield!
if nargs == 3
return Some{Any}(swapfield!(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4])))
elseif nargs == 4
Expand All @@ -372,13 +334,7 @@ function maybe_evaluate_builtin(frame, call_expr, expand::Bool)
return Some{Any}(swapfield!(getargs(args, frame)...))
end
elseif @static isdefined(Core, :swapglobal!) && f === swapglobal!
if nargs == 3
return Some{Any}(swapglobal!(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4])))
elseif nargs == 4
return Some{Any}(swapglobal!(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4]), @lookup(frame, args[5])))
else
return Some{Any}(swapglobal!(getargs(args, frame)...))
end
return Some{Any}(swapglobal!(getargs(args, frame)...))
elseif f === throw
if nargs == 1
return Some{Any}(throw(@lookup(frame, args[2])))
Expand Down Expand Up @@ -500,16 +456,14 @@ function maybe_evaluate_builtin(frame, call_expr, expand::Bool)
end
if isa(f, Core.IntrinsicFunction)
cargs = getargs(args, frame)
@static if isdefined(Core.Intrinsics, :have_fma)
if f === Core.Intrinsics.have_fma && length(cargs) == 1
cargs1 = cargs[1]
if cargs1 == Float64
return Some{Any}(FMA_FLOAT64[])
elseif cargs1 == Float32
return Some{Any}(FMA_FLOAT32[])
elseif cargs1 == Float16
return Some{Any}(FMA_FLOAT16[])
end
if f === Core.Intrinsics.have_fma && length(cargs) == 1
cargs1 = cargs[1]
if cargs1 == Float64
return Some{Any}(FMA_FLOAT64[])
elseif cargs1 == Float32
return Some{Any}(FMA_FLOAT32[])
elseif cargs1 == Float16
return Some{Any}(FMA_FLOAT16[])
end
end
if f === Core.Intrinsics.muladd_float && length(cargs) == 3
Expand Down
12 changes: 3 additions & 9 deletions src/commands.jl
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,7 @@ function maybe_step_through_wrapper!(@nospecialize(recurse), frame::Frame)
if unwrap1 isa DataType
param1 = Base.unwrap_unionall(unwrap1.parameters[1])
if param1 isa DataType
is_kw = isdefined(Core, :kwcall) ? param1.name.name === Symbol("#kwcall") :
endswith(String(param1.name.name), "#kw")
is_kw = param1.name.name === Symbol("#kwcall")
end
end
end
Expand Down Expand Up @@ -255,13 +254,8 @@ function maybe_step_through_wrapper!(@nospecialize(recurse), frame::Frame)
end
maybe_step_through_wrapper!(frame::Frame) = maybe_step_through_wrapper!(finish_and_return!, frame)

if isdefined(Core, :kwcall)
const kwhandler = Core.kwcall
const kwextrastep = 0
else
const kwhandler = Core.kwfunc
const kwextrastep = 1
end
const kwhandler = Core.kwcall
const kwextrastep = 0

"""
frame = maybe_step_through_kwprep!(recurse, frame)
Expand Down
Loading

2 comments on commit cc89e74

@aviatesk
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/119895

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.9.38 -m "<description of version>" cc89e748519e4a7d0898adbfc9cdb3278179d8b3
git push origin v0.9.38

Please sign in to comment.