Skip to content

Commit 934fe49

Browse files
authored
bump the minimum supported Julia version to 1.10 (LTS) (#121)
1 parent 37fe489 commit 934fe49

File tree

9 files changed

+63
-177
lines changed

9 files changed

+63
-177
lines changed

.github/workflows/CI.yml

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,35 @@ jobs:
99
test:
1010
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
1111
runs-on: ${{ matrix.os }}
12+
timeout-minutes: 30
1213
strategy:
1314
fail-fast: false
1415
matrix:
15-
version:
16-
- '1.6' # current LTS
17-
- '1' # latest stable
18-
os:
19-
- ubuntu-latest
20-
- macOS-latest
21-
- windows-latest
22-
arch:
23-
- x64
2416
include:
25-
- version: 'nightly'
17+
- version: '1' # current stable
2618
os: ubuntu-latest
2719
arch: x64
28-
allow_failures: true
20+
- version: '1.10' # lowest version supported
21+
os: ubuntu-latest
22+
arch: x64
23+
- version: '1.12-nightly' # next release
24+
os: ubuntu-latest
25+
arch: x64
26+
- version: 'nightly' # dev
27+
os: ubuntu-latest
28+
arch: x64
29+
#- version: '1' # x86 ubuntu -- disabled since PyCall/conda is broken on this platform
30+
# os: ubuntu-latest
31+
# arch: x86
32+
- version: '1' # x86 windows
33+
os: windows-latest
34+
arch: x86
35+
- version: '1' # x64 windows
36+
os: windows-latest
37+
arch: x64
38+
- version: '1' # x64 macOS
39+
os: macos-latest
40+
arch: x64
2941
steps:
3042
- uses: actions/checkout@v4
3143
- uses: julia-actions/setup-julia@v2

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
name = "LoweredCodeUtils"
22
uuid = "6f1432cf-f94c-5a45-995e-cdbf5db27b0b"
33
authors = ["Tim Holy <[email protected]>"]
4-
version = "3.0.5"
4+
version = "3.1.0"
55

66
[deps]
77
JuliaInterpreter = "aa1ae85d-cabe-5617-a682-6adf51b2e16a"
88

99
[compat]
1010
JuliaInterpreter = "0.9"
11-
julia = "1.6"
11+
julia = "1.10"
1212

1313
[extras]
1414
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"

src/codeedges.jl

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,10 @@ function print_names(io::IO, cl::CodeLinks)
9696
end
9797
end
9898

99-
const preprinter_sentinel = isdefined(Base.IRShow, :statementidx_lineinfo_printer) ? 0 : typemin(Int32)
100-
10199
function print_with_code(preprint, postprint, io::IO, src::CodeInfo)
102100
src = copy(src)
103101
JuliaInterpreter.replace_coretypes!(src; rev=true)
104-
if isdefined(JuliaInterpreter, :reverse_lookup_globalref!)
105-
JuliaInterpreter.reverse_lookup_globalref!(src.code)
106-
end
102+
JuliaInterpreter.reverse_lookup_globalref!(src.code)
107103
io = IOContext(io,
108104
:displaysize=>displaysize(io),
109105
:SOURCE_SLOTNAMES => Base.sourceinfo_slotnames(src))
@@ -134,7 +130,7 @@ function print_with_code(preprint, postprint, io::IO, src::CodeInfo)
134130
bb_idx_prev = bb_idx
135131
end
136132
max_bb_idx_size = ndigits(length(cfg.blocks))
137-
line_info_preprinter(io, " "^(max_bb_idx_size + 2), preprinter_sentinel)
133+
line_info_preprinter(io, " "^(max_bb_idx_size + 2), 0)
138134
postprint(io)
139135
return nothing
140136
end
@@ -531,12 +527,7 @@ function print_with_code(io::IO, src::CodeInfo, edges::CodeEdges)
531527
end
532528
printstyled(io, "\nCode:\n", color=:yellow)
533529
end
534-
@static if isdefined(Base.IRShow, :show_ir_stmt)
535-
preprint(::IO, ::Int) = nothing
536-
else
537-
nd = ndigits(length(src.code))
538-
preprint(io::IO, i::Int) = print(io, lpad(i, nd), " ")
539-
end
530+
preprint(::IO, ::Int) = nothing
540531
postprint(::IO) = nothing
541532
postprint(io::IO, idx::Int, bbchanged::Bool) = postprint_lineedges(io, idx, edges, bbchanged)
542533

@@ -1072,9 +1063,7 @@ end
10721063

10731064
function print_with_code(io::IO, frame::Frame, obj)
10741065
src = frame.framecode.src
1075-
if isdefined(JuliaInterpreter, :reverse_lookup_globalref!)
1076-
src = copy(src)
1077-
JuliaInterpreter.reverse_lookup_globalref!(src.code)
1078-
end
1066+
src = copy(src)
1067+
JuliaInterpreter.reverse_lookup_globalref!(src.code)
10791068
print_with_code(io, src, obj)
10801069
end

src/packagedef.jl

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
if isdefined(Base, :Experimental) && isdefined(Base.Experimental, Symbol("@optlevel"))
2-
@eval Base.Experimental.@optlevel 1
3-
end
1+
Base.Experimental.@optlevel 1
42

53
using Core: SimpleVector
64
using Core.IR
5+
using Core.Compiler: construct_domtree, construct_postdomtree, nearest_common_dominator,
6+
postdominates
77
using Base.Meta: isexpr
88

99
const SSAValues = Union{Core.Compiler.SSAValue, JuliaInterpreter.SSAValue}
@@ -17,14 +17,6 @@ export CodeEdges, lines_required, lines_required!, selective_eval!, selective_ev
1717
include("utils.jl")
1818
include("signatures.jl")
1919
include("codeedges.jl")
20-
if Base.VERSION < v"1.10"
21-
include("domtree.jl")
22-
else
23-
const construct_domtree = Core.Compiler.construct_domtree
24-
const construct_postdomtree = Core.Compiler.construct_postdomtree
25-
const postdominates = Core.Compiler.postdominates
26-
const nearest_common_dominator = Core.Compiler.nearest_common_dominator
27-
end
2820

2921
# precompilation
3022

src/signatures.jl

Lines changed: 7 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ function identify_framemethod_calls(frame)
201201
mkey = normalize_defsig(refstmt, frame)
202202
end
203203
end
204-
if is_global_ref(mkey, Core, isdefined(Core, :_apply_iterate) ? :_apply_iterate : :_apply)
204+
if is_global_ref(mkey, Core, :_apply_iterate)
205205
ssaref = mstmt.args[end-1]
206206
if isa(ssaref, JuliaInterpreter.SSAValue)
207207
id = ssaref.id
@@ -684,54 +684,11 @@ Return the "body method" for a method `m`. `mbody` contains the code of the func
684684
when `m` was defined.
685685
"""
686686
function bodymethod(mkw::Method)
687-
@static if isdefined(Core, :kwcall)
688-
Base.unwrap_unionall(mkw.sig).parameters[1] !== typeof(Core.kwcall) && isempty(Base.kwarg_decl(mkw)) && return mkw
689-
mths = methods(Base.bodyfunction(mkw))
690-
if length(mths) != 1
691-
@show mkw
692-
display(mths)
693-
end
694-
return only(mths)
695-
else
696-
m = mkw
697-
local src
698-
while true
699-
framecode = JuliaInterpreter.get_framecode(m)
700-
fakeargs = Any[nothing for i = 1:(framecode.scope::Method).nargs]
701-
frame = JuliaInterpreter.prepare_frame(framecode, fakeargs, isa(m.sig, UnionAll) ? sparam_ub(m) : Core.svec())
702-
src = framecode.src
703-
(length(src.code) > 1 && is_self_call(src.code[end-1], src.slotnames)) || break
704-
# Build the optional arg, so we can get its type
705-
pc = frame.pc
706-
while pc < length(src.code) - 1
707-
pc = step_expr!(frame)
708-
end
709-
val = pc > 1 ? frame.framedata.ssavalues[pc-1] : (src.code[1]::Expr).args[end]
710-
sig = Tuple{(Base.unwrap_unionall(m.sig)::DataType).parameters..., typeof(val)}
711-
m = whichtt(sig)
712-
end
713-
length(src.code) > 1 || return m
714-
stmt = src.code[end-1]
715-
if isexpr(stmt, :call) && (f = (stmt::Expr).args[1]; isa(f, QuoteNode))
716-
if f.value === (isdefined(Core, :_apply_iterate) ? Core._apply_iterate : Core._apply)
717-
ssaref = stmt.args[end-1]
718-
if isa(ssaref, JuliaInterpreter.SSAValue)
719-
id = ssaref.id
720-
has_self_call(src, src.code[id]) || return m
721-
end
722-
f = stmt.args[end-2]
723-
if isa(f, JuliaInterpreter.SSAValue)
724-
f = src.code[f.id]
725-
end
726-
else
727-
has_self_call(src, stmt) || return m
728-
end
729-
f = f.value
730-
mths = methods(f)
731-
if length(mths) == 1
732-
return first(mths)
733-
end
734-
end
735-
return m
687+
Base.unwrap_unionall(mkw.sig).parameters[1] !== typeof(Core.kwcall) && isempty(Base.kwarg_decl(mkw)) && return mkw
688+
mths = methods(Base.bodyfunction(mkw))
689+
if length(mths) != 1
690+
@show mkw
691+
display(mths)
736692
end
693+
return only(mths)
737694
end

src/utils.jl

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,13 @@ function isanonymous_typedef(stmt)
118118
stmt = src.code[end-1]
119119
isexpr(stmt, :call) || return false
120120
is_global_ref(stmt.args[1], Core, :_typebody!) || return false
121-
@static if VERSION v"1.9.0-DEV.391"
122-
stmt = isa(stmt.args[3], Core.SSAValue) ? src.code[end-3] : src.code[end-2]
123-
is_assignment_like(stmt) || return false
124-
name = stmt.args[1]
125-
if isa(name, GlobalRef)
126-
name = name.name
127-
else
128-
isa(name, Symbol) || return false
129-
end
121+
stmt = isa(stmt.args[3], Core.SSAValue) ? src.code[end-3] : src.code[end-2]
122+
is_assignment_like(stmt) || return false
123+
name = stmt.args[1]
124+
if isa(name, GlobalRef)
125+
name = name.name
130126
else
131-
name = stmt.args[2]::Symbol
127+
isa(name, Symbol) || return false
132128
end
133129
return startswith(String(name), "#")
134130
end
@@ -176,11 +172,9 @@ function typedef_range(src::CodeInfo, idx)
176172
if isa(stmt, Expr)
177173
stmt.head === :global && break
178174
if stmt.head === :call
179-
if (is_global_ref(stmt.args[1], Core, :_typebody!) ||
180-
isdefined(Core, :_typebody!) && is_quotenode_egal(stmt.args[1], Core._typebody!))
175+
if (is_global_ref(stmt.args[1], Core, :_typebody!) || is_quotenode_egal(stmt.args[1], Core._typebody!))
181176
have_typebody = true
182-
elseif (is_global_ref(stmt.args[1], Core, :_equiv_typedef) ||
183-
isdefined(Core, :_equiv_typedef) && is_quotenode_egal(stmt.args[1], Core._equiv_typedef))
177+
elseif (is_global_ref(stmt.args[1], Core, :_equiv_typedef) || is_quotenode_egal(stmt.args[1], Core._equiv_typedef))
184178
have_equivtypedef = true
185179
# Advance to the type-assignment
186180
while iend <= n

test/codeedges.jl

Lines changed: 12 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -344,17 +344,15 @@ module ModSelective end
344344
idx = findfirst(@nospecialize(stmt)->Meta.isexpr(stmt, :(=)) && Meta.isexpr(stmt.args[2], :call) && is_global_ref(stmt.args[2].args[1], Core, :Box), src.code)
345345
@test lr[idx]
346346
# but make sure we don't break primitivetype & abstracttype (https://github.com/timholy/Revise.jl/pull/611)
347-
if isdefined(Core, :_primitivetype)
348-
thk = Meta.lower(Main, quote
349-
primitive type WindowsRawSocket sizeof(Ptr) * 8 end
350-
end)
351-
src = thk.args[1]
352-
edges = CodeEdges(Main, src)
353-
idx = findfirst(istypedef, src.code)
354-
r = LoweredCodeUtils.typedef_range(src, idx)
355-
# 1 before :latestworld, 2 after
356-
@test (length(src.code) - last(r)) in (1, 2)
357-
end
347+
thk = Meta.lower(Main, quote
348+
primitive type WindowsRawSocket sizeof(Ptr) * 8 end
349+
end)
350+
src = thk.args[1]
351+
edges = CodeEdges(Main, src)
352+
idx = findfirst(istypedef, src.code)
353+
r = LoweredCodeUtils.typedef_range(src, idx)
354+
# 1 before :latestworld, 2 after
355+
@test (length(src.code) - last(r)) in (1, 2)
358356

359357
@testset "Display" begin
360358
# worth testing because this has proven quite crucial for debugging and
@@ -381,69 +379,22 @@ module ModSelective end
381379
str = String(take!(io))
382380
@test occursin(r"slot 1:\n preds: ssas: \[\d+, \d+\], slots: ∅, names: ∅;\n succs: ssas: \[\d+, \d+, \d+\], slots: ∅, names: ∅;\n assign @: \[\d+, \d+\]", str)
383381
@test occursin(r"succs: ssas: ∅, slots: \[\d+\], names: ∅;", str)
384-
# Some of these differ due to changes by Julia version in global var inference
385-
if Base.VERSION < v"1.10"
386-
@test occursin(r"s:\n preds: ssas: \[\d+\], slots: ∅, names: ∅;\n succs: ssas: \[\d+, \d+, \d+\], slots: ∅, names: ∅;\n assign @: \[\d, \d+\]", str) ||
387-
occursin(r"s:\n preds: ssas: \[\d+, \d+\], slots: ∅, names: ∅;\n succs: ssas: \[\d+, \d+, \d+\], slots: ∅, names: ∅;\n assign @: \[\d, \d+\]", str) # with global var inference
388-
end
389-
if Base.VERSION < v"1.8"
390-
@test occursin(r"\d+ preds: ssas: \[\d+\], slots: ∅, names: \[\:\(Main\.s\)\];\n\d+ succs: ssas: ∅, slots: ∅, names: \[\:\(Main\.s\)\];", str)
391-
end
392382
LoweredCodeUtils.print_with_code(io, src, cl)
393383
str = String(take!(io))
394-
if isdefined(Base.IRShow, :show_ir_stmt)
395-
@test occursin(r"slot 1:\n preds: ssas: \[\d+, \d+\], slots: ∅, names: ∅;\n succs: ssas: \[\d+, \d+, \d+\], slots: ∅, names: ∅;\n assign @: \[\d+, \d+\]", str)
396-
@test occursin("# see name Main.s", str)
397-
@test occursin("# see slot 1", str)
398-
if Base.VERSION < v"1.8" # changed by global var inference
399-
@test occursin(r"# preds: ssas: \[\d+\], slots: ∅, names: \[\:\(Main\.s\)\]; succs: ssas: ∅, slots: ∅, names: \[\:\(Main\.s\)\];", str)
400-
end
401-
else
402-
@test occursin("No IR statement printer", str)
403-
end
384+
@test occursin(r"slot 1:\n preds: ssas: \[\d+, \d+\], slots: ∅, names: ∅;\n succs: ssas: \[\d+, \d+, \d+\], slots: ∅, names: ∅;\n assign @: \[\d+, \d+\]", str)
385+
@test occursin("# see name Main.s", str)
386+
@test occursin("# see slot 1", str)
404387
# CodeEdges
405388
edges = CodeEdges(Main, src)
406389
show(io, edges)
407390
str = String(take!(io))
408-
if Base.VERSION < v"1.10"
409-
@test occursin(r"s: assigned on \[\d, \d+\], depends on \[\d+\], and used by \[\d+, \d+, \d+\]", str) ||
410-
occursin(r"s: assigned on \[\d, \d+\], depends on \[\d+, \d+\], and used by \[\d+, \d+, \d+\]", str) # global var inference
411-
end
412-
if Base.VERSION < v"1.9"
413-
@test (count(occursin("statement $i depends on [1, $(i-1), $(i+1)] and is used by [1, $(i+1)]", str) for i = 1:length(src.code)) == 1) ||
414-
(count(occursin("statement $i depends on [4, $(i-1), $(i+4)] and is used by [$(i+2)]", str) for i = 1:length(src.code)) == 1)
415-
end
416391
LoweredCodeUtils.print_with_code(io, src, edges)
417392
str = String(take!(io))
418-
if isdefined(Base.IRShow, :show_ir_stmt)
419-
if Base.VERSION < v"1.10"
420-
@test occursin(r"s: assigned on \[\d, \d+\], depends on \[\d+\], and used by \[\d+, \d+, \d+\]", str) ||
421-
occursin(r"s: assigned on \[\d, \d+\], depends on \[\d+, \d+\], and used by \[\d+, \d+, \d+\]", str)
422-
end
423-
if Base.VERSION < v"1.9"
424-
@test (count(occursin("preds: [1, $(i-1), $(i+1)], succs: [1, $(i+1)]", str) for i = 1:length(src.code)) == 1) ||
425-
(count(occursin("preds: [4, $(i-1), $(i+4)], succs: [$(i+2)]", str) for i = 1:length(src.code)) == 1) # global var inference
426-
end
427-
else
428-
@test occursin("No IR statement printer", str)
429-
end
430393
# Works with Frames too
431394
frame = Frame(ModSelective, ex)
432395
edges = CodeEdges(ModSelective, frame.framecode.src)
433396
LoweredCodeUtils.print_with_code(io, frame, edges)
434397
str = String(take!(io))
435-
if isdefined(Base.IRShow, :show_ir_stmt)
436-
if Base.VERSION < v"1.10"
437-
@test occursin(r"s: assigned on \[\d, \d+\], depends on \[\d+\], and used by \[\d+, \d+, \d+\]", str) ||
438-
occursin(r"s: assigned on \[\d, \d+\], depends on \[\d, \d+\], and used by \[\d+, \d+, \d+\]", str) # global var inference
439-
end
440-
if Base.VERSION < v"1.9"
441-
@test (count(occursin("preds: [1, $(i-1), $(i+1)], succs: [1, $(i+1)]", str) for i = 1:length(src.code)) == 1) ||
442-
(count(occursin("preds: [4, $(i-1), $(i+4)], succs: [$(i+2)]", str) for i = 1:length(src.code)) == 1) # global var inference
443-
end
444-
else
445-
@test occursin("No IR statement printer", str)
446-
end
447398

448399
# display slot names
449400
ex = :(let

test/runtests.jl

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ using Test
66
# end
77

88
@testset "LoweredCodeUtils.jl" begin
9-
@static if VERSION v"1.8"
10-
@testset "signatures.jl" include("signatures.jl")
11-
@testset "codeedges.jl" include("codeedges.jl")
12-
else
13-
include("signatures.jl")
14-
include("codeedges.jl")
15-
end
9+
@testset "signatures.jl" include("signatures.jl")
10+
@testset "codeedges.jl" include("codeedges.jl")
1611
end

test/signatures.jl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ bodymethtest5(x, y=Dict(1=>2)) = 5
281281
rename_framemethods!(frame)
282282
empty!(signatures)
283283
methoddefs!(signatures, frame; define=false)
284-
@test length(signatures) >= 3 - isdefined(Core, :kwcall)
284+
@test length(signatures) >= 2
285285

286286
ex = :(typedsig(x) = 1)
287287
frame = Frame(Lowering, ex)
@@ -353,10 +353,6 @@ bodymethtest5(x, y=Dict(1=>2)) = 5
353353
@test dct[ks[1]] == dct[ks[2]]
354354
@test ks[1].mod === ks[2].mod === Lowering
355355
@test isdefined(Lowering, ks[1].name) || isdefined(Lowering, ks[2].name)
356-
if !isdefined(Core, :kwcall)
357-
nms = filter(sym->occursin(r"#Items#\d+#\d+", String(sym)), names(Lowering; all=true))
358-
@test length(nms) == 1
359-
end
360356

361357
# https://github.com/timholy/Revise.jl/issues/422
362358
ex = :(@generated function fneg(x::T) where T<:LT{<:FloatingTypes}

0 commit comments

Comments
 (0)