-
Notifications
You must be signed in to change notification settings - Fork 8
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
Interp2 #365
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@@ -779,6 +779,11 @@ function compile(f, args; client=nothing, optimize=true, sync=false) | |||
return register_thunk(fname, body) | |||
end | |||
|
|||
# Compiling within a compile should return simply the original function | |||
Reactant.@reactant_override function Reactant.Compiler.compile(f, args; client=nothing, optimize=true, sync=false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
Reactant.@reactant_override function Reactant.Compiler.compile(f, args; client=nothing, optimize=true, sync=false) | |
Reactant.@reactant_override function Reactant.Compiler.compile( | |
f, args; client=nothing, optimize=true, sync=false | |
) |
arginfo2 = ArgInfo( | ||
fargs isa Nothing ? nothing : | ||
fargs[2:end], | ||
argtypes[2:end], | ||
) | ||
return abstract_call( | ||
interp, | ||
arginfo2::ArgInfo, | ||
si, | ||
sv, | ||
max_methods, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
arginfo2 = ArgInfo( | |
fargs isa Nothing ? nothing : | |
fargs[2:end], | |
argtypes[2:end], | |
) | |
return abstract_call( | |
interp, | |
arginfo2::ArgInfo, | |
si, | |
sv, | |
max_methods, | |
) | |
arginfo2 = ArgInfo(fargs isa Nothing ? nothing : fargs[2:end], argtypes[2:end]) | |
return abstract_call(interp, arginfo2::ArgInfo, si, sv, max_methods) |
end | ||
end | ||
if Meta.isexpr(inst, :invoke) | ||
# return false, Expr(:call, inst.args[2:end]...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
# return false, Expr(:call, inst.args[2:end]...) | |
# return false, Expr(:call, inst.args[2:end]...) |
function make_oc(@nospecialize(sig::Type), @nospecialize(rt::Type), @nospecialize(rt2::Type), method::Core.Method) | ||
Base.llvmcall((""" | ||
declare {} addrspace(10)* @jl_new_opaque_closure_jlcall({} addrspace(10)*, {} addrspace(10)**, i32); | ||
|
||
declare {} addrspace(10)* @julia.call(...) | ||
|
||
define {} addrspace(10)* @f({} addrspace(10)* %a0, {} addrspace(10)* %a1, {} addrspace(10)* %a2, {} addrspace(10)* %a3) { | ||
%res = call {} addrspace(10)* (...) @julia.call({} addrspace(10)* ({} addrspace(10)*, {} addrspace(10)**, i32)* @jl_new_opaque_closure_jlcall, {} addrspace(10)* %a0, {} addrspace(10)* %a1, {} addrspace(10)* %a2, {} addrspace(10)* %a3) | ||
ret {} addrspace(10)* %res | ||
} | ||
""", "f"), Any, Tuple{Any, Any, Any, Any}, sig, rt, rt2, method) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
function make_oc(@nospecialize(sig::Type), @nospecialize(rt::Type), @nospecialize(rt2::Type), method::Core.Method) | |
Base.llvmcall((""" | |
declare {} addrspace(10)* @jl_new_opaque_closure_jlcall({} addrspace(10)*, {} addrspace(10)**, i32); | |
declare {} addrspace(10)* @julia.call(...) | |
define {} addrspace(10)* @f({} addrspace(10)* %a0, {} addrspace(10)* %a1, {} addrspace(10)* %a2, {} addrspace(10)* %a3) { | |
%res = call {} addrspace(10)* (...) @julia.call({} addrspace(10)* ({} addrspace(10)*, {} addrspace(10)**, i32)* @jl_new_opaque_closure_jlcall, {} addrspace(10)* %a0, {} addrspace(10)* %a1, {} addrspace(10)* %a2, {} addrspace(10)* %a3) | |
ret {} addrspace(10)* %res | |
} | |
""", "f"), Any, Tuple{Any, Any, Any, Any}, sig, rt, rt2, method) | |
function make_oc( | |
@nospecialize(sig::Type), | |
@nospecialize(rt::Type), | |
@nospecialize(rt2::Type), | |
method::Core.Method, | |
) | |
return Base.llvmcall( | |
( | |
""" | |
declare {} addrspace(10)* @jl_new_opaque_closure_jlcall({} addrspace(10)*, {} addrspace(10)**, i32); | |
declare {} addrspace(10)* @julia.call(...) | |
define {} addrspace(10)* @f({} addrspace(10)* %a0, {} addrspace(10)* %a1, {} addrspace(10)* %a2, {} addrspace(10)* %a3) { | |
%res = call {} addrspace(10)* (...) @julia.call({} addrspace(10)* ({} addrspace(10)*, {} addrspace(10)**, i32)* @jl_new_opaque_closure_jlcall, {} addrspace(10)* %a0, {} addrspace(10)* %a1, {} addrspace(10)* %a2, {} addrspace(10)* %a3) | |
ret {} addrspace(10)* %res | |
} | |
""", | |
"f", | |
), | |
Any, | |
Tuple{Any,Any,Any,Any}, | |
sig, | |
rt, | |
rt2, | |
method, | |
) |
@nospecialize | ||
args = redub_arguments | ||
|
||
ccall(:jl_, Any, (Any,), "world="*string(world)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
ccall(:jl_, Any, (Any,), "world="*string(world)) | |
ccall(:jl_, Any, (Any,), "world=" * string(world)) |
end | ||
|
||
if lookup_result === nothing || lookup_result === missing | ||
ccall(:jl_, Any, (Any,), "no rlookup_result"*string(lookup_result)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
ccall(:jl_, Any, (Any,), "no rlookup_result"*string(lookup_result)) | |
ccall(:jl_, Any, (Any,), "no rlookup_result" * string(lookup_result)) |
ccall(:jl_, Any, (Any,), "no matches "*string(lookup_result)) | ||
ccall(:jl_, Any, (Any,), "no matches2 "*string(matches)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
ccall(:jl_, Any, (Any,), "no matches "*string(lookup_result)) | |
ccall(:jl_, Any, (Any,), "no matches2 "*string(matches)) | |
ccall(:jl_, Any, (Any,), "no matches " * string(lookup_result)) | |
ccall(:jl_, Any, (Any,), "no matches2 " * string(matches)) |
|
||
result = Core.Compiler.InferenceResult(mi, Core.Compiler.typeinf_lattice(interp)) | ||
frame = Core.Compiler.InferenceState(result, :local, interp) #=cache_mode=# | ||
ccall(:jl_, Any, (Any,), "frame="*string(frame)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
ccall(:jl_, Any, (Any,), "frame="*string(frame)) | |
ccall(:jl_, Any, (Any,), "frame=" * string(frame)) |
Core.Compiler.ipo_dataflow_analysis!(interp, ir, caller) | ||
end | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
|
||
src = Core.Compiler.ir_to_codeinf!(opt) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
meth.nargs = method.nargs | ||
meth.file = Symbol("") | ||
meth.line = 0 # source | ||
ccall(:jl_method_set_source, Cvoid, (Ref{Core.Method}, Ref{Core.Compiler.CodeInfo}), meth, src) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
ccall(:jl_method_set_source, Cvoid, (Ref{Core.Method}, Ref{Core.Compiler.CodeInfo}), meth, src) | |
ccall( | |
:jl_method_set_source, | |
Cvoid, | |
(Ref{Core.Method}, Ref{Core.Compiler.CodeInfo}), | |
meth, | |
src, | |
) |
meth.line = 0 # source | ||
ccall(:jl_method_set_source, Cvoid, (Ref{Core.Method}, Ref{Core.Compiler.CodeInfo}), meth, src) | ||
|
||
nmi = ccall(:jl_specializations_get_linfo, Ref{Core.MethodInstance}, (Any, Any, Any), meth, sig, Core.svec()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
nmi = ccall(:jl_specializations_get_linfo, Ref{Core.MethodInstance}, (Any, Any, Any), meth, sig, Core.svec()) | |
nmi = ccall( | |
:jl_specializations_get_linfo, | |
Ref{Core.MethodInstance}, | |
(Any, Any, Any), | |
meth, | |
sig, | |
Core.svec(), | |
) |
nmi::Core.MethodInstance, rt, #=@nospecialize(inferred_const)=#C_NULL, | ||
#=@nospecialize(inferred)=#src, #=const_flags=#Int32(0), lookup_result.valid_worlds.min_world, lookup_result.valid_worlds.max_world, | ||
#=ipo_effects::UInt32=#UInt32(0), #=effects::UInt32=#UInt32(0), #=@nospecialize(argescapes#=::Union{Nothing,Vector{ArgEscapeInfo}}=#)=#nothing, | ||
#=src.relocatability=#UInt8(0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
nmi::Core.MethodInstance, rt, #=@nospecialize(inferred_const)=#C_NULL, | |
#=@nospecialize(inferred)=#src, #=const_flags=#Int32(0), lookup_result.valid_worlds.min_world, lookup_result.valid_worlds.max_world, | |
#=ipo_effects::UInt32=#UInt32(0), #=effects::UInt32=#UInt32(0), #=@nospecialize(argescapes#=::Union{Nothing,Vector{ArgEscapeInfo}}=#)=#nothing, | |
#=src.relocatability=#UInt8(0)) | |
nmi::Core.MethodInstance, | |
rt, | |
C_NULL, #=@nospecialize(inferred_const)=# | |
src, | |
Int32(0), | |
lookup_result.valid_worlds.min_world, | |
lookup_result.valid_worlds.max_world, #=const_flags=# | |
UInt32(0), | |
UInt32(0), | |
nothing, #=@nospecialize(argescapes#=::Union{Nothing,Vector{ArgEscapeInfo}}=#)=# | |
UInt8(0), | |
) #=src.relocatability=# |
|
||
# oc = Core.OpaqueClosure(sig, rt, rt, method, C_NULL, 0, true) # | ||
|
||
ocargs = Any[Tuple{typeof(Reactant.apply), sig.parameters...}, rt, rt, meth] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
ocargs = Any[Tuple{typeof(Reactant.apply), sig.parameters...}, rt, rt, meth] | |
ocargs = Any[Tuple{typeof(Reactant.apply),sig.parameters...}, rt, rt, meth] |
@show meth.nargs | ||
@show length(ocargs[1].parameters) | ||
flush(stdout) | ||
oc = ccall(:jl_new_opaque_closure_jlcall, Any, (Ptr{Cvoid}, Ptr{Any}, Int32), C_NULL, ocargs, Int32(4)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
oc = ccall(:jl_new_opaque_closure_jlcall, Any, (Ptr{Cvoid}, Ptr{Any}, Int32), C_NULL, ocargs, Int32(4)) | |
oc = ccall( | |
:jl_new_opaque_closure_jlcall, | |
Any, | |
(Ptr{Cvoid}, Ptr{Any}, Int32), | |
C_NULL, | |
ocargs, | |
Int32(4), | |
) |
push!( | ||
overdubbed_code, | ||
Expr( | ||
:(call), | ||
oc, | ||
fn_args... | ||
), | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
push!( | |
overdubbed_code, | |
Expr( | |
:(call), | |
oc, | |
fn_args... | |
), | |
) | |
push!(overdubbed_code, Expr(:(call), oc, fn_args...)) |
push!( | ||
overdubbed_code, | ||
Core.ReturnNode(Core.SSAValue(length(overdubbed_code))) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
push!( | |
overdubbed_code, | |
Core.ReturnNode(Core.SSAValue(length(overdubbed_code))) | |
) | |
push!(overdubbed_code, Core.ReturnNode(Core.SSAValue(length(overdubbed_code)))) |
No description provided.