Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bump the minimum supported Julia version to 1.10 (LTS) #654

Merged
merged 7 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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' # lowerest version supported
aviatesk marked this conversation as resolved.
Show resolved Hide resolved
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.10.0"
aviatesk marked this conversation as resolved.
Show resolved Hide resolved

[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
22 changes: 10 additions & 12 deletions bin/generate_builtins.jl
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,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 @@ -324,16 +324,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
80 changes: 17 additions & 63 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 @@ -152,11 +152,7 @@ function maybe_evaluate_builtin(frame, call_expr, expand::Bool)
return Some{Any}(Core.finalizer(getargs(args, frame)...))
end
elseif @static isdefined(Core, :get_binding_type) && f === Core.get_binding_type
simeonschaub marked this conversation as resolved.
Show resolved Hide resolved
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
return Some{Any}(Core.get_binding_type(getargs(args, frame)...))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I thought splatting here was bad for inference, which is why n == 2 was special cased before?

Copy link
Member Author

Choose a reason for hiding this comment

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

Now the compiler has the special casings for these builtin functions and it doesn't register any tfuncs for them. Maybe we can recover tfuncs that are simplified version of the special cases.

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 @@ -256,13 +252,7 @@ function maybe_evaluate_builtin(frame, call_expr, expand::Bool)
return Some{Any}(getfield(getargs(args, frame)...))
end
elseif @static isdefined(Core, :getglobal) && f === getglobal
simeonschaub marked this conversation as resolved.
Show resolved Hide resolved
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
return Some{Any}(getglobal(getargs(args, frame)...))
elseif f === invoke
if !expand
argswrapped = getargs(args, frame)
Expand Down Expand Up @@ -294,13 +284,7 @@ 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])))
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 @@ -346,23 +322,9 @@ function maybe_evaluate_builtin(frame, call_expr, expand::Bool)
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
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
return Some{Any}(setglobalonce!(getargs(args, frame)...))
elseif @static isdefined(Core, :swapfield!) && f === swapfield!
if nargs == 3
return Some{Any}(swapfield!(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[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
22 changes: 7 additions & 15 deletions src/construct.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,10 @@ end

get_source(meth::Method) = Base.uncompressed_ast(meth)

@static if VERSION < v"1.10.0-DEV.873" # julia#48766
function get_source(g::GeneratedFunctionStub, env, file, line)
b = g(env..., g.argnames...)
b isa CodeInfo && return b
return eval(b)
end
else
function get_source(g::GeneratedFunctionStub, env, file, line::Int)
b = g(Base.get_world_counter(), LineNumberNode(line, file), env..., g.argnames...)
b isa CodeInfo && return b
return eval(b)
end
function get_source(g::GeneratedFunctionStub, env, file, line::Int)
b = g(Base.get_world_counter(), LineNumberNode(line, file), env..., g.argnames...)
b isa CodeInfo && return b
return eval(b)
end

"""
Expand Down Expand Up @@ -241,10 +233,10 @@ function prepare_call(@nospecialize(f), allargs; enter_generated = false)
end
argtypesv = Any[_Typeof(a) for a in allargs]
argtypes = Tuple{argtypesv...}
if @static isdefined(Core, :OpaqueClosure) && f isa Core.OpaqueClosure
if f isa Core.OpaqueClosure
method = f.source
# don't try to interpret optimized ir
if Core.Compiler.uncompressed_ir(method).inferred
if Base.uncompressed_ir(method).inferred
@debug "not interpreting opaque closure $f since it contains inferred code"
return nothing
end
Expand Down Expand Up @@ -308,7 +300,7 @@ function prepare_framedata(framecode, argvals::Vector{Any}, lenv::SimpleVector=e
islastva = meth.isva && nargs >= meth_nargs
for i = 1:meth_nargs-islastva
# for OCs #self# actually refers to the captures instead
if @static isdefined(Core, :OpaqueClosure) && i == 1 && (oc = argvals[1]) isa Core.OpaqueClosure
if i == 1 && (oc = argvals[1]) isa Core.OpaqueClosure
locals[i], last_reference[i] = Some{Any}(oc.captures), 1
elseif i <= nargs
locals[i], last_reference[i] = Some{Any}(argvals[i]), 1
Expand Down
23 changes: 5 additions & 18 deletions src/interpret.jl
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,7 @@ function evaluate_foreigncall(@nospecialize(recurse), frame::Frame, call_expr::E
sig = scope.sig
args[2] = instantiate_type_in_env(args[2], sig, data.sparams)
arg3 = args[3]
if (@static VERSION < v"1.7.0" && arg3 isa Core.SimpleVector) ||
head === :foreigncall
if head === :foreigncall
args[3] = Core.svec(map(arg3) do arg
instantiate_type_in_env(arg, sig, data.sparams)
end...)
Expand All @@ -209,11 +208,7 @@ function bypass_builtins(@nospecialize(recurse), frame::Frame, call_expr::Expr,
fmod = parentmodule(f)::Module
if fmod === JuliaInterpreter.CompiledCalls || fmod === Core.Compiler
# Fixing https://github.com/JuliaDebug/JuliaInterpreter.jl/issues/432.
@static if VERSION >= v"1.7.0"
return Some{Any}(Base.invoke_in_world(get_world_counter(), f, fargs[2:end]...))
else
return Some{Any}(Base.invokelatest(f, fargs[2:end]...))
end
return Some{Any}(Base.invoke_in_world(get_world_counter(), f, fargs[2:end]...))
else
return Some{Any}(f(fargs[2:end]...))
end
Expand Down Expand Up @@ -326,11 +321,7 @@ function evaluate_methoddef(frame::Frame, node::Expr)
sig = @lookup(frame, node.args[2])::SimpleVector
body = @lookup(frame, node.args[3])::Union{CodeInfo, Expr}
# branching on https://github.com/JuliaLang/julia/pull/41137
@static if isdefined(Core.Compiler, :OverlayMethodTable)
ccall(:jl_method_def, Cvoid, (Any, Ptr{Cvoid}, Any, Any), sig, C_NULL, body, moduleof(frame)::Module)
else
ccall(:jl_method_def, Cvoid, (Any, Any, Any), sig, body, moduleof(frame)::Module)
end
ccall(:jl_method_def, Cvoid, (Any, Ptr{Cvoid}, Any, Any), sig, C_NULL, body, moduleof(frame)::Module)
return f
end

Expand All @@ -346,11 +337,7 @@ function do_assignment!(frame::Frame, @nospecialize(lhs), @nospecialize(rhs))
mod = lhs isa Symbol ? moduleof(frame) : lhs.mod
name = lhs isa Symbol ? lhs : lhs.name
Core.eval(mod, Expr(:global, name))
@static if @isdefined setglobal!
setglobal!(mod, name, rhs)
else
ccall(:jl_set_global, Cvoid, (Any, Any, Any), mod, name, rhs)
end
setglobal!(mod, name, rhs)
end
end

Expand Down Expand Up @@ -461,7 +448,7 @@ function step_expr!(@nospecialize(recurse), frame::Frame, @nospecialize(node), i
# @show node
# end
@assert is_leaf(frame)
@static VERSION >= v"1.8.0-DEV.370" && coverage_visit_line!(frame)
coverage_visit_line!(frame)
local rhs
# For debugging:
# show_stackloc(frame)
Expand Down
6 changes: 1 addition & 5 deletions src/optimize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,7 @@ function replace_coretypes_list!(list::AbstractVector; rev::Bool=false)
isa(x, Core.SSAValue) && return SSAValue(x.id)
isa(x, Core.SlotNumber) && return SlotNumber(x.id)
@static if VERSION < v"1.11.0-DEV.337"
@static if VERSION ≥ v"1.10.0-DEV.631"
isa(x, Core.Compiler.TypedSlot) && return SlotNumber(x.id)
else
isa(x, Core.TypedSlot) && return SlotNumber(x.id)
end
isa(x, Core.Compiler.TypedSlot) && return SlotNumber(x.id)
end
return x
end
Expand Down
Loading
Loading