|
1 | 1 | # Codegen shared by both stage1 and stage2 |
2 | 2 |
|
3 | | -function make_opaque_closure(interp, typ, name, meth_nargs::Int, isva, lno, cis, revs...) |
| 3 | +function make_opaque_closure(interp, typ, name, meth_nargs::Int, isva, lno, ci, revs...) |
4 | 4 | if interp !== nothing |
5 | | - cis.inferred = true |
6 | | - ocm = ccall(:jl_new_opaque_closure_from_code_info, Any, (Any, Any, Any, Any, Any, Cint, Any, Cint, Cint, Any), |
7 | | - typ, Union{}, cis.rettype, @__MODULE__, cis, lno.line, lno.file, meth_nargs, isva, ()).source |
8 | | - return Expr(:new_opaque_closure, typ, Union{}, Any, |
9 | | - ocm, revs...) |
| 5 | + @static if VERSION ≥ v"1.12.0-DEV.15" |
| 6 | + rettype = Any # ci.rettype # TODO revisit |
| 7 | + else |
| 8 | + ci.inferred = true |
| 9 | + rettype = ci.rettype |
| 10 | + end |
| 11 | + @static if VERSION ≥ v"1.12.0-DEV.15" |
| 12 | + ocm = Core.OpaqueClosure(ci; rettype, nargs=meth_nargs, isva, sig=typ).source |
| 13 | + else |
| 14 | + ocm = ccall(:jl_new_opaque_closure_from_code_info, Any, (Any, Any, Any, Any, Any, Cint, Any, Cint, Cint, Any), |
| 15 | + typ, Union{}, rettype, @__MODULE__, ci, lno.line, lno.file, meth_nargs, isva, ()).source |
| 16 | + end |
| 17 | + return Expr(:new_opaque_closure, typ, Union{}, Any, ocm, revs...) |
10 | 18 | else |
11 | 19 | oc_nargs = Int64(meth_nargs) |
12 | 20 | Expr(:new_opaque_closure, typ, Union{}, Any, |
13 | | - Expr(:opaque_closure_method, name, oc_nargs, isva, lno, cis), revs...) |
| 21 | + Expr(:opaque_closure_method, name, oc_nargs, isva, lno, ci), revs...) |
14 | 22 | end |
15 | 23 | end |
16 | 24 |
|
@@ -107,8 +115,12 @@ function diffract_ir!(ir, ci, meth, sparams::Core.SimpleVector, nargs::Int, N::I |
107 | 115 | opaque_ci.slotnames = [Symbol("#oc#"), ci.slotnames...] |
108 | 116 | opaque_ci.slotflags = UInt8[0, ci.slotflags...] |
109 | 117 | end |
110 | | - opaque_ci.linetable = Core.LineInfoNode[ci.linetable[1]] |
111 | | - opaque_ci.inferred = false |
| 118 | + @static if VERSION ≥ v"1.12.0-DEV.173" |
| 119 | + opaque_ci.debuginfo = ci.debuginfo |
| 120 | + else |
| 121 | + opaque_ci.linetable = Core.LineInfoNode[ci.linetable[1]] |
| 122 | + opaque_ci.inferred = false |
| 123 | + end |
112 | 124 | opaque_ci |
113 | 125 | end |
114 | 126 |
|
@@ -393,12 +405,17 @@ function diffract_ir!(ir, ci, meth, sparams::Core.SimpleVector, nargs::Int, N::I |
393 | 405 | code = opaque_ci.code = expand_switch(code, bb_ranges, slot_map) |
394 | 406 | end |
395 | 407 |
|
396 | | - opaque_ci.codelocs = Int32[0 for i=1:length(code)] |
| 408 | + @static if VERSION ≥ v"1.12.0-DEV.173" |
| 409 | + debuginfo = Core.Compiler.DebugInfoStream(nothing, opaque_ci.debuginfo, length(code)) |
| 410 | + debuginfo.def = :var"N/A" |
| 411 | + opaque_ci.debuginfo = Core.DebugInfo(debuginfo, length(code)) |
| 412 | + else |
| 413 | + opaque_ci.codelocs = Int32[0 for i=1:length(code)] |
| 414 | + end |
397 | 415 | opaque_ci.ssavaluetypes = length(code) |
398 | | - opaque_ci.ssaflags = UInt8[0 for i=1:length(code)] |
| 416 | + opaque_ci.ssaflags = SSAFlagType[zero(SSAFlagType) for i=1:length(code)] |
399 | 417 | end |
400 | 418 |
|
401 | | - |
402 | 419 | for nc = 2:2:n_closures |
403 | 420 | fwds = Any[nothing for i = 1:length(ir.stmts)] |
404 | 421 |
|
@@ -475,9 +492,15 @@ function diffract_ir!(ir, ci, meth, sparams::Core.SimpleVector, nargs::Int, N::I |
475 | 492 | end |
476 | 493 | end |
477 | 494 |
|
478 | | - opaque_ci.codelocs = Int32[0 for i=1:length(code)] |
| 495 | + @static if VERSION ≥ v"1.12.0-DEV.173" |
| 496 | + debuginfo = Core.Compiler.DebugInfoStream(nothing, opaque_ci.debuginfo, length(code)) |
| 497 | + debuginfo.def = :var"N/A" |
| 498 | + opaque_ci.debuginfo = Core.DebugInfo(debuginfo, length(code)) |
| 499 | + else |
| 500 | + opaque_ci.codelocs = Int32[0 for i=1:length(code)] |
| 501 | + end |
479 | 502 | opaque_ci.ssavaluetypes = length(code) |
480 | | - opaque_ci.ssaflags = UInt8[0 for i=1:length(code)] |
| 503 | + opaque_ci.ssaflags = SSAFlagType[zero(SSAFlagType) for i=1:length(code)] |
481 | 504 | end |
482 | 505 |
|
483 | 506 | # TODO: This is absolutely aweful, but the best we can do given the data structures we have |
|
0 commit comments