JIT: Support loading Swift self register from SwiftSelf struct#99132
JIT: Support loading Swift self register from SwiftSelf struct#99132amanasifkhalid merged 4 commits intodotnet:mainfrom
Conversation
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch Issue DetailsAdds JIT support for loading the Swift self/context register value from the
|
|
cc @jakobbotsch @kotlarmilos @jkoritzinsky. Here's a snippet of what the codegen looks like on x64, where the self register is r13: And on arm64, where the self register is x20: |
| // Exception: Lower SwiftSelf struct arg to GT_LCL_FLD | ||
| if (call->gtArgs.IsNonStandard(this, call, &arg) && arg.AbiInfo.IsPassedInRegisters() && | ||
| (arg.GetWellKnownArg() != WellKnownArg::SwiftSelf)) | ||
| { |
There was a problem hiding this comment.
Why is this necessary? That doesn't seem right.
There was a problem hiding this comment.
Likely we should instead insert a new arg in the importer that represents "self" as a primitive instead of keeping this as a struct argument. It being a struct argument is just an artifact of the design and it wouldn't work to keep it as a struct on all ABIs.
There was a problem hiding this comment.
Let's just keep it as is for now. I'm refactoring stuff for the struct work which should make this change simple to make.
There was a problem hiding this comment.
Likely we should instead insert a new arg in the importer that represents "self" as a primitive instead of keeping this as a struct argument.
Yeah, the fact that the argument was being kept as TYP_STRUCT was causing asserts in later phases.
Let's just keep it as is for now. I'm refactoring stuff for the struct work which should make this change simple to make.
Sure thing.
| class CallArgs; | ||
|
|
||
| enum class WellKnownArg | ||
| enum class WellKnownArg : unsigned |
There was a problem hiding this comment.
Why this change? (Seems fine, just curious)
There was a problem hiding this comment.
CallArg::m_wellKnownArg is 5 bits, and WellKnownArg::SwiftSelf has a value of 16 (also 5 bits). If m_wellKnownArg is signed, then we lose the most-significant bit, so comparisons like m_wellKnownArg == WellKnownArg::SwiftSelf fail.
|
ryujit-bot doesn't seem to be running, so I'll point out here that this is a no-diff change. |
Adds JIT support for loading the Swift self/context register value from the
SwiftSelfstruct argument passed to a Swift call. Also enables corresponding tests.