-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
JIT: Support loading Swift self register from SwiftSelf struct #99132
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this necessary? That doesn't seem right.
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -4401,7 +4401,7 @@ enum class CFGCallKind | |||
|
|||
class CallArgs; | |||
|
|||
enum class WellKnownArg | |||
enum class WellKnownArg : unsigned |
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.
Why this change? (Seems fine, just curious)
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.
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
SwiftSelf
struct argument passed to a Swift call. Also enables corresponding tests.