Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ protected override void EmitCode(NodeFactory factory, ref Wasm.WasmEmitter instr
expressions.Add(I32.Store(0));

// Build the arguments for the R2R call_indirect.
// Target R2R wasm params: ($sp, [retbuf], [this], explicit_params..., portableEntrypoint)
// Target R2R wasm params: ($sp, [this], [retbuf], explicit_params..., portableEntrypoint)
// (matches Compiler::lvaInitArgs / WasmR2RToInterpreterThunkNode local order.)
// We track targetParamIndex to look up the correct wasm type for each arg.
int targetParamIndex = 0;

Expand All @@ -154,13 +155,6 @@ protected override void EmitCode(NodeFactory factory, ref Wasm.WasmEmitter instr
expressions.Add(Global.Get(WasmObjectWriter.StackPointerGlobalIndex));
targetParamIndex++;

// If the R2R function takes a return buffer, pass pRet directly as the retbuf arg
if (hasRetBuffArg)
{
expressions.Add(Local.Get(LocalPRet));
targetParamIndex++;
}

// If the method has a 'this' pointer, load it from pArgs at offset 0
// (ArgIterator offset for this = OffsetOfArgumentRegisters = SizeOfTransitionBlock)
if (hasThis)
Expand All @@ -171,6 +165,13 @@ protected override void EmitCode(NodeFactory factory, ref Wasm.WasmEmitter instr
targetParamIndex++;
}

// If the R2R function takes a return buffer, pass pRet directly as the retbuf arg
if (hasRetBuffArg)
{
expressions.Add(Local.Get(LocalPRet));
targetParamIndex++;
}

// Explicit parameters — load each from pArgs at the ArgIterator-derived offset
for (int i = 0; i < methodSignature.Length; i++)
{
Expand Down
Loading