summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/wasm/gc/bug-1879096.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
commitfbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 (patch)
tree4c1ccaf5486d4f2009f9a338a98a83e886e29c97 /js/src/jit-test/tests/wasm/gc/bug-1879096.js
parentReleasing progress-linux version 124.0.1-1~progress7.99u1. (diff)
downloadfirefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.tar.xz
firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.zip
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jit-test/tests/wasm/gc/bug-1879096.js')
-rw-r--r--js/src/jit-test/tests/wasm/gc/bug-1879096.js65
1 files changed, 65 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/wasm/gc/bug-1879096.js b/js/src/jit-test/tests/wasm/gc/bug-1879096.js
new file mode 100644
index 0000000000..e71d2bac27
--- /dev/null
+++ b/js/src/jit-test/tests/wasm/gc/bug-1879096.js
@@ -0,0 +1,65 @@
+// |jit-test| test-also=--setpref=wasm_test_serialization; skip-if: !wasmGcEnabled()
+
+// Conditional branch instructions need to rewrite their stack types according
+// to the destination label types. This loses information but is mandated by
+// the spec.
+
+// br_if
+wasmFailValidateText(`(module
+ (func (result anyref)
+ ref.null array ;; stack: [arrayref]
+ ref.null struct ;; stack: [arrayref structref]
+ i32.const 0 ;; stack: [arrayref structref i32]
+ br_if 0 ;; stack: [arrayref anyref]
+ ref.eq ;; should fail (anyref is not eq)
+ unreachable
+ )
+)`, /type mismatch: expression has type anyref but expected eqref/);
+
+// br_on_null
+wasmFailValidateText(`(module
+ (func (param externref) (result anyref)
+ ref.null array ;; stack: [arrayref]
+ local.get 0 ;; stack: [arrayref externref]
+ br_on_null 0 ;; stack: [anyref (ref extern)]
+ drop ;; stack: [anyref]
+ array.len ;; should fail
+ unreachable
+ )
+)`, /type mismatch: expression has type anyref but expected arrayref/);
+
+// br_on_non_null
+wasmFailValidateText(`(module
+ (func (param externref) (result anyref (ref extern))
+ ref.null array ;; stack: [arrayref]
+ ref.null struct ;; stack: [arrayref structref]
+ local.get 0 ;; stack: [arrayref structref externref]
+ br_on_non_null 0 ;; stack: [arrayref anyref]
+ ref.eq ;; should fail (anyref is not eq)
+ unreachable
+ )
+)`, /type mismatch: expression has type anyref but expected eqref/);
+
+// br_on_cast
+wasmFailValidateText(`(module
+ (type $s (struct))
+ (func (result anyref (ref $s))
+ ref.null array ;; stack: [arrayref]
+ ref.null struct ;; stack: [arrayref structref]
+ br_on_cast 0 structref (ref $s) ;; stack: [anyref structref]
+ ref.eq ;; should fail (anyref is not eq)
+ unreachable
+ )
+)`, /type mismatch: expression has type anyref but expected eqref/);
+
+// br_on_cast_fail
+wasmFailValidateText(`(module
+ (type $s (struct))
+ (func (result anyref anyref)
+ ref.null array ;; stack: [arrayref]
+ ref.null struct ;; stack: [arrayref structref]
+ br_on_cast_fail 0 structref (ref $s) ;; stack: [anyref (ref $s)]
+ ref.eq ;; should fail (anyref is not eq)
+ unreachable
+ )
+)`, /type mismatch: expression has type anyref but expected eqref/);