-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[Wasm RyuJIT] Initial scaffolding for calls and helper calls #123044
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
base: main
Are you sure you want to change the base?
Conversation
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
741ddb8 to
e805a10
Compare
AndyAyersMS
left a comment
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.
We still need to figure out in detail how to specify what method we want to call.
We know roughly what kind of Wasm we want to produce (per the calling convention doc we'll be making lots of indirect calls) but we need help from the JIT host to make this all work out.
I think it might be ok for now to just defer this part of the work and try and get everything else lined up?
| // Generate a direct call to a non-virtual user defined or helper method | ||
| assert(call->IsHelperCall() || (call->gtCallType == CT_USER_FUNC)); | ||
|
|
||
| if (call->gtEntryPoint.addr != NULL) |
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.
Per the calling convention, for user and helper calls we'll also be invoking them indirectly.
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.
Right. I'm not clear on whether that means there won't be an addr filled in
b95ce18 to
499127d
Compare
|
This branch now hits this in crossgen2: |
|
For this: [MethodImpl(MethodImplOptions.NoInlining)]
static void voidFunc () {
}
[MethodImpl(MethodImplOptions.NoInlining)]
static void callVoidFunc () {
voidFunc();
}R2R now compiles without crashing or asserting, and disasmo generates this: ; Method Program:callVoidFunc() (FullOpts)
G_M45341_IG01: ;; offset=0x0000
local.cnt 4
local[0] type=i32
local[1] type=i64
local[2] type=f32
local[3] type=f64
;; size=9 bbWeight=1 PerfScore 5.00
G_M45341_IG02: ;; offset=0x0009
i32.const 140722950757336
i32.load 0 0
call_indirect 0 0
;; size=14 bbWeight=1 PerfScore 3.00
G_M45341_IG03: ;; offset=0x0017
end
;; size=1 bbWeight=1 PerfScore 1.00
; Total bytes of code: 24It's not correct but it's a start. |
|
cc @dotnet/jit-contrib need to figure out how this should actually be factored and shaped and implemented, now that it "works". I don't understand 75% of the code I touched here, for example whether we use EA_8BYTE or a different one still makes no sense to me, and the way we historically separate out |
|
|
||
| genConsumeRegs(op1); | ||
|
|
||
| genEmitHelperCall(CORINFO_HELP_THROWNULLREF, 0, EA_UNKNOWN, REG_NA); |
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 does GT_NULLCHECK just unconditionally calls CORINFO_HELP_THROWNULLREF?
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.
Was trying to just get the JIT to emit a helper call, since Andy is working on actual null checks. But I never found a way to get a GT_NULLCHECK node
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.
Something like that should?
unsafe void Foo(int* x)
{
_ = *x;
}TransformUnusedIndirection is expected to convert this unused GT_IND into GT_NULLCHECK
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.
Thanks for pointing this out though, I had forgotten to put a comment in
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.
Something like that should?
unsafe void Foo(int* x) { _ = *x; }
TransformUnusedIndirectionis expected to convert this unused GT_IND into GT_NULLCHECK
This indeed appears to work! Thank you very much
Depends on #123021
Starting to put together all the code we need for helper calls and calls in general.