Skip to content

Commit 10fd8fc

Browse files
authored
Merge pull request #499 from JuliaDebug/avi/lts
update LTS version, drop v1.0 support
2 parents 716d7f6 + 988d98b commit 10fd8fc

16 files changed

+47
-167
lines changed

.github/workflows/CI.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
version:
16-
- '1.0'
17-
- '1'
16+
- '1.6' # LTS
17+
- '1' # current stable
1818
- 'nightly'
1919
os:
2020
- ubuntu-latest

Project.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "JuliaInterpreter"
22
uuid = "aa1ae85d-cabe-5617-a682-6adf51b2e16a"
3-
version = "0.8.21"
3+
version = "0.9.0"
44

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

1111
[compat]
1212
CodeTracking = "0.5.9, 1"
13-
julia = "1"
13+
julia = "1.6"
1414

1515
[extras]
1616
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
@@ -22,9 +22,8 @@ Mmap = "a63ad114-7e13-5084-954f-fe012c677804"
2222
PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"
2323
SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce"
2424
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
25-
TableReader = "70df011a-6618-58d7-8e16-3cf9e384cb47"
2625
Tensors = "48a634ad-e948-5137-8d70-aa71f2a747f4"
2726
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2827

2928
[targets]
30-
test = ["Test", "Dates", "Distributed", "HTTP", "LinearAlgebra", "Mmap", "PyCall", "SHA", "SparseArrays", "Tensors", "TableReader", "DataFrames"]
29+
test = ["DataFrames", "Dates", "Distributed", "HTTP", "LinearAlgebra", "Mmap", "PyCall", "SHA", "SparseArrays", "Tensors", "Test"]

src/commands.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,7 @@ function maybe_step_through_wrapper!(@nospecialize(recurse), frame::Frame)
218218
length(stmts) < 2 && return frame
219219
last = stmts[end-1]
220220
isexpr(last, :(=)) && (last = last.args[2])
221-
comp = VERSION < v"1.4.0-DEV.215" ? startswith : endswith
222-
is_kw = isa(scope, Method) && comp(String(Base.unwrap_unionall(Base.unwrap_unionall(scope.sig).parameters[1]).name.name), "#kw")
221+
is_kw = isa(scope, Method) && endswith(String(Base.unwrap_unionall(Base.unwrap_unionall(scope.sig).parameters[1]).name.name), "#kw")
223222
has_selfarg = isexpr(last, :call) && any(isequal(SlotNumber(1)), last.args)
224223
issplatcall, _callee = unpack_splatcall(last)
225224
if is_kw || has_selfarg || (issplatcall && is_bodyfunc(_callee))

src/construct.jl

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -94,22 +94,6 @@ function get_source(g::GeneratedFunctionStub, env)
9494
return eval(b)
9595
end
9696

97-
function copy_codeinfo(code::CodeInfo)
98-
@static if VERSION < v"1.1.0-DEV.762"
99-
newcode = ccall(:jl_new_struct_uninit, Any, (Any,), CodeInfo)::CodeInfo
100-
for (i, name) in enumerate(fieldnames(CodeInfo))
101-
if isdefined(code, name)
102-
val = getfield(code, name)
103-
ccall(:jl_set_nth_field, Cvoid, (Any, Csize_t, Any), newcode, i-1, val===nothing || isa(val, Union{Type, Method}) ? val : copy(val))
104-
end
105-
end
106-
return newcode
107-
else
108-
# Inline this when support for VERSION above is dropped
109-
return copy(code)
110-
end
111-
end
112-
11397
"""
11498
frun, allargs = prepare_args(fcall, fargs, kwargs)
11599
@@ -148,13 +132,6 @@ function prepare_args(@nospecialize(f), allargs, kwargs)
148132
return f, allargs
149133
end
150134

151-
if VERSION < v"1.2-" || !isdefined(Core.Compiler, :specialize_method)
152-
specialize_method(method::Method, @nospecialize(atypes), sparams::SimpleVector) =
153-
Core.Compiler.code_for_method(method, atypes, sparams, typemax(UInt))
154-
else
155-
const specialize_method = Core.Compiler.specialize_method
156-
end
157-
158135
function prepare_framecode(method::Method, @nospecialize(argtypes); enter_generated=false)
159136
sig = method.sig
160137
if (method.module compiled_modules || method compiled_methods) && !(method interpreted_methods)
@@ -174,7 +151,7 @@ function prepare_framecode(method::Method, @nospecialize(argtypes); enter_genera
174151
# If we're stepping into a staged function, we need to use
175152
# the specialization, rather than stepping through the
176153
# unspecialized method.
177-
code = Core.Compiler.get_staged(specialize_method(method, argtypes, lenv))
154+
code = Core.Compiler.get_staged(Core.Compiler.specialize_method(method, argtypes, lenv))
178155
code === nothing && return nothing
179156
generator = false
180157
else
@@ -282,7 +259,7 @@ end
282259

283260
function prepare_framedata(framecode, argvals::Vector{Any}, lenv::SimpleVector=empty_svec, caller_will_catch_err::Bool=false)
284261
src = framecode.src
285-
slotnames = src.slotnames::SlotNamesType
262+
slotnames = src.slotnames
286263
ssavt = src.ssavaluetypes
287264
ng, ns = isa(ssavt, Int) ? ssavt : length(ssavt::Vector{Any}), length(src.slotflags)
288265
if length(junk_framedata) > 0
@@ -514,15 +491,6 @@ function queuenext!(iter::ExprSplitter)
514491
ex = ex.args[3]::Expr
515492
push_modex!(iter, mod, ex)
516493
return queuenext!(iter)
517-
elseif VERSION < v"1.2" && is_function_def(ex)
518-
# Newer Julia versions insert a LineNumberNode between statements, but at least Julia 1.0 does not.
519-
# Scan the function body for a LNN
520-
lnn = firstline(ex)
521-
if isa(lnn, LineNumberNode)
522-
if iter.lnn === nothing || iter.lnn.line < lnn.line
523-
iter.lnn = LineNumberNode(lnn.line-1, lnn.file)
524-
end
525-
end
526494
elseif head === :macrocall
527495
iter.lnn = ex.args[2]::LineNumberNode
528496
elseif head === :block || head === :toplevel

src/interpret.jl

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -329,15 +329,13 @@ function evaluate_structtype(@nospecialize(recurse), frame, node)
329329
end
330330
end
331331
Core.eval(mod, newstructexpr)
332-
VERSION < v"1.2.0-DEV.239" && set_structtype_const(mod, name)
333332
end
334333

335334
function evaluate_abstracttype(@nospecialize(recurse), frame, node)
336335
name, mod = structname(frame, node)
337336
params = lookup_or_eval(recurse, frame, node.args[2])::SimpleVector
338337
supertype = lookup_or_eval(recurse, frame, node.args[3])::Type
339338
Core.eval(mod, Expr(:abstract_type, name, params, supertype))
340-
VERSION < v"1.2.0-DEV.239" && set_structtype_const(mod, name)
341339
end
342340

343341
function evaluate_primitivetype(@nospecialize(recurse), frame, node)
@@ -346,7 +344,6 @@ function evaluate_primitivetype(@nospecialize(recurse), frame, node)
346344
nbits = node.args[3]::Int
347345
supertype = lookup_or_eval(recurse, frame, node.args[4])::Type
348346
Core.eval(mod, Expr(:primitive_type, name, params, nbits, supertype))
349-
VERSION < v"1.2.0-DEV.239" && set_structtype_const(mod, name)
350347
end
351348

352349
function do_assignment!(frame, @nospecialize(lhs), @nospecialize(rhs))
@@ -407,7 +404,7 @@ function eval_rhs(@nospecialize(recurse), frame, node::Expr)
407404
return length(frame.framedata.exception_frames)
408405
elseif head === :boundscheck
409406
return true
410-
elseif head === :meta || head === :inbounds || head == (@static VERSION >= v"1.2.0-DEV.462" ? :loopinfo : :simdloop) ||
407+
elseif head === :meta || head === :inbounds || head == :loopinfo ||
411408
head === :gc_preserve_begin || head === :gc_preserve_end
412409
return nothing
413410
elseif head === :method && length(node.args) == 1
@@ -517,9 +514,7 @@ function step_expr!(@nospecialize(recurse), frame, @nospecialize(node), istoplev
517514
else
518515
mod, name = moduleof(frame), g::Symbol
519516
end
520-
if VERSION >= v"1.2.0-DEV.239" # depends on https://github.com/JuliaLang/julia/pull/30893
521-
Core.eval(mod, Expr(:const, name))
522-
end
517+
Core.eval(mod, Expr(:const, name))
523518
elseif node.head === :thunk
524519
newframe = Frame(moduleof(frame), node.args[1])
525520
if isa(recurse, Compiled)

src/optimize.jl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,6 @@ function lookup_global_refs!(ex::Expr)
133133
return nothing
134134
end
135135

136-
# See https://github.com/JuliaLang/julia/pull/32800
137-
const foreigncall_version = VERSION < v"1.3.0-alpha.108" ? 0 : 1
138-
139136
"""
140137
optimize!(code::CodeInfo, mod::Module)
141138
@@ -190,7 +187,7 @@ function optimize!(code::CodeInfo, scope)
190187
append!(delete_idxs, delete_idx)
191188
end
192189
elseif stmt.head === :foreigncall && scope isa Method
193-
nargs = foreigncall_version == 0 ? stmt.args[5]::Int : length(stmt.args[3]::SimpleVector)
190+
nargs = length(stmt.args[3]::SimpleVector)
194191
# Call via `invokelatest` to avoid compiling it until we need it
195192
delete_idx = Base.invokelatest(build_compiled_call!, stmt, :ccall, code, idx, nargs, sparams, evalmod)
196193
if delete_idx !== nothing
@@ -365,7 +362,7 @@ function build_compiled_call!(stmt::Expr, fcall, code, idx, nargs::Int, sparams:
365362
push!(wrapargs, :(::$TVal{$sparam}))
366363
end
367364
methname = gensym("compiledcall")
368-
calling_convention = stmt.args[foreigncall_version == 0 ? 4 : 5]
365+
calling_convention = stmt.args[5]
369366
if calling_convention === :(:llvmcall)
370367
def = :(
371368
function $methname($(wrapargs...)) where {$(sparams...)}

src/packagedef.jl

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using Base.Meta
2-
import Base: +, -, convert, isless
2+
import Base: +, -, convert, isless, get_world_counter
33
using Core: CodeInfo, SimpleVector, LineInfoNode, GotoNode, Slot,
44
GeneratedFunctionStub, MethodInstance, NewvarNode, TypeName
55

@@ -18,18 +18,9 @@ module CompiledCalls
1818
# This module is for handling intrinsics that must be compiled (llvmcall) as well as ccalls
1919
end
2020

21-
# "Backport" of https://github.com/JuliaLang/julia/pull/31536
22-
if VERSION < v"1.2.0-DEV.572"
23-
Base.convert(::Type{Some{T}}, x::Some{T}) where {T} = x
24-
end
25-
26-
const SlotNamesType = VERSION < v"1.2.0-DEV.606" ? Vector{Any} : Vector{Symbol}
21+
const SlotNamesType = Vector{Symbol}
2722

28-
@static if VERSION < v"1.3.0-DEV.179"
29-
const append_any = Base.append_any
30-
else
31-
append_any(@nospecialize x...) = append!([], Core.svec((x...)...))
32-
end
23+
append_any(@nospecialize x...) = append!([], Core.svec((x...)...))
3324

3425
if isdefined(Base, :mapany)
3526
const mapany = Base.mapany

src/precompile.jl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ function _precompile_()
3636
@assert precompile(Tuple{typeof(extract_args), Module, Expr})
3737
@assert precompile(Tuple{typeof(enter_call), Int, Int})
3838
@assert precompile(Tuple{typeof(enter_call_expr), Expr})
39-
@assert precompile(Tuple{typeof(copy_codeinfo), Core.CodeInfo})
4039
@assert precompile(Tuple{typeof(optimize!), Core.CodeInfo, Module})
4140
@assert precompile(Tuple{typeof(optimize!), Core.CodeInfo, Method})
4241
@assert precompile(Tuple{typeof(build_compiled_call!), Expr, Symbol, Core.CodeInfo, Int, Int, Vector{Symbol}, Module})
@@ -48,9 +47,7 @@ function _precompile_()
4847
@assert precompile(Tuple{typeof(find_used), Core.CodeInfo})
4948
@assert precompile(Tuple{typeof(do_assignment!), Frame, Any, Any})
5049
@assert precompile(Tuple{typeof(pc_expr), Frame})
51-
if VERSION >= v"1.3.0-DEV.179" # there are different definitions depending on Julia version
52-
@assert precompile(Tuple{typeof(append_any), Any})
53-
@assert precompile(Tuple{typeof(append_any), Any, Vararg{Any, 100}})
54-
end
50+
@assert precompile(Tuple{typeof(append_any), Any})
51+
@assert precompile(Tuple{typeof(append_any), Any, Vararg{Any, 100}})
5552
@assert precompile(Tuple{typeof(whichtt), Any})
5653
end

src/types.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ function is_breakpoint_expr(ex::Expr)
112112
end
113113
function FrameCode(scope, src::CodeInfo; generator=false, optimize=true)
114114
if optimize
115-
src, methodtables = optimize!(copy_codeinfo(src), scope)
115+
src, methodtables = optimize!(copy(src), scope)
116116
else
117-
src = replace_coretypes!(copy_codeinfo(src))
117+
src = replace_coretypes!(copy(src))
118118
methodtables = Vector{Union{Compiled,DispatchableMethod}}(undef, length(src.code))
119119
end
120120
breakpoints = Vector{BreakpointState}(undef, length(src.code))

src/utils.jl

Lines changed: 12 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,6 @@ function to_function(@nospecialize(x))
2525
isa(x, GlobalRef) ? getfield(x.mod, x.name) : x
2626
end
2727

28-
@static if isdefined(Base, :get_world_counter)
29-
import Base: get_world_counter
30-
else
31-
get_world_counter() = ccall(:jl_get_world_counter, UInt, ())
32-
end
33-
3428
"""
3529
method = whichtt(tt)
3630
@@ -199,20 +193,11 @@ is_call_or_return(@nospecialize(node)) = is_call(node) || is_return(node)
199193

200194
is_dummy(bpref::BreakpointRef) = bpref.stmtidx == 0 && bpref.err === nothing
201195

202-
if VERSION >= v"1.4.0-DEV.304"
203-
function unpack_splatcall(stmt)
204-
if isexpr(stmt, :call) && length(stmt.args) >= 3 && is_quotenode_egal(stmt.args[1], Core._apply_iterate)
205-
return true, stmt.args[3]
206-
end
207-
return false, nothing
208-
end
209-
else
210-
function unpack_splatcall(stmt)
211-
if isexpr(stmt, :call) && length(stmt.args) >= 2 && is_quotenode_egal(stmt.args[1], Core._apply)
212-
return true, stmt.args[2]
213-
end
214-
return false, nothing
196+
function unpack_splatcall(stmt)
197+
if isexpr(stmt, :call) && length(stmt.args) >= 3 && is_quotenode_egal(stmt.args[1], Core._apply_iterate)
198+
return true, stmt.args[3]
215199
end
200+
return false, nothing
216201
end
217202

218203
function is_bodyfunc(@nospecialize(arg))
@@ -324,28 +309,10 @@ function getline(ln::Union{LineTypes,Expr})
324309
_getline(ln::Expr) = ln.args[1] # assuming ln.head === :line
325310
return Int(_getline(ln))::Int
326311
end
327-
# work around compiler error on 1.2
328-
@static if v"1.2.0" <= VERSION < v"1.3"
329-
getfile(ln) = begin
330-
path = if isexpr(ln, :line)
331-
String(ln.args[2])
332-
else
333-
try
334-
file = String(ln.file)
335-
isfile(file)
336-
file
337-
catch err
338-
""
339-
end
340-
end
341-
CodeTracking.maybe_fixup_stdlib_path(path)
342-
end
343-
else
344-
function getfile(ln::Union{LineTypes,Expr})
345-
_getfile(ln::LineTypes) = ln.file::Symbol
346-
_getfile(ln::Expr) = ln.args[2]::Symbol # assuming ln.head === :line
347-
return CodeTracking.maybe_fixup_stdlib_path(String(_getfile(ln)))
348-
end
312+
function getfile(ln::Union{LineTypes,Expr})
313+
_getfile(ln::LineTypes) = ln.file::Symbol
314+
_getfile(ln::Expr) = ln.args[2]::Symbol # assuming ln.head === :line
315+
return CodeTracking.maybe_fixup_stdlib_path(String(_getfile(ln)))
349316
end
350317

351318
function firstline(ex::Expr)
@@ -460,7 +427,7 @@ function framecode_lines(src::CodeInfo)
460427
buf = IOBuffer()
461428
if isdefined(Base.IRShow, :show_ir_stmt)
462429
lines = String[]
463-
src = replace_coretypes!(copy_codeinfo(src); rev=true)
430+
src = replace_coretypes!(copy(src); rev=true)
464431
reverse_lookup_globalref!(src.code)
465432
io = IOContext(buf, :displaysize => displaysize(stdout),
466433
:SOURCE_SLOTNAMES => Base.sourceinfo_slotnames(src))
@@ -497,7 +464,7 @@ function print_framecode(io::IO, framecode::FrameCode; pc=0, range=1:nstatements
497464
offset = lineoffset(framecode)
498465
ndline = isempty(lt) ? 0 : ndigits(getline(lt[end]) + offset)
499466
nullline = " "^ndline
500-
src = copy_codeinfo(framecode.src)
467+
src = copy(framecode.src)
501468
replace_coretypes!(src; rev=true)
502469
code = framecode_lines(src)
503470
isfirst = true
@@ -527,7 +494,7 @@ function locals(frame::Frame)
527494
vars, var_counter = Variable[], Int[]
528495
varlookup = Dict{Symbol,Int}()
529496
data, code = frame.framedata, frame.framecode
530-
slotnames = code.src.slotnames::SlotNamesType
497+
slotnames = code.src.slotnames
531498
for (sym, counter, val) in zip(slotnames, data.last_reference, data.locals)
532499
counter == 0 && continue
533500
val = something(val)
@@ -714,7 +681,7 @@ function Base.StackTraces.StackFrame(frame::Frame)
714681
atypes = Tuple{mapany(_Typeof, method_args)...}
715682
sig = method.sig
716683
sparams = Core.svec(frame.framedata.sparams...)
717-
mi = specialize_method(method, atypes, sparams)
684+
mi = Core.Compiler.specialize_method(method, atypes, sparams)
718685
fname = frame.framecode.scope.name
719686
else
720687
mi = frame.framecode.src

test/breakpoints.jl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -408,11 +408,7 @@ empty!(breakpoint_update_hooks)
408408
# breakpoint in top-level line
409409
mod, ex = exprs[1]
410410
frame = Frame(mod, ex)
411-
if VERSION < v"1.2"
412-
@test_broken JuliaInterpreter.shouldbreak(frame, frame.pc)
413-
else
414-
@test JuliaInterpreter.shouldbreak(frame, frame.pc)
415-
end
411+
@test JuliaInterpreter.shouldbreak(frame, frame.pc)
416412
ret = JuliaInterpreter.finish_and_return!(frame, true)
417413
@test ret === 2
418414

test/eval_code.jl

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,14 @@ fr, bp = debug_command(fr, :c)
7474
eval_code(fr, "non_accessible_variable = 5.0")
7575
@test eval_code(fr, "non_accessible_variable") == 5.0
7676

77-
if VERSION >= v"1.4" # for var"" syntax
78-
# Evaluating SSAValues
79-
f(x) = x^2
80-
frame = JuliaInterpreter.enter_call(f, 5)
81-
JuliaInterpreter.step_expr!(frame)
82-
JuliaInterpreter.step_expr!(frame)
83-
# This could change with changes to Julia lowering
84-
@test eval_code(frame, "var\"%2\"") == Val(2)
85-
@test eval_code(frame, "var\"@_1\"") == f
86-
end
77+
# Evaluating SSAValues
78+
f(x) = x^2
79+
frame = JuliaInterpreter.enter_call(f, 5)
80+
JuliaInterpreter.step_expr!(frame)
81+
JuliaInterpreter.step_expr!(frame)
82+
# This could change with changes to Julia lowering
83+
@test eval_code(frame, "var\"%2\"") == Val(2)
84+
@test eval_code(frame, "var\"@_1\"") == f
8785

8886
function fun(;output=:sym)
8987
x = 5

0 commit comments

Comments
 (0)