Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion src/coreclr/vm/codeman.inl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ inline TADDR IJitManager::JitTokenToModuleRVABase(const METHODTOKEN& MethodToken
{
#ifdef TARGET_WASM
if (MethodToken.m_pRangeSection->_flags & RangeSection::RANGE_SECTION_VIRTUALIP)
return (TADDR)MethodToken.m_pRangeSection->_pR2RModule->GetModuleBaseAddress();
return dac_cast<TADDR>(MethodToken.m_pRangeSection->_pR2RModule->GetReadyToRunInfo()->GetImage()->GetBase());
#endif
// For non-wasm, the rva base is always the same as the range base.
return MethodToken.m_pRangeSection->_range.RangeStart();
Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/vm/frames.h
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,9 @@ inline CONTEXT * GETREDIRECTEDCONTEXT(Thread * thread) { LIMITED_METHOD_CONTRACT
typedef DPTR(class TransitionFrame) PTR_TransitionFrame;

#ifdef TARGET_WASM
// Wasm has no native return address for an R2R inline P/Invoke. This sentinel marks the frame as
// active; stack walkers recover the caller virtual IP from m_pCallSiteSP.
static constexpr TADDR INLINED_PINVOKE_FROM_R2R = 1;
TADDR GetWasmVirtualIPFromStackPointer(TADDR sp);
#endif

Expand Down
12 changes: 12 additions & 0 deletions src/coreclr/vm/stackwalk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2330,6 +2330,18 @@ StackWalkAction StackFrameIterator::NextRaw(void)

_ASSERTE(!pInlinedFrame || adr);

#ifdef TARGET_WASM
if ((pInlinedFrame != NULL) && (adr == (PCODE)INLINED_PINVOKE_FROM_R2R))
{
adr = GetWasmVirtualIPFromStackPointer(dac_cast<TADDR>(((InlinedCallFrame*)pInlinedFrame)->GetCallSiteSP()));
if (adr == (PCODE)NULL)
{
retVal = SWA_FAILED;
goto Cleanup;
}
Comment thread
lewing marked this conversation as resolved.
}
#endif // TARGET_WASM

if (adr)
{
ProcessIp(adr);
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/vm/wasm/helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

#define WASM_STRINGIFY_HELPER(value) #value
#define WASM_STRINGIFY(value) WASM_STRINGIFY_HELPER(value)
#define INLINED_PINVOKE_FROM_R2R 1

void ExecuteInterpretedMethodWithArgs_PortableEntryPoint(PCODE portableEntrypoint, TransitionBlock* block, size_t argsSize, int8_t* retBuff);

Expand Down
Loading