From 0b70948126deb2af3447f70752098d6f7fcfd2ed Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Mon, 11 Dec 2023 22:26:18 -0800 Subject: [PATCH] [EH] Use random value for exnref encoding when legacy GC is used (#6166) Currently the legacy GC encoding's nullexternref encoding overlaps with exnref's. We assume the legacy GC encoding won't be used with the exnref for the moment and assign a random value to it to prevent the clash. --- src/wasm-binary.h | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/wasm-binary.h b/src/wasm-binary.h index 58d641dc949..9e68ca33039 100644 --- a/src/wasm-binary.h +++ b/src/wasm-binary.h @@ -412,8 +412,15 @@ enum EncodedType { nullable = -0x14, // 0x6c nonnullable = -0x15, // 0x6b #endif +#if STANDARD_GC_ENCODINGS // exception handling - exnref = -0x17, // 0x69 + exnref = -0x17, // 0x69 +#else + // Currently the legacy GC encoding's nullexternref encoding overlaps with + // exnref's. We assume the legacy GC encoding won't be used with the exnref + // for the moment and assign a random value to it to prevent the clash. + exnref = -0xfe, +#endif nullexnref = -0xff, // TODO // string reference types #if STANDARD_GC_ENCODINGS @@ -456,11 +463,18 @@ enum EncodedHeapType { nofunc = -0x18, // 0x68 none = -0x1b, // 0x65 #endif - func = -0x10, // 0x70 - ext = -0x11, // 0x6f - any = -0x12, // 0x6e - eq = -0x13, // 0x6d - exn = -0x17, // 0x69 + func = -0x10, // 0x70 + ext = -0x11, // 0x6f + any = -0x12, // 0x6e + eq = -0x13, // 0x6d +#if STANDARD_GC_ENCODINGS + exn = -0x17, // 0x69 +#else + // Currently the legacy GC encoding's nullexternref encoding overlaps with + // exnref's. We assume the legacy GC encoding won't be used with the exnref + // for the moment and assign a random value to it to prevent the clash. + exn = -0xfe, +#endif noexn = -0xff, // TODO #if STANDARD_GC_ENCODINGS i31 = -0x14, // 0x6c