-
Notifications
You must be signed in to change notification settings - Fork 5.1k
[wasm][coreclr] Get further in the runtime initialization #116383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Add corewasmhost binary to test runtime initialization Fix linking of the host binary with coreclr and interpreter Allow calling interpreter with arguments and handle return value Use fake precode stubs to pass the precode type and method desc Make alternate signal stack calls no-op on wasm Implement CallDescrWorkerInternal on wasm Fix PE image loading without RTR on wasm Do not use unsupported syscalls
c49f135
to
b32ad25
Compare
Tagging subscribers to 'arch-wasm': @lewing |
Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com>
And do not build coreclr
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
@@ -39,6 +39,11 @@ if (DEFINED CLR_CMAKE_ICU_DIR) | |||
include_directories(${CLR_CMAKE_ICU_DIR}/include) | |||
endif(DEFINED CLR_CMAKE_ICU_DIR) | |||
|
|||
if (CLR_CMAKE_TARGET_ARCH_WASM) | |||
add_compile_options(-fwasm-exceptions) | |||
add_link_options(-fwasm-exceptions -sEXIT_RUNTIME=1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add_link_options(-fwasm-exceptions -sEXIT_RUNTIME=1) |
This is duplicated in src/coreclr/hosts/corewasmrun/CMakeLists.txt. Do we need it here?
set_property(TARGET coreclr APPEND_STRING PROPERTY LINK_DEPENDS ${EXPORTS_FILE}) | ||
set_property(TARGET coreclr APPEND_STRING PROPERTY LINK_FLAGS ${EXPORTS_LINKER_OPTION}) | ||
set_property(TARGET coreclr APPEND_STRING PROPERTY LINK_DEPENDS ${EXPORTS_FILE}) | ||
endif(NOT CLR_CMAKE_HOST_ARCH_WASM) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
endif(NOT CLR_CMAKE_HOST_ARCH_WASM) | |
set(LIB_CORDBEE cordbee_wks) | |
set(LIB_INTEROP interop) | |
set(LIB_CDAC_CONTRACT_DESCRIPTOR cdac_contract_descriptor) | |
endif(NOT CLR_CMAKE_HOST_ARCH_WASM) |
|
||
if (NOT CLR_CMAKE_TARGET_ARCH_WASM) | ||
set(LIB_CORDBEE cordbee_wks) | ||
set(LIB_INTEROP interop) | ||
set(LIB_CDAC_CONTRACT_DESCRIPTOR cdac_contract_descriptor) | ||
endif (NOT CLR_CMAKE_TARGET_ARCH_WASM) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (NOT CLR_CMAKE_TARGET_ARCH_WASM) | |
set(LIB_CORDBEE cordbee_wks) | |
set(LIB_INTEROP interop) | |
set(LIB_CDAC_CONTRACT_DESCRIPTOR cdac_contract_descriptor) | |
endif (NOT CLR_CMAKE_TARGET_ARCH_WASM) |
Folded this into the earlier if?
@@ -576,7 +577,7 @@ static void* VirtualReserveInner(size_t size, size_t alignment, uint32_t flags, | |||
} | |||
|
|||
pRetVal = pAlignedRetVal; | |||
#ifdef MADV_DONTDUMP | |||
#if defined(MADV_DONTDUMP) && !defined(TARGET_BROWSER) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you believe that the rest of this implementation is going to work on wasm?
runtimelab branch reimplemented it from scratch for wasm: https://github.com/dotnet/runtimelab/blob/feature/NativeAOT-LLVM/src/coreclr/gc/wasm/gcenv.wasm.cpp . dotnet/runtimelab#1510 describes the motivation. Should we adopt this implementation instead of trying to ifdef what's here today?
@@ -624,9 +625,13 @@ bool GCToOSInterface::VirtualRelease(void* address, size_t size) | |||
// true if it has succeeded, false if it has failed | |||
static bool VirtualCommitInner(void* address, size_t size, uint16_t node, bool newMemory) | |||
{ | |||
#ifndef TARGET_BROWSER |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dtto
@@ -6047,11 +6047,13 @@ BOOL Thread::SetStackLimits(SetStackLimitScope scope) | |||
{ | |||
m_CacheStackBase = GetStackUpperBound(); | |||
m_CacheStackLimit = GetStackLowerBound(); | |||
#ifndef TARGET_WASM // stack can start at address 0 on wasm/emscripten and usually does |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still needed now that we are using emscripten_stack_get_base
?
@@ -515,6 +515,9 @@ void MethodDescCallSite::CallTargetWorker(const ARG_SLOT *pArguments, ARG_SLOT * | |||
CallDescrData callDescrData; | |||
|
|||
callDescrData.pSrc = pTransitionBlock + sizeof(TransitionBlock); | |||
#ifdef TARGET_WASM | |||
callDescrData.pTransitionBlock = (TransitionBlock*)pTransitionBlock; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I can live with what's in this PR, but we should avoid growing it organically. We want to have discussion about how the calling convention should actually work before doing more work on it here.
this PR vs. extra PR
This PR has a bunch of good changes and a bunch of changes that need more work. If you would like to, I can go over it with you over it and separate the good non-controversial changes and get those in, and then work on the rest separately.
|
||
// for numeric_limits | ||
#include <limits> | ||
|
||
FCDECL1(float, JIT_ULng2Flt, uint64_t val); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this incorrectly resolved merge conflict?
@@ -201,6 +201,7 @@ DEFINE_METASIG_T(SM(Exception_Obj_RefIntPtr_RetVoidPtr, C(EXCEPTION) j r(I), P(v | |||
#endif // FEATURE_OBJCMARSHAL | |||
DEFINE_METASIG(SM(Int_RetVoid, i, v)) | |||
DEFINE_METASIG(SM(Int_RetObj, i, j)) | |||
DEFINE_METASIG(SM(Int_RetInt, i, i)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrectly resolved merge conflict?
@@ -2664,18 +2664,22 @@ FlushProcessWriteBuffers() | |||
int status = pthread_mutex_lock(&flushProcessWriteBuffersMutex); | |||
FATAL_ASSERT(status == 0, "Failed to lock the flushProcessWriteBuffersMutex lock"); | |||
|
|||
#ifndef TARGET_BROWSER |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is same code as what's in src/coreclr/gc/unix/gcenv.unix.cpp. It should be ifdefed same way.
(Ideally, we would move this to minipal to avoid the duplication - but that would be larger change.)
@@ -260,7 +266,11 @@ TADDR PEAssembly::GetIL(RVA il) | |||
CONTRACT_END; | |||
|
|||
PEImageLayout *image = NULL; | |||
#ifdef PEIMAGE_FLAT_LAYOUT_ONLY |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be better to return the flat layout from GetLoadedLayout
. I suspect that we would need to ifdef a lot of calls to GetLoadedLayout
otherwise.
Add corewasmhost binary to test runtime initialization
Fix linking of the host binary with coreclr and interpreter
Allow calling interpreter with arguments and handle return value
Use fake precode stubs to pass the precode type and method desc
Make alternate signal stack calls no-op on wasm
Implement CallDescrWorkerInternal on wasm
Use flat PE image loading on wasm
Do not use unsupported syscalls