You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the happy case (capture types known + AT / RT are Const), the compiler can statically resolve the dispatch to MethodInstance (::typeof.(captures))(::AT...) for oc_method and simplify the construction of this OpaqueClosure significantly (including compiling all of its code ahead-of-time)
Right now, codegen attempts to resolve this on-the-fly to a compiled CodeInstance, which can then be used to codegen essentially:
where specptr was taken out of a CodeInstance that the oc_method has been resolved to.
This is the right transformation, but it's happening in the wrong place, since codegen is no longer allowed to call into type-inference (this is one of the last offenders).
In order to support this, we need some way of providing the CI to codegen ahead-of-time.
if (ci == NULL || (jl_value_t*)ci == jl_nothing || ci->rettype != rettype || !jl_egal(sigtype, mi->specTypes)) { // TODO: correctly handle the ABI conversion if rettype != ci->rettype
ci->rettype is required by inference to be the inferred return type, not a widened (or intersected/type-asserted) version of the same, and right now we simply lose this optimization if you don't infer exactly as expected:
Maybe ABIOverride can be a suitable mechanism for requesting compilation for the required ABI?
What prevents us from just overriding the rettype in the CodeInstance? ABIOverride was required precisely because the CodeInstance did not have a place for specifying the argument ABI other than mi->specTypes, but it does for the rt.
OpaqueClosures are currently constructed with this (lower-transformed) constructor:
In the happy case (
capture
types known +AT
/RT
areConst
), the compiler can statically resolve the dispatch toMethodInstance (::typeof.(captures))(::AT...) for oc_method
and simplify the construction of this OpaqueClosure significantly (including compiling all of its code ahead-of-time)Right now, codegen attempts to resolve this on-the-fly to a compiled
CodeInstance
, which can then be used to codegen essentially:where
specptr
was taken out of aCodeInstance
that the oc_method has been resolved to.This is the right transformation, but it's happening in the wrong place, since codegen is no longer allowed to call into type-inference (this is one of the last offenders).
In order to support this, we need some way of providing the CI to codegen ahead-of-time.
The simplest proposal may be to support:
One related wrinkle will be solving this TODO:
julia/src/codegen.cpp
Line 6197 in f211a77
ci->rettype
is required by inference to be the inferred return type, not a widened (or intersected/type-asserted) version of the same, and right now we simply lose this optimization if you don't infer exactly as expected:which for
--trim
also means that you lose the ability to compile / run this code.Maybe
ABIOverride
can be a suitable mechanism for requesting compilation for the required ABI?The text was updated successfully, but these errors were encountered: