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
6 changes: 3 additions & 3 deletions eng/native/configureplatform.cmake
Original file line numberDiff line numberDiff line change
Expand Up@@ -221,10 +221,10 @@ if(CLR_CMAKE_HOST_OS STREQUAL emscripten)
set(CLR_CMAKE_HOST_BROWSER 1)
endif(CLR_CMAKE_HOST_OS STREQUAL emscripten)

if(CLR_CMAKE_TARGET_OS STREQUAL wasi)
if(CLR_CMAKE_HOST_OS STREQUAL wasi)
set(CLR_CMAKE_HOST_WASI 1)
set(CLR_CMAKE_HOST_UNIX 1)
endif(CLR_CMAKE_TARGET_OS STREQUAL wasi)
endif(CLR_CMAKE_HOST_OS STREQUAL wasi)

#--------------------------------------------
# This repo builds two set of binaries
Expand DownExpand Up@@ -525,7 +525,7 @@ else()
add_compile_options(-mbulk-memory)
add_compile_options(-msimd128)
endif()
if(CLR_CMAKE_TARGET_WASI)
if(CLR_CMAKE_TARGET_WASI AND NOT CLR_CROSS_COMPONENTS_BUILD)
# Native wasm exceptions: sjlj cannot handle the interpreter's
# ResumeAfterCatch (throw-from-catch). -wasm-use-legacy-eh=false
# selects the new try_table/throw_ref proposal that wasmtime 45+
Expand Down
18 changes: 17 additions & 1 deletion src/coreclr/pal/src/arch/wasm/stubs.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -207,7 +207,9 @@ RaiseException(
extern "C" VOID PALAPI
DebugBreak()
{
_ASSERT(!"DebugBreak not implemented on wasi");
// No host debugger on WASI. Must NOT call _ASSERT here: AssertBreak calls
// DebugBreak, so asserting would recurse until the stack is exhausted and
// hide the original assert. Trap directly instead.
__builtin_debugtrap();
abort();
}
Expand All@@ -224,6 +226,20 @@ OutputDebugStringW(IN LPCWSTR lpOutputString)
(void)lpOutputString; // wchar_t* — not converted here; stub only
}

// PAL_ProbeMemory — normally in pal/src/debug/debug.cpp, excluded on WASI. wasm
// linear memory is one contiguous region, so a range is valid iff it ends
// within the current memory size (64 KiB pages).
extern "C" PALIMPORT BOOL PALAPI
PAL_ProbeMemory(PVOID pBuffer, DWORD cbBuffer, BOOL fWriteAccess)
{
(void)fWriteAccess;
if ((uintptr_t)((PBYTE)pBuffer + cbBuffer) <= (__builtin_wasm_memory_size(0) * 65536))
{
return TRUE;
}
return FALSE;
}
Comment thread
pavelsavara marked this conversation as resolved.

// PAL exception-record allocation — normally in seh-unwind.cpp which we
// exclude on WASI. Both records share a single allocation (mirroring the
// Unix layout) so the matching free is a single free() of the combined
Expand Down
10 changes: 2 additions & 8 deletions src/coreclr/pal/src/debug/debug.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -584,13 +584,7 @@ PAL_ProbeMemory(
return TRUE;
}
return FALSE;
#elif defined(TARGET_WASI)
if ((uintptr_t)((PBYTE)pBuffer + cbBuffer) <= (__builtin_wasm_memory_size(0) * 65536))
{
return TRUE;
}
return FALSE;
#else // TARGET_BROWSER || TARGET_WASI
#else // TARGET_BROWSER
int fds[2];
int flags;

Expand DownExpand Up@@ -647,7 +641,7 @@ PAL_ProbeMemory(
close(fds[1]);

return result;
#endif // TARGET_BROWSER || TARGET_WASI
#endif // TARGET_BROWSER
}

} // extern "C"
10 changes: 7 additions & 3 deletions src/coreclr/vm/jitinterface.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -11279,9 +11279,13 @@ void CEECodeGenInfo::getHelperFtn(CorInfoHelpFunc ftnNum, /* IN
helperMD = GetMethodDescForILBasedDynamicJitHelper(dynamicFtnNum);
_ASSERTE(PortableEntryPoint::GetMethodDesc((PCODE)targetAddr) == helperMD);
#ifdef FEATURE_READYTORUN
// With R2R disabled the helper runs interpreted and its portable entry point has no native
// code; the published-native-code invariant only holds when ReadyToRun is enabled.
_ASSERTE(!g_pConfig->ReadyToRun() || PortableEntryPoint::GetActualCode((PCODE)targetAddr) != NULL);
// Even with ReadyToRun enabled an IL-based dynamic helper can legitimately run interpreted
// (not present in the R2R image / interpreter-preferred entry point), in which case it has no
// native code. Only assert the published-native-code invariant when the entry point actually
// has native code -- calling GetActualCode otherwise asserts on !HasNativeCode().
_ASSERTE(!g_pConfig->ReadyToRun()
|| !PortableEntryPoint::HasNativeEntryPoint((PCODE)targetAddr)
|| PortableEntryPoint::GetActualCode((PCODE)targetAddr) != NULL);
#endif
}

Expand Down
Loading
Loading