Skip to content
Merged
Show file tree
Hide file tree
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
11 changes: 11 additions & 0 deletions src/coreclr/jit/codegenlinear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,7 @@ BasicBlock* CodeGen::genEmitEndBlock(BasicBlock* block)
break;

case BBJ_THROW:
{
// If we have a throw at the end of a function or funclet, we need to emit another instruction
// afterwards to help the OS unwinder determine the correct context during unwind.
// We insert an unexecuted breakpoint instruction in several situations
Expand Down Expand Up @@ -822,7 +823,17 @@ BasicBlock* CodeGen::genEmitEndBlock(BasicBlock* block)
}
}

#if defined(TARGET_WASM)
// For wasm the last instruction in a function or funclet must be end.
//
if (block->IsLast() || m_compiler->bbIsFuncletBeg(block->Next()))
{
GetEmitter()->emitIns(INS_end);
}
#endif // defined(TARGET_WASM)

break;
}

case BBJ_CALLFINALLY:
result = genCallFinally(block);
Expand Down
5 changes: 2 additions & 3 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2346,9 +2346,8 @@ int GenTreeCall::GetNonStandardAddedArgCount(Compiler* compiler) const
{
#if defined(TARGET_WASM)
// TODO-WASM: may need adjustments for other hidden args
// For now: managed calls get extra SP + PortableEntryPoint args, but
// we're not adding the PE arg yet. So just note one extra arg.
return IsUnmanaged() ? 0 : 1;
// For now: managed calls get extra SP + PortableEntryPoint args.
return IsUnmanaged() ? 0 : 2;
#endif // defined(TARGET_WASM)

if (IsUnmanaged() && !compiler->opts.ShouldUsePInvokeHelpers())
Expand Down
6 changes: 5 additions & 1 deletion src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1836,8 +1836,12 @@ void CallArgs::AddFinalArgsAndDetermineABIInfo(Compiler* comp, GenTreeCall* call
{
GenTree* const stackPointer = comp->gtNewLclVarNode(comp->lvaWasmSpArg, TYP_I_IMPL);
PushFront(comp, NewCallArg::Primitive(stackPointer).WellKnown(WellKnownArg::WasmShadowStackPointer));

// TODO-WASM: pass proper portable entry point as the last argument for managed calls
GenTree* const pePointer = comp->gtNewZeroConNode(TYP_I_IMPL);
PushBack(comp, NewCallArg::Primitive(pePointer).WellKnown(WellKnownArg::WasmPortableEntryPoint));
}
// TODO-WASM: pass the portable entry point as the last argument for managed calls

#endif // defined(TARGET_WASM)

ClassifierInfo info;
Expand Down
Loading