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
5 changes: 5 additions & 0 deletions src/coreclr/vm/codeman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1515,6 +1515,11 @@ void EEJitManager::SetCpuInfo()
}
#endif

#if defined(TARGET_WASM)
CPUCompileFlags.Set(InstructionSet_WasmBase);
CPUCompileFlags.Set(InstructionSet_PackedSimd);
#endif

#if defined(TARGET_X86) || defined(TARGET_AMD64)
CPUCompileFlags.Set(InstructionSet_VectorT128);

Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/vm/excep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10728,7 +10728,7 @@ void SoftwareExceptionFrame::UpdateContextFromTransitionBlock(TransitionBlock *p
}

#elif defined(TARGET_WASM)

TADDR GetWasmFramePointerFromStackPointer(TADDR sp);
void SoftwareExceptionFrame::UpdateContextFromTransitionBlock(TransitionBlock *pTransitionBlock)
{
Comment thread
davidwrighton marked this conversation as resolved.
LIMITED_METHOD_CONTRACT;
Expand All @@ -10740,7 +10740,7 @@ void SoftwareExceptionFrame::UpdateContextFromTransitionBlock(TransitionBlock *p
if (pTransitionBlock != nullptr)
{
m_Context.InterpreterSP = pTransitionBlock->m_StackPointer;
m_Context.InterpreterFP = 0;
m_Context.InterpreterFP = GetWasmFramePointerFromStackPointer(m_Context.InterpreterSP);
m_Context.InterpreterIP = GetWasmVirtualIPFromStackPointer(pTransitionBlock->m_StackPointer);
m_ReturnAddress = m_Context.InterpreterIP;
m_Context.InterpreterWalkFramePointer = 0;
Expand Down
18 changes: 17 additions & 1 deletion src/coreclr/vm/wasm/helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,12 +520,26 @@ void FaultingExceptionFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool u
PORTABILITY_ASSERT("FaultingExceptionFrame::UpdateRegDisplay_Impl is not implemented on wasm");
}

TADDR GetWasmFramePointerFromStackPointer(TADDR sp);

void TransitionFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats)
{
pRD->IsCallerContextValid = FALSE;

pRD->pCurrentContext->InterpreterIP = GetReturnAddress();
pRD->pCurrentContext->InterpreterSP = GetSP();
TADDR sp = GetSP();
pRD->pCurrentContext->InterpreterSP = sp;

// Recover the frame pointer so GC-info readers can locate frame slots, but only when
// the stack pointer refers to a real R2R frame. When this frame represents a transition
// out of interpreted code, GetSP() returns the address just past the TransitionBlock (the
// outgoing argument area) rather than a frame pointer (see TransitionFrame::GetSP). Decoding
// that would dereference arbitrary memory, so leave the frame pointer as 0 in that case.
TransitionBlock* pTransitionBlock = (TransitionBlock*)GetTransitionBlock();
bool hasR2RStackPointer = (pTransitionBlock != NULL) &&
(pTransitionBlock->m_ReturnAddress != 0) &&
(pTransitionBlock->m_StackPointer != 0);
pRD->pCurrentContext->InterpreterFP = hasR2RStackPointer ? GetWasmFramePointerFromStackPointer(sp) : 0;

SyncRegDisplayToCurrentContext(pRD);

Expand Down Expand Up @@ -1514,13 +1528,15 @@ RtlVirtualUnwind (
PTR_BYTE pUnwindData = dac_cast<PTR_BYTE>(FunctionEntry->UnwindData + ImageBase);
ContextRecord->InterpreterSP = fp + DecodeULEB128AsU32(&pUnwindData); // Unwind the frame pointer to the callers stack pointer
ContextRecord->InterpreterIP = GetWasmVirtualIPFromStackPointer(ContextRecord->InterpreterSP);
ContextRecord->InterpreterFP = GetWasmFramePointerFromStackPointer(ContextRecord->InterpreterSP);
}
else
{
// Unwind failed!
_ASSERTE(FALSE);
ContextRecord->InterpreterIP = 0;
ContextRecord->InterpreterSP = 0;
ContextRecord->InterpreterFP = 0;
}

return nullptr;
Expand Down
8 changes: 8 additions & 0 deletions src/tests/Common/CLRTest.CrossGen.targets
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ if [ ! -z ${RunCrossGen2+x} ]%3B then
echo --targetos:$(TargetOS) >> "$__ResponseFile"
echo --verify-type-and-field-layout >> "$__ResponseFile"
echo --method-layout:random >> "$__ResponseFile"
if [ "$(CrossGen2OutputFormat)" == "wasm" ]; then
echo --codegenopt:JitWasmNyiToR2RUnsupported=1 >> "$__ResponseFile"
echo --codegenopt:JitWasmSimdNyiToR2RUnsupported=1 >> "$__ResponseFile"
fi
if [ ! -z ${CrossGen2SynthesizePgo+x} ]%3B then
echo --synthesize-random-mibc >> "$__ResponseFile"
echo --embed-pgo-data >> "$__ResponseFile"
Expand Down Expand Up @@ -339,6 +343,10 @@ if defined RunCrossGen2 (
echo --targetos:$(TargetOS)>>!__ResponseFile!
echo --verify-type-and-field-layout>>!__ResponseFile!
echo --method-layout:random>>!__ResponseFile!
if "$(CrossGen2OutputFormat)"=="wasm" (
echo "--codegenopt:JitWasmNyiToR2RUnsupported=1">>!__ResponseFile!
echo "--codegenopt:JitWasmSimdNyiToR2RUnsupported=1">>!__ResponseFile!
)
if not "$(CrossGen2OutputFormat)"=="" (
echo -f:$(CrossGen2OutputFormat)>>!__ResponseFile!
)
Expand Down
Loading