Skip to content

Commit 864002c

Browse files
authored
drop v1.9 support (#545)
* drop v1.9 support * minor version bump
1 parent ff129ca commit 864002c

8 files changed

Lines changed: 35 additions & 144 deletions

File tree

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
matrix:
1515
version:
1616
- '1'
17-
- '1.9.0'
17+
- '1.10.0'
1818
- 'nightly'
1919
os:
2020
- ubuntu-latest

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Cthulhu"
22
uuid = "f68482b8-f384-11e8-15f7-abe071a5a75f"
33
authors = ["Valentin Churavy <v.churavy@gmail.com> and contributors"]
4-
version = "2.10.2"
4+
version = "2.11.0"
55

66
[deps]
77
CodeTracking = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2"
@@ -28,7 +28,7 @@ TypedSyntax = "1.2.2"
2828
UUIDs = "1.9"
2929
Unicode = "1.9"
3030
WidthLimitedIO = "1"
31-
julia = "1.9"
31+
julia = "1.10.0"
3232

3333
[extras]
3434
DeepDiffs = "ab62b9b5-e342-54a8-a765-a90f495de1a6"

src/codeview.jl

Lines changed: 17 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -22,41 +22,25 @@ end
2222

2323
function cthulhu_llvm(io::IO, mi, optimize::Bool, debuginfo, world::UInt,
2424
config::CthulhuConfig, dump_module::Bool=false, raw::Bool=false)
25-
dump = @static if VERSION v"1.10.0-DEV.1386"
26-
InteractiveUtils._dump_function_llvm(
27-
mi, world,
28-
#=wrapper=# false, !raw,
29-
dump_module, optimize, debuginfo != DInfo.none ? :source : :none,
30-
Base.CodegenParams())
31-
else
32-
InteractiveUtils._dump_function_linfo_llvm(
33-
mi, world,
34-
#=wrapper=# false, #=strip_ir_metadata=# true,
35-
dump_module, optimize, debuginfo != DInfo.none ? :source : :none,
36-
Base.CodegenParams())
37-
end
25+
dump = InteractiveUtils._dump_function_llvm(
26+
mi, world,
27+
#=wrapper=# false, !raw,
28+
dump_module, optimize, debuginfo != DInfo.none ? :source : :none,
29+
Base.CodegenParams())
3830
highlight(io, dump, "llvm", config)
3931
end
4032

4133
function cthulhu_native(io::IO, mi, ::Bool, debuginfo, world::UInt,
4234
config::CthulhuConfig, dump_module::Bool=false, raw::Bool=false)
43-
dump = @static if VERSION v"1.10.0-DEV.1386"
44-
if dump_module
45-
InteractiveUtils._dump_function_native_assembly(
46-
mi, world,
47-
#=wrapper=# false, #=syntax=# config.asm_syntax,
48-
debuginfo != DInfo.none ? :source : :none,
49-
#=binary=# false, raw,
50-
Base.CodegenParams())
51-
else
52-
InteractiveUtils._dump_function_native_disassembly(
53-
mi, world,
54-
#=wrapper=# false, #=syntax=# config.asm_syntax,
55-
debuginfo != DInfo.none ? :source : :none,
56-
#=binary=# false)
57-
end
35+
if dump_module
36+
dump = InteractiveUtils._dump_function_native_assembly(
37+
mi, world,
38+
#=wrapper=# false, #=syntax=# config.asm_syntax,
39+
debuginfo != DInfo.none ? :source : :none,
40+
#=binary=# false, raw,
41+
Base.CodegenParams())
5842
else
59-
InteractiveUtils._dump_function_linfo_native(
43+
dump = InteractiveUtils._dump_function_native_disassembly(
6044
mi, world,
6145
#=wrapper=# false, #=syntax=# config.asm_syntax,
6246
debuginfo != DInfo.none ? :source : :none,
@@ -221,10 +205,11 @@ function cthulhu_typed(io::IO, debuginfo::Symbol,
221205
end
222206
cst = Vector{Int}(undef, length(code))
223207
params = CC.OptimizationParams(interp)
208+
sparams = CC.VarState[CC.VarState(sparam, false) for sparam in mi.sparam_vals]
224209
@static if VERSION v"1.11.0-DEV.32"
225-
CC.statement_costs!(cst, code, src, sptypes(mi.sparam_vals), params)
210+
CC.statement_costs!(cst, code, src, sparams, params)
226211
else
227-
CC.statement_costs!(cst, code, src, sptypes(mi.sparam_vals), false, params)
212+
CC.statement_costs!(cst, code, src, sparams, false, params)
228213
end
229214
total_cost = sum(cst)
230215
nd = ndigits(total_cost)
@@ -386,13 +371,6 @@ function add_callsites!(d::AbstractDict, visited_mis::AbstractSet, diagnostics::
386371
end
387372
end
388373

389-
@static if VERSION >= v"1.10.0-DEV.552"
390-
using Core.Compiler: VarState
391-
sptypes(sparams) = VarState[VarState.(sparams, false)...]
392-
else
393-
sptypes(sparams) = Any[sparams...]
394-
end
395-
396374
function show_variables(io, src, slotnames)
397375
println(io, "Variables")
398376
slottypes = src.slottypes
@@ -465,12 +443,7 @@ function InteractiveUtils.code_typed(b::Bookmark; optimize::Bool=true)
465443
(; src, rt, codeinf) = lookup(interp, mi, optimize)
466444
src = preprocess_ci!(src, mi, optimize, CONFIG)
467445
if src isa IRCode
468-
@static if VERSION v"1.10.0-DEV.870"
469-
CC.replace_code_newstyle!(codeinf, src)
470-
else
471-
nargs = Int((mi.def::Method).nargs) - 1
472-
CC.replace_code_newstyle!(codeinf, src, nargs)
473-
end
446+
CC.replace_code_newstyle!(codeinf, src)
474447
end
475448
return codeinf => rt
476449
end

src/interpreter.jl

Lines changed: 2 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
using .CC: AbstractInterpreter, NativeInterpreter, InferenceState, OptimizationState,
2-
CodeInfo, CodeInstance, InferenceResult, WorldRange, WorldView, IRCode, SSAValue
3-
4-
const CCCallInfo = CC.CallInfo
5-
const NoCallInfo = CC.NoCallInfo
2+
CodeInfo, CodeInstance, InferenceResult, WorldRange, WorldView, IRCode, SSAValue,
3+
CallInfo as CCCallInfo, NoCallInfo
64

75
struct InferredSource
86
src::CodeInfo
@@ -103,57 +101,8 @@ function CC.merge_effects!(interp::CthulhuInterpreter, sv::InferenceState, effec
103101
@invoke CC.merge_effects!(interp::AbstractInterpreter, sv::InferenceState, effects::Effects)
104102
end
105103

106-
@static if VERSION v"1.10.0-DEV.221"
107-
function CC.type_annotate!(interp::CthulhuInterpreter, sv::InferenceState, run_optimizer::Bool)
108-
changemap = @invoke CC.type_annotate!(interp::AbstractInterpreter, sv::InferenceState, run_optimizer::Bool)
109-
changemap === nothing && return nothing
110-
key = CC.any(sv.result.overridden_by_const) ? sv.result : sv.linfo
111-
pc2remarks = get(interp.remarks, key, nothing)
112-
if pc2remarks !== nothing
113-
sort!(pc2remarks)
114-
unique!(pc2remarks)
115-
for (idx, v) in enumerate(changemap)
116-
if v == typemin(Int)
117-
for i = searchsorted(pc2remarks, idx=>"", by=((idx,msg),)->idx)
118-
@assert false "remarks found in unreached region"
119-
end
120-
end
121-
end
122-
for (idx, v) in enumerate(changemap)
123-
if v < 0
124-
for i = searchsorted(pc2remarks, idx=>"", by=((idx,msg),)->idx)
125-
pc2remarks[i] = pc2remarks[i].first+v => pc2remarks[i].second
126-
end
127-
end
128-
end
129-
end
130-
pc2effects = get(interp.effects, key, nothing)
131-
if pc2effects !== nothing
132-
for (idx, v) in enumerate(changemap)
133-
if v == typemin(Int)
134-
delete!(pc2effects, idx)
135-
end
136-
end
137-
for (idx, v) in enumerate(changemap)
138-
if v < 0
139-
haskey(pc2effects, idx) || continue
140-
pc2effects[idx+v] = pc2effects[idx]
141-
delete!(pc2effects, idx)
142-
end
143-
end
144-
end
145-
return changemap
146-
end
147-
end
148-
149104
function InferredSource(state::InferenceState)
150105
unoptsrc = copy(state.src)
151-
@static if VERSION < v"1.10.0-DEV.1033"
152-
# xref: https://github.com/JuliaLang/julia/pull/49378
153-
unoptsrc.slottypes = let slottypes = unoptsrc.slottypes
154-
slottypes === nothing ? nothing : copy(slottypes)
155-
end
156-
end
157106
exct = @static VERSION v"1.11.0-DEV.207" ? state.result.exc_result : nothing
158107
return InferredSource(
159108
unoptsrc,
@@ -218,7 +167,6 @@ function CC.inlining_policy(interp::CthulhuInterpreter,
218167
end
219168
end
220169

221-
@static if isdefined(CC, :AbsIntState)
222170
function CC.IRInterpretationState(interp::CthulhuInterpreter,
223171
code::CodeInstance, mi::MethodInstance, argtypes::Vector{Any}, world::UInt)
224172
inferred = @atomic :monotonic code.inferred
@@ -230,14 +178,6 @@ function CC.IRInterpretationState(interp::CthulhuInterpreter,
230178
return CC.IRInterpretationState(interp, method_info, ir, mi, argtypes, world,
231179
src.min_world, src.max_world)
232180
end
233-
else
234-
function CC.codeinst_to_ir(interp::CthulhuInterpreter, code::CodeInstance)
235-
inferred = @atomic :monotonic code.inferred
236-
inferred === nothing && return nothing
237-
inferred = inferred::OptimizedSource
238-
return CC.copy(inferred.ir)
239-
end
240-
end
241181

242182
@static if VERSION v"1.11.0-DEV.737"
243183
function CC.finish!(interp::CthulhuInterpreter, caller::InferenceState)

src/reflection.jl

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,7 @@ function preprocess_ci!(ci::CodeInfo, mi::MethodInstance, optimize, config::Cthu
261261
argtypes = CC.matching_cache_argtypes(mi, nothing, false)[1]
262262
ir = CC.inflate_ir(ci, sptypes_from_meth_instance(mi), argtypes)
263263
ir = dce!(ir)
264-
@static if VERSION v"1.10.0-DEV.870"
265-
ci = CC.replace_code_newstyle!(ci, ir)
266-
else
267-
ci = CC.replace_code_newstyle!(ci, ir, length(argtypes)-1)
268-
end
264+
ci = CC.replace_code_newstyle!(ci, ir)
269265
end
270266
return ci
271267
end
@@ -384,11 +380,7 @@ function truncate_if_defaultargs!(tsn, mappings, meth)
384380
return tsn, mappings
385381
end
386382

387-
if isdefined(Core, :kwcall)
388-
is_kw_dispatch(meth::Method) = meth.name == :kwcall || Base.unwrap_unionall(meth.sig).parameters[1] === typeof(Core.kwcall) || !isempty(Base.kwarg_decl(meth))
389-
else
390-
is_kw_dispatch(meth::Method) = endswith(string(meth.name), "##kw") || !isempty(Base.kwarg_decl(meth))
391-
end
383+
is_kw_dispatch(meth::Method) = meth.name == :kwcall || Base.unwrap_unionall(meth.sig).parameters[1] === typeof(Core.kwcall) || !isempty(Base.kwarg_decl(meth))
392384

393385
function tag_runtime(node::TypedSyntaxNode, info)
394386
node.runtime = isa(info, RTCallInfo)

test/irutils.jl

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
using Core: CodeInfo, ReturnNode, MethodInstance
2-
using Core.Compiler: IRCode, IncrementalCompact, singleton_type, VarState
2+
using Core.Compiler: IRCode, IncrementalCompact, singleton_type
33
using Base.Meta: isexpr
44
using InteractiveUtils: gen_call_with_extracted_types_and_kwargs
55

66
argextype(@nospecialize args...) = Core.Compiler.argextype(args...)
7-
@static if VERSION >= v"1.10.0-DEV.556"
8-
argextype(@nospecialize(x), src::CodeInfo) = argextype(x, src, VarState[])
9-
else
10-
argextype(@nospecialize(x), src::CodeInfo) = argextype(x, src, Any[])
11-
end
7+
argextype(@nospecialize(x), src::CodeInfo) = argextype(x, src, Core.Compiler.VarState[])
128
code_typed1(args...; kwargs...) = first(only(code_typed(args...; kwargs...)))::CodeInfo
139
macro code_typed1(ex0...)
1410
return gen_call_with_extracted_types_and_kwargs(__module__, :code_typed1, ex0)

test/setup.jl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,3 @@ end
2626
macro find_callsites_by_ftt(ex0...)
2727
return InteractiveUtils.gen_call_with_extracted_types_and_kwargs(__module__, :find_callsites_by_ftt, ex0)
2828
end
29-
30-
@static if isdefined(Core.Compiler, :is_foldable_nothrow)
31-
using Core.Compiler: is_foldable_nothrow
32-
else
33-
const is_foldable_nothrow = Core.Compiler.is_total
34-
end

test/test_Cthulhu.jl

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ function bar346(x::ComplexF64)
352352
x = ComplexF64(x.re, 1.0)
353353
return sin(x.im)
354354
end
355-
@static VERSION >= v"1.10-" && @testset "issue #346" begin
355+
@testset "issue #346" begin
356356
let (; interp, src, infos, mi, slottypes) = cthulhu_info(bar346, Tuple{ComplexF64}; optimize=false)
357357
callsites, _ = Cthulhu.find_callsites(interp, src, infos, mi, slottypes, false)
358358
@test isa(callsites[1].info, Cthulhu.SemiConcreteCallInfo)
@@ -373,8 +373,8 @@ struct SingletonPureCallable{N} end
373373
@test occursin("SingletonPureCallable{1}()(::Float64)::Float64", s)
374374

375375

376-
@test Cthulhu.get_effects(c1) |> is_foldable_nothrow
377-
@test Cthulhu.get_effects(c2) |> is_foldable_nothrow
376+
@test Cthulhu.get_effects(c1) |> Core.Compiler.is_foldable_nothrow
377+
@test Cthulhu.get_effects(c2) |> Core.Compiler.is_foldable_nothrow
378378
end
379379

380380
@testset "ReturnTypeCallInfo" begin
@@ -406,8 +406,8 @@ end
406406
print(io, callsites[2])
407407
@test occursin("return_type < only_ints(::Float64)::Union{} >", String(take!(io)))
408408

409-
@test Cthulhu.get_effects(callinfo1) |> is_foldable_nothrow
410-
@test Cthulhu.get_effects(callinfo2) |> is_foldable_nothrow
409+
@test Cthulhu.get_effects(callinfo1) |> Core.Compiler.is_foldable_nothrow
410+
@test Cthulhu.get_effects(callinfo2) |> Core.Compiler.is_foldable_nothrow
411411
end
412412

413413
@testset "OCCallInfo" begin
@@ -418,7 +418,7 @@ end
418418
@test length(callsites) == 1
419419
callinfo = only(callsites).info
420420
@test callinfo isa Cthulhu.OCCallInfo
421-
@test Cthulhu.get_effects(callinfo) |> !is_foldable_nothrow
421+
@test Cthulhu.get_effects(callinfo) |> !Core.Compiler.is_foldable_nothrow
422422
# TODO not sure what these effects are (and neither is Base.infer_effects yet)
423423
@test callinfo.ci.rt === Base.return_types((Int,Int)) do a, b
424424
sin(a) + cos(b)
@@ -476,7 +476,7 @@ invoke_constcall(a::Number, c::Bool) = c ? Number : :number
476476
callsite = only(callsites)
477477
info = callsite.info
478478
@test isa(info, Cthulhu.InvokeCallInfo)
479-
@test Cthulhu.get_effects(info) |> is_foldable_nothrow
479+
@test Cthulhu.get_effects(info) |> Core.Compiler.is_foldable_nothrow
480480
rt = Core.Compiler.Const(:Integer)
481481
@test info.ci.rt === rt
482482
buf = IOBuffer()
@@ -489,7 +489,7 @@ invoke_constcall(a::Number, c::Bool) = c ? Number : :number
489489
callsite = only(callsites)
490490
info = callsite.info
491491
@test isa(info, Cthulhu.InvokeCallInfo)
492-
@test Cthulhu.get_effects(info) |> is_foldable_nothrow
492+
@test Cthulhu.get_effects(info) |> Core.Compiler.is_foldable_nothrow
493493
@test info.ci.rt === Core.Compiler.Const(:Int)
494494
end
495495

@@ -500,7 +500,7 @@ invoke_constcall(a::Number, c::Bool) = c ? Number : :number
500500
callsite = only(callsites)
501501
info = callsite.info
502502
@test isa(info, Cthulhu.InvokeCallInfo)
503-
@test Cthulhu.get_effects(info) |> is_foldable_nothrow
503+
@test Cthulhu.get_effects(info) |> Core.Compiler.is_foldable_nothrow
504504
inner = info.ci
505505
rt = Core.Compiler.Const(Any)
506506
@test Cthulhu.get_rt(info) === rt
@@ -1015,11 +1015,7 @@ end
10151015
let (interp, mi) = Cthulhu.mkinterp((Int,)) do var::Int
10161016
countvars50037(1, var)
10171017
end
1018-
@static if VERSION v"1.10"
10191018
key = only(Base.specializations(only(methods(countvars50037))))
1020-
else
1021-
key = only(methods(countvars50037)).specializations[1]
1022-
end
10231019
codeinst = interp.opt[key]
10241020
inferred = @atomic :monotonic codeinst.inferred
10251021
@test length(inferred.ir.cfg.blocks) == 1

0 commit comments

Comments
 (0)