From b10fa7881c314cc0bbc4295d1cd9f5492edcf702 Mon Sep 17 00:00:00 2001 From: Andy Ayers Date: Wed, 18 Mar 2026 15:49:23 -0700 Subject: [PATCH 1/4] [Wasm RyuJit] Add JIT config JitWasmNyiToR2RUnsupported Set this to allow crossgen2 for Wasm to continue even if there is a method that runs into an NYI_WASM in the JIT. --- src/coreclr/jit/error.h | 4 +++- src/coreclr/jit/jitconfigvalues.h | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/coreclr/jit/error.h b/src/coreclr/jit/error.h index 5692730cd4b6b0..02987a3ac3e471 100644 --- a/src/coreclr/jit/error.h +++ b/src/coreclr/jit/error.h @@ -225,7 +225,9 @@ extern void notYetImplemented(const char* msg, const char* file, unsigned line); #define NYI_ARM64(msg) do { } while (0) #define NYI_LOONGARCH64(msg) do { } while (0) #define NYI_RISCV64(msg) do { } while (0) -#define NYI_WASM(msg) NYIRAW("NYI_WASM: " msg) +#define NYI_WASM(msg) do { if (JitConfig.JitWasmNyiToR2RUnsupported() > 0) \ + { JITDUMP("NYI_WASM:" msg); implReadyToRunUnsupported(); } \ + else { NYIRAW("NYI_WASM: " msg); } } while (0) #else diff --git a/src/coreclr/jit/jitconfigvalues.h b/src/coreclr/jit/jitconfigvalues.h index 7741e0f6b8fe19..149d2a1b7dca3b 100644 --- a/src/coreclr/jit/jitconfigvalues.h +++ b/src/coreclr/jit/jitconfigvalues.h @@ -864,6 +864,11 @@ CONFIG_INTEGER(JitUseScalableVectorT, "JitUseScalableVectorT", 0) CONFIG_INTEGER(JitDispIns, "JitDispIns", 0) #endif // defined(TARGET_LOONGARCH64) +#if defined(TARGET_WASM) +// Set this to 1 to turn NYI_WASM into R2R unsupportedfailures instead of asserts. +CONFIG_INTEGER(JitWasmNyiToR2RUnsupported, "JitWasmNyiToR2RUnsupported", 0) +#endif // defined(TARGET_WASM) + // Allow to enregister locals with struct type. RELEASE_CONFIG_INTEGER(JitEnregStructLocals, "JitEnregStructLocals", 1) From b8fa3a802deebe4eb67ca035d1a944697546ba71 Mon Sep 17 00:00:00 2001 From: Andy Ayers Date: Wed, 18 Mar 2026 16:11:02 -0700 Subject: [PATCH 2/4] add nyi for unimplemented tree node codegen --- src/coreclr/jit/codegenwasm.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/coreclr/jit/codegenwasm.cpp b/src/coreclr/jit/codegenwasm.cpp index 32f5ef4cdb950b..45dce609c4e6ef 100644 --- a/src/coreclr/jit/codegenwasm.cpp +++ b/src/coreclr/jit/codegenwasm.cpp @@ -650,6 +650,11 @@ void CodeGen::genCodeForTreeNode(GenTree* treeNode) default: #ifdef DEBUG + if (JitConfig.JitWasmNyiToR2RUnsupported()) + { + NYI_WASM("Opcode not implemented"); + } + NYIRAW(GenTree::OpName(treeNode->OperGet())); #else NYI_WASM("Opcode not implemented"); From 472570972726af831d55e31198d365f7c5ec1e91 Mon Sep 17 00:00:00 2001 From: Andy Ayers Date: Wed, 18 Mar 2026 16:17:51 -0700 Subject: [PATCH 3/4] review feedback --- src/coreclr/jit/emit.h | 3 +++ src/coreclr/jit/error.h | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/coreclr/jit/emit.h b/src/coreclr/jit/emit.h index f674d75f0dd0c4..9ffcd4b440594e 100644 --- a/src/coreclr/jit/emit.h +++ b/src/coreclr/jit/emit.h @@ -3922,6 +3922,9 @@ template inline emitAttr emitTypeSize(T type) { assert(TypeGet(type) < TYP_COUNT); + + if (emitTypeSizes[TypeGet(type)] == 0) + NYI_WASM("oops"); assert(emitTypeSizes[TypeGet(type)] > 0); return (emitAttr)emitTypeSizes[TypeGet(type)]; } diff --git a/src/coreclr/jit/error.h b/src/coreclr/jit/error.h index 02987a3ac3e471..cf2103620f2c9f 100644 --- a/src/coreclr/jit/error.h +++ b/src/coreclr/jit/error.h @@ -225,9 +225,14 @@ extern void notYetImplemented(const char* msg, const char* file, unsigned line); #define NYI_ARM64(msg) do { } while (0) #define NYI_LOONGARCH64(msg) do { } while (0) #define NYI_RISCV64(msg) do { } while (0) + +#if DEBUG #define NYI_WASM(msg) do { if (JitConfig.JitWasmNyiToR2RUnsupported() > 0) \ - { JITDUMP("NYI_WASM:" msg); implReadyToRunUnsupported(); } \ + { JITDUMP("NYI_WASM: " msg); implReadyToRunUnsupported(); } \ else { NYIRAW("NYI_WASM: " msg); } } while (0) +#else +#define NYI_WASM(msg) NYIRAW("NYI_WASM: " msg) +#endif // DEBUG #else From 88895c42f813bf54924478516b6c01c4ac599bd2 Mon Sep 17 00:00:00 2001 From: Andy Ayers Date: Wed, 18 Mar 2026 16:40:20 -0700 Subject: [PATCH 4/4] revert some interim workarounds --- src/coreclr/jit/emit.h | 3 --- src/coreclr/jit/jitconfigvalues.h | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/coreclr/jit/emit.h b/src/coreclr/jit/emit.h index 9ffcd4b440594e..f674d75f0dd0c4 100644 --- a/src/coreclr/jit/emit.h +++ b/src/coreclr/jit/emit.h @@ -3922,9 +3922,6 @@ template inline emitAttr emitTypeSize(T type) { assert(TypeGet(type) < TYP_COUNT); - - if (emitTypeSizes[TypeGet(type)] == 0) - NYI_WASM("oops"); assert(emitTypeSizes[TypeGet(type)] > 0); return (emitAttr)emitTypeSizes[TypeGet(type)]; } diff --git a/src/coreclr/jit/jitconfigvalues.h b/src/coreclr/jit/jitconfigvalues.h index 149d2a1b7dca3b..2c2e9a350aa80f 100644 --- a/src/coreclr/jit/jitconfigvalues.h +++ b/src/coreclr/jit/jitconfigvalues.h @@ -865,7 +865,7 @@ CONFIG_INTEGER(JitDispIns, "JitDispIns", 0) #endif // defined(TARGET_LOONGARCH64) #if defined(TARGET_WASM) -// Set this to 1 to turn NYI_WASM into R2R unsupportedfailures instead of asserts. +// Set this to 1 to turn NYI_WASM into R2R unsupported failures instead of asserts. CONFIG_INTEGER(JitWasmNyiToR2RUnsupported, "JitWasmNyiToR2RUnsupported", 0) #endif // defined(TARGET_WASM)