diff options
Diffstat (limited to 'js/src/jit-test/tests/wasm/spec/memory64')
12 files changed, 5233 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/wasm/spec/memory64/address64.wast.js b/js/src/jit-test/tests/wasm/spec/memory64/address64.wast.js new file mode 100644 index 0000000000..c6de7e8ed7 --- /dev/null +++ b/js/src/jit-test/tests/wasm/spec/memory64/address64.wast.js @@ -0,0 +1,1025 @@ +/* Copyright 2021 Mozilla Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ./test/core/address64.wast + +// ./test/core/address64.wast:3 +let $0 = instantiate(`(module + (memory i64 1) + (data (i64.const 0) "abcdefghijklmnopqrstuvwxyz") + + (func (export "8u_good1") (param $$i i64) (result i32) + (i32.load8_u offset=0 (local.get $$i)) ;; 97 'a' + ) + (func (export "8u_good2") (param $$i i64) (result i32) + (i32.load8_u align=1 (local.get $$i)) ;; 97 'a' + ) + (func (export "8u_good3") (param $$i i64) (result i32) + (i32.load8_u offset=1 align=1 (local.get $$i)) ;; 98 'b' + ) + (func (export "8u_good4") (param $$i i64) (result i32) + (i32.load8_u offset=2 align=1 (local.get $$i)) ;; 99 'c' + ) + (func (export "8u_good5") (param $$i i64) (result i32) + (i32.load8_u offset=25 align=1 (local.get $$i)) ;; 122 'z' + ) + + (func (export "8s_good1") (param $$i i64) (result i32) + (i32.load8_s offset=0 (local.get $$i)) ;; 97 'a' + ) + (func (export "8s_good2") (param $$i i64) (result i32) + (i32.load8_s align=1 (local.get $$i)) ;; 97 'a' + ) + (func (export "8s_good3") (param $$i i64) (result i32) + (i32.load8_s offset=1 align=1 (local.get $$i)) ;; 98 'b' + ) + (func (export "8s_good4") (param $$i i64) (result i32) + (i32.load8_s offset=2 align=1 (local.get $$i)) ;; 99 'c' + ) + (func (export "8s_good5") (param $$i i64) (result i32) + (i32.load8_s offset=25 align=1 (local.get $$i)) ;; 122 'z' + ) + + (func (export "16u_good1") (param $$i i64) (result i32) + (i32.load16_u offset=0 (local.get $$i)) ;; 25185 'ab' + ) + (func (export "16u_good2") (param $$i i64) (result i32) + (i32.load16_u align=1 (local.get $$i)) ;; 25185 'ab' + ) + (func (export "16u_good3") (param $$i i64) (result i32) + (i32.load16_u offset=1 align=1 (local.get $$i)) ;; 25442 'bc' + ) + (func (export "16u_good4") (param $$i i64) (result i32) + (i32.load16_u offset=2 align=2 (local.get $$i)) ;; 25699 'cd' + ) + (func (export "16u_good5") (param $$i i64) (result i32) + (i32.load16_u offset=25 align=2 (local.get $$i)) ;; 122 'z\\0' + ) + + (func (export "16s_good1") (param $$i i64) (result i32) + (i32.load16_s offset=0 (local.get $$i)) ;; 25185 'ab' + ) + (func (export "16s_good2") (param $$i i64) (result i32) + (i32.load16_s align=1 (local.get $$i)) ;; 25185 'ab' + ) + (func (export "16s_good3") (param $$i i64) (result i32) + (i32.load16_s offset=1 align=1 (local.get $$i)) ;; 25442 'bc' + ) + (func (export "16s_good4") (param $$i i64) (result i32) + (i32.load16_s offset=2 align=2 (local.get $$i)) ;; 25699 'cd' + ) + (func (export "16s_good5") (param $$i i64) (result i32) + (i32.load16_s offset=25 align=2 (local.get $$i)) ;; 122 'z\\0' + ) + + (func (export "32_good1") (param $$i i64) (result i32) + (i32.load offset=0 (local.get $$i)) ;; 1684234849 'abcd' + ) + (func (export "32_good2") (param $$i i64) (result i32) + (i32.load align=1 (local.get $$i)) ;; 1684234849 'abcd' + ) + (func (export "32_good3") (param $$i i64) (result i32) + (i32.load offset=1 align=1 (local.get $$i)) ;; 1701077858 'bcde' + ) + (func (export "32_good4") (param $$i i64) (result i32) + (i32.load offset=2 align=2 (local.get $$i)) ;; 1717920867 'cdef' + ) + (func (export "32_good5") (param $$i i64) (result i32) + (i32.load offset=25 align=4 (local.get $$i)) ;; 122 'z\\0\\0\\0' + ) + + (func (export "8u_bad") (param $$i i64) + (drop (i32.load8_u offset=4294967295 (local.get $$i))) + ) + (func (export "8s_bad") (param $$i i64) + (drop (i32.load8_s offset=4294967295 (local.get $$i))) + ) + (func (export "16u_bad") (param $$i i64) + (drop (i32.load16_u offset=4294967295 (local.get $$i))) + ) + (func (export "16s_bad") (param $$i i64) + (drop (i32.load16_s offset=4294967295 (local.get $$i))) + ) + (func (export "32_bad") (param $$i i64) + (drop (i32.load offset=4294967295 (local.get $$i))) + ) +)`); + +// ./test/core/address64.wast:104 +assert_return(() => invoke($0, `8u_good1`, [0n]), [value("i32", 97)]); + +// ./test/core/address64.wast:105 +assert_return(() => invoke($0, `8u_good2`, [0n]), [value("i32", 97)]); + +// ./test/core/address64.wast:106 +assert_return(() => invoke($0, `8u_good3`, [0n]), [value("i32", 98)]); + +// ./test/core/address64.wast:107 +assert_return(() => invoke($0, `8u_good4`, [0n]), [value("i32", 99)]); + +// ./test/core/address64.wast:108 +assert_return(() => invoke($0, `8u_good5`, [0n]), [value("i32", 122)]); + +// ./test/core/address64.wast:110 +assert_return(() => invoke($0, `8s_good1`, [0n]), [value("i32", 97)]); + +// ./test/core/address64.wast:111 +assert_return(() => invoke($0, `8s_good2`, [0n]), [value("i32", 97)]); + +// ./test/core/address64.wast:112 +assert_return(() => invoke($0, `8s_good3`, [0n]), [value("i32", 98)]); + +// ./test/core/address64.wast:113 +assert_return(() => invoke($0, `8s_good4`, [0n]), [value("i32", 99)]); + +// ./test/core/address64.wast:114 +assert_return(() => invoke($0, `8s_good5`, [0n]), [value("i32", 122)]); + +// ./test/core/address64.wast:116 +assert_return(() => invoke($0, `16u_good1`, [0n]), [value("i32", 25185)]); + +// ./test/core/address64.wast:117 +assert_return(() => invoke($0, `16u_good2`, [0n]), [value("i32", 25185)]); + +// ./test/core/address64.wast:118 +assert_return(() => invoke($0, `16u_good3`, [0n]), [value("i32", 25442)]); + +// ./test/core/address64.wast:119 +assert_return(() => invoke($0, `16u_good4`, [0n]), [value("i32", 25699)]); + +// ./test/core/address64.wast:120 +assert_return(() => invoke($0, `16u_good5`, [0n]), [value("i32", 122)]); + +// ./test/core/address64.wast:122 +assert_return(() => invoke($0, `16s_good1`, [0n]), [value("i32", 25185)]); + +// ./test/core/address64.wast:123 +assert_return(() => invoke($0, `16s_good2`, [0n]), [value("i32", 25185)]); + +// ./test/core/address64.wast:124 +assert_return(() => invoke($0, `16s_good3`, [0n]), [value("i32", 25442)]); + +// ./test/core/address64.wast:125 +assert_return(() => invoke($0, `16s_good4`, [0n]), [value("i32", 25699)]); + +// ./test/core/address64.wast:126 +assert_return(() => invoke($0, `16s_good5`, [0n]), [value("i32", 122)]); + +// ./test/core/address64.wast:128 +assert_return(() => invoke($0, `32_good1`, [0n]), [value("i32", 1684234849)]); + +// ./test/core/address64.wast:129 +assert_return(() => invoke($0, `32_good2`, [0n]), [value("i32", 1684234849)]); + +// ./test/core/address64.wast:130 +assert_return(() => invoke($0, `32_good3`, [0n]), [value("i32", 1701077858)]); + +// ./test/core/address64.wast:131 +assert_return(() => invoke($0, `32_good4`, [0n]), [value("i32", 1717920867)]); + +// ./test/core/address64.wast:132 +assert_return(() => invoke($0, `32_good5`, [0n]), [value("i32", 122)]); + +// ./test/core/address64.wast:134 +assert_return(() => invoke($0, `8u_good1`, [65507n]), [value("i32", 0)]); + +// ./test/core/address64.wast:135 +assert_return(() => invoke($0, `8u_good2`, [65507n]), [value("i32", 0)]); + +// ./test/core/address64.wast:136 +assert_return(() => invoke($0, `8u_good3`, [65507n]), [value("i32", 0)]); + +// ./test/core/address64.wast:137 +assert_return(() => invoke($0, `8u_good4`, [65507n]), [value("i32", 0)]); + +// ./test/core/address64.wast:138 +assert_return(() => invoke($0, `8u_good5`, [65507n]), [value("i32", 0)]); + +// ./test/core/address64.wast:140 +assert_return(() => invoke($0, `8s_good1`, [65507n]), [value("i32", 0)]); + +// ./test/core/address64.wast:141 +assert_return(() => invoke($0, `8s_good2`, [65507n]), [value("i32", 0)]); + +// ./test/core/address64.wast:142 +assert_return(() => invoke($0, `8s_good3`, [65507n]), [value("i32", 0)]); + +// ./test/core/address64.wast:143 +assert_return(() => invoke($0, `8s_good4`, [65507n]), [value("i32", 0)]); + +// ./test/core/address64.wast:144 +assert_return(() => invoke($0, `8s_good5`, [65507n]), [value("i32", 0)]); + +// ./test/core/address64.wast:146 +assert_return(() => invoke($0, `16u_good1`, [65507n]), [value("i32", 0)]); + +// ./test/core/address64.wast:147 +assert_return(() => invoke($0, `16u_good2`, [65507n]), [value("i32", 0)]); + +// ./test/core/address64.wast:148 +assert_return(() => invoke($0, `16u_good3`, [65507n]), [value("i32", 0)]); + +// ./test/core/address64.wast:149 +assert_return(() => invoke($0, `16u_good4`, [65507n]), [value("i32", 0)]); + +// ./test/core/address64.wast:150 +assert_return(() => invoke($0, `16u_good5`, [65507n]), [value("i32", 0)]); + +// ./test/core/address64.wast:152 +assert_return(() => invoke($0, `16s_good1`, [65507n]), [value("i32", 0)]); + +// ./test/core/address64.wast:153 +assert_return(() => invoke($0, `16s_good2`, [65507n]), [value("i32", 0)]); + +// ./test/core/address64.wast:154 +assert_return(() => invoke($0, `16s_good3`, [65507n]), [value("i32", 0)]); + +// ./test/core/address64.wast:155 +assert_return(() => invoke($0, `16s_good4`, [65507n]), [value("i32", 0)]); + +// ./test/core/address64.wast:156 +assert_return(() => invoke($0, `16s_good5`, [65507n]), [value("i32", 0)]); + +// ./test/core/address64.wast:158 +assert_return(() => invoke($0, `32_good1`, [65507n]), [value("i32", 0)]); + +// ./test/core/address64.wast:159 +assert_return(() => invoke($0, `32_good2`, [65507n]), [value("i32", 0)]); + +// ./test/core/address64.wast:160 +assert_return(() => invoke($0, `32_good3`, [65507n]), [value("i32", 0)]); + +// ./test/core/address64.wast:161 +assert_return(() => invoke($0, `32_good4`, [65507n]), [value("i32", 0)]); + +// ./test/core/address64.wast:162 +assert_return(() => invoke($0, `32_good5`, [65507n]), [value("i32", 0)]); + +// ./test/core/address64.wast:164 +assert_return(() => invoke($0, `8u_good1`, [65508n]), [value("i32", 0)]); + +// ./test/core/address64.wast:165 +assert_return(() => invoke($0, `8u_good2`, [65508n]), [value("i32", 0)]); + +// ./test/core/address64.wast:166 +assert_return(() => invoke($0, `8u_good3`, [65508n]), [value("i32", 0)]); + +// ./test/core/address64.wast:167 +assert_return(() => invoke($0, `8u_good4`, [65508n]), [value("i32", 0)]); + +// ./test/core/address64.wast:168 +assert_return(() => invoke($0, `8u_good5`, [65508n]), [value("i32", 0)]); + +// ./test/core/address64.wast:170 +assert_return(() => invoke($0, `8s_good1`, [65508n]), [value("i32", 0)]); + +// ./test/core/address64.wast:171 +assert_return(() => invoke($0, `8s_good2`, [65508n]), [value("i32", 0)]); + +// ./test/core/address64.wast:172 +assert_return(() => invoke($0, `8s_good3`, [65508n]), [value("i32", 0)]); + +// ./test/core/address64.wast:173 +assert_return(() => invoke($0, `8s_good4`, [65508n]), [value("i32", 0)]); + +// ./test/core/address64.wast:174 +assert_return(() => invoke($0, `8s_good5`, [65508n]), [value("i32", 0)]); + +// ./test/core/address64.wast:176 +assert_return(() => invoke($0, `16u_good1`, [65508n]), [value("i32", 0)]); + +// ./test/core/address64.wast:177 +assert_return(() => invoke($0, `16u_good2`, [65508n]), [value("i32", 0)]); + +// ./test/core/address64.wast:178 +assert_return(() => invoke($0, `16u_good3`, [65508n]), [value("i32", 0)]); + +// ./test/core/address64.wast:179 +assert_return(() => invoke($0, `16u_good4`, [65508n]), [value("i32", 0)]); + +// ./test/core/address64.wast:180 +assert_return(() => invoke($0, `16u_good5`, [65508n]), [value("i32", 0)]); + +// ./test/core/address64.wast:182 +assert_return(() => invoke($0, `16s_good1`, [65508n]), [value("i32", 0)]); + +// ./test/core/address64.wast:183 +assert_return(() => invoke($0, `16s_good2`, [65508n]), [value("i32", 0)]); + +// ./test/core/address64.wast:184 +assert_return(() => invoke($0, `16s_good3`, [65508n]), [value("i32", 0)]); + +// ./test/core/address64.wast:185 +assert_return(() => invoke($0, `16s_good4`, [65508n]), [value("i32", 0)]); + +// ./test/core/address64.wast:186 +assert_return(() => invoke($0, `16s_good5`, [65508n]), [value("i32", 0)]); + +// ./test/core/address64.wast:188 +assert_return(() => invoke($0, `32_good1`, [65508n]), [value("i32", 0)]); + +// ./test/core/address64.wast:189 +assert_return(() => invoke($0, `32_good2`, [65508n]), [value("i32", 0)]); + +// ./test/core/address64.wast:190 +assert_return(() => invoke($0, `32_good3`, [65508n]), [value("i32", 0)]); + +// ./test/core/address64.wast:191 +assert_return(() => invoke($0, `32_good4`, [65508n]), [value("i32", 0)]); + +// ./test/core/address64.wast:192 +assert_trap(() => invoke($0, `32_good5`, [65508n]), `out of bounds memory access`); + +// ./test/core/address64.wast:194 +assert_trap(() => invoke($0, `8u_bad`, [0n]), `out of bounds memory access`); + +// ./test/core/address64.wast:195 +assert_trap(() => invoke($0, `8s_bad`, [0n]), `out of bounds memory access`); + +// ./test/core/address64.wast:196 +assert_trap(() => invoke($0, `16u_bad`, [0n]), `out of bounds memory access`); + +// ./test/core/address64.wast:197 +assert_trap(() => invoke($0, `16s_bad`, [0n]), `out of bounds memory access`); + +// ./test/core/address64.wast:198 +assert_trap(() => invoke($0, `32_bad`, [0n]), `out of bounds memory access`); + +// ./test/core/address64.wast:200 +assert_trap(() => invoke($0, `8u_bad`, [1n]), `out of bounds memory access`); + +// ./test/core/address64.wast:201 +assert_trap(() => invoke($0, `8s_bad`, [1n]), `out of bounds memory access`); + +// ./test/core/address64.wast:202 +assert_trap(() => invoke($0, `16u_bad`, [1n]), `out of bounds memory access`); + +// ./test/core/address64.wast:203 +assert_trap(() => invoke($0, `16s_bad`, [1n]), `out of bounds memory access`); + +// ./test/core/address64.wast:204 +assert_trap(() => invoke($0, `32_bad`, [1n]), `out of bounds memory access`); + +// ./test/core/address64.wast:209 +let $1 = instantiate(`(module + (memory i64 1) + (data (i64.const 0) "abcdefghijklmnopqrstuvwxyz") + + (func (export "8u_good1") (param $$i i64) (result i64) + (i64.load8_u offset=0 (local.get $$i)) ;; 97 'a' + ) + (func (export "8u_good2") (param $$i i64) (result i64) + (i64.load8_u align=1 (local.get $$i)) ;; 97 'a' + ) + (func (export "8u_good3") (param $$i i64) (result i64) + (i64.load8_u offset=1 align=1 (local.get $$i)) ;; 98 'b' + ) + (func (export "8u_good4") (param $$i i64) (result i64) + (i64.load8_u offset=2 align=1 (local.get $$i)) ;; 99 'c' + ) + (func (export "8u_good5") (param $$i i64) (result i64) + (i64.load8_u offset=25 align=1 (local.get $$i)) ;; 122 'z' + ) + + (func (export "8s_good1") (param $$i i64) (result i64) + (i64.load8_s offset=0 (local.get $$i)) ;; 97 'a' + ) + (func (export "8s_good2") (param $$i i64) (result i64) + (i64.load8_s align=1 (local.get $$i)) ;; 97 'a' + ) + (func (export "8s_good3") (param $$i i64) (result i64) + (i64.load8_s offset=1 align=1 (local.get $$i)) ;; 98 'b' + ) + (func (export "8s_good4") (param $$i i64) (result i64) + (i64.load8_s offset=2 align=1 (local.get $$i)) ;; 99 'c' + ) + (func (export "8s_good5") (param $$i i64) (result i64) + (i64.load8_s offset=25 align=1 (local.get $$i)) ;; 122 'z' + ) + + (func (export "16u_good1") (param $$i i64) (result i64) + (i64.load16_u offset=0 (local.get $$i)) ;; 25185 'ab' + ) + (func (export "16u_good2") (param $$i i64) (result i64) + (i64.load16_u align=1 (local.get $$i)) ;; 25185 'ab' + ) + (func (export "16u_good3") (param $$i i64) (result i64) + (i64.load16_u offset=1 align=1 (local.get $$i)) ;; 25442 'bc' + ) + (func (export "16u_good4") (param $$i i64) (result i64) + (i64.load16_u offset=2 align=2 (local.get $$i)) ;; 25699 'cd' + ) + (func (export "16u_good5") (param $$i i64) (result i64) + (i64.load16_u offset=25 align=2 (local.get $$i)) ;; 122 'z\\0' + ) + + (func (export "16s_good1") (param $$i i64) (result i64) + (i64.load16_s offset=0 (local.get $$i)) ;; 25185 'ab' + ) + (func (export "16s_good2") (param $$i i64) (result i64) + (i64.load16_s align=1 (local.get $$i)) ;; 25185 'ab' + ) + (func (export "16s_good3") (param $$i i64) (result i64) + (i64.load16_s offset=1 align=1 (local.get $$i)) ;; 25442 'bc' + ) + (func (export "16s_good4") (param $$i i64) (result i64) + (i64.load16_s offset=2 align=2 (local.get $$i)) ;; 25699 'cd' + ) + (func (export "16s_good5") (param $$i i64) (result i64) + (i64.load16_s offset=25 align=2 (local.get $$i)) ;; 122 'z\\0' + ) + + (func (export "32u_good1") (param $$i i64) (result i64) + (i64.load32_u offset=0 (local.get $$i)) ;; 1684234849 'abcd' + ) + (func (export "32u_good2") (param $$i i64) (result i64) + (i64.load32_u align=1 (local.get $$i)) ;; 1684234849 'abcd' + ) + (func (export "32u_good3") (param $$i i64) (result i64) + (i64.load32_u offset=1 align=1 (local.get $$i)) ;; 1701077858 'bcde' + ) + (func (export "32u_good4") (param $$i i64) (result i64) + (i64.load32_u offset=2 align=2 (local.get $$i)) ;; 1717920867 'cdef' + ) + (func (export "32u_good5") (param $$i i64) (result i64) + (i64.load32_u offset=25 align=4 (local.get $$i)) ;; 122 'z\\0\\0\\0' + ) + + (func (export "32s_good1") (param $$i i64) (result i64) + (i64.load32_s offset=0 (local.get $$i)) ;; 1684234849 'abcd' + ) + (func (export "32s_good2") (param $$i i64) (result i64) + (i64.load32_s align=1 (local.get $$i)) ;; 1684234849 'abcd' + ) + (func (export "32s_good3") (param $$i i64) (result i64) + (i64.load32_s offset=1 align=1 (local.get $$i)) ;; 1701077858 'bcde' + ) + (func (export "32s_good4") (param $$i i64) (result i64) + (i64.load32_s offset=2 align=2 (local.get $$i)) ;; 1717920867 'cdef' + ) + (func (export "32s_good5") (param $$i i64) (result i64) + (i64.load32_s offset=25 align=4 (local.get $$i)) ;; 122 'z\\0\\0\\0' + ) + + (func (export "64_good1") (param $$i i64) (result i64) + (i64.load offset=0 (local.get $$i)) ;; 0x6867666564636261 'abcdefgh' + ) + (func (export "64_good2") (param $$i i64) (result i64) + (i64.load align=1 (local.get $$i)) ;; 0x6867666564636261 'abcdefgh' + ) + (func (export "64_good3") (param $$i i64) (result i64) + (i64.load offset=1 align=1 (local.get $$i)) ;; 0x6968676665646362 'bcdefghi' + ) + (func (export "64_good4") (param $$i i64) (result i64) + (i64.load offset=2 align=2 (local.get $$i)) ;; 0x6a69686766656463 'cdefghij' + ) + (func (export "64_good5") (param $$i i64) (result i64) + (i64.load offset=25 align=8 (local.get $$i)) ;; 122 'z\\0\\0\\0\\0\\0\\0\\0' + ) + + (func (export "8u_bad") (param $$i i64) + (drop (i64.load8_u offset=4294967295 (local.get $$i))) + ) + (func (export "8s_bad") (param $$i i64) + (drop (i64.load8_s offset=4294967295 (local.get $$i))) + ) + (func (export "16u_bad") (param $$i i64) + (drop (i64.load16_u offset=4294967295 (local.get $$i))) + ) + (func (export "16s_bad") (param $$i i64) + (drop (i64.load16_s offset=4294967295 (local.get $$i))) + ) + (func (export "32u_bad") (param $$i i64) + (drop (i64.load32_u offset=4294967295 (local.get $$i))) + ) + (func (export "32s_bad") (param $$i i64) + (drop (i64.load32_s offset=4294967295 (local.get $$i))) + ) + (func (export "64_bad") (param $$i i64) + (drop (i64.load offset=4294967295 (local.get $$i))) + ) +)`); + +// ./test/core/address64.wast:348 +assert_return(() => invoke($1, `8u_good1`, [0n]), [value("i64", 97n)]); + +// ./test/core/address64.wast:349 +assert_return(() => invoke($1, `8u_good2`, [0n]), [value("i64", 97n)]); + +// ./test/core/address64.wast:350 +assert_return(() => invoke($1, `8u_good3`, [0n]), [value("i64", 98n)]); + +// ./test/core/address64.wast:351 +assert_return(() => invoke($1, `8u_good4`, [0n]), [value("i64", 99n)]); + +// ./test/core/address64.wast:352 +assert_return(() => invoke($1, `8u_good5`, [0n]), [value("i64", 122n)]); + +// ./test/core/address64.wast:354 +assert_return(() => invoke($1, `8s_good1`, [0n]), [value("i64", 97n)]); + +// ./test/core/address64.wast:355 +assert_return(() => invoke($1, `8s_good2`, [0n]), [value("i64", 97n)]); + +// ./test/core/address64.wast:356 +assert_return(() => invoke($1, `8s_good3`, [0n]), [value("i64", 98n)]); + +// ./test/core/address64.wast:357 +assert_return(() => invoke($1, `8s_good4`, [0n]), [value("i64", 99n)]); + +// ./test/core/address64.wast:358 +assert_return(() => invoke($1, `8s_good5`, [0n]), [value("i64", 122n)]); + +// ./test/core/address64.wast:360 +assert_return(() => invoke($1, `16u_good1`, [0n]), [value("i64", 25185n)]); + +// ./test/core/address64.wast:361 +assert_return(() => invoke($1, `16u_good2`, [0n]), [value("i64", 25185n)]); + +// ./test/core/address64.wast:362 +assert_return(() => invoke($1, `16u_good3`, [0n]), [value("i64", 25442n)]); + +// ./test/core/address64.wast:363 +assert_return(() => invoke($1, `16u_good4`, [0n]), [value("i64", 25699n)]); + +// ./test/core/address64.wast:364 +assert_return(() => invoke($1, `16u_good5`, [0n]), [value("i64", 122n)]); + +// ./test/core/address64.wast:366 +assert_return(() => invoke($1, `16s_good1`, [0n]), [value("i64", 25185n)]); + +// ./test/core/address64.wast:367 +assert_return(() => invoke($1, `16s_good2`, [0n]), [value("i64", 25185n)]); + +// ./test/core/address64.wast:368 +assert_return(() => invoke($1, `16s_good3`, [0n]), [value("i64", 25442n)]); + +// ./test/core/address64.wast:369 +assert_return(() => invoke($1, `16s_good4`, [0n]), [value("i64", 25699n)]); + +// ./test/core/address64.wast:370 +assert_return(() => invoke($1, `16s_good5`, [0n]), [value("i64", 122n)]); + +// ./test/core/address64.wast:372 +assert_return(() => invoke($1, `32u_good1`, [0n]), [value("i64", 1684234849n)]); + +// ./test/core/address64.wast:373 +assert_return(() => invoke($1, `32u_good2`, [0n]), [value("i64", 1684234849n)]); + +// ./test/core/address64.wast:374 +assert_return(() => invoke($1, `32u_good3`, [0n]), [value("i64", 1701077858n)]); + +// ./test/core/address64.wast:375 +assert_return(() => invoke($1, `32u_good4`, [0n]), [value("i64", 1717920867n)]); + +// ./test/core/address64.wast:376 +assert_return(() => invoke($1, `32u_good5`, [0n]), [value("i64", 122n)]); + +// ./test/core/address64.wast:378 +assert_return(() => invoke($1, `32s_good1`, [0n]), [value("i64", 1684234849n)]); + +// ./test/core/address64.wast:379 +assert_return(() => invoke($1, `32s_good2`, [0n]), [value("i64", 1684234849n)]); + +// ./test/core/address64.wast:380 +assert_return(() => invoke($1, `32s_good3`, [0n]), [value("i64", 1701077858n)]); + +// ./test/core/address64.wast:381 +assert_return(() => invoke($1, `32s_good4`, [0n]), [value("i64", 1717920867n)]); + +// ./test/core/address64.wast:382 +assert_return(() => invoke($1, `32s_good5`, [0n]), [value("i64", 122n)]); + +// ./test/core/address64.wast:384 +assert_return(() => invoke($1, `64_good1`, [0n]), [value("i64", 7523094288207667809n)]); + +// ./test/core/address64.wast:385 +assert_return(() => invoke($1, `64_good2`, [0n]), [value("i64", 7523094288207667809n)]); + +// ./test/core/address64.wast:386 +assert_return(() => invoke($1, `64_good3`, [0n]), [value("i64", 7595434461045744482n)]); + +// ./test/core/address64.wast:387 +assert_return(() => invoke($1, `64_good4`, [0n]), [value("i64", 7667774633883821155n)]); + +// ./test/core/address64.wast:388 +assert_return(() => invoke($1, `64_good5`, [0n]), [value("i64", 122n)]); + +// ./test/core/address64.wast:390 +assert_return(() => invoke($1, `8u_good1`, [65503n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:391 +assert_return(() => invoke($1, `8u_good2`, [65503n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:392 +assert_return(() => invoke($1, `8u_good3`, [65503n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:393 +assert_return(() => invoke($1, `8u_good4`, [65503n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:394 +assert_return(() => invoke($1, `8u_good5`, [65503n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:396 +assert_return(() => invoke($1, `8s_good1`, [65503n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:397 +assert_return(() => invoke($1, `8s_good2`, [65503n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:398 +assert_return(() => invoke($1, `8s_good3`, [65503n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:399 +assert_return(() => invoke($1, `8s_good4`, [65503n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:400 +assert_return(() => invoke($1, `8s_good5`, [65503n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:402 +assert_return(() => invoke($1, `16u_good1`, [65503n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:403 +assert_return(() => invoke($1, `16u_good2`, [65503n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:404 +assert_return(() => invoke($1, `16u_good3`, [65503n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:405 +assert_return(() => invoke($1, `16u_good4`, [65503n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:406 +assert_return(() => invoke($1, `16u_good5`, [65503n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:408 +assert_return(() => invoke($1, `16s_good1`, [65503n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:409 +assert_return(() => invoke($1, `16s_good2`, [65503n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:410 +assert_return(() => invoke($1, `16s_good3`, [65503n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:411 +assert_return(() => invoke($1, `16s_good4`, [65503n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:412 +assert_return(() => invoke($1, `16s_good5`, [65503n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:414 +assert_return(() => invoke($1, `32u_good1`, [65503n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:415 +assert_return(() => invoke($1, `32u_good2`, [65503n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:416 +assert_return(() => invoke($1, `32u_good3`, [65503n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:417 +assert_return(() => invoke($1, `32u_good4`, [65503n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:418 +assert_return(() => invoke($1, `32u_good5`, [65503n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:420 +assert_return(() => invoke($1, `32s_good1`, [65503n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:421 +assert_return(() => invoke($1, `32s_good2`, [65503n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:422 +assert_return(() => invoke($1, `32s_good3`, [65503n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:423 +assert_return(() => invoke($1, `32s_good4`, [65503n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:424 +assert_return(() => invoke($1, `32s_good5`, [65503n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:426 +assert_return(() => invoke($1, `64_good1`, [65503n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:427 +assert_return(() => invoke($1, `64_good2`, [65503n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:428 +assert_return(() => invoke($1, `64_good3`, [65503n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:429 +assert_return(() => invoke($1, `64_good4`, [65503n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:430 +assert_return(() => invoke($1, `64_good5`, [65503n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:432 +assert_return(() => invoke($1, `8u_good1`, [65504n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:433 +assert_return(() => invoke($1, `8u_good2`, [65504n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:434 +assert_return(() => invoke($1, `8u_good3`, [65504n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:435 +assert_return(() => invoke($1, `8u_good4`, [65504n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:436 +assert_return(() => invoke($1, `8u_good5`, [65504n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:438 +assert_return(() => invoke($1, `8s_good1`, [65504n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:439 +assert_return(() => invoke($1, `8s_good2`, [65504n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:440 +assert_return(() => invoke($1, `8s_good3`, [65504n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:441 +assert_return(() => invoke($1, `8s_good4`, [65504n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:442 +assert_return(() => invoke($1, `8s_good5`, [65504n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:444 +assert_return(() => invoke($1, `16u_good1`, [65504n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:445 +assert_return(() => invoke($1, `16u_good2`, [65504n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:446 +assert_return(() => invoke($1, `16u_good3`, [65504n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:447 +assert_return(() => invoke($1, `16u_good4`, [65504n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:448 +assert_return(() => invoke($1, `16u_good5`, [65504n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:450 +assert_return(() => invoke($1, `16s_good1`, [65504n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:451 +assert_return(() => invoke($1, `16s_good2`, [65504n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:452 +assert_return(() => invoke($1, `16s_good3`, [65504n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:453 +assert_return(() => invoke($1, `16s_good4`, [65504n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:454 +assert_return(() => invoke($1, `16s_good5`, [65504n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:456 +assert_return(() => invoke($1, `32u_good1`, [65504n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:457 +assert_return(() => invoke($1, `32u_good2`, [65504n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:458 +assert_return(() => invoke($1, `32u_good3`, [65504n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:459 +assert_return(() => invoke($1, `32u_good4`, [65504n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:460 +assert_return(() => invoke($1, `32u_good5`, [65504n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:462 +assert_return(() => invoke($1, `32s_good1`, [65504n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:463 +assert_return(() => invoke($1, `32s_good2`, [65504n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:464 +assert_return(() => invoke($1, `32s_good3`, [65504n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:465 +assert_return(() => invoke($1, `32s_good4`, [65504n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:466 +assert_return(() => invoke($1, `32s_good5`, [65504n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:468 +assert_return(() => invoke($1, `64_good1`, [65504n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:469 +assert_return(() => invoke($1, `64_good2`, [65504n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:470 +assert_return(() => invoke($1, `64_good3`, [65504n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:471 +assert_return(() => invoke($1, `64_good4`, [65504n]), [value("i64", 0n)]); + +// ./test/core/address64.wast:472 +assert_trap(() => invoke($1, `64_good5`, [65504n]), `out of bounds memory access`); + +// ./test/core/address64.wast:474 +assert_trap(() => invoke($1, `8u_bad`, [0n]), `out of bounds memory access`); + +// ./test/core/address64.wast:475 +assert_trap(() => invoke($1, `8s_bad`, [0n]), `out of bounds memory access`); + +// ./test/core/address64.wast:476 +assert_trap(() => invoke($1, `16u_bad`, [0n]), `out of bounds memory access`); + +// ./test/core/address64.wast:477 +assert_trap(() => invoke($1, `16s_bad`, [0n]), `out of bounds memory access`); + +// ./test/core/address64.wast:478 +assert_trap(() => invoke($1, `32u_bad`, [0n]), `out of bounds memory access`); + +// ./test/core/address64.wast:479 +assert_trap(() => invoke($1, `32s_bad`, [0n]), `out of bounds memory access`); + +// ./test/core/address64.wast:480 +assert_trap(() => invoke($1, `64_bad`, [0n]), `out of bounds memory access`); + +// ./test/core/address64.wast:482 +assert_trap(() => invoke($1, `8u_bad`, [1n]), `out of bounds memory access`); + +// ./test/core/address64.wast:483 +assert_trap(() => invoke($1, `8s_bad`, [1n]), `out of bounds memory access`); + +// ./test/core/address64.wast:484 +assert_trap(() => invoke($1, `16u_bad`, [1n]), `out of bounds memory access`); + +// ./test/core/address64.wast:485 +assert_trap(() => invoke($1, `16s_bad`, [1n]), `out of bounds memory access`); + +// ./test/core/address64.wast:486 +assert_trap(() => invoke($1, `32u_bad`, [0n]), `out of bounds memory access`); + +// ./test/core/address64.wast:487 +assert_trap(() => invoke($1, `32s_bad`, [0n]), `out of bounds memory access`); + +// ./test/core/address64.wast:488 +assert_trap(() => invoke($1, `64_bad`, [1n]), `out of bounds memory access`); + +// ./test/core/address64.wast:492 +let $2 = instantiate(`(module + (memory i64 1) + (data (i64.const 0) "\\00\\00\\00\\00\\00\\00\\a0\\7f\\01\\00\\d0\\7f") + + (func (export "32_good1") (param $$i i64) (result f32) + (f32.load offset=0 (local.get $$i)) ;; 0.0 '\\00\\00\\00\\00' + ) + (func (export "32_good2") (param $$i i64) (result f32) + (f32.load align=1 (local.get $$i)) ;; 0.0 '\\00\\00\\00\\00' + ) + (func (export "32_good3") (param $$i i64) (result f32) + (f32.load offset=1 align=1 (local.get $$i)) ;; 0.0 '\\00\\00\\00\\00' + ) + (func (export "32_good4") (param $$i i64) (result f32) + (f32.load offset=2 align=2 (local.get $$i)) ;; 0.0 '\\00\\00\\00\\00' + ) + (func (export "32_good5") (param $$i i64) (result f32) + (f32.load offset=8 align=4 (local.get $$i)) ;; nan:0x500001 '\\01\\00\\d0\\7f' + ) + (func (export "32_bad") (param $$i i64) + (drop (f32.load offset=4294967295 (local.get $$i))) + ) +)`); + +// ./test/core/address64.wast:516 +assert_return(() => invoke($2, `32_good1`, [0n]), [value("f32", 0)]); + +// ./test/core/address64.wast:517 +assert_return(() => invoke($2, `32_good2`, [0n]), [value("f32", 0)]); + +// ./test/core/address64.wast:518 +assert_return(() => invoke($2, `32_good3`, [0n]), [value("f32", 0)]); + +// ./test/core/address64.wast:519 +assert_return(() => invoke($2, `32_good4`, [0n]), [value("f32", 0)]); + +// ./test/core/address64.wast:520 +assert_return(() => invoke($2, `32_good5`, [0n]), [bytes("f32", [0x1, 0x0, 0xd0, 0x7f])]); + +// ./test/core/address64.wast:522 +assert_return(() => invoke($2, `32_good1`, [65524n]), [value("f32", 0)]); + +// ./test/core/address64.wast:523 +assert_return(() => invoke($2, `32_good2`, [65524n]), [value("f32", 0)]); + +// ./test/core/address64.wast:524 +assert_return(() => invoke($2, `32_good3`, [65524n]), [value("f32", 0)]); + +// ./test/core/address64.wast:525 +assert_return(() => invoke($2, `32_good4`, [65524n]), [value("f32", 0)]); + +// ./test/core/address64.wast:526 +assert_return(() => invoke($2, `32_good5`, [65524n]), [value("f32", 0)]); + +// ./test/core/address64.wast:528 +assert_return(() => invoke($2, `32_good1`, [65525n]), [value("f32", 0)]); + +// ./test/core/address64.wast:529 +assert_return(() => invoke($2, `32_good2`, [65525n]), [value("f32", 0)]); + +// ./test/core/address64.wast:530 +assert_return(() => invoke($2, `32_good3`, [65525n]), [value("f32", 0)]); + +// ./test/core/address64.wast:531 +assert_return(() => invoke($2, `32_good4`, [65525n]), [value("f32", 0)]); + +// ./test/core/address64.wast:532 +assert_trap(() => invoke($2, `32_good5`, [65525n]), `out of bounds memory access`); + +// ./test/core/address64.wast:534 +assert_trap(() => invoke($2, `32_bad`, [0n]), `out of bounds memory access`); + +// ./test/core/address64.wast:535 +assert_trap(() => invoke($2, `32_bad`, [1n]), `out of bounds memory access`); + +// ./test/core/address64.wast:539 +let $3 = instantiate(`(module + (memory i64 1) + (data (i64.const 0) "\\00\\00\\00\\00\\00\\00\\00\\00\\00\\00\\00\\00\\00\\00\\00\\00\\f4\\7f\\01\\00\\00\\00\\00\\00\\fc\\7f") + + (func (export "64_good1") (param $$i i64) (result f64) + (f64.load offset=0 (local.get $$i)) ;; 0.0 '\\00\\00\\00\\00\\00\\00\\00\\00' + ) + (func (export "64_good2") (param $$i i64) (result f64) + (f64.load align=1 (local.get $$i)) ;; 0.0 '\\00\\00\\00\\00\\00\\00\\00\\00' + ) + (func (export "64_good3") (param $$i i64) (result f64) + (f64.load offset=1 align=1 (local.get $$i)) ;; 0.0 '\\00\\00\\00\\00\\00\\00\\00\\00' + ) + (func (export "64_good4") (param $$i i64) (result f64) + (f64.load offset=2 align=2 (local.get $$i)) ;; 0.0 '\\00\\00\\00\\00\\00\\00\\00\\00' + ) + (func (export "64_good5") (param $$i i64) (result f64) + (f64.load offset=18 align=8 (local.get $$i)) ;; nan:0xc000000000001 '\\01\\00\\00\\00\\00\\00\\fc\\7f' + ) + (func (export "64_bad") (param $$i i64) + (drop (f64.load offset=4294967295 (local.get $$i))) + ) +)`); + +// ./test/core/address64.wast:563 +assert_return(() => invoke($3, `64_good1`, [0n]), [value("f64", 0)]); + +// ./test/core/address64.wast:564 +assert_return(() => invoke($3, `64_good2`, [0n]), [value("f64", 0)]); + +// ./test/core/address64.wast:565 +assert_return(() => invoke($3, `64_good3`, [0n]), [value("f64", 0)]); + +// ./test/core/address64.wast:566 +assert_return(() => invoke($3, `64_good4`, [0n]), [value("f64", 0)]); + +// ./test/core/address64.wast:567 +assert_return( + () => invoke($3, `64_good5`, [0n]), + [bytes("f64", [0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfc, 0x7f])], +); + +// ./test/core/address64.wast:569 +assert_return(() => invoke($3, `64_good1`, [65510n]), [value("f64", 0)]); + +// ./test/core/address64.wast:570 +assert_return(() => invoke($3, `64_good2`, [65510n]), [value("f64", 0)]); + +// ./test/core/address64.wast:571 +assert_return(() => invoke($3, `64_good3`, [65510n]), [value("f64", 0)]); + +// ./test/core/address64.wast:572 +assert_return(() => invoke($3, `64_good4`, [65510n]), [value("f64", 0)]); + +// ./test/core/address64.wast:573 +assert_return(() => invoke($3, `64_good5`, [65510n]), [value("f64", 0)]); + +// ./test/core/address64.wast:575 +assert_return(() => invoke($3, `64_good1`, [65511n]), [value("f64", 0)]); + +// ./test/core/address64.wast:576 +assert_return(() => invoke($3, `64_good2`, [65511n]), [value("f64", 0)]); + +// ./test/core/address64.wast:577 +assert_return(() => invoke($3, `64_good3`, [65511n]), [value("f64", 0)]); + +// ./test/core/address64.wast:578 +assert_return(() => invoke($3, `64_good4`, [65511n]), [value("f64", 0)]); + +// ./test/core/address64.wast:579 +assert_trap(() => invoke($3, `64_good5`, [65511n]), `out of bounds memory access`); + +// ./test/core/address64.wast:581 +assert_trap(() => invoke($3, `64_bad`, [0n]), `out of bounds memory access`); + +// ./test/core/address64.wast:582 +assert_trap(() => invoke($3, `64_bad`, [1n]), `out of bounds memory access`); diff --git a/js/src/jit-test/tests/wasm/spec/memory64/align64.wast.js b/js/src/jit-test/tests/wasm/spec/memory64/align64.wast.js new file mode 100644 index 0000000000..34b4990f8f --- /dev/null +++ b/js/src/jit-test/tests/wasm/spec/memory64/align64.wast.js @@ -0,0 +1,1090 @@ +/* Copyright 2021 Mozilla Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ./test/core/align64.wast + +// ./test/core/align64.wast:3 +let $0 = instantiate(`(module (memory i64 0) (func (drop (i32.load8_s align=1 (i64.const 0)))))`); + +// ./test/core/align64.wast:4 +let $1 = instantiate(`(module (memory i64 0) (func (drop (i32.load8_u align=1 (i64.const 0)))))`); + +// ./test/core/align64.wast:5 +let $2 = instantiate(`(module (memory i64 0) (func (drop (i32.load16_s align=2 (i64.const 0)))))`); + +// ./test/core/align64.wast:6 +let $3 = instantiate(`(module (memory i64 0) (func (drop (i32.load16_u align=2 (i64.const 0)))))`); + +// ./test/core/align64.wast:7 +let $4 = instantiate(`(module (memory i64 0) (func (drop (i32.load align=4 (i64.const 0)))))`); + +// ./test/core/align64.wast:8 +let $5 = instantiate(`(module (memory i64 0) (func (drop (i64.load8_s align=1 (i64.const 0)))))`); + +// ./test/core/align64.wast:9 +let $6 = instantiate(`(module (memory i64 0) (func (drop (i64.load8_u align=1 (i64.const 0)))))`); + +// ./test/core/align64.wast:10 +let $7 = instantiate(`(module (memory i64 0) (func (drop (i64.load16_s align=2 (i64.const 0)))))`); + +// ./test/core/align64.wast:11 +let $8 = instantiate(`(module (memory i64 0) (func (drop (i64.load16_u align=2 (i64.const 0)))))`); + +// ./test/core/align64.wast:12 +let $9 = instantiate(`(module (memory i64 0) (func (drop (i64.load32_s align=4 (i64.const 0)))))`); + +// ./test/core/align64.wast:13 +let $10 = instantiate(`(module (memory i64 0) (func (drop (i64.load32_u align=4 (i64.const 0)))))`); + +// ./test/core/align64.wast:14 +let $11 = instantiate(`(module (memory i64 0) (func (drop (i64.load align=8 (i64.const 0)))))`); + +// ./test/core/align64.wast:15 +let $12 = instantiate(`(module (memory i64 0) (func (drop (f32.load align=4 (i64.const 0)))))`); + +// ./test/core/align64.wast:16 +let $13 = instantiate(`(module (memory i64 0) (func (drop (f64.load align=8 (i64.const 0)))))`); + +// ./test/core/align64.wast:17 +let $14 = instantiate(`(module (memory i64 0) (func (i32.store8 align=1 (i64.const 0) (i32.const 1))))`); + +// ./test/core/align64.wast:18 +let $15 = instantiate(`(module (memory i64 0) (func (i32.store16 align=2 (i64.const 0) (i32.const 1))))`); + +// ./test/core/align64.wast:19 +let $16 = instantiate(`(module (memory i64 0) (func (i32.store align=4 (i64.const 0) (i32.const 1))))`); + +// ./test/core/align64.wast:20 +let $17 = instantiate(`(module (memory i64 0) (func (i64.store8 align=1 (i64.const 0) (i64.const 1))))`); + +// ./test/core/align64.wast:21 +let $18 = instantiate(`(module (memory i64 0) (func (i64.store16 align=2 (i64.const 0) (i64.const 1))))`); + +// ./test/core/align64.wast:22 +let $19 = instantiate(`(module (memory i64 0) (func (i64.store32 align=4 (i64.const 0) (i64.const 1))))`); + +// ./test/core/align64.wast:23 +let $20 = instantiate(`(module (memory i64 0) (func (i64.store align=8 (i64.const 0) (i64.const 1))))`); + +// ./test/core/align64.wast:24 +let $21 = instantiate(`(module (memory i64 0) (func (f32.store align=4 (i64.const 0) (f32.const 1.0))))`); + +// ./test/core/align64.wast:25 +let $22 = instantiate(`(module (memory i64 0) (func (f64.store align=8 (i64.const 0) (f64.const 1.0))))`); + +// ./test/core/align64.wast:27 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (drop (i32.load8_s align=0 (i64.const 0))))) `), + `alignment`, +); + +// ./test/core/align64.wast:33 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (drop (i32.load8_s align=7 (i64.const 0))))) `), + `alignment`, +); + +// ./test/core/align64.wast:39 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (drop (i32.load8_u align=0 (i64.const 0))))) `), + `alignment`, +); + +// ./test/core/align64.wast:45 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (drop (i32.load8_u align=7 (i64.const 0))))) `), + `alignment`, +); + +// ./test/core/align64.wast:51 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (drop (i32.load16_s align=0 (i64.const 0))))) `), + `alignment`, +); + +// ./test/core/align64.wast:57 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (drop (i32.load16_s align=7 (i64.const 0))))) `), + `alignment`, +); + +// ./test/core/align64.wast:63 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (drop (i32.load16_u align=0 (i64.const 0))))) `), + `alignment`, +); + +// ./test/core/align64.wast:69 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (drop (i32.load16_u align=7 (i64.const 0))))) `), + `alignment`, +); + +// ./test/core/align64.wast:75 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (drop (i32.load align=0 (i64.const 0))))) `), + `alignment`, +); + +// ./test/core/align64.wast:81 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (drop (i32.load align=7 (i64.const 0))))) `), + `alignment`, +); + +// ./test/core/align64.wast:87 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (drop (i64.load8_s align=0 (i64.const 0))))) `), + `alignment`, +); + +// ./test/core/align64.wast:93 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (drop (i64.load8_s align=7 (i64.const 0))))) `), + `alignment`, +); + +// ./test/core/align64.wast:99 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (drop (i64.load8_u align=0 (i64.const 0))))) `), + `alignment`, +); + +// ./test/core/align64.wast:105 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (drop (i64.load8_u align=7 (i64.const 0))))) `), + `alignment`, +); + +// ./test/core/align64.wast:111 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (drop (i64.load16_s align=0 (i64.const 0))))) `), + `alignment`, +); + +// ./test/core/align64.wast:117 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (drop (i64.load16_s align=7 (i64.const 0))))) `), + `alignment`, +); + +// ./test/core/align64.wast:123 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (drop (i64.load16_u align=0 (i64.const 0))))) `), + `alignment`, +); + +// ./test/core/align64.wast:129 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (drop (i64.load16_u align=7 (i64.const 0))))) `), + `alignment`, +); + +// ./test/core/align64.wast:135 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (drop (i64.load32_s align=0 (i64.const 0))))) `), + `alignment`, +); + +// ./test/core/align64.wast:141 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (drop (i64.load32_s align=7 (i64.const 0))))) `), + `alignment`, +); + +// ./test/core/align64.wast:147 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (drop (i64.load32_u align=0 (i64.const 0))))) `), + `alignment`, +); + +// ./test/core/align64.wast:153 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (drop (i64.load32_u align=7 (i64.const 0))))) `), + `alignment`, +); + +// ./test/core/align64.wast:159 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (drop (i64.load align=0 (i64.const 0))))) `), + `alignment`, +); + +// ./test/core/align64.wast:165 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (drop (i64.load align=7 (i64.const 0))))) `), + `alignment`, +); + +// ./test/core/align64.wast:171 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (drop (f32.load align=0 (i64.const 0))))) `), + `alignment`, +); + +// ./test/core/align64.wast:177 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (drop (f32.load align=7 (i64.const 0))))) `), + `alignment`, +); + +// ./test/core/align64.wast:183 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (drop (f64.load align=0 (i64.const 0))))) `), + `alignment`, +); + +// ./test/core/align64.wast:189 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (drop (f64.load align=7 (i64.const 0))))) `), + `alignment`, +); + +// ./test/core/align64.wast:196 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (i32.store8 align=0 (i64.const 0) (i32.const 0)))) `), + `alignment`, +); + +// ./test/core/align64.wast:202 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (i32.store8 align=7 (i64.const 0) (i32.const 0)))) `), + `alignment`, +); + +// ./test/core/align64.wast:208 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (i32.store16 align=0 (i64.const 0) (i32.const 0)))) `), + `alignment`, +); + +// ./test/core/align64.wast:214 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (i32.store16 align=7 (i64.const 0) (i32.const 0)))) `), + `alignment`, +); + +// ./test/core/align64.wast:220 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (i32.store align=0 (i64.const 0) (i32.const 0)))) `), + `alignment`, +); + +// ./test/core/align64.wast:226 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (i32.store align=7 (i64.const 0) (i32.const 0)))) `), + `alignment`, +); + +// ./test/core/align64.wast:232 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (i64.store8 align=0 (i64.const 0) (i64.const 0)))) `), + `alignment`, +); + +// ./test/core/align64.wast:238 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (i64.store8 align=7 (i64.const 0) (i64.const 0)))) `), + `alignment`, +); + +// ./test/core/align64.wast:244 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (i64.store16 align=0 (i64.const 0) (i64.const 0)))) `), + `alignment`, +); + +// ./test/core/align64.wast:250 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (i64.store16 align=7 (i64.const 0) (i64.const 0)))) `), + `alignment`, +); + +// ./test/core/align64.wast:256 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (i64.store32 align=0 (i64.const 0) (i64.const 0)))) `), + `alignment`, +); + +// ./test/core/align64.wast:262 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (i64.store32 align=7 (i64.const 0) (i64.const 0)))) `), + `alignment`, +); + +// ./test/core/align64.wast:268 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (i64.store align=0 (i64.const 0) (i64.const 0)))) `), + `alignment`, +); + +// ./test/core/align64.wast:274 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (i64.store align=7 (i64.const 0) (i64.const 0)))) `), + `alignment`, +); + +// ./test/core/align64.wast:280 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (f32.store align=0 (i64.const 0) (f32.const 0)))) `), + `alignment`, +); + +// ./test/core/align64.wast:286 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (f32.store align=7 (i64.const 0) (f32.const 0)))) `), + `alignment`, +); + +// ./test/core/align64.wast:292 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (f64.store align=0 (i64.const 0) (f32.const 0)))) `), + `alignment`, +); + +// ./test/core/align64.wast:298 +assert_malformed( + () => instantiate(`(module (memory i64 0) (func (f64.store align=7 (i64.const 0) (f32.const 0)))) `), + `alignment`, +); + +// ./test/core/align64.wast:305 +assert_invalid( + () => instantiate(`(module (memory i64 0) (func (drop (i32.load8_s align=2 (i64.const 0)))))`), + `alignment must not be larger than natural`, +); + +// ./test/core/align64.wast:309 +assert_invalid( + () => instantiate(`(module (memory i64 0) (func (drop (i32.load8_u align=2 (i64.const 0)))))`), + `alignment must not be larger than natural`, +); + +// ./test/core/align64.wast:313 +assert_invalid( + () => instantiate(`(module (memory i64 0) (func (drop (i32.load16_s align=4 (i64.const 0)))))`), + `alignment must not be larger than natural`, +); + +// ./test/core/align64.wast:317 +assert_invalid( + () => instantiate(`(module (memory i64 0) (func (drop (i32.load16_u align=4 (i64.const 0)))))`), + `alignment must not be larger than natural`, +); + +// ./test/core/align64.wast:321 +assert_invalid( + () => instantiate(`(module (memory i64 0) (func (drop (i32.load align=8 (i64.const 0)))))`), + `alignment must not be larger than natural`, +); + +// ./test/core/align64.wast:325 +assert_invalid( + () => instantiate(`(module (memory i64 0) (func (drop (i64.load8_s align=2 (i64.const 0)))))`), + `alignment must not be larger than natural`, +); + +// ./test/core/align64.wast:329 +assert_invalid( + () => instantiate(`(module (memory i64 0) (func (drop (i64.load8_u align=2 (i64.const 0)))))`), + `alignment must not be larger than natural`, +); + +// ./test/core/align64.wast:333 +assert_invalid( + () => instantiate(`(module (memory i64 0) (func (drop (i64.load16_s align=4 (i64.const 0)))))`), + `alignment must not be larger than natural`, +); + +// ./test/core/align64.wast:337 +assert_invalid( + () => instantiate(`(module (memory i64 0) (func (drop (i64.load16_u align=4 (i64.const 0)))))`), + `alignment must not be larger than natural`, +); + +// ./test/core/align64.wast:341 +assert_invalid( + () => instantiate(`(module (memory i64 0) (func (drop (i64.load32_s align=8 (i64.const 0)))))`), + `alignment must not be larger than natural`, +); + +// ./test/core/align64.wast:345 +assert_invalid( + () => instantiate(`(module (memory i64 0) (func (drop (i64.load32_u align=8 (i64.const 0)))))`), + `alignment must not be larger than natural`, +); + +// ./test/core/align64.wast:349 +assert_invalid( + () => instantiate(`(module (memory i64 0) (func (drop (i64.load align=16 (i64.const 0)))))`), + `alignment must not be larger than natural`, +); + +// ./test/core/align64.wast:353 +assert_invalid( + () => instantiate(`(module (memory i64 0) (func (drop (f32.load align=8 (i64.const 0)))))`), + `alignment must not be larger than natural`, +); + +// ./test/core/align64.wast:357 +assert_invalid( + () => instantiate(`(module (memory i64 0) (func (drop (f64.load align=16 (i64.const 0)))))`), + `alignment must not be larger than natural`, +); + +// ./test/core/align64.wast:362 +assert_invalid( + () => instantiate(`(module (memory i64 0) (func (drop (i32.load8_s align=2 (i64.const 0)))))`), + `alignment must not be larger than natural`, +); + +// ./test/core/align64.wast:366 +assert_invalid( + () => instantiate(`(module (memory i64 0) (func (drop (i32.load8_u align=2 (i64.const 0)))))`), + `alignment must not be larger than natural`, +); + +// ./test/core/align64.wast:370 +assert_invalid( + () => instantiate(`(module (memory i64 0) (func (drop (i32.load16_s align=4 (i64.const 0)))))`), + `alignment must not be larger than natural`, +); + +// ./test/core/align64.wast:374 +assert_invalid( + () => instantiate(`(module (memory i64 0) (func (drop (i32.load16_u align=4 (i64.const 0)))))`), + `alignment must not be larger than natural`, +); + +// ./test/core/align64.wast:378 +assert_invalid( + () => instantiate(`(module (memory i64 0) (func (drop (i32.load align=8 (i64.const 0)))))`), + `alignment must not be larger than natural`, +); + +// ./test/core/align64.wast:382 +assert_invalid( + () => instantiate(`(module (memory i64 0) (func (drop (i64.load8_s align=2 (i64.const 0)))))`), + `alignment must not be larger than natural`, +); + +// ./test/core/align64.wast:386 +assert_invalid( + () => instantiate(`(module (memory i64 0) (func (drop (i64.load8_u align=2 (i64.const 0)))))`), + `alignment must not be larger than natural`, +); + +// ./test/core/align64.wast:390 +assert_invalid( + () => instantiate(`(module (memory i64 0) (func (drop (i64.load16_s align=4 (i64.const 0)))))`), + `alignment must not be larger than natural`, +); + +// ./test/core/align64.wast:394 +assert_invalid( + () => instantiate(`(module (memory i64 0) (func (drop (i64.load16_u align=4 (i64.const 0)))))`), + `alignment must not be larger than natural`, +); + +// ./test/core/align64.wast:398 +assert_invalid( + () => instantiate(`(module (memory i64 0) (func (drop (i64.load32_s align=8 (i64.const 0)))))`), + `alignment must not be larger than natural`, +); + +// ./test/core/align64.wast:402 +assert_invalid( + () => instantiate(`(module (memory i64 0) (func (drop (i64.load32_u align=8 (i64.const 0)))))`), + `alignment must not be larger than natural`, +); + +// ./test/core/align64.wast:406 +assert_invalid( + () => instantiate(`(module (memory i64 0) (func (drop (i64.load align=16 (i64.const 0)))))`), + `alignment must not be larger than natural`, +); + +// ./test/core/align64.wast:410 +assert_invalid( + () => instantiate(`(module (memory i64 0) (func (drop (f32.load align=8 (i64.const 0)))))`), + `alignment must not be larger than natural`, +); + +// ./test/core/align64.wast:414 +assert_invalid( + () => instantiate(`(module (memory i64 0) (func (drop (f64.load align=16 (i64.const 0)))))`), + `alignment must not be larger than natural`, +); + +// ./test/core/align64.wast:419 +assert_invalid( + () => instantiate(`(module (memory i64 0) (func (i32.store8 align=2 (i64.const 0) (i32.const 0))))`), + `alignment must not be larger than natural`, +); + +// ./test/core/align64.wast:423 +assert_invalid( + () => instantiate(`(module (memory i64 0) (func (i32.store16 align=4 (i64.const 0) (i32.const 0))))`), + `alignment must not be larger than natural`, +); + +// ./test/core/align64.wast:427 +assert_invalid( + () => instantiate(`(module (memory i64 0) (func (i32.store align=8 (i64.const 0) (i32.const 0))))`), + `alignment must not be larger than natural`, +); + +// ./test/core/align64.wast:431 +assert_invalid( + () => instantiate(`(module (memory i64 0) (func (i64.store8 align=2 (i64.const 0) (i64.const 0))))`), + `alignment must not be larger than natural`, +); + +// ./test/core/align64.wast:435 +assert_invalid( + () => instantiate(`(module (memory i64 0) (func (i64.store16 align=4 (i64.const 0) (i64.const 0))))`), + `alignment must not be larger than natural`, +); + +// ./test/core/align64.wast:439 +assert_invalid( + () => instantiate(`(module (memory i64 0) (func (i64.store32 align=8 (i64.const 0) (i64.const 0))))`), + `alignment must not be larger than natural`, +); + +// ./test/core/align64.wast:443 +assert_invalid( + () => instantiate(`(module (memory i64 0) (func (i64.store align=16 (i64.const 0) (i64.const 0))))`), + `alignment must not be larger than natural`, +); + +// ./test/core/align64.wast:447 +assert_invalid( + () => instantiate(`(module (memory i64 0) (func (f32.store align=8 (i64.const 0) (f32.const 0))))`), + `alignment must not be larger than natural`, +); + +// ./test/core/align64.wast:451 +assert_invalid( + () => instantiate(`(module (memory i64 0) (func (f64.store align=16 (i64.const 0) (f64.const 0))))`), + `alignment must not be larger than natural`, +); + +// ./test/core/align64.wast:458 +let $23 = instantiate(`(module + (memory i64 1) + + ;; $$default: natural alignment, $$1: align=1, $$2: align=2, $$4: align=4, $$8: align=8 + + (func (export "f32_align_switch") (param i32) (result f32) + (local f32 f32) + (local.set 1 (f32.const 10.0)) + (block $$4 + (block $$2 + (block $$1 + (block $$default + (block $$0 + (br_table $$0 $$default $$1 $$2 $$4 (local.get 0)) + ) ;; 0 + (f32.store (i64.const 0) (local.get 1)) + (local.set 2 (f32.load (i64.const 0))) + (br $$4) + ) ;; default + (f32.store align=1 (i64.const 0) (local.get 1)) + (local.set 2 (f32.load align=1 (i64.const 0))) + (br $$4) + ) ;; 1 + (f32.store align=2 (i64.const 0) (local.get 1)) + (local.set 2 (f32.load align=2 (i64.const 0))) + (br $$4) + ) ;; 2 + (f32.store align=4 (i64.const 0) (local.get 1)) + (local.set 2 (f32.load align=4 (i64.const 0))) + ) ;; 4 + (local.get 2) + ) + + (func (export "f64_align_switch") (param i32) (result f64) + (local f64 f64) + (local.set 1 (f64.const 10.0)) + (block $$8 + (block $$4 + (block $$2 + (block $$1 + (block $$default + (block $$0 + (br_table $$0 $$default $$1 $$2 $$4 $$8 (local.get 0)) + ) ;; 0 + (f64.store (i64.const 0) (local.get 1)) + (local.set 2 (f64.load (i64.const 0))) + (br $$8) + ) ;; default + (f64.store align=1 (i64.const 0) (local.get 1)) + (local.set 2 (f64.load align=1 (i64.const 0))) + (br $$8) + ) ;; 1 + (f64.store align=2 (i64.const 0) (local.get 1)) + (local.set 2 (f64.load align=2 (i64.const 0))) + (br $$8) + ) ;; 2 + (f64.store align=4 (i64.const 0) (local.get 1)) + (local.set 2 (f64.load align=4 (i64.const 0))) + (br $$8) + ) ;; 4 + (f64.store align=8 (i64.const 0) (local.get 1)) + (local.set 2 (f64.load align=8 (i64.const 0))) + ) ;; 8 + (local.get 2) + ) + + ;; $$8s: i32/i64.load8_s, $$8u: i32/i64.load8_u, $$16s: i32/i64.load16_s, $$16u: i32/i64.load16_u, $$32: i32.load + ;; $$32s: i64.load32_s, $$32u: i64.load32_u, $$64: i64.load + + (func (export "i32_align_switch") (param i32 i32) (result i32) + (local i32 i32) + (local.set 2 (i32.const 10)) + (block $$32 + (block $$16u + (block $$16s + (block $$8u + (block $$8s + (block $$0 + (br_table $$0 $$8s $$8u $$16s $$16u $$32 (local.get 0)) + ) ;; 0 + (if (i32.eq (local.get 1) (i32.const 0)) + (then + (i32.store8 (i64.const 0) (local.get 2)) + (local.set 3 (i32.load8_s (i64.const 0))) + ) + ) + (if (i32.eq (local.get 1) (i32.const 1)) + (then + (i32.store8 align=1 (i64.const 0) (local.get 2)) + (local.set 3 (i32.load8_s align=1 (i64.const 0))) + ) + ) + (br $$32) + ) ;; 8s + (if (i32.eq (local.get 1) (i32.const 0)) + (then + (i32.store8 (i64.const 0) (local.get 2)) + (local.set 3 (i32.load8_u (i64.const 0))) + ) + ) + (if (i32.eq (local.get 1) (i32.const 1)) + (then + (i32.store8 align=1 (i64.const 0) (local.get 2)) + (local.set 3 (i32.load8_u align=1 (i64.const 0))) + ) + ) + (br $$32) + ) ;; 8u + (if (i32.eq (local.get 1) (i32.const 0)) + (then + (i32.store16 (i64.const 0) (local.get 2)) + (local.set 3 (i32.load16_s (i64.const 0))) + ) + ) + (if (i32.eq (local.get 1) (i32.const 1)) + (then + (i32.store16 align=1 (i64.const 0) (local.get 2)) + (local.set 3 (i32.load16_s align=1 (i64.const 0))) + ) + ) + (if (i32.eq (local.get 1) (i32.const 2)) + (then + (i32.store16 align=2 (i64.const 0) (local.get 2)) + (local.set 3 (i32.load16_s align=2 (i64.const 0))) + ) + ) + (br $$32) + ) ;; 16s + (if (i32.eq (local.get 1) (i32.const 0)) + (then + (i32.store16 (i64.const 0) (local.get 2)) + (local.set 3 (i32.load16_u (i64.const 0))) + ) + ) + (if (i32.eq (local.get 1) (i32.const 1)) + (then + (i32.store16 align=1 (i64.const 0) (local.get 2)) + (local.set 3 (i32.load16_u align=1 (i64.const 0))) + ) + ) + (if (i32.eq (local.get 1) (i32.const 2)) + (then + (i32.store16 align=2 (i64.const 0) (local.get 2)) + (local.set 3 (i32.load16_u align=2 (i64.const 0))) + ) + ) + (br $$32) + ) ;; 16u + (if (i32.eq (local.get 1) (i32.const 0)) + (then + (i32.store (i64.const 0) (local.get 2)) + (local.set 3 (i32.load (i64.const 0))) + ) + ) + (if (i32.eq (local.get 1) (i32.const 1)) + (then + (i32.store align=1 (i64.const 0) (local.get 2)) + (local.set 3 (i32.load align=1 (i64.const 0))) + ) + ) + (if (i32.eq (local.get 1) (i32.const 2)) + (then + (i32.store align=2 (i64.const 0) (local.get 2)) + (local.set 3 (i32.load align=2 (i64.const 0))) + ) + ) + (if (i32.eq (local.get 1) (i32.const 4)) + (then + (i32.store align=4 (i64.const 0) (local.get 2)) + (local.set 3 (i32.load align=4 (i64.const 0))) + ) + ) + ) ;; 32 + (local.get 3) + ) + + (func (export "i64_align_switch") (param i32 i32) (result i64) + (local i64 i64) + (local.set 2 (i64.const 10)) + (block $$64 + (block $$32u + (block $$32s + (block $$16u + (block $$16s + (block $$8u + (block $$8s + (block $$0 + (br_table $$0 $$8s $$8u $$16s $$16u $$32s $$32u $$64 (local.get 0)) + ) ;; 0 + (if (i32.eq (local.get 1) (i32.const 0)) + (then + (i64.store8 (i64.const 0) (local.get 2)) + (local.set 3 (i64.load8_s (i64.const 0))) + ) + ) + (if (i32.eq (local.get 1) (i32.const 1)) + (then + (i64.store8 align=1 (i64.const 0) (local.get 2)) + (local.set 3 (i64.load8_s align=1 (i64.const 0))) + ) + ) + (br $$64) + ) ;; 8s + (if (i32.eq (local.get 1) (i32.const 0)) + (then + (i64.store8 (i64.const 0) (local.get 2)) + (local.set 3 (i64.load8_u (i64.const 0))) + ) + ) + (if (i32.eq (local.get 1) (i32.const 1)) + (then + (i64.store8 align=1 (i64.const 0) (local.get 2)) + (local.set 3 (i64.load8_u align=1 (i64.const 0))) + ) + ) + (br $$64) + ) ;; 8u + (if (i32.eq (local.get 1) (i32.const 0)) + (then + (i64.store16 (i64.const 0) (local.get 2)) + (local.set 3 (i64.load16_s (i64.const 0))) + ) + ) + (if (i32.eq (local.get 1) (i32.const 1)) + (then + (i64.store16 align=1 (i64.const 0) (local.get 2)) + (local.set 3 (i64.load16_s align=1 (i64.const 0))) + ) + ) + (if (i32.eq (local.get 1) (i32.const 2)) + (then + (i64.store16 align=2 (i64.const 0) (local.get 2)) + (local.set 3 (i64.load16_s align=2 (i64.const 0))) + ) + ) + (br $$64) + ) ;; 16s + (if (i32.eq (local.get 1) (i32.const 0)) + (then + (i64.store16 (i64.const 0) (local.get 2)) + (local.set 3 (i64.load16_u (i64.const 0))) + ) + ) + (if (i32.eq (local.get 1) (i32.const 1)) + (then + (i64.store16 align=1 (i64.const 0) (local.get 2)) + (local.set 3 (i64.load16_u align=1 (i64.const 0))) + ) + ) + (if (i32.eq (local.get 1) (i32.const 2)) + (then + (i64.store16 align=2 (i64.const 0) (local.get 2)) + (local.set 3 (i64.load16_u align=2 (i64.const 0))) + ) + ) + (br $$64) + ) ;; 16u + (if (i32.eq (local.get 1) (i32.const 0)) + (then + (i64.store32 (i64.const 0) (local.get 2)) + (local.set 3 (i64.load32_s (i64.const 0))) + ) + ) + (if (i32.eq (local.get 1) (i32.const 1)) + (then + (i64.store32 align=1 (i64.const 0) (local.get 2)) + (local.set 3 (i64.load32_s align=1 (i64.const 0))) + ) + ) + (if (i32.eq (local.get 1) (i32.const 2)) + (then + (i64.store32 align=2 (i64.const 0) (local.get 2)) + (local.set 3 (i64.load32_s align=2 (i64.const 0))) + ) + ) + (if (i32.eq (local.get 1) (i32.const 4)) + (then + (i64.store32 align=4 (i64.const 0) (local.get 2)) + (local.set 3 (i64.load32_s align=4 (i64.const 0))) + ) + ) + (br $$64) + ) ;; 32s + (if (i32.eq (local.get 1) (i32.const 0)) + (then + (i64.store32 (i64.const 0) (local.get 2)) + (local.set 3 (i64.load32_u (i64.const 0))) + ) + ) + (if (i32.eq (local.get 1) (i32.const 1)) + (then + (i64.store32 align=1 (i64.const 0) (local.get 2)) + (local.set 3 (i64.load32_u align=1 (i64.const 0))) + ) + ) + (if (i32.eq (local.get 1) (i32.const 2)) + (then + (i64.store32 align=2 (i64.const 0) (local.get 2)) + (local.set 3 (i64.load32_u align=2 (i64.const 0))) + ) + ) + (if (i32.eq (local.get 1) (i32.const 4)) + (then + (i64.store32 align=4 (i64.const 0) (local.get 2)) + (local.set 3 (i64.load32_u align=4 (i64.const 0))) + ) + ) + (br $$64) + ) ;; 32u + (if (i32.eq (local.get 1) (i32.const 0)) + (then + (i64.store (i64.const 0) (local.get 2)) + (local.set 3 (i64.load (i64.const 0))) + ) + ) + (if (i32.eq (local.get 1) (i32.const 1)) + (then + (i64.store align=1 (i64.const 0) (local.get 2)) + (local.set 3 (i64.load align=1 (i64.const 0))) + ) + ) + (if (i32.eq (local.get 1) (i32.const 2)) + (then + (i64.store align=2 (i64.const 0) (local.get 2)) + (local.set 3 (i64.load align=2 (i64.const 0))) + ) + ) + (if (i32.eq (local.get 1) (i32.const 4)) + (then + (i64.store align=4 (i64.const 0) (local.get 2)) + (local.set 3 (i64.load align=4 (i64.const 0))) + ) + ) + (if (i32.eq (local.get 1) (i32.const 8)) + (then + (i64.store align=8 (i64.const 0) (local.get 2)) + (local.set 3 (i64.load align=8 (i64.const 0))) + ) + ) + ) ;; 64 + (local.get 3) + ) +)`); + +// ./test/core/align64.wast:802 +assert_return(() => invoke($23, `f32_align_switch`, [0]), [value("f32", 10)]); + +// ./test/core/align64.wast:803 +assert_return(() => invoke($23, `f32_align_switch`, [1]), [value("f32", 10)]); + +// ./test/core/align64.wast:804 +assert_return(() => invoke($23, `f32_align_switch`, [2]), [value("f32", 10)]); + +// ./test/core/align64.wast:805 +assert_return(() => invoke($23, `f32_align_switch`, [3]), [value("f32", 10)]); + +// ./test/core/align64.wast:807 +assert_return(() => invoke($23, `f64_align_switch`, [0]), [value("f64", 10)]); + +// ./test/core/align64.wast:808 +assert_return(() => invoke($23, `f64_align_switch`, [1]), [value("f64", 10)]); + +// ./test/core/align64.wast:809 +assert_return(() => invoke($23, `f64_align_switch`, [2]), [value("f64", 10)]); + +// ./test/core/align64.wast:810 +assert_return(() => invoke($23, `f64_align_switch`, [3]), [value("f64", 10)]); + +// ./test/core/align64.wast:811 +assert_return(() => invoke($23, `f64_align_switch`, [4]), [value("f64", 10)]); + +// ./test/core/align64.wast:813 +assert_return(() => invoke($23, `i32_align_switch`, [0, 0]), [value("i32", 10)]); + +// ./test/core/align64.wast:814 +assert_return(() => invoke($23, `i32_align_switch`, [0, 1]), [value("i32", 10)]); + +// ./test/core/align64.wast:815 +assert_return(() => invoke($23, `i32_align_switch`, [1, 0]), [value("i32", 10)]); + +// ./test/core/align64.wast:816 +assert_return(() => invoke($23, `i32_align_switch`, [1, 1]), [value("i32", 10)]); + +// ./test/core/align64.wast:817 +assert_return(() => invoke($23, `i32_align_switch`, [2, 0]), [value("i32", 10)]); + +// ./test/core/align64.wast:818 +assert_return(() => invoke($23, `i32_align_switch`, [2, 1]), [value("i32", 10)]); + +// ./test/core/align64.wast:819 +assert_return(() => invoke($23, `i32_align_switch`, [2, 2]), [value("i32", 10)]); + +// ./test/core/align64.wast:820 +assert_return(() => invoke($23, `i32_align_switch`, [3, 0]), [value("i32", 10)]); + +// ./test/core/align64.wast:821 +assert_return(() => invoke($23, `i32_align_switch`, [3, 1]), [value("i32", 10)]); + +// ./test/core/align64.wast:822 +assert_return(() => invoke($23, `i32_align_switch`, [3, 2]), [value("i32", 10)]); + +// ./test/core/align64.wast:823 +assert_return(() => invoke($23, `i32_align_switch`, [4, 0]), [value("i32", 10)]); + +// ./test/core/align64.wast:824 +assert_return(() => invoke($23, `i32_align_switch`, [4, 1]), [value("i32", 10)]); + +// ./test/core/align64.wast:825 +assert_return(() => invoke($23, `i32_align_switch`, [4, 2]), [value("i32", 10)]); + +// ./test/core/align64.wast:826 +assert_return(() => invoke($23, `i32_align_switch`, [4, 4]), [value("i32", 10)]); + +// ./test/core/align64.wast:828 +assert_return(() => invoke($23, `i64_align_switch`, [0, 0]), [value("i64", 10n)]); + +// ./test/core/align64.wast:829 +assert_return(() => invoke($23, `i64_align_switch`, [0, 1]), [value("i64", 10n)]); + +// ./test/core/align64.wast:830 +assert_return(() => invoke($23, `i64_align_switch`, [1, 0]), [value("i64", 10n)]); + +// ./test/core/align64.wast:831 +assert_return(() => invoke($23, `i64_align_switch`, [1, 1]), [value("i64", 10n)]); + +// ./test/core/align64.wast:832 +assert_return(() => invoke($23, `i64_align_switch`, [2, 0]), [value("i64", 10n)]); + +// ./test/core/align64.wast:833 +assert_return(() => invoke($23, `i64_align_switch`, [2, 1]), [value("i64", 10n)]); + +// ./test/core/align64.wast:834 +assert_return(() => invoke($23, `i64_align_switch`, [2, 2]), [value("i64", 10n)]); + +// ./test/core/align64.wast:835 +assert_return(() => invoke($23, `i64_align_switch`, [3, 0]), [value("i64", 10n)]); + +// ./test/core/align64.wast:836 +assert_return(() => invoke($23, `i64_align_switch`, [3, 1]), [value("i64", 10n)]); + +// ./test/core/align64.wast:837 +assert_return(() => invoke($23, `i64_align_switch`, [3, 2]), [value("i64", 10n)]); + +// ./test/core/align64.wast:838 +assert_return(() => invoke($23, `i64_align_switch`, [4, 0]), [value("i64", 10n)]); + +// ./test/core/align64.wast:839 +assert_return(() => invoke($23, `i64_align_switch`, [4, 1]), [value("i64", 10n)]); + +// ./test/core/align64.wast:840 +assert_return(() => invoke($23, `i64_align_switch`, [4, 2]), [value("i64", 10n)]); + +// ./test/core/align64.wast:841 +assert_return(() => invoke($23, `i64_align_switch`, [4, 4]), [value("i64", 10n)]); + +// ./test/core/align64.wast:842 +assert_return(() => invoke($23, `i64_align_switch`, [5, 0]), [value("i64", 10n)]); + +// ./test/core/align64.wast:843 +assert_return(() => invoke($23, `i64_align_switch`, [5, 1]), [value("i64", 10n)]); + +// ./test/core/align64.wast:844 +assert_return(() => invoke($23, `i64_align_switch`, [5, 2]), [value("i64", 10n)]); + +// ./test/core/align64.wast:845 +assert_return(() => invoke($23, `i64_align_switch`, [5, 4]), [value("i64", 10n)]); + +// ./test/core/align64.wast:846 +assert_return(() => invoke($23, `i64_align_switch`, [6, 0]), [value("i64", 10n)]); + +// ./test/core/align64.wast:847 +assert_return(() => invoke($23, `i64_align_switch`, [6, 1]), [value("i64", 10n)]); + +// ./test/core/align64.wast:848 +assert_return(() => invoke($23, `i64_align_switch`, [6, 2]), [value("i64", 10n)]); + +// ./test/core/align64.wast:849 +assert_return(() => invoke($23, `i64_align_switch`, [6, 4]), [value("i64", 10n)]); + +// ./test/core/align64.wast:850 +assert_return(() => invoke($23, `i64_align_switch`, [6, 8]), [value("i64", 10n)]); + +// ./test/core/align64.wast:854 +let $24 = instantiate(`(module + (memory i64 1) + (func (export "store") (param i64 i64) + (i64.store align=4 (local.get 0) (local.get 1)) + ) + (func (export "load") (param i64) (result i32) + (i32.load (local.get 0)) + ) +)`); + +// Bug 1737225 - do not observe the partial store caused by bug 1666747 on +// some native platforms. +if (!partialOobWriteMayWritePartialData()) { + // ./test/core/align64.wast:864 + assert_trap( + () => invoke($24, `store`, [65532n, -1n]), + `out of bounds memory access`, + ); + + // ./test/core/align64.wast:866 + assert_return(() => invoke($24, `load`, [65532n]), [value("i32", 0)]); +} diff --git a/js/src/jit-test/tests/wasm/spec/memory64/directives.txt b/js/src/jit-test/tests/wasm/spec/memory64/directives.txt new file mode 100644 index 0000000000..bbc47fb788 --- /dev/null +++ b/js/src/jit-test/tests/wasm/spec/memory64/directives.txt @@ -0,0 +1 @@ +|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--wasm-test-serialization; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); local-include:harness/harness.js; skip-if: !wasmMemory64Enabled()
\ No newline at end of file diff --git a/js/src/jit-test/tests/wasm/spec/memory64/endianness64.wast.js b/js/src/jit-test/tests/wasm/spec/memory64/endianness64.wast.js new file mode 100644 index 0000000000..651714be6f --- /dev/null +++ b/js/src/jit-test/tests/wasm/spec/memory64/endianness64.wast.js @@ -0,0 +1,385 @@ +/* Copyright 2021 Mozilla Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ./test/core/endianness64.wast + +// ./test/core/endianness64.wast:1 +let $0 = instantiate(`(module + (memory i64 1) + + ;; Stores an i16 value in little-endian-format + (func $$i16_store_little (param $$address i64) (param $$value i32) + (i32.store8 (local.get $$address) (local.get $$value)) + (i32.store8 (i64.add (local.get $$address) (i64.const 1)) (i32.shr_u (local.get $$value) (i32.const 8))) + ) + + ;; Stores an i32 value in little-endian format + (func $$i32_store_little (param $$address i64) (param $$value i32) + (call $$i16_store_little (local.get $$address) (local.get $$value)) + (call $$i16_store_little (i64.add (local.get $$address) (i64.const 2)) (i32.shr_u (local.get $$value) (i32.const 16))) + ) + + ;; Stores an i64 value in little-endian format + (func $$i64_store_little (param $$address i64) (param $$value i64) + (call $$i32_store_little (local.get $$address) (i32.wrap_i64 (local.get $$value))) + (call $$i32_store_little (i64.add (local.get $$address) (i64.const 4)) (i32.wrap_i64 (i64.shr_u (local.get $$value) (i64.const 32)))) + ) + + ;; Loads an i16 value in little-endian format + (func $$i16_load_little (param $$address i64) (result i32) + (i32.or + (i32.load8_u (local.get $$address)) + (i32.shl (i32.load8_u (i64.add (local.get $$address) (i64.const 1))) (i32.const 8)) + ) + ) + + ;; Loads an i32 value in little-endian format + (func $$i32_load_little (param $$address i64) (result i32) + (i32.or + (call $$i16_load_little (local.get $$address)) + (i32.shl (call $$i16_load_little (i64.add (local.get $$address) (i64.const 2))) (i32.const 16)) + ) + ) + + ;; Loads an i64 value in little-endian format + (func $$i64_load_little (param $$address i64) (result i64) + (i64.or + (i64.extend_i32_u (call $$i32_load_little (local.get $$address))) + (i64.shl (i64.extend_i32_u (call $$i32_load_little (i64.add (local.get $$address) (i64.const 4)))) (i64.const 32)) + ) + ) + + (func (export "i32_load16_s") (param $$value i32) (result i32) + (call $$i16_store_little (i64.const 0) (local.get $$value)) + (i32.load16_s (i64.const 0)) + ) + + (func (export "i32_load16_u") (param $$value i32) (result i32) + (call $$i16_store_little (i64.const 0) (local.get $$value)) + (i32.load16_u (i64.const 0)) + ) + + (func (export "i32_load") (param $$value i32) (result i32) + (call $$i32_store_little (i64.const 0) (local.get $$value)) + (i32.load (i64.const 0)) + ) + + (func (export "i64_load16_s") (param $$value i64) (result i64) + (call $$i16_store_little (i64.const 0) (i32.wrap_i64 (local.get $$value))) + (i64.load16_s (i64.const 0)) + ) + + (func (export "i64_load16_u") (param $$value i64) (result i64) + (call $$i16_store_little (i64.const 0) (i32.wrap_i64 (local.get $$value))) + (i64.load16_u (i64.const 0)) + ) + + (func (export "i64_load32_s") (param $$value i64) (result i64) + (call $$i32_store_little (i64.const 0) (i32.wrap_i64 (local.get $$value))) + (i64.load32_s (i64.const 0)) + ) + + (func (export "i64_load32_u") (param $$value i64) (result i64) + (call $$i32_store_little (i64.const 0) (i32.wrap_i64 (local.get $$value))) + (i64.load32_u (i64.const 0)) + ) + + (func (export "i64_load") (param $$value i64) (result i64) + (call $$i64_store_little (i64.const 0) (local.get $$value)) + (i64.load (i64.const 0)) + ) + + (func (export "f32_load") (param $$value f32) (result f32) + (call $$i32_store_little (i64.const 0) (i32.reinterpret_f32 (local.get $$value))) + (f32.load (i64.const 0)) + ) + + (func (export "f64_load") (param $$value f64) (result f64) + (call $$i64_store_little (i64.const 0) (i64.reinterpret_f64 (local.get $$value))) + (f64.load (i64.const 0)) + ) + + + (func (export "i32_store16") (param $$value i32) (result i32) + (i32.store16 (i64.const 0) (local.get $$value)) + (call $$i16_load_little (i64.const 0)) + ) + + (func (export "i32_store") (param $$value i32) (result i32) + (i32.store (i64.const 0) (local.get $$value)) + (call $$i32_load_little (i64.const 0)) + ) + + (func (export "i64_store16") (param $$value i64) (result i64) + (i64.store16 (i64.const 0) (local.get $$value)) + (i64.extend_i32_u (call $$i16_load_little (i64.const 0))) + ) + + (func (export "i64_store32") (param $$value i64) (result i64) + (i64.store32 (i64.const 0) (local.get $$value)) + (i64.extend_i32_u (call $$i32_load_little (i64.const 0))) + ) + + (func (export "i64_store") (param $$value i64) (result i64) + (i64.store (i64.const 0) (local.get $$value)) + (call $$i64_load_little (i64.const 0)) + ) + + (func (export "f32_store") (param $$value f32) (result f32) + (f32.store (i64.const 0) (local.get $$value)) + (f32.reinterpret_i32 (call $$i32_load_little (i64.const 0))) + ) + + (func (export "f64_store") (param $$value f64) (result f64) + (f64.store (i64.const 0) (local.get $$value)) + (f64.reinterpret_i64 (call $$i64_load_little (i64.const 0))) + ) +)`); + +// ./test/core/endianness64.wast:133 +assert_return(() => invoke($0, `i32_load16_s`, [-1]), [value("i32", -1)]); + +// ./test/core/endianness64.wast:134 +assert_return(() => invoke($0, `i32_load16_s`, [-4242]), [value("i32", -4242)]); + +// ./test/core/endianness64.wast:135 +assert_return(() => invoke($0, `i32_load16_s`, [42]), [value("i32", 42)]); + +// ./test/core/endianness64.wast:136 +assert_return(() => invoke($0, `i32_load16_s`, [12816]), [value("i32", 12816)]); + +// ./test/core/endianness64.wast:138 +assert_return(() => invoke($0, `i32_load16_u`, [-1]), [value("i32", 65535)]); + +// ./test/core/endianness64.wast:139 +assert_return(() => invoke($0, `i32_load16_u`, [-4242]), [value("i32", 61294)]); + +// ./test/core/endianness64.wast:140 +assert_return(() => invoke($0, `i32_load16_u`, [42]), [value("i32", 42)]); + +// ./test/core/endianness64.wast:141 +assert_return(() => invoke($0, `i32_load16_u`, [51966]), [value("i32", 51966)]); + +// ./test/core/endianness64.wast:143 +assert_return(() => invoke($0, `i32_load`, [-1]), [value("i32", -1)]); + +// ./test/core/endianness64.wast:144 +assert_return(() => invoke($0, `i32_load`, [-42424242]), [value("i32", -42424242)]); + +// ./test/core/endianness64.wast:145 +assert_return(() => invoke($0, `i32_load`, [42424242]), [value("i32", 42424242)]); + +// ./test/core/endianness64.wast:146 +assert_return(() => invoke($0, `i32_load`, [-1414717974]), [value("i32", -1414717974)]); + +// ./test/core/endianness64.wast:148 +assert_return(() => invoke($0, `i64_load16_s`, [-1n]), [value("i64", -1n)]); + +// ./test/core/endianness64.wast:149 +assert_return(() => invoke($0, `i64_load16_s`, [-4242n]), [value("i64", -4242n)]); + +// ./test/core/endianness64.wast:150 +assert_return(() => invoke($0, `i64_load16_s`, [42n]), [value("i64", 42n)]); + +// ./test/core/endianness64.wast:151 +assert_return(() => invoke($0, `i64_load16_s`, [12816n]), [value("i64", 12816n)]); + +// ./test/core/endianness64.wast:153 +assert_return(() => invoke($0, `i64_load16_u`, [-1n]), [value("i64", 65535n)]); + +// ./test/core/endianness64.wast:154 +assert_return(() => invoke($0, `i64_load16_u`, [-4242n]), [value("i64", 61294n)]); + +// ./test/core/endianness64.wast:155 +assert_return(() => invoke($0, `i64_load16_u`, [42n]), [value("i64", 42n)]); + +// ./test/core/endianness64.wast:156 +assert_return(() => invoke($0, `i64_load16_u`, [51966n]), [value("i64", 51966n)]); + +// ./test/core/endianness64.wast:158 +assert_return(() => invoke($0, `i64_load32_s`, [-1n]), [value("i64", -1n)]); + +// ./test/core/endianness64.wast:159 +assert_return(() => invoke($0, `i64_load32_s`, [-42424242n]), [value("i64", -42424242n)]); + +// ./test/core/endianness64.wast:160 +assert_return(() => invoke($0, `i64_load32_s`, [42424242n]), [value("i64", 42424242n)]); + +// ./test/core/endianness64.wast:161 +assert_return(() => invoke($0, `i64_load32_s`, [305419896n]), [value("i64", 305419896n)]); + +// ./test/core/endianness64.wast:163 +assert_return(() => invoke($0, `i64_load32_u`, [-1n]), [value("i64", 4294967295n)]); + +// ./test/core/endianness64.wast:164 +assert_return(() => invoke($0, `i64_load32_u`, [-42424242n]), [value("i64", 4252543054n)]); + +// ./test/core/endianness64.wast:165 +assert_return(() => invoke($0, `i64_load32_u`, [42424242n]), [value("i64", 42424242n)]); + +// ./test/core/endianness64.wast:166 +assert_return(() => invoke($0, `i64_load32_u`, [2880249322n]), [value("i64", 2880249322n)]); + +// ./test/core/endianness64.wast:168 +assert_return(() => invoke($0, `i64_load`, [-1n]), [value("i64", -1n)]); + +// ./test/core/endianness64.wast:169 +assert_return(() => invoke($0, `i64_load`, [-42424242n]), [value("i64", -42424242n)]); + +// ./test/core/endianness64.wast:170 +assert_return(() => invoke($0, `i64_load`, [2880249322n]), [value("i64", 2880249322n)]); + +// ./test/core/endianness64.wast:171 +assert_return( + () => invoke($0, `i64_load`, [-6075977126246539798n]), + [value("i64", -6075977126246539798n)], +); + +// ./test/core/endianness64.wast:173 +assert_return(() => invoke($0, `f32_load`, [value("f32", -1)]), [value("f32", -1)]); + +// ./test/core/endianness64.wast:174 +assert_return(() => invoke($0, `f32_load`, [value("f32", 0.01234)]), [value("f32", 0.01234)]); + +// ./test/core/endianness64.wast:175 +assert_return(() => invoke($0, `f32_load`, [value("f32", 4242.4243)]), [value("f32", 4242.4243)]); + +// ./test/core/endianness64.wast:176 +assert_return( + () => invoke($0, `f32_load`, [value("f32", 340282350000000000000000000000000000000)]), + [value("f32", 340282350000000000000000000000000000000)], +); + +// ./test/core/endianness64.wast:178 +assert_return(() => invoke($0, `f64_load`, [value("f64", -1)]), [value("f64", -1)]); + +// ./test/core/endianness64.wast:179 +assert_return(() => invoke($0, `f64_load`, [value("f64", 1234.56789)]), [value("f64", 1234.56789)]); + +// ./test/core/endianness64.wast:180 +assert_return( + () => invoke($0, `f64_load`, [value("f64", 424242.424242)]), + [value("f64", 424242.424242)], +); + +// ./test/core/endianness64.wast:181 +assert_return( + () => invoke($0, `f64_load`, [ + value("f64", 179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000), + ]), + [ + value("f64", 179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000), + ], +); + +// ./test/core/endianness64.wast:184 +assert_return(() => invoke($0, `i32_store16`, [-1]), [value("i32", 65535)]); + +// ./test/core/endianness64.wast:185 +assert_return(() => invoke($0, `i32_store16`, [-4242]), [value("i32", 61294)]); + +// ./test/core/endianness64.wast:186 +assert_return(() => invoke($0, `i32_store16`, [42]), [value("i32", 42)]); + +// ./test/core/endianness64.wast:187 +assert_return(() => invoke($0, `i32_store16`, [51966]), [value("i32", 51966)]); + +// ./test/core/endianness64.wast:189 +assert_return(() => invoke($0, `i32_store`, [-1]), [value("i32", -1)]); + +// ./test/core/endianness64.wast:190 +assert_return(() => invoke($0, `i32_store`, [-4242]), [value("i32", -4242)]); + +// ./test/core/endianness64.wast:191 +assert_return(() => invoke($0, `i32_store`, [42424242]), [value("i32", 42424242)]); + +// ./test/core/endianness64.wast:192 +assert_return(() => invoke($0, `i32_store`, [-559035650]), [value("i32", -559035650)]); + +// ./test/core/endianness64.wast:194 +assert_return(() => invoke($0, `i64_store16`, [-1n]), [value("i64", 65535n)]); + +// ./test/core/endianness64.wast:195 +assert_return(() => invoke($0, `i64_store16`, [-4242n]), [value("i64", 61294n)]); + +// ./test/core/endianness64.wast:196 +assert_return(() => invoke($0, `i64_store16`, [42n]), [value("i64", 42n)]); + +// ./test/core/endianness64.wast:197 +assert_return(() => invoke($0, `i64_store16`, [51966n]), [value("i64", 51966n)]); + +// ./test/core/endianness64.wast:199 +assert_return(() => invoke($0, `i64_store32`, [-1n]), [value("i64", 4294967295n)]); + +// ./test/core/endianness64.wast:200 +assert_return(() => invoke($0, `i64_store32`, [-4242n]), [value("i64", 4294963054n)]); + +// ./test/core/endianness64.wast:201 +assert_return(() => invoke($0, `i64_store32`, [42424242n]), [value("i64", 42424242n)]); + +// ./test/core/endianness64.wast:202 +assert_return(() => invoke($0, `i64_store32`, [3735931646n]), [value("i64", 3735931646n)]); + +// ./test/core/endianness64.wast:204 +assert_return(() => invoke($0, `i64_store`, [-1n]), [value("i64", -1n)]); + +// ./test/core/endianness64.wast:205 +assert_return(() => invoke($0, `i64_store`, [-42424242n]), [value("i64", -42424242n)]); + +// ./test/core/endianness64.wast:206 +assert_return(() => invoke($0, `i64_store`, [2880249322n]), [value("i64", 2880249322n)]); + +// ./test/core/endianness64.wast:207 +assert_return( + () => invoke($0, `i64_store`, [-6075977126246539798n]), + [value("i64", -6075977126246539798n)], +); + +// ./test/core/endianness64.wast:209 +assert_return(() => invoke($0, `f32_store`, [value("f32", -1)]), [value("f32", -1)]); + +// ./test/core/endianness64.wast:210 +assert_return(() => invoke($0, `f32_store`, [value("f32", 0.01234)]), [value("f32", 0.01234)]); + +// ./test/core/endianness64.wast:211 +assert_return(() => invoke($0, `f32_store`, [value("f32", 4242.4243)]), [value("f32", 4242.4243)]); + +// ./test/core/endianness64.wast:212 +assert_return( + () => invoke($0, `f32_store`, [value("f32", 340282350000000000000000000000000000000)]), + [value("f32", 340282350000000000000000000000000000000)], +); + +// ./test/core/endianness64.wast:214 +assert_return(() => invoke($0, `f64_store`, [value("f64", -1)]), [value("f64", -1)]); + +// ./test/core/endianness64.wast:215 +assert_return(() => invoke($0, `f64_store`, [value("f64", 1234.56789)]), [value("f64", 1234.56789)]); + +// ./test/core/endianness64.wast:216 +assert_return( + () => invoke($0, `f64_store`, [value("f64", 424242.424242)]), + [value("f64", 424242.424242)], +); + +// ./test/core/endianness64.wast:217 +assert_return( + () => invoke($0, `f64_store`, [ + value("f64", 179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000), + ]), + [ + value("f64", 179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000), + ], +); diff --git a/js/src/jit-test/tests/wasm/spec/memory64/float_memory64.wast.js b/js/src/jit-test/tests/wasm/spec/memory64/float_memory64.wast.js new file mode 100644 index 0000000000..70f5605577 --- /dev/null +++ b/js/src/jit-test/tests/wasm/spec/memory64/float_memory64.wast.js @@ -0,0 +1,361 @@ +/* Copyright 2021 Mozilla Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ./test/core/float_memory64.wast + +// ./test/core/float_memory64.wast:5 +let $0 = instantiate(`(module + (memory i64 (data "\\00\\00\\a0\\7f")) + + (func (export "f32.load") (result f32) (f32.load (i64.const 0))) + (func (export "i32.load") (result i32) (i32.load (i64.const 0))) + (func (export "f32.store") (f32.store (i64.const 0) (f32.const nan:0x200000))) + (func (export "i32.store") (i32.store (i64.const 0) (i32.const 0x7fa00000))) + (func (export "reset") (i32.store (i64.const 0) (i32.const 0))) +)`); + +// ./test/core/float_memory64.wast:15 +assert_return(() => invoke($0, `i32.load`, []), [value("i32", 2141192192)]); + +// ./test/core/float_memory64.wast:16 +assert_return(() => invoke($0, `f32.load`, []), [bytes("f32", [0x0, 0x0, 0xa0, 0x7f])]); + +// ./test/core/float_memory64.wast:17 +invoke($0, `reset`, []); + +// ./test/core/float_memory64.wast:18 +assert_return(() => invoke($0, `i32.load`, []), [value("i32", 0)]); + +// ./test/core/float_memory64.wast:19 +assert_return(() => invoke($0, `f32.load`, []), [value("f32", 0)]); + +// ./test/core/float_memory64.wast:20 +invoke($0, `f32.store`, []); + +// ./test/core/float_memory64.wast:21 +assert_return(() => invoke($0, `i32.load`, []), [value("i32", 2141192192)]); + +// ./test/core/float_memory64.wast:22 +assert_return(() => invoke($0, `f32.load`, []), [bytes("f32", [0x0, 0x0, 0xa0, 0x7f])]); + +// ./test/core/float_memory64.wast:23 +invoke($0, `reset`, []); + +// ./test/core/float_memory64.wast:24 +assert_return(() => invoke($0, `i32.load`, []), [value("i32", 0)]); + +// ./test/core/float_memory64.wast:25 +assert_return(() => invoke($0, `f32.load`, []), [value("f32", 0)]); + +// ./test/core/float_memory64.wast:26 +invoke($0, `i32.store`, []); + +// ./test/core/float_memory64.wast:27 +assert_return(() => invoke($0, `i32.load`, []), [value("i32", 2141192192)]); + +// ./test/core/float_memory64.wast:28 +assert_return(() => invoke($0, `f32.load`, []), [bytes("f32", [0x0, 0x0, 0xa0, 0x7f])]); + +// ./test/core/float_memory64.wast:30 +let $1 = instantiate(`(module + (memory i64 (data "\\00\\00\\00\\00\\00\\00\\f4\\7f")) + + (func (export "f64.load") (result f64) (f64.load (i64.const 0))) + (func (export "i64.load") (result i64) (i64.load (i64.const 0))) + (func (export "f64.store") (f64.store (i64.const 0) (f64.const nan:0x4000000000000))) + (func (export "i64.store") (i64.store (i64.const 0) (i64.const 0x7ff4000000000000))) + (func (export "reset") (i64.store (i64.const 0) (i64.const 0))) +)`); + +// ./test/core/float_memory64.wast:40 +assert_return(() => invoke($1, `i64.load`, []), [value("i64", 9219994337134247936n)]); + +// ./test/core/float_memory64.wast:41 +assert_return( + () => invoke($1, `f64.load`, []), + [bytes("f64", [0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf4, 0x7f])], +); + +// ./test/core/float_memory64.wast:42 +invoke($1, `reset`, []); + +// ./test/core/float_memory64.wast:43 +assert_return(() => invoke($1, `i64.load`, []), [value("i64", 0n)]); + +// ./test/core/float_memory64.wast:44 +assert_return(() => invoke($1, `f64.load`, []), [value("f64", 0)]); + +// ./test/core/float_memory64.wast:45 +invoke($1, `f64.store`, []); + +// ./test/core/float_memory64.wast:46 +assert_return(() => invoke($1, `i64.load`, []), [value("i64", 9219994337134247936n)]); + +// ./test/core/float_memory64.wast:47 +assert_return( + () => invoke($1, `f64.load`, []), + [bytes("f64", [0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf4, 0x7f])], +); + +// ./test/core/float_memory64.wast:48 +invoke($1, `reset`, []); + +// ./test/core/float_memory64.wast:49 +assert_return(() => invoke($1, `i64.load`, []), [value("i64", 0n)]); + +// ./test/core/float_memory64.wast:50 +assert_return(() => invoke($1, `f64.load`, []), [value("f64", 0)]); + +// ./test/core/float_memory64.wast:51 +invoke($1, `i64.store`, []); + +// ./test/core/float_memory64.wast:52 +assert_return(() => invoke($1, `i64.load`, []), [value("i64", 9219994337134247936n)]); + +// ./test/core/float_memory64.wast:53 +assert_return( + () => invoke($1, `f64.load`, []), + [bytes("f64", [0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf4, 0x7f])], +); + +// ./test/core/float_memory64.wast:57 +let $2 = instantiate(`(module + (memory i64 (data "\\00\\00\\00\\a0\\7f")) + + (func (export "f32.load") (result f32) (f32.load (i64.const 1))) + (func (export "i32.load") (result i32) (i32.load (i64.const 1))) + (func (export "f32.store") (f32.store (i64.const 1) (f32.const nan:0x200000))) + (func (export "i32.store") (i32.store (i64.const 1) (i32.const 0x7fa00000))) + (func (export "reset") (i32.store (i64.const 1) (i32.const 0))) +)`); + +// ./test/core/float_memory64.wast:67 +assert_return(() => invoke($2, `i32.load`, []), [value("i32", 2141192192)]); + +// ./test/core/float_memory64.wast:68 +assert_return(() => invoke($2, `f32.load`, []), [bytes("f32", [0x0, 0x0, 0xa0, 0x7f])]); + +// ./test/core/float_memory64.wast:69 +invoke($2, `reset`, []); + +// ./test/core/float_memory64.wast:70 +assert_return(() => invoke($2, `i32.load`, []), [value("i32", 0)]); + +// ./test/core/float_memory64.wast:71 +assert_return(() => invoke($2, `f32.load`, []), [value("f32", 0)]); + +// ./test/core/float_memory64.wast:72 +invoke($2, `f32.store`, []); + +// ./test/core/float_memory64.wast:73 +assert_return(() => invoke($2, `i32.load`, []), [value("i32", 2141192192)]); + +// ./test/core/float_memory64.wast:74 +assert_return(() => invoke($2, `f32.load`, []), [bytes("f32", [0x0, 0x0, 0xa0, 0x7f])]); + +// ./test/core/float_memory64.wast:75 +invoke($2, `reset`, []); + +// ./test/core/float_memory64.wast:76 +assert_return(() => invoke($2, `i32.load`, []), [value("i32", 0)]); + +// ./test/core/float_memory64.wast:77 +assert_return(() => invoke($2, `f32.load`, []), [value("f32", 0)]); + +// ./test/core/float_memory64.wast:78 +invoke($2, `i32.store`, []); + +// ./test/core/float_memory64.wast:79 +assert_return(() => invoke($2, `i32.load`, []), [value("i32", 2141192192)]); + +// ./test/core/float_memory64.wast:80 +assert_return(() => invoke($2, `f32.load`, []), [bytes("f32", [0x0, 0x0, 0xa0, 0x7f])]); + +// ./test/core/float_memory64.wast:82 +let $3 = instantiate(`(module + (memory i64 (data "\\00\\00\\00\\00\\00\\00\\00\\f4\\7f")) + + (func (export "f64.load") (result f64) (f64.load (i64.const 1))) + (func (export "i64.load") (result i64) (i64.load (i64.const 1))) + (func (export "f64.store") (f64.store (i64.const 1) (f64.const nan:0x4000000000000))) + (func (export "i64.store") (i64.store (i64.const 1) (i64.const 0x7ff4000000000000))) + (func (export "reset") (i64.store (i64.const 1) (i64.const 0))) +)`); + +// ./test/core/float_memory64.wast:92 +assert_return(() => invoke($3, `i64.load`, []), [value("i64", 9219994337134247936n)]); + +// ./test/core/float_memory64.wast:93 +assert_return( + () => invoke($3, `f64.load`, []), + [bytes("f64", [0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf4, 0x7f])], +); + +// ./test/core/float_memory64.wast:94 +invoke($3, `reset`, []); + +// ./test/core/float_memory64.wast:95 +assert_return(() => invoke($3, `i64.load`, []), [value("i64", 0n)]); + +// ./test/core/float_memory64.wast:96 +assert_return(() => invoke($3, `f64.load`, []), [value("f64", 0)]); + +// ./test/core/float_memory64.wast:97 +invoke($3, `f64.store`, []); + +// ./test/core/float_memory64.wast:98 +assert_return(() => invoke($3, `i64.load`, []), [value("i64", 9219994337134247936n)]); + +// ./test/core/float_memory64.wast:99 +assert_return( + () => invoke($3, `f64.load`, []), + [bytes("f64", [0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf4, 0x7f])], +); + +// ./test/core/float_memory64.wast:100 +invoke($3, `reset`, []); + +// ./test/core/float_memory64.wast:101 +assert_return(() => invoke($3, `i64.load`, []), [value("i64", 0n)]); + +// ./test/core/float_memory64.wast:102 +assert_return(() => invoke($3, `f64.load`, []), [value("f64", 0)]); + +// ./test/core/float_memory64.wast:103 +invoke($3, `i64.store`, []); + +// ./test/core/float_memory64.wast:104 +assert_return(() => invoke($3, `i64.load`, []), [value("i64", 9219994337134247936n)]); + +// ./test/core/float_memory64.wast:105 +assert_return( + () => invoke($3, `f64.load`, []), + [bytes("f64", [0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf4, 0x7f])], +); + +// ./test/core/float_memory64.wast:109 +let $4 = instantiate(`(module + (memory i64 (data "\\01\\00\\d0\\7f")) + + (func (export "f32.load") (result f32) (f32.load (i64.const 0))) + (func (export "i32.load") (result i32) (i32.load (i64.const 0))) + (func (export "f32.store") (f32.store (i64.const 0) (f32.const nan:0x500001))) + (func (export "i32.store") (i32.store (i64.const 0) (i32.const 0x7fd00001))) + (func (export "reset") (i32.store (i64.const 0) (i32.const 0))) +)`); + +// ./test/core/float_memory64.wast:119 +assert_return(() => invoke($4, `i32.load`, []), [value("i32", 2144337921)]); + +// ./test/core/float_memory64.wast:120 +assert_return(() => invoke($4, `f32.load`, []), [bytes("f32", [0x1, 0x0, 0xd0, 0x7f])]); + +// ./test/core/float_memory64.wast:121 +invoke($4, `reset`, []); + +// ./test/core/float_memory64.wast:122 +assert_return(() => invoke($4, `i32.load`, []), [value("i32", 0)]); + +// ./test/core/float_memory64.wast:123 +assert_return(() => invoke($4, `f32.load`, []), [value("f32", 0)]); + +// ./test/core/float_memory64.wast:124 +invoke($4, `f32.store`, []); + +// ./test/core/float_memory64.wast:125 +assert_return(() => invoke($4, `i32.load`, []), [value("i32", 2144337921)]); + +// ./test/core/float_memory64.wast:126 +assert_return(() => invoke($4, `f32.load`, []), [bytes("f32", [0x1, 0x0, 0xd0, 0x7f])]); + +// ./test/core/float_memory64.wast:127 +invoke($4, `reset`, []); + +// ./test/core/float_memory64.wast:128 +assert_return(() => invoke($4, `i32.load`, []), [value("i32", 0)]); + +// ./test/core/float_memory64.wast:129 +assert_return(() => invoke($4, `f32.load`, []), [value("f32", 0)]); + +// ./test/core/float_memory64.wast:130 +invoke($4, `i32.store`, []); + +// ./test/core/float_memory64.wast:131 +assert_return(() => invoke($4, `i32.load`, []), [value("i32", 2144337921)]); + +// ./test/core/float_memory64.wast:132 +assert_return(() => invoke($4, `f32.load`, []), [bytes("f32", [0x1, 0x0, 0xd0, 0x7f])]); + +// ./test/core/float_memory64.wast:134 +let $5 = instantiate(`(module + (memory i64 (data "\\01\\00\\00\\00\\00\\00\\fc\\7f")) + + (func (export "f64.load") (result f64) (f64.load (i64.const 0))) + (func (export "i64.load") (result i64) (i64.load (i64.const 0))) + (func (export "f64.store") (f64.store (i64.const 0) (f64.const nan:0xc000000000001))) + (func (export "i64.store") (i64.store (i64.const 0) (i64.const 0x7ffc000000000001))) + (func (export "reset") (i64.store (i64.const 0) (i64.const 0))) +)`); + +// ./test/core/float_memory64.wast:144 +assert_return(() => invoke($5, `i64.load`, []), [value("i64", 9222246136947933185n)]); + +// ./test/core/float_memory64.wast:145 +assert_return( + () => invoke($5, `f64.load`, []), + [bytes("f64", [0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfc, 0x7f])], +); + +// ./test/core/float_memory64.wast:146 +invoke($5, `reset`, []); + +// ./test/core/float_memory64.wast:147 +assert_return(() => invoke($5, `i64.load`, []), [value("i64", 0n)]); + +// ./test/core/float_memory64.wast:148 +assert_return(() => invoke($5, `f64.load`, []), [value("f64", 0)]); + +// ./test/core/float_memory64.wast:149 +invoke($5, `f64.store`, []); + +// ./test/core/float_memory64.wast:150 +assert_return(() => invoke($5, `i64.load`, []), [value("i64", 9222246136947933185n)]); + +// ./test/core/float_memory64.wast:151 +assert_return( + () => invoke($5, `f64.load`, []), + [bytes("f64", [0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfc, 0x7f])], +); + +// ./test/core/float_memory64.wast:152 +invoke($5, `reset`, []); + +// ./test/core/float_memory64.wast:153 +assert_return(() => invoke($5, `i64.load`, []), [value("i64", 0n)]); + +// ./test/core/float_memory64.wast:154 +assert_return(() => invoke($5, `f64.load`, []), [value("f64", 0)]); + +// ./test/core/float_memory64.wast:155 +invoke($5, `i64.store`, []); + +// ./test/core/float_memory64.wast:156 +assert_return(() => invoke($5, `i64.load`, []), [value("i64", 9222246136947933185n)]); + +// ./test/core/float_memory64.wast:157 +assert_return( + () => invoke($5, `f64.load`, []), + [bytes("f64", [0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfc, 0x7f])], +); diff --git a/js/src/jit-test/tests/wasm/spec/memory64/harness/directives.txt b/js/src/jit-test/tests/wasm/spec/memory64/harness/directives.txt new file mode 100644 index 0000000000..d41243abbb --- /dev/null +++ b/js/src/jit-test/tests/wasm/spec/memory64/harness/directives.txt @@ -0,0 +1 @@ +|jit-test| skip-if: true
\ No newline at end of file diff --git a/js/src/jit-test/tests/wasm/spec/memory64/harness/harness.js b/js/src/jit-test/tests/wasm/spec/memory64/harness/harness.js new file mode 100644 index 0000000000..a1a18d4b58 --- /dev/null +++ b/js/src/jit-test/tests/wasm/spec/memory64/harness/harness.js @@ -0,0 +1,371 @@ +"use strict"; + +/* Copyright 2021 Mozilla Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +if (!wasmIsSupported()) { + quit(); +} + +function partialOobWriteMayWritePartialData() { + let cfg = getBuildConfiguration(); + let arm_native = cfg["arm"] && !cfg["arm-simulator"]; + let arm64_native = cfg["arm64"] && !cfg["arm64-simulator"]; + return arm_native || arm64_native; +} + +let cfg = getBuildConfiguration(); +let native_arm = cfg["arm"] && !cfg["arm-simulator"]; +let native_arm64 = cfg["arm64"] && !cfg["arm64-simulator"]; + +function bytes(type, bytes) { + var typedBuffer = new Uint8Array(bytes); + return wasmGlobalFromArrayBuffer(type, typedBuffer.buffer); +} +function value(type, value) { + return new WebAssembly.Global({ + value: type, + mutable: false, + }, value); +} + +function i8x16(elements) { + let typedBuffer = new Uint8Array(elements); + return wasmGlobalFromArrayBuffer("v128", typedBuffer.buffer); +} +function i16x8(elements) { + let typedBuffer = new Uint16Array(elements); + return wasmGlobalFromArrayBuffer("v128", typedBuffer.buffer); +} +function i32x4(elements) { + let typedBuffer = new Uint32Array(elements); + return wasmGlobalFromArrayBuffer("v128", typedBuffer.buffer); +} +function i64x2(elements) { + let typedBuffer = new BigUint64Array(elements); + return wasmGlobalFromArrayBuffer("v128", typedBuffer.buffer); +} +function f32x4(elements) { + let typedBuffer = new Float32Array(elements); + return wasmGlobalFromArrayBuffer("v128", typedBuffer.buffer); +} +function f64x2(elements) { + let typedBuffer = new Float64Array(elements); + return wasmGlobalFromArrayBuffer("v128", typedBuffer.buffer); +} + +function either(...arr) { + return new EitherVariants(arr); +} + +class F32x4Pattern { + constructor(x, y, z, w) { + this.x = x; + this.y = y; + this.z = z; + this.w = w; + } +} + +class F64x2Pattern { + constructor(x, y) { + this.x = x; + this.y = y; + } +} + +let externrefs = {}; +let externsym = Symbol("externref"); +function externref(s) { + if (!(s in externrefs)) externrefs[s] = { [externsym]: s }; + return externrefs[s]; +} +function is_externref(x) { + return (x !== null && externsym in x) ? 1 : 0; +} +function is_funcref(x) { + return typeof x === "function" ? 1 : 0; +} +function eq_externref(x, y) { + return x === y ? 1 : 0; +} +function eq_funcref(x, y) { + return x === y ? 1 : 0; +} + +let spectest = { + externref: externref, + is_externref: is_externref, + is_funcref: is_funcref, + eq_externref: eq_externref, + eq_funcref: eq_funcref, + print: console.log.bind(console), + print_i32: console.log.bind(console), + print_i32_f32: console.log.bind(console), + print_f64_f64: console.log.bind(console), + print_f32: console.log.bind(console), + print_f64: console.log.bind(console), + global_i32: 666, + global_i64: 666n, + global_f32: 666, + global_f64: 666, + table: new WebAssembly.Table({ + initial: 10, + maximum: 20, + element: "anyfunc", + }), + memory: new WebAssembly.Memory({ initial: 1, maximum: 2 }), +}; + +let linkage = { + spectest, +}; + +function getInstance(instanceish) { + if (typeof instanceish === "string") { + assertEq( + instanceish in linkage, + true, + `'${instanceish}'' must be registered`, + ); + return linkage[instanceish]; + } + return instanceish; +} + +function instantiate(source) { + let bytecode = wasmTextToBinary(source); + let module = new WebAssembly.Module(bytecode); + let instance = new WebAssembly.Instance(module, linkage); + return instance.exports; +} + +function register(instanceish, name) { + linkage[name] = getInstance(instanceish); +} + +function invoke(instanceish, field, params) { + let func = getInstance(instanceish)[field]; + assertEq(func instanceof Function, true, "expected a function"); + return wasmLosslessInvoke(func, ...params); +} + +function get(instanceish, field) { + let global = getInstance(instanceish)[field]; + assertEq( + global instanceof WebAssembly.Global, + true, + "expected a WebAssembly.Global", + ); + return global; +} + +function assert_trap(thunk, message) { + try { + thunk(); + assertEq("normal return", "trap"); + } catch (err) { + assertEq( + err instanceof WebAssembly.RuntimeError, + true, + "expected trap", + ); + } +} + +let StackOverflow; +try { + (function f() { + 1 + f(); + })(); +} catch (e) { + StackOverflow = e.constructor; +} +function assert_exhaustion(thunk, message) { + try { + thunk(); + assertEq("normal return", "exhaustion"); + } catch (err) { + assertEq( + err instanceof StackOverflow, + true, + "expected exhaustion", + ); + } +} + +function assert_invalid(thunk, message) { + try { + thunk(); + assertEq("valid module", "invalid module"); + } catch (err) { + assertEq( + err instanceof WebAssembly.LinkError || + err instanceof WebAssembly.CompileError, + true, + "expected an invalid module", + ); + } +} + +function assert_unlinkable(thunk, message) { + try { + thunk(); + assertEq(true, false, "expected an unlinkable module"); + } catch (err) { + assertEq( + err instanceof WebAssembly.LinkError || + err instanceof WebAssembly.CompileError, + true, + "expected an unlinkable module", + ); + } +} + +function assert_malformed(thunk, message) { + try { + thunk(); + assertEq("valid module", "malformed module"); + } catch (err) { + assertEq( + err instanceof TypeError || + err instanceof SyntaxError || + err instanceof WebAssembly.CompileError || + err instanceof WebAssembly.LinkError, + true, + `expected a malformed module`, + ); + } +} + +function assert_exception(thunk) { + let thrown = false; + try { + thunk(); + } catch (err) { + thrown = true; + } + assertEq(thrown, true, "expected an exception to be thrown"); +} + +function assert_return(thunk, expected) { + let results = thunk(); + + if (results === undefined) { + results = []; + } else if (!Array.isArray(results)) { + results = [results]; + } + if (!Array.isArray(expected)) { + expected = [expected]; + } + + if (!compareResults(results, expected)) { + let got = results.map((x) => formatResult(x)).join(", "); + let wanted = expected.map((x) => formatExpected(x)).join(", "); + assertEq( + `[${got}]`, + `[${wanted}]`, + ); + assertEq(true, false, `${got} !== ${wanted}`); + } +} + +function formatResult(result) { + if (typeof (result) === "object") { + return wasmGlobalToString(result); + } else { + return `${result}`; + } +} + +function formatExpected(expected) { + if ( + expected === `f32_canonical_nan` || + expected === `f32_arithmetic_nan` || + expected === `f64_canonical_nan` || + expected === `f64_arithmetic_nan` + ) { + return expected; + } else if (expected instanceof F32x4Pattern) { + return `f32x4(${formatExpected(expected.x)}, ${ + formatExpected(expected.y) + }, ${formatExpected(expected.z)}, ${formatExpected(expected.w)})`; + } else if (expected instanceof F64x2Pattern) { + return `f64x2(${formatExpected(expected.x)}, ${ + formatExpected(expected.y) + })`; + } else if (expected instanceof EitherVariants) { + return expected.formatExpected(); + } else if (typeof (expected) === "object") { + return wasmGlobalToString(expected); + } else { + throw new Error("unknown expected result"); + } +} + +class EitherVariants { + constructor(arr) { + this.arr = arr; + } + matches(v) { + return this.arr.some((e) => compareResult(v, e)); + } + formatExpected() { + return `either(${this.arr.map(formatExpected).join(", ")})`; + } +} + +function compareResults(results, expected) { + if (results.length !== expected.length) { + return false; + } + for (let i in results) { + if (expected[i] instanceof EitherVariants) { + return expected[i].matches(results[i]); + } + if (!compareResult(results[i], expected[i])) { + return false; + } + } + return true; +} + +function compareResult(result, expected) { + if ( + expected === `canonical_nan` || + expected === `arithmetic_nan` + ) { + return wasmGlobalIsNaN(result, expected); + } else if (expected instanceof F32x4Pattern) { + return compareResult( + wasmGlobalExtractLane(result, "f32x4", 0), + expected.x, + ) && + compareResult(wasmGlobalExtractLane(result, "f32x4", 1), expected.y) && + compareResult(wasmGlobalExtractLane(result, "f32x4", 2), expected.z) && + compareResult(wasmGlobalExtractLane(result, "f32x4", 3), expected.w); + } else if (expected instanceof F64x2Pattern) { + return compareResult( + wasmGlobalExtractLane(result, "f64x2", 0), + expected.x, + ) && + compareResult(wasmGlobalExtractLane(result, "f64x2", 1), expected.y); + } else if (typeof (expected) === "object") { + return wasmGlobalsEqual(result, expected); + } else { + throw new Error("unknown expected result"); + } +} diff --git a/js/src/jit-test/tests/wasm/spec/memory64/load64.wast.js b/js/src/jit-test/tests/wasm/spec/memory64/load64.wast.js new file mode 100644 index 0000000000..c353960337 --- /dev/null +++ b/js/src/jit-test/tests/wasm/spec/memory64/load64.wast.js @@ -0,0 +1,749 @@ +/* Copyright 2021 Mozilla Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ./test/core/load64.wast + +// ./test/core/load64.wast:3 +let $0 = instantiate(`(module + (memory i64 1) + + (func (export "as-br-value") (result i32) + (block (result i32) (br 0 (i32.load (i64.const 0)))) + ) + + (func (export "as-br_if-cond") + (block (br_if 0 (i32.load (i64.const 0)))) + ) + (func (export "as-br_if-value") (result i32) + (block (result i32) + (drop (br_if 0 (i32.load (i64.const 0)) (i32.const 1))) (i32.const 7) + ) + ) + (func (export "as-br_if-value-cond") (result i32) + (block (result i32) + (drop (br_if 0 (i32.const 6) (i32.load (i64.const 0)))) (i32.const 7) + ) + ) + + (func (export "as-br_table-index") + (block (br_table 0 0 0 (i32.load (i64.const 0)))) + ) + (func (export "as-br_table-value") (result i32) + (block (result i32) + (br_table 0 0 0 (i32.load (i64.const 0)) (i32.const 1)) (i32.const 7) + ) + ) + (func (export "as-br_table-value-index") (result i32) + (block (result i32) + (br_table 0 0 (i32.const 6) (i32.load (i64.const 0))) (i32.const 7) + ) + ) + + (func (export "as-return-value") (result i32) + (return (i32.load (i64.const 0))) + ) + + (func (export "as-if-cond") (result i32) + (if (result i32) (i32.load (i64.const 0)) + (then (i32.const 0)) (else (i32.const 1)) + ) + ) + (func (export "as-if-then") (result i32) + (if (result i32) (i32.const 1) + (then (i32.load (i64.const 0))) (else (i32.const 0)) + ) + ) + (func (export "as-if-else") (result i32) + (if (result i32) (i32.const 0) + (then (i32.const 0)) (else (i32.load (i64.const 0))) + ) + ) + + (func (export "as-select-first") (param i32 i32) (result i32) + (select (i32.load (i64.const 0)) (local.get 0) (local.get 1)) + ) + (func (export "as-select-second") (param i32 i32) (result i32) + (select (local.get 0) (i32.load (i64.const 0)) (local.get 1)) + ) + (func (export "as-select-cond") (result i32) + (select (i32.const 0) (i32.const 1) (i32.load (i64.const 0))) + ) + + (func $$f (param i32 i32 i32) (result i32) (i32.const -1)) + (func (export "as-call-first") (result i32) + (call $$f (i32.load (i64.const 0)) (i32.const 2) (i32.const 3)) + ) + (func (export "as-call-mid") (result i32) + (call $$f (i32.const 1) (i32.load (i64.const 0)) (i32.const 3)) + ) + (func (export "as-call-last") (result i32) + (call $$f (i32.const 1) (i32.const 2) (i32.load (i64.const 0))) + ) + + (type $$sig (func (param i32 i32 i32) (result i32))) + (table funcref (elem $$f)) + (func (export "as-call_indirect-first") (result i32) + (call_indirect (type $$sig) + (i32.load (i64.const 0)) (i32.const 2) (i32.const 3) (i32.const 0) + ) + ) + (func (export "as-call_indirect-mid") (result i32) + (call_indirect (type $$sig) + (i32.const 1) (i32.load (i64.const 0)) (i32.const 3) (i32.const 0) + ) + ) + (func (export "as-call_indirect-last") (result i32) + (call_indirect (type $$sig) + (i32.const 1) (i32.const 2) (i32.load (i64.const 0)) (i32.const 0) + ) + ) + (func (export "as-call_indirect-index") (result i32) + (call_indirect (type $$sig) + (i32.const 1) (i32.const 2) (i32.const 3) (i32.load (i64.const 0)) + ) + ) + + (func (export "as-local.set-value") (local i32) + (local.set 0 (i32.load (i64.const 0))) + ) + (func (export "as-local.tee-value") (result i32) (local i32) + (local.tee 0 (i32.load (i64.const 0))) + ) + (global $$g (mut i32) (i32.const 0)) + (func (export "as-global.set-value") (local i32) + (global.set $$g (i32.load (i64.const 0))) + ) + + (func (export "as-load-address") (result i32) + (i32.load (i64.load (i64.const 0))) + ) + (func (export "as-loadN-address") (result i32) + (i32.load8_s (i64.load (i64.const 0))) + ) + + (func (export "as-store-address") + (i32.store (i64.load (i64.const 0)) (i32.const 7)) + ) + (func (export "as-store-value") + (i32.store (i64.const 2) (i32.load (i64.const 0))) + ) + + (func (export "as-storeN-address") + (i32.store8 (i64.load8_s (i64.const 0)) (i32.const 7)) + ) + (func (export "as-storeN-value") + (i32.store16 (i64.const 2) (i32.load (i64.const 0))) + ) + + (func (export "as-unary-operand") (result i32) + (i32.clz (i32.load (i64.const 100))) + ) + + (func (export "as-binary-left") (result i32) + (i32.add (i32.load (i64.const 100)) (i32.const 10)) + ) + (func (export "as-binary-right") (result i32) + (i32.sub (i32.const 10) (i32.load (i64.const 100))) + ) + + (func (export "as-test-operand") (result i32) + (i32.eqz (i32.load (i64.const 100))) + ) + + (func (export "as-compare-left") (result i32) + (i32.le_s (i32.load (i64.const 100)) (i32.const 10)) + ) + (func (export "as-compare-right") (result i32) + (i32.ne (i32.const 10) (i32.load (i64.const 100))) + ) + + (func (export "as-memory.grow-size") (result i64) + (memory.grow (i64.load (i64.const 100))) + ) +)`); + +// ./test/core/load64.wast:161 +assert_return(() => invoke($0, `as-br-value`, []), [value("i32", 0)]); + +// ./test/core/load64.wast:163 +assert_return(() => invoke($0, `as-br_if-cond`, []), []); + +// ./test/core/load64.wast:164 +assert_return(() => invoke($0, `as-br_if-value`, []), [value("i32", 0)]); + +// ./test/core/load64.wast:165 +assert_return(() => invoke($0, `as-br_if-value-cond`, []), [value("i32", 7)]); + +// ./test/core/load64.wast:167 +assert_return(() => invoke($0, `as-br_table-index`, []), []); + +// ./test/core/load64.wast:168 +assert_return(() => invoke($0, `as-br_table-value`, []), [value("i32", 0)]); + +// ./test/core/load64.wast:169 +assert_return(() => invoke($0, `as-br_table-value-index`, []), [value("i32", 6)]); + +// ./test/core/load64.wast:171 +assert_return(() => invoke($0, `as-return-value`, []), [value("i32", 0)]); + +// ./test/core/load64.wast:173 +assert_return(() => invoke($0, `as-if-cond`, []), [value("i32", 1)]); + +// ./test/core/load64.wast:174 +assert_return(() => invoke($0, `as-if-then`, []), [value("i32", 0)]); + +// ./test/core/load64.wast:175 +assert_return(() => invoke($0, `as-if-else`, []), [value("i32", 0)]); + +// ./test/core/load64.wast:177 +assert_return(() => invoke($0, `as-select-first`, [0, 1]), [value("i32", 0)]); + +// ./test/core/load64.wast:178 +assert_return(() => invoke($0, `as-select-second`, [0, 0]), [value("i32", 0)]); + +// ./test/core/load64.wast:179 +assert_return(() => invoke($0, `as-select-cond`, []), [value("i32", 1)]); + +// ./test/core/load64.wast:181 +assert_return(() => invoke($0, `as-call-first`, []), [value("i32", -1)]); + +// ./test/core/load64.wast:182 +assert_return(() => invoke($0, `as-call-mid`, []), [value("i32", -1)]); + +// ./test/core/load64.wast:183 +assert_return(() => invoke($0, `as-call-last`, []), [value("i32", -1)]); + +// ./test/core/load64.wast:185 +assert_return(() => invoke($0, `as-call_indirect-first`, []), [value("i32", -1)]); + +// ./test/core/load64.wast:186 +assert_return(() => invoke($0, `as-call_indirect-mid`, []), [value("i32", -1)]); + +// ./test/core/load64.wast:187 +assert_return(() => invoke($0, `as-call_indirect-last`, []), [value("i32", -1)]); + +// ./test/core/load64.wast:188 +assert_return(() => invoke($0, `as-call_indirect-index`, []), [value("i32", -1)]); + +// ./test/core/load64.wast:190 +assert_return(() => invoke($0, `as-local.set-value`, []), []); + +// ./test/core/load64.wast:191 +assert_return(() => invoke($0, `as-local.tee-value`, []), [value("i32", 0)]); + +// ./test/core/load64.wast:192 +assert_return(() => invoke($0, `as-global.set-value`, []), []); + +// ./test/core/load64.wast:194 +assert_return(() => invoke($0, `as-load-address`, []), [value("i32", 0)]); + +// ./test/core/load64.wast:195 +assert_return(() => invoke($0, `as-loadN-address`, []), [value("i32", 0)]); + +// ./test/core/load64.wast:196 +assert_return(() => invoke($0, `as-store-address`, []), []); + +// ./test/core/load64.wast:197 +assert_return(() => invoke($0, `as-store-value`, []), []); + +// ./test/core/load64.wast:198 +assert_return(() => invoke($0, `as-storeN-address`, []), []); + +// ./test/core/load64.wast:199 +assert_return(() => invoke($0, `as-storeN-value`, []), []); + +// ./test/core/load64.wast:201 +assert_return(() => invoke($0, `as-unary-operand`, []), [value("i32", 32)]); + +// ./test/core/load64.wast:203 +assert_return(() => invoke($0, `as-binary-left`, []), [value("i32", 10)]); + +// ./test/core/load64.wast:204 +assert_return(() => invoke($0, `as-binary-right`, []), [value("i32", 10)]); + +// ./test/core/load64.wast:206 +assert_return(() => invoke($0, `as-test-operand`, []), [value("i32", 1)]); + +// ./test/core/load64.wast:208 +assert_return(() => invoke($0, `as-compare-left`, []), [value("i32", 1)]); + +// ./test/core/load64.wast:209 +assert_return(() => invoke($0, `as-compare-right`, []), [value("i32", 1)]); + +// ./test/core/load64.wast:211 +assert_return(() => invoke($0, `as-memory.grow-size`, []), [value("i64", 1n)]); + +// ./test/core/load64.wast:213 +assert_malformed( + () => instantiate(`(memory i64 1) (func (param i64) (result i32) (i32.load32 (local.get 0))) `), + `unknown operator`, +); + +// ./test/core/load64.wast:220 +assert_malformed( + () => instantiate(`(memory i64 1) (func (param i64) (result i32) (i32.load32_u (local.get 0))) `), + `unknown operator`, +); + +// ./test/core/load64.wast:227 +assert_malformed( + () => instantiate(`(memory i64 1) (func (param i64) (result i32) (i32.load32_s (local.get 0))) `), + `unknown operator`, +); + +// ./test/core/load64.wast:234 +assert_malformed( + () => instantiate(`(memory i64 1) (func (param i64) (result i32) (i32.load64 (local.get 0))) `), + `unknown operator`, +); + +// ./test/core/load64.wast:241 +assert_malformed( + () => instantiate(`(memory i64 1) (func (param i64) (result i32) (i32.load64_u (local.get 0))) `), + `unknown operator`, +); + +// ./test/core/load64.wast:248 +assert_malformed( + () => instantiate(`(memory i64 1) (func (param i64) (result i32) (i32.load64_s (local.get 0))) `), + `unknown operator`, +); + +// ./test/core/load64.wast:256 +assert_malformed( + () => instantiate(`(memory i64 1) (func (param i64) (result i64) (i64.load64 (local.get 0))) `), + `unknown operator`, +); + +// ./test/core/load64.wast:263 +assert_malformed( + () => instantiate(`(memory i64 1) (func (param i64) (result i64) (i64.load64_u (local.get 0))) `), + `unknown operator`, +); + +// ./test/core/load64.wast:270 +assert_malformed( + () => instantiate(`(memory i64 1) (func (param i64) (result i64) (i64.load64_s (local.get 0))) `), + `unknown operator`, +); + +// ./test/core/load64.wast:278 +assert_malformed( + () => instantiate(`(memory i64 1) (func (param i64) (result f32) (f32.load32 (local.get 0))) `), + `unknown operator`, +); + +// ./test/core/load64.wast:285 +assert_malformed( + () => instantiate(`(memory i64 1) (func (param i64) (result f32) (f32.load64 (local.get 0))) `), + `unknown operator`, +); + +// ./test/core/load64.wast:293 +assert_malformed( + () => instantiate(`(memory i64 1) (func (param i64) (result f64) (f64.load32 (local.get 0))) `), + `unknown operator`, +); + +// ./test/core/load64.wast:300 +assert_malformed( + () => instantiate(`(memory i64 1) (func (param i64) (result f64) (f64.load64 (local.get 0))) `), + `unknown operator`, +); + +// ./test/core/load64.wast:311 +assert_invalid( + () => instantiate(`(module (memory i64 1) (func $$load_i32 (i32.load (i64.const 0))))`), + `type mismatch`, +); + +// ./test/core/load64.wast:315 +assert_invalid( + () => instantiate(`(module (memory i64 1) (func $$load8_s_i32 (i32.load8_s (i64.const 0))))`), + `type mismatch`, +); + +// ./test/core/load64.wast:319 +assert_invalid( + () => instantiate(`(module (memory i64 1) (func $$load8_u_i32 (i32.load8_u (i64.const 0))))`), + `type mismatch`, +); + +// ./test/core/load64.wast:323 +assert_invalid( + () => instantiate(`(module (memory i64 1) (func $$load16_s_i32 (i32.load16_s (i64.const 0))))`), + `type mismatch`, +); + +// ./test/core/load64.wast:327 +assert_invalid( + () => instantiate(`(module (memory i64 1) (func $$load16_u_i32 (i32.load16_u (i64.const 0))))`), + `type mismatch`, +); + +// ./test/core/load64.wast:331 +assert_invalid( + () => instantiate(`(module (memory i64 1) (func $$load_i64 (i64.load (i64.const 0))))`), + `type mismatch`, +); + +// ./test/core/load64.wast:335 +assert_invalid( + () => instantiate(`(module (memory i64 1) (func $$load8_s_i64 (i64.load8_s (i64.const 0))))`), + `type mismatch`, +); + +// ./test/core/load64.wast:339 +assert_invalid( + () => instantiate(`(module (memory i64 1) (func $$load8_u_i64 (i64.load8_u (i64.const 0))))`), + `type mismatch`, +); + +// ./test/core/load64.wast:343 +assert_invalid( + () => instantiate(`(module (memory i64 1) (func $$load16_s_i64 (i64.load16_s (i64.const 0))))`), + `type mismatch`, +); + +// ./test/core/load64.wast:347 +assert_invalid( + () => instantiate(`(module (memory i64 1) (func $$load16_u_i64 (i64.load16_u (i64.const 0))))`), + `type mismatch`, +); + +// ./test/core/load64.wast:351 +assert_invalid( + () => instantiate(`(module (memory i64 1) (func $$load32_s_i64 (i64.load32_s (i64.const 0))))`), + `type mismatch`, +); + +// ./test/core/load64.wast:355 +assert_invalid( + () => instantiate(`(module (memory i64 1) (func $$load32_u_i64 (i64.load32_u (i64.const 0))))`), + `type mismatch`, +); + +// ./test/core/load64.wast:359 +assert_invalid( + () => instantiate(`(module (memory i64 1) (func $$load_f32 (f32.load (i64.const 0))))`), + `type mismatch`, +); + +// ./test/core/load64.wast:363 +assert_invalid( + () => instantiate(`(module (memory i64 1) (func $$load_f64 (f64.load (i64.const 0))))`), + `type mismatch`, +); + +// ./test/core/load64.wast:371 +assert_invalid( + () => instantiate(`(module (memory i64 1) (func (result i32) (i32.load (f32.const 0))))`), + `type mismatch`, +); + +// ./test/core/load64.wast:372 +assert_invalid( + () => instantiate(`(module (memory i64 1) (func (result i32) (i32.load8_s (f32.const 0))))`), + `type mismatch`, +); + +// ./test/core/load64.wast:373 +assert_invalid( + () => instantiate(`(module (memory i64 1) (func (result i32) (i32.load8_u (f32.const 0))))`), + `type mismatch`, +); + +// ./test/core/load64.wast:374 +assert_invalid( + () => instantiate(`(module (memory i64 1) (func (result i32) (i32.load16_s (f32.const 0))))`), + `type mismatch`, +); + +// ./test/core/load64.wast:375 +assert_invalid( + () => instantiate(`(module (memory i64 1) (func (result i32) (i32.load16_u (f32.const 0))))`), + `type mismatch`, +); + +// ./test/core/load64.wast:376 +assert_invalid( + () => instantiate(`(module (memory i64 1) (func (result i64) (i64.load (f32.const 0))))`), + `type mismatch`, +); + +// ./test/core/load64.wast:377 +assert_invalid( + () => instantiate(`(module (memory i64 1) (func (result i64) (i64.load8_s (f32.const 0))))`), + `type mismatch`, +); + +// ./test/core/load64.wast:378 +assert_invalid( + () => instantiate(`(module (memory i64 1) (func (result i64) (i64.load8_u (f32.const 0))))`), + `type mismatch`, +); + +// ./test/core/load64.wast:379 +assert_invalid( + () => instantiate(`(module (memory i64 1) (func (result i64) (i64.load16_s (f32.const 0))))`), + `type mismatch`, +); + +// ./test/core/load64.wast:380 +assert_invalid( + () => instantiate(`(module (memory i64 1) (func (result i64) (i64.load16_u (f32.const 0))))`), + `type mismatch`, +); + +// ./test/core/load64.wast:381 +assert_invalid( + () => instantiate(`(module (memory i64 1) (func (result i64) (i64.load32_s (f32.const 0))))`), + `type mismatch`, +); + +// ./test/core/load64.wast:382 +assert_invalid( + () => instantiate(`(module (memory i64 1) (func (result i64) (i64.load32_u (f32.const 0))))`), + `type mismatch`, +); + +// ./test/core/load64.wast:383 +assert_invalid( + () => instantiate(`(module (memory i64 1) (func (result f32) (f32.load (f32.const 0))))`), + `type mismatch`, +); + +// ./test/core/load64.wast:384 +assert_invalid( + () => instantiate(`(module (memory i64 1) (func (result f64) (f64.load (f32.const 0))))`), + `type mismatch`, +); + +// ./test/core/load64.wast:387 +assert_invalid( + () => instantiate(`(module + (memory i64 0) + (func $$type-address-empty + (i32.load) (drop) + ) + )`), + `type mismatch`, +); + +// ./test/core/load64.wast:396 +assert_invalid( + () => instantiate(`(module + (memory i64 0) + (func $$type-address-empty-in-block + (i32.const 0) + (block (i32.load) (drop)) + ) + )`), + `type mismatch`, +); + +// ./test/core/load64.wast:406 +assert_invalid( + () => instantiate(`(module + (memory i64 0) + (func $$type-address-empty-in-loop + (i32.const 0) + (loop (i32.load) (drop)) + ) + )`), + `type mismatch`, +); + +// ./test/core/load64.wast:416 +assert_invalid( + () => instantiate(`(module + (memory i64 0) + (func $$type-address-empty-in-then + (i32.const 0) (i32.const 0) + (if (then (i32.load) (drop))) + ) + )`), + `type mismatch`, +); + +// ./test/core/load64.wast:426 +assert_invalid( + () => instantiate(`(module + (memory i64 0) + (func $$type-address-empty-in-else + (i32.const 0) (i32.const 0) + (if (result i32) (then (i32.const 0)) (else (i32.load))) (drop) + ) + )`), + `type mismatch`, +); + +// ./test/core/load64.wast:436 +assert_invalid( + () => instantiate(`(module + (memory i64 0) + (func $$type-address-empty-in-br + (i32.const 0) + (block (br 0 (i32.load)) (drop)) + ) + )`), + `type mismatch`, +); + +// ./test/core/load64.wast:446 +assert_invalid( + () => instantiate(`(module + (memory i64 0) + (func $$type-address-empty-in-br_if + (i32.const 0) + (block (br_if 0 (i32.load) (i32.const 1)) (drop)) + ) + )`), + `type mismatch`, +); + +// ./test/core/load64.wast:456 +assert_invalid( + () => instantiate(`(module + (memory i64 0) + (func $$type-address-empty-in-br_table + (i32.const 0) + (block (br_table 0 (i32.load)) (drop)) + ) + )`), + `type mismatch`, +); + +// ./test/core/load64.wast:466 +assert_invalid( + () => instantiate(`(module + (memory i64 0) + (func $$type-address-empty-in-return + (return (i32.load)) (drop) + ) + )`), + `type mismatch`, +); + +// ./test/core/load64.wast:475 +assert_invalid( + () => instantiate(`(module + (memory i64 0) + (func $$type-address-empty-in-select + (select (i32.load) (i32.const 1) (i32.const 2)) (drop) + ) + )`), + `type mismatch`, +); + +// ./test/core/load64.wast:484 +assert_invalid( + () => instantiate(`(module + (memory i64 0) + (func $$type-address-empty-in-call + (call 1 (i32.load)) (drop) + ) + (func (param i32) (result i32) (local.get 0)) + )`), + `type mismatch`, +); + +// ./test/core/load64.wast:494 +assert_invalid( + () => instantiate(`(module + (memory i64 0) + (func $$f (param i32) (result i32) (local.get 0)) + (type $$sig (func (param i32) (result i32))) + (table funcref (elem $$f)) + (func $$type-address-empty-in-call_indirect + (block (result i32) + (call_indirect (type $$sig) + (i32.load) (i32.const 0) + ) + (drop) + ) + ) + )`), + `type mismatch`, +); + +// ./test/core/load64.wast:511 +assert_invalid( + () => instantiate(`(module + (memory i64 0) + (func $$type-address-empty-in-local.set + (local i32) + (local.set 0 (i32.load)) (local.get 0) (drop) + ) + )`), + `type mismatch`, +); + +// ./test/core/load64.wast:521 +assert_invalid( + () => instantiate(`(module + (memory i64 0) + (func $$type-address-empty-in-local.tee + (local i32) + (local.tee 0 (i32.load)) (drop) + ) + )`), + `type mismatch`, +); + +// ./test/core/load64.wast:531 +assert_invalid( + () => instantiate(`(module + (memory i64 0) + (global $$x (mut i32) (i32.const 0)) + (func $$type-address-empty-in-global.set + (global.set $$x (i32.load)) (global.get $$x) (drop) + ) + )`), + `type mismatch`, +); + +// ./test/core/load64.wast:541 +assert_invalid( + () => instantiate(`(module + (memory i64 0) + (func $$type-address-empty-in-memory.grow + (memory.grow (i64.load)) (drop) + ) + )`), + `type mismatch`, +); + +// ./test/core/load64.wast:550 +assert_invalid( + () => instantiate(`(module + (memory i64 0) + (func $$type-address-empty-in-load + (i32.load (i32.load)) (drop) + ) + )`), + `type mismatch`, +); + +// ./test/core/load64.wast:559 +assert_invalid( + () => instantiate(`(module + (memory i64 1) + (func $$type-address-empty-in-store + (i32.store (i32.load) (i32.const 1)) + ) + )`), + `type mismatch`, +); diff --git a/js/src/jit-test/tests/wasm/spec/memory64/memory64.wast.js b/js/src/jit-test/tests/wasm/spec/memory64/memory64.wast.js new file mode 100644 index 0000000000..341742ab86 --- /dev/null +++ b/js/src/jit-test/tests/wasm/spec/memory64/memory64.wast.js @@ -0,0 +1,324 @@ +/* Copyright 2021 Mozilla Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ./test/core/memory64.wast + +// ./test/core/memory64.wast:3 +let $0 = instantiate(`(module (memory i64 0 0))`); + +// ./test/core/memory64.wast:4 +let $1 = instantiate(`(module (memory i64 0 1))`); + +// ./test/core/memory64.wast:5 +let $2 = instantiate(`(module (memory i64 1 256))`); + +// ./test/core/memory64.wast:6 +let $3 = instantiate(`(module (memory i64 0 65536))`); + +// ./test/core/memory64.wast:8 +assert_invalid( + () => instantiate(`(module (memory i64 0) (memory i64 0))`), + `multiple memories`, +); + +// ./test/core/memory64.wast:9 +assert_invalid( + () => instantiate(`(module (memory (import "spectest" "memory") i64 0) (memory i64 0))`), + `multiple memories`, +); + +// ./test/core/memory64.wast:11 +let $4 = instantiate(`(module (memory i64 (data)) (func (export "memsize") (result i64) (memory.size)))`); + +// ./test/core/memory64.wast:12 +assert_return(() => invoke($4, `memsize`, []), [value("i64", 0n)]); + +// ./test/core/memory64.wast:13 +let $5 = instantiate(`(module (memory i64 (data "")) (func (export "memsize") (result i64) (memory.size)))`); + +// ./test/core/memory64.wast:14 +assert_return(() => invoke($5, `memsize`, []), [value("i64", 0n)]); + +// ./test/core/memory64.wast:15 +let $6 = instantiate(`(module (memory i64 (data "x")) (func (export "memsize") (result i64) (memory.size)))`); + +// ./test/core/memory64.wast:16 +assert_return(() => invoke($6, `memsize`, []), [value("i64", 1n)]); + +// ./test/core/memory64.wast:18 +assert_invalid(() => instantiate(`(module (data (i64.const 0)))`), `unknown memory`); + +// ./test/core/memory64.wast:19 +assert_invalid(() => instantiate(`(module (data (i64.const 0) ""))`), `unknown memory`); + +// ./test/core/memory64.wast:20 +assert_invalid(() => instantiate(`(module (data (i64.const 0) "x"))`), `unknown memory`); + +// ./test/core/memory64.wast:22 +assert_invalid( + () => instantiate(`(module (func (drop (f32.load (i64.const 0)))))`), + `unknown memory`, +); + +// ./test/core/memory64.wast:26 +assert_invalid( + () => instantiate(`(module (func (f32.store (i64.const 0) (f32.const 0))))`), + `unknown memory`, +); + +// ./test/core/memory64.wast:30 +assert_invalid( + () => instantiate(`(module (func (drop (i32.load8_s (i64.const 0)))))`), + `unknown memory`, +); + +// ./test/core/memory64.wast:34 +assert_invalid( + () => instantiate(`(module (func (i32.store8 (i64.const 0) (i32.const 0))))`), + `unknown memory`, +); + +// ./test/core/memory64.wast:38 +assert_invalid( + () => instantiate(`(module (func (drop (memory.size))))`), + `unknown memory`, +); + +// ./test/core/memory64.wast:42 +assert_invalid( + () => instantiate(`(module (func (drop (memory.grow (i64.const 0)))))`), + `unknown memory`, +); + +// ./test/core/memory64.wast:48 +assert_invalid( + () => instantiate(`(module (memory i64 1 0))`), + `size minimum must not be greater than maximum`, +); + +// ./test/core/memory64.wast:53 +let $7 = instantiate(`(module + (memory i64 1) + (data (i64.const 0) "ABC\\a7D") (data (i64.const 20) "WASM") + + ;; Data section + (func (export "data") (result i32) + (i32.and + (i32.and + (i32.and + (i32.eq (i32.load8_u (i64.const 0)) (i32.const 65)) + (i32.eq (i32.load8_u (i64.const 3)) (i32.const 167)) + ) + (i32.and + (i32.eq (i32.load8_u (i64.const 6)) (i32.const 0)) + (i32.eq (i32.load8_u (i64.const 19)) (i32.const 0)) + ) + ) + (i32.and + (i32.and + (i32.eq (i32.load8_u (i64.const 20)) (i32.const 87)) + (i32.eq (i32.load8_u (i64.const 23)) (i32.const 77)) + ) + (i32.and + (i32.eq (i32.load8_u (i64.const 24)) (i32.const 0)) + (i32.eq (i32.load8_u (i64.const 1023)) (i32.const 0)) + ) + ) + ) + ) + + ;; Memory cast + (func (export "cast") (result f64) + (i64.store (i64.const 8) (i64.const -12345)) + (if + (f64.eq + (f64.load (i64.const 8)) + (f64.reinterpret_i64 (i64.const -12345)) + ) + (then (return (f64.const 0))) + ) + (i64.store align=1 (i64.const 9) (i64.const 0)) + (i32.store16 align=1 (i64.const 15) (i32.const 16453)) + (f64.load align=1 (i64.const 9)) + ) + + ;; Sign and zero extending memory loads + (func (export "i32_load8_s") (param $$i i32) (result i32) + (i32.store8 (i64.const 8) (local.get $$i)) + (i32.load8_s (i64.const 8)) + ) + (func (export "i32_load8_u") (param $$i i32) (result i32) + (i32.store8 (i64.const 8) (local.get $$i)) + (i32.load8_u (i64.const 8)) + ) + (func (export "i32_load16_s") (param $$i i32) (result i32) + (i32.store16 (i64.const 8) (local.get $$i)) + (i32.load16_s (i64.const 8)) + ) + (func (export "i32_load16_u") (param $$i i32) (result i32) + (i32.store16 (i64.const 8) (local.get $$i)) + (i32.load16_u (i64.const 8)) + ) + (func (export "i64_load8_s") (param $$i i64) (result i64) + (i64.store8 (i64.const 8) (local.get $$i)) + (i64.load8_s (i64.const 8)) + ) + (func (export "i64_load8_u") (param $$i i64) (result i64) + (i64.store8 (i64.const 8) (local.get $$i)) + (i64.load8_u (i64.const 8)) + ) + (func (export "i64_load16_s") (param $$i i64) (result i64) + (i64.store16 (i64.const 8) (local.get $$i)) + (i64.load16_s (i64.const 8)) + ) + (func (export "i64_load16_u") (param $$i i64) (result i64) + (i64.store16 (i64.const 8) (local.get $$i)) + (i64.load16_u (i64.const 8)) + ) + (func (export "i64_load32_s") (param $$i i64) (result i64) + (i64.store32 (i64.const 8) (local.get $$i)) + (i64.load32_s (i64.const 8)) + ) + (func (export "i64_load32_u") (param $$i i64) (result i64) + (i64.store32 (i64.const 8) (local.get $$i)) + (i64.load32_u (i64.const 8)) + ) +)`); + +// ./test/core/memory64.wast:141 +assert_return(() => invoke($7, `data`, []), [value("i32", 1)]); + +// ./test/core/memory64.wast:142 +assert_return(() => invoke($7, `cast`, []), [value("f64", 42)]); + +// ./test/core/memory64.wast:144 +assert_return(() => invoke($7, `i32_load8_s`, [-1]), [value("i32", -1)]); + +// ./test/core/memory64.wast:145 +assert_return(() => invoke($7, `i32_load8_u`, [-1]), [value("i32", 255)]); + +// ./test/core/memory64.wast:146 +assert_return(() => invoke($7, `i32_load16_s`, [-1]), [value("i32", -1)]); + +// ./test/core/memory64.wast:147 +assert_return(() => invoke($7, `i32_load16_u`, [-1]), [value("i32", 65535)]); + +// ./test/core/memory64.wast:149 +assert_return(() => invoke($7, `i32_load8_s`, [100]), [value("i32", 100)]); + +// ./test/core/memory64.wast:150 +assert_return(() => invoke($7, `i32_load8_u`, [200]), [value("i32", 200)]); + +// ./test/core/memory64.wast:151 +assert_return(() => invoke($7, `i32_load16_s`, [20000]), [value("i32", 20000)]); + +// ./test/core/memory64.wast:152 +assert_return(() => invoke($7, `i32_load16_u`, [40000]), [value("i32", 40000)]); + +// ./test/core/memory64.wast:154 +assert_return(() => invoke($7, `i32_load8_s`, [-19110589]), [value("i32", 67)]); + +// ./test/core/memory64.wast:155 +assert_return(() => invoke($7, `i32_load8_s`, [878104047]), [value("i32", -17)]); + +// ./test/core/memory64.wast:156 +assert_return(() => invoke($7, `i32_load8_u`, [-19110589]), [value("i32", 67)]); + +// ./test/core/memory64.wast:157 +assert_return(() => invoke($7, `i32_load8_u`, [878104047]), [value("i32", 239)]); + +// ./test/core/memory64.wast:158 +assert_return(() => invoke($7, `i32_load16_s`, [-19110589]), [value("i32", 25923)]); + +// ./test/core/memory64.wast:159 +assert_return(() => invoke($7, `i32_load16_s`, [878104047]), [value("i32", -12817)]); + +// ./test/core/memory64.wast:160 +assert_return(() => invoke($7, `i32_load16_u`, [-19110589]), [value("i32", 25923)]); + +// ./test/core/memory64.wast:161 +assert_return(() => invoke($7, `i32_load16_u`, [878104047]), [value("i32", 52719)]); + +// ./test/core/memory64.wast:163 +assert_return(() => invoke($7, `i64_load8_s`, [-1n]), [value("i64", -1n)]); + +// ./test/core/memory64.wast:164 +assert_return(() => invoke($7, `i64_load8_u`, [-1n]), [value("i64", 255n)]); + +// ./test/core/memory64.wast:165 +assert_return(() => invoke($7, `i64_load16_s`, [-1n]), [value("i64", -1n)]); + +// ./test/core/memory64.wast:166 +assert_return(() => invoke($7, `i64_load16_u`, [-1n]), [value("i64", 65535n)]); + +// ./test/core/memory64.wast:167 +assert_return(() => invoke($7, `i64_load32_s`, [-1n]), [value("i64", -1n)]); + +// ./test/core/memory64.wast:168 +assert_return(() => invoke($7, `i64_load32_u`, [-1n]), [value("i64", 4294967295n)]); + +// ./test/core/memory64.wast:170 +assert_return(() => invoke($7, `i64_load8_s`, [100n]), [value("i64", 100n)]); + +// ./test/core/memory64.wast:171 +assert_return(() => invoke($7, `i64_load8_u`, [200n]), [value("i64", 200n)]); + +// ./test/core/memory64.wast:172 +assert_return(() => invoke($7, `i64_load16_s`, [20000n]), [value("i64", 20000n)]); + +// ./test/core/memory64.wast:173 +assert_return(() => invoke($7, `i64_load16_u`, [40000n]), [value("i64", 40000n)]); + +// ./test/core/memory64.wast:174 +assert_return(() => invoke($7, `i64_load32_s`, [20000n]), [value("i64", 20000n)]); + +// ./test/core/memory64.wast:175 +assert_return(() => invoke($7, `i64_load32_u`, [40000n]), [value("i64", 40000n)]); + +// ./test/core/memory64.wast:177 +assert_return(() => invoke($7, `i64_load8_s`, [-81985529755441853n]), [value("i64", 67n)]); + +// ./test/core/memory64.wast:178 +assert_return(() => invoke($7, `i64_load8_s`, [3771275841602506223n]), [value("i64", -17n)]); + +// ./test/core/memory64.wast:179 +assert_return(() => invoke($7, `i64_load8_u`, [-81985529755441853n]), [value("i64", 67n)]); + +// ./test/core/memory64.wast:180 +assert_return(() => invoke($7, `i64_load8_u`, [3771275841602506223n]), [value("i64", 239n)]); + +// ./test/core/memory64.wast:181 +assert_return(() => invoke($7, `i64_load16_s`, [-81985529755441853n]), [value("i64", 25923n)]); + +// ./test/core/memory64.wast:182 +assert_return(() => invoke($7, `i64_load16_s`, [3771275841602506223n]), [value("i64", -12817n)]); + +// ./test/core/memory64.wast:183 +assert_return(() => invoke($7, `i64_load16_u`, [-81985529755441853n]), [value("i64", 25923n)]); + +// ./test/core/memory64.wast:184 +assert_return(() => invoke($7, `i64_load16_u`, [3771275841602506223n]), [value("i64", 52719n)]); + +// ./test/core/memory64.wast:185 +assert_return(() => invoke($7, `i64_load32_s`, [-81985529755441853n]), [value("i64", 1446274371n)]); + +// ./test/core/memory64.wast:186 +assert_return(() => invoke($7, `i64_load32_s`, [3771275841602506223n]), [value("i64", -1732588049n)]); + +// ./test/core/memory64.wast:187 +assert_return(() => invoke($7, `i64_load32_u`, [-81985529755441853n]), [value("i64", 1446274371n)]); + +// ./test/core/memory64.wast:188 +assert_return(() => invoke($7, `i64_load32_u`, [3771275841602506223n]), [value("i64", 2562379247n)]); diff --git a/js/src/jit-test/tests/wasm/spec/memory64/memory_grow64.wast.js b/js/src/jit-test/tests/wasm/spec/memory64/memory_grow64.wast.js new file mode 100644 index 0000000000..5286d975d8 --- /dev/null +++ b/js/src/jit-test/tests/wasm/spec/memory64/memory_grow64.wast.js @@ -0,0 +1,199 @@ +/* Copyright 2021 Mozilla Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ./test/core/memory_grow64.wast + +// ./test/core/memory_grow64.wast:1 +let $0 = instantiate(`(module + (memory i64 0) + + (func (export "load_at_zero") (result i32) (i32.load (i64.const 0))) + (func (export "store_at_zero") (i32.store (i64.const 0) (i32.const 2))) + + (func (export "load_at_page_size") (result i32) (i32.load (i64.const 0x10000))) + (func (export "store_at_page_size") (i32.store (i64.const 0x10000) (i32.const 3))) + + (func (export "grow") (param $$sz i64) (result i64) (memory.grow (local.get $$sz))) + (func (export "size") (result i64) (memory.size)) +)`); + +// ./test/core/memory_grow64.wast:14 +assert_return(() => invoke($0, `size`, []), [value("i64", 0n)]); + +// ./test/core/memory_grow64.wast:15 +assert_trap(() => invoke($0, `store_at_zero`, []), `out of bounds memory access`); + +// ./test/core/memory_grow64.wast:16 +assert_trap(() => invoke($0, `load_at_zero`, []), `out of bounds memory access`); + +// ./test/core/memory_grow64.wast:17 +assert_trap(() => invoke($0, `store_at_page_size`, []), `out of bounds memory access`); + +// ./test/core/memory_grow64.wast:18 +assert_trap(() => invoke($0, `load_at_page_size`, []), `out of bounds memory access`); + +// ./test/core/memory_grow64.wast:19 +assert_return(() => invoke($0, `grow`, [1n]), [value("i64", 0n)]); + +// ./test/core/memory_grow64.wast:20 +assert_return(() => invoke($0, `size`, []), [value("i64", 1n)]); + +// ./test/core/memory_grow64.wast:21 +assert_return(() => invoke($0, `load_at_zero`, []), [value("i32", 0)]); + +// ./test/core/memory_grow64.wast:22 +assert_return(() => invoke($0, `store_at_zero`, []), []); + +// ./test/core/memory_grow64.wast:23 +assert_return(() => invoke($0, `load_at_zero`, []), [value("i32", 2)]); + +// ./test/core/memory_grow64.wast:24 +assert_trap(() => invoke($0, `store_at_page_size`, []), `out of bounds memory access`); + +// ./test/core/memory_grow64.wast:25 +assert_trap(() => invoke($0, `load_at_page_size`, []), `out of bounds memory access`); + +// ./test/core/memory_grow64.wast:26 +assert_return(() => invoke($0, `grow`, [4n]), [value("i64", 1n)]); + +// ./test/core/memory_grow64.wast:27 +assert_return(() => invoke($0, `size`, []), [value("i64", 5n)]); + +// ./test/core/memory_grow64.wast:28 +assert_return(() => invoke($0, `load_at_zero`, []), [value("i32", 2)]); + +// ./test/core/memory_grow64.wast:29 +assert_return(() => invoke($0, `store_at_zero`, []), []); + +// ./test/core/memory_grow64.wast:30 +assert_return(() => invoke($0, `load_at_zero`, []), [value("i32", 2)]); + +// ./test/core/memory_grow64.wast:31 +assert_return(() => invoke($0, `load_at_page_size`, []), [value("i32", 0)]); + +// ./test/core/memory_grow64.wast:32 +assert_return(() => invoke($0, `store_at_page_size`, []), []); + +// ./test/core/memory_grow64.wast:33 +assert_return(() => invoke($0, `load_at_page_size`, []), [value("i32", 3)]); + +// ./test/core/memory_grow64.wast:36 +let $1 = instantiate(`(module + (memory i64 0) + (func (export "grow") (param i64) (result i64) (memory.grow (local.get 0))) +)`); + +// ./test/core/memory_grow64.wast:41 +assert_return(() => invoke($1, `grow`, [0n]), [value("i64", 0n)]); + +// ./test/core/memory_grow64.wast:42 +assert_return(() => invoke($1, `grow`, [1n]), [value("i64", 0n)]); + +// ./test/core/memory_grow64.wast:43 +assert_return(() => invoke($1, `grow`, [0n]), [value("i64", 1n)]); + +// ./test/core/memory_grow64.wast:44 +assert_return(() => invoke($1, `grow`, [2n]), [value("i64", 1n)]); + +// ./test/core/memory_grow64.wast:45 +assert_return(() => invoke($1, `grow`, [800n]), [value("i64", 3n)]); + +// ./test/core/memory_grow64.wast:46 +assert_return(() => invoke($1, `grow`, [1n]), [value("i64", 803n)]); + +// ./test/core/memory_grow64.wast:48 +let $2 = instantiate(`(module + (memory i64 0 10) + (func (export "grow") (param i64) (result i64) (memory.grow (local.get 0))) +)`); + +// ./test/core/memory_grow64.wast:53 +assert_return(() => invoke($2, `grow`, [0n]), [value("i64", 0n)]); + +// ./test/core/memory_grow64.wast:54 +assert_return(() => invoke($2, `grow`, [1n]), [value("i64", 0n)]); + +// ./test/core/memory_grow64.wast:55 +assert_return(() => invoke($2, `grow`, [1n]), [value("i64", 1n)]); + +// ./test/core/memory_grow64.wast:56 +assert_return(() => invoke($2, `grow`, [2n]), [value("i64", 2n)]); + +// ./test/core/memory_grow64.wast:57 +assert_return(() => invoke($2, `grow`, [6n]), [value("i64", 4n)]); + +// ./test/core/memory_grow64.wast:58 +assert_return(() => invoke($2, `grow`, [0n]), [value("i64", 10n)]); + +// ./test/core/memory_grow64.wast:59 +assert_return(() => invoke($2, `grow`, [1n]), [value("i64", -1n)]); + +// ./test/core/memory_grow64.wast:60 +assert_return(() => invoke($2, `grow`, [65536n]), [value("i64", -1n)]); + +// ./test/core/memory_grow64.wast:64 +let $3 = instantiate(`(module + (memory i64 1) + (func (export "grow") (param i64) (result i64) + (memory.grow (local.get 0)) + ) + (func (export "check-memory-zero") (param i64 i64) (result i32) + (local i32) + (local.set 2 (i32.const 1)) + (block + (loop + (local.set 2 (i32.load8_u (local.get 0))) + (br_if 1 (i32.ne (local.get 2) (i32.const 0))) + (br_if 1 (i64.ge_u (local.get 0) (local.get 1))) + (local.set 0 (i64.add (local.get 0) (i64.const 1))) + (br_if 0 (i64.le_u (local.get 0) (local.get 1))) + ) + ) + (local.get 2) + ) +)`); + +// ./test/core/memory_grow64.wast:85 +assert_return(() => invoke($3, `check-memory-zero`, [0n, 65535n]), [value("i32", 0)]); + +// ./test/core/memory_grow64.wast:86 +assert_return(() => invoke($3, `grow`, [1n]), [value("i64", 1n)]); + +// ./test/core/memory_grow64.wast:87 +assert_return(() => invoke($3, `check-memory-zero`, [65536n, 131071n]), [value("i32", 0)]); + +// ./test/core/memory_grow64.wast:88 +assert_return(() => invoke($3, `grow`, [1n]), [value("i64", 2n)]); + +// ./test/core/memory_grow64.wast:89 +assert_return(() => invoke($3, `check-memory-zero`, [131072n, 196607n]), [value("i32", 0)]); + +// ./test/core/memory_grow64.wast:90 +assert_return(() => invoke($3, `grow`, [1n]), [value("i64", 3n)]); + +// ./test/core/memory_grow64.wast:91 +assert_return(() => invoke($3, `check-memory-zero`, [196608n, 262143n]), [value("i32", 0)]); + +// ./test/core/memory_grow64.wast:92 +assert_return(() => invoke($3, `grow`, [1n]), [value("i64", 4n)]); + +// ./test/core/memory_grow64.wast:93 +assert_return(() => invoke($3, `check-memory-zero`, [262144n, 327679n]), [value("i32", 0)]); + +// ./test/core/memory_grow64.wast:94 +assert_return(() => invoke($3, `grow`, [1n]), [value("i64", 5n)]); + +// ./test/core/memory_grow64.wast:95 +assert_return(() => invoke($3, `check-memory-zero`, [327680n, 393215n]), [value("i32", 0)]); diff --git a/js/src/jit-test/tests/wasm/spec/memory64/memory_redundancy64.wast.js b/js/src/jit-test/tests/wasm/spec/memory64/memory_redundancy64.wast.js new file mode 100644 index 0000000000..5801c3057e --- /dev/null +++ b/js/src/jit-test/tests/wasm/spec/memory64/memory_redundancy64.wast.js @@ -0,0 +1,95 @@ +/* Copyright 2021 Mozilla Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ./test/core/memory_redundancy64.wast + +// ./test/core/memory_redundancy64.wast:5 +let $0 = instantiate(`(module + (memory i64 1 1) + + (func (export "zero_everything") + (i32.store (i64.const 0) (i32.const 0)) + (i32.store (i64.const 4) (i32.const 0)) + (i32.store (i64.const 8) (i32.const 0)) + (i32.store (i64.const 12) (i32.const 0)) + ) + + (func (export "test_store_to_load") (result i32) + (i32.store (i64.const 8) (i32.const 0)) + (f32.store (i64.const 5) (f32.const -0.0)) + (i32.load (i64.const 8)) + ) + + (func (export "test_redundant_load") (result i32) + (local $$t i32) + (local $$s i32) + (local.set $$t (i32.load (i64.const 8))) + (i32.store (i64.const 5) (i32.const 0x80000000)) + (local.set $$s (i32.load (i64.const 8))) + (i32.add (local.get $$t) (local.get $$s)) + ) + + (func (export "test_dead_store") (result f32) + (local $$t f32) + (i32.store (i64.const 8) (i32.const 0x23232323)) + (local.set $$t (f32.load (i64.const 11))) + (i32.store (i64.const 8) (i32.const 0)) + (local.get $$t) + ) + + ;; A function named "malloc" which implementations nonetheless shouldn't + ;; assume behaves like C malloc. + (func $$malloc (export "malloc") + (param $$size i64) + (result i64) + (i64.const 16) + ) + + ;; Call malloc twice, but unlike C malloc, we don't get non-aliasing pointers. + (func (export "malloc_aliasing") + (result i32) + (local $$x i64) + (local $$y i64) + (local.set $$x (call $$malloc (i64.const 4))) + (local.set $$y (call $$malloc (i64.const 4))) + (i32.store (local.get $$x) (i32.const 42)) + (i32.store (local.get $$y) (i32.const 43)) + (i32.load (local.get $$x)) + ) +)`); + +// ./test/core/memory_redundancy64.wast:59 +assert_return(() => invoke($0, `test_store_to_load`, []), [value("i32", 128)]); + +// ./test/core/memory_redundancy64.wast:60 +invoke($0, `zero_everything`, []); + +// ./test/core/memory_redundancy64.wast:61 +assert_return(() => invoke($0, `test_redundant_load`, []), [value("i32", 128)]); + +// ./test/core/memory_redundancy64.wast:62 +invoke($0, `zero_everything`, []); + +// ./test/core/memory_redundancy64.wast:63 +assert_return( + () => invoke($0, `test_dead_store`, []), + [value("f32", 0.000000000000000000000000000000000000000000049)], +); + +// ./test/core/memory_redundancy64.wast:64 +invoke($0, `zero_everything`, []); + +// ./test/core/memory_redundancy64.wast:65 +assert_return(() => invoke($0, `malloc_aliasing`, []), [value("i32", 43)]); diff --git a/js/src/jit-test/tests/wasm/spec/memory64/memory_trap64.wast.js b/js/src/jit-test/tests/wasm/spec/memory64/memory_trap64.wast.js new file mode 100644 index 0000000000..ffc8eb2cb3 --- /dev/null +++ b/js/src/jit-test/tests/wasm/spec/memory64/memory_trap64.wast.js @@ -0,0 +1,632 @@ +/* Copyright 2021 Mozilla Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ./test/core/memory_trap64.wast + +// ./test/core/memory_trap64.wast:1 +let $0 = instantiate(`(module + (memory i64 1) + + (func $$addr_limit (result i64) + (i64.mul (memory.size) (i64.const 0x10000)) + ) + + (func (export "store") (param $$i i64) (param $$v i32) + (i32.store (i64.add (call $$addr_limit) (local.get $$i)) (local.get $$v)) + ) + + (func (export "load") (param $$i i64) (result i32) + (i32.load (i64.add (call $$addr_limit) (local.get $$i))) + ) + + (func (export "memory.grow") (param i64) (result i64) + (memory.grow (local.get 0)) + ) +)`); + +// ./test/core/memory_trap64.wast:21 +assert_return(() => invoke($0, `store`, [-4n, 42]), []); + +// ./test/core/memory_trap64.wast:22 +assert_return(() => invoke($0, `load`, [-4n]), [value("i32", 42)]); + +// ./test/core/memory_trap64.wast:23 +assert_trap(() => invoke($0, `store`, [-3n, 13]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:24 +assert_trap(() => invoke($0, `load`, [-3n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:25 +assert_trap(() => invoke($0, `store`, [-2n, 13]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:26 +assert_trap(() => invoke($0, `load`, [-2n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:27 +assert_trap(() => invoke($0, `store`, [-1n, 13]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:28 +assert_trap(() => invoke($0, `load`, [-1n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:29 +assert_trap(() => invoke($0, `store`, [0n, 13]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:30 +assert_trap(() => invoke($0, `load`, [0n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:31 +assert_trap(() => invoke($0, `store`, [2147483648n, 13]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:32 +assert_trap(() => invoke($0, `load`, [2147483648n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:34 +let $1 = instantiate(`(module + (memory i64 1) + (data (i64.const 0) "abcdefgh") + (data (i64.const 0xfff8) "abcdefgh") + + (func (export "i32.load") (param $$a i64) (result i32) + (i32.load (local.get $$a)) + ) + (func (export "i64.load") (param $$a i64) (result i64) + (i64.load (local.get $$a)) + ) + (func (export "f32.load") (param $$a i64) (result f32) + (f32.load (local.get $$a)) + ) + (func (export "f64.load") (param $$a i64) (result f64) + (f64.load (local.get $$a)) + ) + (func (export "i32.load8_s") (param $$a i64) (result i32) + (i32.load8_s (local.get $$a)) + ) + (func (export "i32.load8_u") (param $$a i64) (result i32) + (i32.load8_u (local.get $$a)) + ) + (func (export "i32.load16_s") (param $$a i64) (result i32) + (i32.load16_s (local.get $$a)) + ) + (func (export "i32.load16_u") (param $$a i64) (result i32) + (i32.load16_u (local.get $$a)) + ) + (func (export "i64.load8_s") (param $$a i64) (result i64) + (i64.load8_s (local.get $$a)) + ) + (func (export "i64.load8_u") (param $$a i64) (result i64) + (i64.load8_u (local.get $$a)) + ) + (func (export "i64.load16_s") (param $$a i64) (result i64) + (i64.load16_s (local.get $$a)) + ) + (func (export "i64.load16_u") (param $$a i64) (result i64) + (i64.load16_u (local.get $$a)) + ) + (func (export "i64.load32_s") (param $$a i64) (result i64) + (i64.load32_s (local.get $$a)) + ) + (func (export "i64.load32_u") (param $$a i64) (result i64) + (i64.load32_u (local.get $$a)) + ) + (func (export "i32.store") (param $$a i64) (param $$v i32) + (i32.store (local.get $$a) (local.get $$v)) + ) + (func (export "i64.store") (param $$a i64) (param $$v i64) + (i64.store (local.get $$a) (local.get $$v)) + ) + (func (export "f32.store") (param $$a i64) (param $$v f32) + (f32.store (local.get $$a) (local.get $$v)) + ) + (func (export "f64.store") (param $$a i64) (param $$v f64) + (f64.store (local.get $$a) (local.get $$v)) + ) + (func (export "i32.store8") (param $$a i64) (param $$v i32) + (i32.store8 (local.get $$a) (local.get $$v)) + ) + (func (export "i32.store16") (param $$a i64) (param $$v i32) + (i32.store16 (local.get $$a) (local.get $$v)) + ) + (func (export "i64.store8") (param $$a i64) (param $$v i64) + (i64.store8 (local.get $$a) (local.get $$v)) + ) + (func (export "i64.store16") (param $$a i64) (param $$v i64) + (i64.store16 (local.get $$a) (local.get $$v)) + ) + (func (export "i64.store32") (param $$a i64) (param $$v i64) + (i64.store32 (local.get $$a) (local.get $$v)) + ) +)`); + +// ./test/core/memory_trap64.wast:110 +assert_trap(() => invoke($1, `i32.store`, [65536n, 0]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:111 +assert_trap(() => invoke($1, `i32.store`, [65535n, 0]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:112 +assert_trap(() => invoke($1, `i32.store`, [65534n, 0]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:113 +assert_trap(() => invoke($1, `i32.store`, [65533n, 0]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:114 +assert_trap(() => invoke($1, `i32.store`, [-1n, 0]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:115 +assert_trap(() => invoke($1, `i32.store`, [-2n, 0]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:116 +assert_trap(() => invoke($1, `i32.store`, [-3n, 0]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:117 +assert_trap(() => invoke($1, `i32.store`, [-4n, 0]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:118 +assert_trap(() => invoke($1, `i64.store`, [65536n, 0n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:119 +assert_trap(() => invoke($1, `i64.store`, [65535n, 0n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:120 +assert_trap(() => invoke($1, `i64.store`, [65534n, 0n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:121 +assert_trap(() => invoke($1, `i64.store`, [65533n, 0n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:122 +assert_trap(() => invoke($1, `i64.store`, [65532n, 0n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:123 +assert_trap(() => invoke($1, `i64.store`, [65531n, 0n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:124 +assert_trap(() => invoke($1, `i64.store`, [65530n, 0n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:125 +assert_trap(() => invoke($1, `i64.store`, [65529n, 0n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:126 +assert_trap(() => invoke($1, `i64.store`, [-1n, 0n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:127 +assert_trap(() => invoke($1, `i64.store`, [-2n, 0n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:128 +assert_trap(() => invoke($1, `i64.store`, [-3n, 0n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:129 +assert_trap(() => invoke($1, `i64.store`, [-4n, 0n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:130 +assert_trap(() => invoke($1, `i64.store`, [-5n, 0n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:131 +assert_trap(() => invoke($1, `i64.store`, [-6n, 0n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:132 +assert_trap(() => invoke($1, `i64.store`, [-7n, 0n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:133 +assert_trap(() => invoke($1, `i64.store`, [-8n, 0n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:134 +assert_trap(() => invoke($1, `f32.store`, [65536n, value("f32", 0)]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:135 +assert_trap(() => invoke($1, `f32.store`, [65535n, value("f32", 0)]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:136 +assert_trap(() => invoke($1, `f32.store`, [65534n, value("f32", 0)]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:137 +assert_trap(() => invoke($1, `f32.store`, [65533n, value("f32", 0)]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:138 +assert_trap(() => invoke($1, `f32.store`, [-1n, value("f32", 0)]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:139 +assert_trap(() => invoke($1, `f32.store`, [-2n, value("f32", 0)]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:140 +assert_trap(() => invoke($1, `f32.store`, [-3n, value("f32", 0)]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:141 +assert_trap(() => invoke($1, `f32.store`, [-4n, value("f32", 0)]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:142 +assert_trap(() => invoke($1, `f64.store`, [65536n, value("f64", 0)]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:143 +assert_trap(() => invoke($1, `f64.store`, [65535n, value("f64", 0)]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:144 +assert_trap(() => invoke($1, `f64.store`, [65534n, value("f64", 0)]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:145 +assert_trap(() => invoke($1, `f64.store`, [65533n, value("f64", 0)]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:146 +assert_trap(() => invoke($1, `f64.store`, [65532n, value("f64", 0)]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:147 +assert_trap(() => invoke($1, `f64.store`, [65531n, value("f64", 0)]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:148 +assert_trap(() => invoke($1, `f64.store`, [65530n, value("f64", 0)]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:149 +assert_trap(() => invoke($1, `f64.store`, [65529n, value("f64", 0)]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:150 +assert_trap(() => invoke($1, `f64.store`, [-1n, value("f64", 0)]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:151 +assert_trap(() => invoke($1, `f64.store`, [-2n, value("f64", 0)]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:152 +assert_trap(() => invoke($1, `f64.store`, [-3n, value("f64", 0)]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:153 +assert_trap(() => invoke($1, `f64.store`, [-4n, value("f64", 0)]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:154 +assert_trap(() => invoke($1, `f64.store`, [-5n, value("f64", 0)]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:155 +assert_trap(() => invoke($1, `f64.store`, [-6n, value("f64", 0)]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:156 +assert_trap(() => invoke($1, `f64.store`, [-7n, value("f64", 0)]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:157 +assert_trap(() => invoke($1, `f64.store`, [-8n, value("f64", 0)]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:158 +assert_trap(() => invoke($1, `i32.store8`, [65536n, 0]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:159 +assert_trap(() => invoke($1, `i32.store8`, [-1n, 0]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:160 +assert_trap(() => invoke($1, `i32.store16`, [65536n, 0]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:161 +assert_trap(() => invoke($1, `i32.store16`, [65535n, 0]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:162 +assert_trap(() => invoke($1, `i32.store16`, [-1n, 0]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:163 +assert_trap(() => invoke($1, `i32.store16`, [-2n, 0]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:164 +assert_trap(() => invoke($1, `i64.store8`, [65536n, 0n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:165 +assert_trap(() => invoke($1, `i64.store8`, [-1n, 0n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:166 +assert_trap(() => invoke($1, `i64.store16`, [65536n, 0n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:167 +assert_trap(() => invoke($1, `i64.store16`, [65535n, 0n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:168 +assert_trap(() => invoke($1, `i64.store16`, [-1n, 0n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:169 +assert_trap(() => invoke($1, `i64.store16`, [-2n, 0n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:170 +assert_trap(() => invoke($1, `i64.store32`, [65536n, 0n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:171 +assert_trap(() => invoke($1, `i64.store32`, [65535n, 0n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:172 +assert_trap(() => invoke($1, `i64.store32`, [65534n, 0n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:173 +assert_trap(() => invoke($1, `i64.store32`, [65533n, 0n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:174 +assert_trap(() => invoke($1, `i64.store32`, [-1n, 0n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:175 +assert_trap(() => invoke($1, `i64.store32`, [-2n, 0n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:176 +assert_trap(() => invoke($1, `i64.store32`, [-3n, 0n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:177 +assert_trap(() => invoke($1, `i64.store32`, [-4n, 0n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:178 +assert_trap(() => invoke($1, `i32.load`, [65536n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:179 +assert_trap(() => invoke($1, `i32.load`, [65535n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:180 +assert_trap(() => invoke($1, `i32.load`, [65534n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:181 +assert_trap(() => invoke($1, `i32.load`, [65533n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:182 +assert_trap(() => invoke($1, `i32.load`, [-1n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:183 +assert_trap(() => invoke($1, `i32.load`, [-2n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:184 +assert_trap(() => invoke($1, `i32.load`, [-3n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:185 +assert_trap(() => invoke($1, `i32.load`, [-4n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:186 +assert_trap(() => invoke($1, `i64.load`, [65536n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:187 +assert_trap(() => invoke($1, `i64.load`, [65535n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:188 +assert_trap(() => invoke($1, `i64.load`, [65534n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:189 +assert_trap(() => invoke($1, `i64.load`, [65533n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:190 +assert_trap(() => invoke($1, `i64.load`, [65532n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:191 +assert_trap(() => invoke($1, `i64.load`, [65531n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:192 +assert_trap(() => invoke($1, `i64.load`, [65530n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:193 +assert_trap(() => invoke($1, `i64.load`, [65529n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:194 +assert_trap(() => invoke($1, `i64.load`, [-1n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:195 +assert_trap(() => invoke($1, `i64.load`, [-2n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:196 +assert_trap(() => invoke($1, `i64.load`, [-3n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:197 +assert_trap(() => invoke($1, `i64.load`, [-4n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:198 +assert_trap(() => invoke($1, `i64.load`, [-5n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:199 +assert_trap(() => invoke($1, `i64.load`, [-6n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:200 +assert_trap(() => invoke($1, `i64.load`, [-7n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:201 +assert_trap(() => invoke($1, `i64.load`, [-8n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:202 +assert_trap(() => invoke($1, `f32.load`, [65536n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:203 +assert_trap(() => invoke($1, `f32.load`, [65535n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:204 +assert_trap(() => invoke($1, `f32.load`, [65534n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:205 +assert_trap(() => invoke($1, `f32.load`, [65533n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:206 +assert_trap(() => invoke($1, `f32.load`, [-1n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:207 +assert_trap(() => invoke($1, `f32.load`, [-2n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:208 +assert_trap(() => invoke($1, `f32.load`, [-3n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:209 +assert_trap(() => invoke($1, `f32.load`, [-4n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:210 +assert_trap(() => invoke($1, `f64.load`, [65536n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:211 +assert_trap(() => invoke($1, `f64.load`, [65535n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:212 +assert_trap(() => invoke($1, `f64.load`, [65534n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:213 +assert_trap(() => invoke($1, `f64.load`, [65533n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:214 +assert_trap(() => invoke($1, `f64.load`, [65532n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:215 +assert_trap(() => invoke($1, `f64.load`, [65531n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:216 +assert_trap(() => invoke($1, `f64.load`, [65530n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:217 +assert_trap(() => invoke($1, `f64.load`, [65529n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:218 +assert_trap(() => invoke($1, `f64.load`, [-1n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:219 +assert_trap(() => invoke($1, `f64.load`, [-2n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:220 +assert_trap(() => invoke($1, `f64.load`, [-3n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:221 +assert_trap(() => invoke($1, `f64.load`, [-4n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:222 +assert_trap(() => invoke($1, `f64.load`, [-5n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:223 +assert_trap(() => invoke($1, `f64.load`, [-6n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:224 +assert_trap(() => invoke($1, `f64.load`, [-7n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:225 +assert_trap(() => invoke($1, `f64.load`, [-8n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:226 +assert_trap(() => invoke($1, `i32.load8_s`, [65536n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:227 +assert_trap(() => invoke($1, `i32.load8_s`, [-1n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:228 +assert_trap(() => invoke($1, `i32.load8_u`, [65536n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:229 +assert_trap(() => invoke($1, `i32.load8_u`, [-1n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:230 +assert_trap(() => invoke($1, `i32.load16_s`, [65536n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:231 +assert_trap(() => invoke($1, `i32.load16_s`, [65535n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:232 +assert_trap(() => invoke($1, `i32.load16_s`, [-1n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:233 +assert_trap(() => invoke($1, `i32.load16_s`, [-2n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:234 +assert_trap(() => invoke($1, `i32.load16_u`, [65536n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:235 +assert_trap(() => invoke($1, `i32.load16_u`, [65535n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:236 +assert_trap(() => invoke($1, `i32.load16_u`, [-1n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:237 +assert_trap(() => invoke($1, `i32.load16_u`, [-2n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:238 +assert_trap(() => invoke($1, `i64.load8_s`, [65536n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:239 +assert_trap(() => invoke($1, `i64.load8_s`, [-1n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:240 +assert_trap(() => invoke($1, `i64.load8_u`, [65536n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:241 +assert_trap(() => invoke($1, `i64.load8_u`, [-1n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:242 +assert_trap(() => invoke($1, `i64.load16_s`, [65536n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:243 +assert_trap(() => invoke($1, `i64.load16_s`, [65535n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:244 +assert_trap(() => invoke($1, `i64.load16_s`, [-1n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:245 +assert_trap(() => invoke($1, `i64.load16_s`, [-2n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:246 +assert_trap(() => invoke($1, `i64.load16_u`, [65536n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:247 +assert_trap(() => invoke($1, `i64.load16_u`, [65535n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:248 +assert_trap(() => invoke($1, `i64.load16_u`, [-1n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:249 +assert_trap(() => invoke($1, `i64.load16_u`, [-2n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:250 +assert_trap(() => invoke($1, `i64.load32_s`, [65536n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:251 +assert_trap(() => invoke($1, `i64.load32_s`, [65535n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:252 +assert_trap(() => invoke($1, `i64.load32_s`, [65534n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:253 +assert_trap(() => invoke($1, `i64.load32_s`, [65533n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:254 +assert_trap(() => invoke($1, `i64.load32_s`, [-1n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:255 +assert_trap(() => invoke($1, `i64.load32_s`, [-2n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:256 +assert_trap(() => invoke($1, `i64.load32_s`, [-3n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:257 +assert_trap(() => invoke($1, `i64.load32_s`, [-4n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:258 +assert_trap(() => invoke($1, `i64.load32_u`, [65536n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:259 +assert_trap(() => invoke($1, `i64.load32_u`, [65535n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:260 +assert_trap(() => invoke($1, `i64.load32_u`, [65534n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:261 +assert_trap(() => invoke($1, `i64.load32_u`, [65533n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:262 +assert_trap(() => invoke($1, `i64.load32_u`, [-1n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:263 +assert_trap(() => invoke($1, `i64.load32_u`, [-2n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:264 +assert_trap(() => invoke($1, `i64.load32_u`, [-3n]), `out of bounds memory access`); + +// ./test/core/memory_trap64.wast:265 +assert_trap(() => invoke($1, `i64.load32_u`, [-4n]), `out of bounds memory access`); + +// Bug 1737225 - do not observe the partial store caused by bug 1666747 on +// some native platforms. +if (!partialOobWriteMayWritePartialData()) { + // ./test/core/memory_trap64.wast:268 + assert_return(() => invoke($1, `i64.load`, [65528n]), [ + value("i64", 7523094288207667809n), + ]); + + // ./test/core/memory_trap64.wast:269 + assert_return(() => invoke($1, `i64.load`, [0n]), [ + value("i64", 7523094288207667809n), + ]); +} |