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

Fixes for julia v1.10 #109

Merged
Merged
4 changes: 3 additions & 1 deletion src/eval.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using Base: invokelatest

dummy() = return
const dummy_m = which(dummy, Tuple{})

function build_codeinfo(ir::IR)
ir = copy(ir)
ci = code_lowered(dummy, Tuple{})[1]
ci = Base.uncompressed_ir(dummy_m)
ci.inlineable = true
for arg in arguments(ir)
push!(ci.slottypes, Type)
push!(ci.slotnames, Symbol(""))
push!(ci.slotflags, 0)
end
Expand Down
5 changes: 3 additions & 2 deletions src/reflection/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,17 @@ function meta(T; types = T, world = worldcounter())
sps = svec(map(untvar, sps)...)
@static if VERSION >= v"1.2-"
mi = Core.Compiler.specialize_method(method, types, sps)
ci = hasgenerator(mi) ? Core.Compiler.get_staged(mi) : Base.uncompressed_ast(method)
ci = hasgenerator(mi) ? Core.Compiler.get_staged(mi, world) : Base.uncompressed_ast(method)
else
mi = Core.Compiler.code_for_method(method, types, sps, world, false)
ci = hasgenerator(mi) ? Core.Compiler.get_staged(mi) : Base.uncompressed_ast(mi)
ci = hasgenerator(mi) ? Core.Compiler.get_staged(mi, world) : Base.uncompressed_ast(mi)
end
Base.Meta.partially_inline!(ci.code, [], method.sig, Any[sps...], 0, 0, :propagate)
Meta(method, mi, ci, method.nargs, sps)
end

function invoke_tweaks!(ci::CodeInfo)
ci.slottypes = [:todo, ci.slottypess[1], :todo, ci.slottypes[2:end]...]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't know what to put here where there is :todo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've gone with

  ci.slottypes = [typeof(invoke), ci.slottypess[1], Type, ci.slottypes[2:end]...]

ci.slotnames = [:invoke, ci.slotnames[1], :T, ci.slotnames[2:end]...]
ci.slotflags = [0x00, ci.slotflags[1], 0x00, ci.slotflags[2:end]...]
ci.code = map(ci.code) do x
Expand Down
7 changes: 6 additions & 1 deletion src/reflection/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ function slots!(ci::CodeInfo)
function f(x)
x isa Slot || return x
haskey(ss, x) && return ss[x]
push!(ci.slottypes, x.type)
push!(ci.slotnames, x.id)
push!(ci.slotflags, 0x00)
ss[x] = SlotNumber(length(ci.slotnames))
Expand Down Expand Up @@ -128,7 +129,11 @@ function splicearg!(ir::IR)
return arg
end

@static if VERSION < v"1.8.0-DEV.267"
@static if VERSION >= v"1.10.0-DEV.870"
function replace_code_newstyle!(ci, ir, _)
return Core.Compiler.replace_code_newstyle!(ci, ir)
Copy link
Contributor

Choose a reason for hiding this comment

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

you also might need to allocate slottypes, if you didn't already do that

    ci.slottypes isa Array || (ci.slottypes = [])

end
elseif VERSION < v"1.8.0-DEV.267"
function replace_code_newstyle!(ci, ir, n_argtypes)
return Core.Compiler.replace_code_newstyle!(ci, ir, n_argtypes-1)
end
Expand Down