diff options
author | Alon Zakai <azakai@google.com> | 2024-06-10 16:02:00 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-10 16:02:00 -0700 |
commit | 0a1a59af573414a20fe457fd77b732729aa92fb2 (patch) | |
tree | 9639e7d7946f6d63737703d5c032ff85d4d2be79 /src/emscripten-optimizer | |
parent | 76d1ac3e9c5abfe589bcdfc84b89f263bac7c574 (diff) | |
download | binaryen-0a1a59af573414a20fe457fd77b732729aa92fb2.tar.gz binaryen-0a1a59af573414a20fe457fd77b732729aa92fb2.tar.bz2 binaryen-0a1a59af573414a20fe457fd77b732729aa92fb2.zip |
wasm2js: Add basic reference operations (#6648)
This adds ref.eq, ref.null, ref.is_null, ref.func.
Diffstat (limited to 'src/emscripten-optimizer')
-rw-r--r-- | src/emscripten-optimizer/optimizer-shared.cpp | 10 | ||||
-rw-r--r-- | src/emscripten-optimizer/optimizer.h | 2 |
2 files changed, 10 insertions, 2 deletions
diff --git a/src/emscripten-optimizer/optimizer-shared.cpp b/src/emscripten-optimizer/optimizer-shared.cpp index 8208f6f47..773c5d9fc 100644 --- a/src/emscripten-optimizer/optimizer-shared.cpp +++ b/src/emscripten-optimizer/optimizer-shared.cpp @@ -104,6 +104,11 @@ Ref makeJsCoercedZero(JsType type) { abort(); } +bool needsJsCoercion(JsType type) { + // References need no coercion, but everything else does. + return type != JS_REF; +} + Ref makeJsCoercion(Ref node, JsType type) { switch (type) { case JS_INT: @@ -122,10 +127,11 @@ Ref makeJsCoercion(Ref node, JsType type) { return ValueBuilder::makeCall(SIMD_INT16X8_CHECK, node); case JS_INT32X4: return ValueBuilder::makeCall(SIMD_INT32X4_CHECK, node); + case JS_REF: case JS_NONE: default: - // non-validating code, emit nothing XXX this is dangerous, we should only - // allow this when we know we are not validating + // No coercion is needed. + // TODO see if JS_NONE is actually used here. return node; } } diff --git a/src/emscripten-optimizer/optimizer.h b/src/emscripten-optimizer/optimizer.h index a27fe25eb..6347c194c 100644 --- a/src/emscripten-optimizer/optimizer.h +++ b/src/emscripten-optimizer/optimizer.h @@ -39,6 +39,7 @@ enum JsType { JS_INT16X8, JS_INT32X4, JS_INT64, + JS_REF, JS_NONE // number of types }; @@ -51,6 +52,7 @@ enum JsSign { }; cashew::Ref makeJsCoercedZero(JsType type); +bool needsJsCoercion(JsType type); cashew::Ref makeJsCoercion(cashew::Ref node, JsType type); cashew::Ref makeSigning(cashew::Ref node, JsSign sign); |