| 1 |
// |jit-test| skip-if: !wasmSimdEnabled() |
| 2 |
|
| 3 |
/* Copyright 2021 Mozilla Foundation |
| 4 |
* |
| 5 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 |
* you may not use this file except in compliance with the License. |
| 7 |
* You may obtain a copy of the License at |
| 8 |
* |
| 9 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 10 |
* |
| 11 |
* Unless required by applicable law or agreed to in writing, software |
| 12 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 13 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 |
* See the License for the specific language governing permissions and |
| 15 |
* limitations under the License. |
| 16 |
*/ |
| 17 |
|
| 18 |
// ./test/core/simd/simd_address.wast |
| 19 |
|
| 20 |
// ./test/core/simd/simd_address.wast:3 |
| 21 |
let $0 = instantiate(`(module |
| 22 |
(memory 1) |
| 23 |
(data (i32.const 0) "\\00\\01\\02\\03\\04\\05\\06\\07\\08\\09\\10\\11\\12\\13\\14\\15") |
| 24 |
(data (offset (i32.const 65505)) "\\16\\17\\18\\19\\20\\21\\22\\23\\24\\25\\26\\27\\28\\29\\30\\31") |
| 25 |
|
| 26 |
(func (export "load_data_1") (param $$i i32) (result v128) |
| 27 |
(v128.load offset=0 (local.get $$i)) ;; 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x10 0x11 0x12 0x13 0x14 0x15 |
| 28 |
) |
| 29 |
(func (export "load_data_2") (param $$i i32) (result v128) |
| 30 |
(v128.load align=1 (local.get $$i)) ;; 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x10 0x11 0x12 0x13 0x14 0x15 |
| 31 |
) |
| 32 |
(func (export "load_data_3") (param $$i i32) (result v128) |
| 33 |
(v128.load offset=1 align=1 (local.get $$i)) ;; 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x10 0x11 0x12 0x13 0x14 0x15 0x00 |
| 34 |
) |
| 35 |
(func (export "load_data_4") (param $$i i32) (result v128) |
| 36 |
(v128.load offset=2 align=1 (local.get $$i)) ;; 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x10 0x11 0x12 0x13 0x14 0x15 0x00 0x00 |
| 37 |
) |
| 38 |
(func (export "load_data_5") (param $$i i32) (result v128) |
| 39 |
(v128.load offset=15 align=1 (local.get $$i)) ;; 0x15 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 |
| 40 |
) |
| 41 |
|
| 42 |
(func (export "store_data_0") (result v128) |
| 43 |
(v128.store offset=0 (i32.const 0) (v128.const f32x4 0 1 2 3)) |
| 44 |
(v128.load offset=0 (i32.const 0)) |
| 45 |
) |
| 46 |
(func (export "store_data_1") (result v128) |
| 47 |
(v128.store align=1 (i32.const 0) (v128.const i32x4 0 1 2 3)) |
| 48 |
(v128.load align=1 (i32.const 0)) |
| 49 |
) |
| 50 |
(func (export "store_data_2") (result v128) |
| 51 |
(v128.store offset=1 align=1 (i32.const 0) (v128.const i16x8 0 1 2 3 4 5 6 7)) |
| 52 |
(v128.load offset=1 align=1 (i32.const 0)) |
| 53 |
) |
| 54 |
(func (export "store_data_3") (result v128) |
| 55 |
(v128.store offset=2 align=1 (i32.const 0) (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)) |
| 56 |
(v128.load offset=2 align=1 (i32.const 0)) |
| 57 |
) |
| 58 |
(func (export "store_data_4") (result v128) |
| 59 |
(v128.store offset=15 align=1 (i32.const 0) (v128.const i32x4 0 1 2 3)) |
| 60 |
(v128.load offset=15 (i32.const 0)) |
| 61 |
) |
| 62 |
(func (export "store_data_5") (result v128) |
| 63 |
(v128.store offset=65520 align=1 (i32.const 0) (v128.const i32x4 0 1 2 3)) |
| 64 |
(v128.load offset=65520 (i32.const 0)) |
| 65 |
) |
| 66 |
(func (export "store_data_6") (param $$i i32) |
| 67 |
(v128.store offset=1 align=1 (local.get $$i) (v128.const i32x4 0 1 2 3)) |
| 68 |
) |
| 69 |
)`); |
| 70 |
|
| 71 |
// ./test/core/simd/simd_address.wast:53 |
| 72 |
assert_return( |
| 73 |
() => invoke($0, `load_data_1`, [0]), |
| 74 |
[i32x4([0x3020100, 0x7060504, 0x11100908, 0x15141312])], |
| 75 |
); |
| 76 |
|
| 77 |
// ./test/core/simd/simd_address.wast:54 |
| 78 |
assert_return( |
| 79 |
() => invoke($0, `load_data_2`, [0]), |
| 80 |
[i32x4([0x3020100, 0x7060504, 0x11100908, 0x15141312])], |
| 81 |
); |
| 82 |
|
| 83 |
// ./test/core/simd/simd_address.wast:55 |
| 84 |
assert_return( |
| 85 |
() => invoke($0, `load_data_3`, [0]), |
| 86 |
[i32x4([0x4030201, 0x8070605, 0x12111009, 0x151413])], |
| 87 |
); |
| 88 |
|
| 89 |
// ./test/core/simd/simd_address.wast:56 |
| 90 |
assert_return(() => invoke($0, `load_data_4`, [0]), [i32x4([0x5040302, 0x9080706, 0x13121110, 0x1514])]); |
| 91 |
|
| 92 |
// ./test/core/simd/simd_address.wast:57 |
| 93 |
assert_return(() => invoke($0, `load_data_5`, [0]), [i32x4([0x15, 0x0, 0x0, 0x0])]); |
| 94 |
|
| 95 |
// ./test/core/simd/simd_address.wast:59 |
| 96 |
assert_return( |
| 97 |
() => invoke($0, `load_data_1`, [0]), |
| 98 |
[i16x8([0x100, 0x302, 0x504, 0x706, 0x908, 0x1110, 0x1312, 0x1514])], |
| 99 |
); |
| 100 |
|
| 101 |
// ./test/core/simd/simd_address.wast:60 |
| 102 |
assert_return( |
| 103 |
() => invoke($0, `load_data_2`, [0]), |
| 104 |
[i16x8([0x100, 0x302, 0x504, 0x706, 0x908, 0x1110, 0x1312, 0x1514])], |
| 105 |
); |
| 106 |
|
| 107 |
// ./test/core/simd/simd_address.wast:61 |
| 108 |
assert_return( |
| 109 |
() => invoke($0, `load_data_3`, [0]), |
| 110 |
[i16x8([0x201, 0x403, 0x605, 0x807, 0x1009, 0x1211, 0x1413, 0x15])], |
| 111 |
); |
| 112 |
|
| 113 |
// ./test/core/simd/simd_address.wast:62 |
| 114 |
assert_return( |
| 115 |
() => invoke($0, `load_data_4`, [0]), |
| 116 |
[i16x8([0x302, 0x504, 0x706, 0x908, 0x1110, 0x1312, 0x1514, 0x0])], |
| 117 |
); |
| 118 |
|
| 119 |
// ./test/core/simd/simd_address.wast:63 |
| 120 |
assert_return(() => invoke($0, `load_data_5`, [0]), [i16x8([0x15, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0])]); |
| 121 |
|
| 122 |
// ./test/core/simd/simd_address.wast:65 |
| 123 |
assert_return( |
| 124 |
() => invoke($0, `load_data_1`, [0]), |
| 125 |
[ |
| 126 |
i8x16([0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15]), |
| 127 |
], |
| 128 |
); |
| 129 |
|
| 130 |
// ./test/core/simd/simd_address.wast:66 |
| 131 |
assert_return( |
| 132 |
() => invoke($0, `load_data_2`, [0]), |
| 133 |
[ |
| 134 |
i8x16([0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15]), |
| 135 |
], |
| 136 |
); |
| 137 |
|
| 138 |
// ./test/core/simd/simd_address.wast:67 |
| 139 |
assert_return( |
| 140 |
() => invoke($0, `load_data_3`, [0]), |
| 141 |
[ |
| 142 |
i8x16([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x0]), |
| 143 |
], |
| 144 |
); |
| 145 |
|
| 146 |
// ./test/core/simd/simd_address.wast:68 |
| 147 |
assert_return( |
| 148 |
() => invoke($0, `load_data_4`, [0]), |
| 149 |
[ |
| 150 |
i8x16([0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x0, 0x0]), |
| 151 |
], |
| 152 |
); |
| 153 |
|
| 154 |
// ./test/core/simd/simd_address.wast:69 |
| 155 |
assert_return( |
| 156 |
() => invoke($0, `load_data_5`, [0]), |
| 157 |
[ |
| 158 |
i8x16([0x15, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0]), |
| 159 |
], |
| 160 |
); |
| 161 |
|
| 162 |
// ./test/core/simd/simd_address.wast:71 |
| 163 |
assert_return( |
| 164 |
() => invoke($0, `load_data_1`, [65505]), |
| 165 |
[i32x4([0x19181716, 0x23222120, 0x27262524, 0x31302928])], |
| 166 |
); |
| 167 |
|
| 168 |
// ./test/core/simd/simd_address.wast:72 |
| 169 |
assert_return( |
| 170 |
() => invoke($0, `load_data_2`, [65505]), |
| 171 |
[i32x4([0x19181716, 0x23222120, 0x27262524, 0x31302928])], |
| 172 |
); |
| 173 |
|
| 174 |
// ./test/core/simd/simd_address.wast:73 |
| 175 |
assert_return( |
| 176 |
() => invoke($0, `load_data_3`, [65505]), |
| 177 |
[i32x4([0x20191817, 0x24232221, 0x28272625, 0x313029])], |
| 178 |
); |
| 179 |
|
| 180 |
// ./test/core/simd/simd_address.wast:74 |
| 181 |
assert_return( |
| 182 |
() => invoke($0, `load_data_4`, [65505]), |
| 183 |
[i32x4([0x21201918, 0x25242322, 0x29282726, 0x3130])], |
| 184 |
); |
| 185 |
|
| 186 |
// ./test/core/simd/simd_address.wast:75 |
| 187 |
assert_return(() => invoke($0, `load_data_5`, [65505]), [i32x4([0x31, 0x0, 0x0, 0x0])]); |
| 188 |
|
| 189 |
// ./test/core/simd/simd_address.wast:77 |
| 190 |
assert_return( |
| 191 |
() => invoke($0, `load_data_1`, [65505]), |
| 192 |
[i16x8([0x1716, 0x1918, 0x2120, 0x2322, 0x2524, 0x2726, 0x2928, 0x3130])], |
| 193 |
); |
| 194 |
|
| 195 |
// ./test/core/simd/simd_address.wast:78 |
| 196 |
assert_return( |
| 197 |
() => invoke($0, `load_data_2`, [65505]), |
| 198 |
[i16x8([0x1716, 0x1918, 0x2120, 0x2322, 0x2524, 0x2726, 0x2928, 0x3130])], |
| 199 |
); |
| 200 |
|
| 201 |
// ./test/core/simd/simd_address.wast:79 |
| 202 |
assert_return( |
| 203 |
() => invoke($0, `load_data_3`, [65505]), |
| 204 |
[i16x8([0x1817, 0x2019, 0x2221, 0x2423, 0x2625, 0x2827, 0x3029, 0x31])], |
| 205 |
); |
| 206 |
|
| 207 |
// ./test/core/simd/simd_address.wast:80 |
| 208 |
assert_return( |
| 209 |
() => invoke($0, `load_data_4`, [65505]), |
| 210 |
[i16x8([0x1918, 0x2120, 0x2322, 0x2524, 0x2726, 0x2928, 0x3130, 0x0])], |
| 211 |
); |
| 212 |
|
| 213 |
// ./test/core/simd/simd_address.wast:81 |
| 214 |
assert_return( |
| 215 |
() => invoke($0, `load_data_5`, [65505]), |
| 216 |
[i16x8([0x31, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0])], |
| 217 |
); |
| 218 |
|
| 219 |
// ./test/core/simd/simd_address.wast:83 |
| 220 |
assert_return( |
| 221 |
() => invoke($0, `load_data_1`, [65505]), |
| 222 |
[ |
| 223 |
i8x16([0x16, 0x17, 0x18, 0x19, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x30, 0x31]), |
| 224 |
], |
| 225 |
); |
| 226 |
|
| 227 |
// ./test/core/simd/simd_address.wast:84 |
| 228 |
assert_return( |
| 229 |
() => invoke($0, `load_data_2`, [65505]), |
| 230 |
[ |
| 231 |
i8x16([0x16, 0x17, 0x18, 0x19, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x30, 0x31]), |
| 232 |
], |
| 233 |
); |
| 234 |
|
| 235 |
// ./test/core/simd/simd_address.wast:85 |
| 236 |
assert_return( |
| 237 |
() => invoke($0, `load_data_3`, [65505]), |
| 238 |
[ |
| 239 |
i8x16([0x17, 0x18, 0x19, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x30, 0x31, 0x0]), |
| 240 |
], |
| 241 |
); |
| 242 |
|
| 243 |
// ./test/core/simd/simd_address.wast:86 |
| 244 |
assert_return( |
| 245 |
() => invoke($0, `load_data_4`, [65505]), |
| 246 |
[ |
| 247 |
i8x16([0x18, 0x19, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x30, 0x31, 0x0, 0x0]), |
| 248 |
], |
| 249 |
); |
| 250 |
|
| 251 |
// ./test/core/simd/simd_address.wast:87 |
| 252 |
assert_return( |
| 253 |
() => invoke($0, `load_data_5`, [65505]), |
| 254 |
[ |
| 255 |
i8x16([0x31, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0]), |
| 256 |
], |
| 257 |
); |
| 258 |
|
| 259 |
// ./test/core/simd/simd_address.wast:89 |
| 260 |
assert_trap(() => invoke($0, `load_data_3`, [-1]), `out of bounds memory access`); |
| 261 |
|
| 262 |
// ./test/core/simd/simd_address.wast:90 |
| 263 |
assert_trap(() => invoke($0, `load_data_5`, [65506]), `out of bounds memory access`); |
| 264 |
|
| 265 |
// ./test/core/simd/simd_address.wast:92 |
| 266 |
assert_return( |
| 267 |
() => invoke($0, `store_data_0`, []), |
| 268 |
[ |
| 269 |
new F32x4Pattern( |
| 270 |
value("f32", 0), |
| 271 |
value("f32", 1), |
| 272 |
value("f32", 2), |
| 273 |
value("f32", 3), |
| 274 |
), |
| 275 |
], |
| 276 |
); |
| 277 |
|
| 278 |
// ./test/core/simd/simd_address.wast:93 |
| 279 |
assert_return(() => invoke($0, `store_data_1`, []), [i32x4([0x0, 0x1, 0x2, 0x3])]); |
| 280 |
|
| 281 |
// ./test/core/simd/simd_address.wast:94 |
| 282 |
assert_return(() => invoke($0, `store_data_2`, []), [i16x8([0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7])]); |
| 283 |
|
| 284 |
// ./test/core/simd/simd_address.wast:95 |
| 285 |
assert_return( |
| 286 |
() => invoke($0, `store_data_3`, []), |
| 287 |
[ |
| 288 |
i8x16([0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf]), |
| 289 |
], |
| 290 |
); |
| 291 |
|
| 292 |
// ./test/core/simd/simd_address.wast:96 |
| 293 |
assert_return(() => invoke($0, `store_data_4`, []), [i32x4([0x0, 0x1, 0x2, 0x3])]); |
| 294 |
|
| 295 |
// ./test/core/simd/simd_address.wast:97 |
| 296 |
assert_return(() => invoke($0, `store_data_5`, []), [i32x4([0x0, 0x1, 0x2, 0x3])]); |
| 297 |
|
| 298 |
// ./test/core/simd/simd_address.wast:99 |
| 299 |
assert_trap(() => invoke($0, `store_data_6`, [-1]), `out of bounds memory access`); |
| 300 |
|
| 301 |
// ./test/core/simd/simd_address.wast:100 |
| 302 |
assert_trap(() => invoke($0, `store_data_6`, [65535]), `out of bounds memory access`); |
| 303 |
|
| 304 |
// ./test/core/simd/simd_address.wast:104 |
| 305 |
let $1 = instantiate(`(module |
| 306 |
(memory 1) |
| 307 |
(func (export "v128.load_offset_65521") |
| 308 |
(drop (v128.load offset=65521 (i32.const 0))) |
| 309 |
) |
| 310 |
)`); |
| 311 |
|
| 312 |
// ./test/core/simd/simd_address.wast:110 |
| 313 |
assert_trap(() => invoke($1, `v128.load_offset_65521`, []), `out of bounds memory access`); |
| 314 |
|
| 315 |
// ./test/core/simd/simd_address.wast:112 |
| 316 |
assert_malformed( |
| 317 |
() => instantiate(`(memory 1) (func (drop (v128.load offset=-1 (i32.const 0))) ) `), |
| 318 |
`unknown operator`, |
| 319 |
); |
| 320 |
|
| 321 |
// ./test/core/simd/simd_address.wast:122 |
| 322 |
let $2 = instantiate(`(module |
| 323 |
(memory 1) |
| 324 |
(func (export "v128.store_offset_65521") |
| 325 |
(v128.store offset=65521 (i32.const 0) (v128.const i32x4 0 0 0 0)) |
| 326 |
) |
| 327 |
)`); |
| 328 |
|
| 329 |
// ./test/core/simd/simd_address.wast:128 |
| 330 |
assert_trap(() => invoke($2, `v128.store_offset_65521`, []), `out of bounds memory access`); |
| 331 |
|
| 332 |
// ./test/core/simd/simd_address.wast:130 |
| 333 |
assert_malformed( |
| 334 |
() => instantiate(`(memory 1) (func (v128.store offset=-1 (i32.const 0) (v128.const i32x4 0 0 0 0)) ) `), |
| 335 |
`unknown operator`, |
| 336 |
); |
| 337 |
|
| 338 |
// ./test/core/simd/simd_address.wast:143 |
| 339 |
assert_invalid( |
| 340 |
() => instantiate(`(memory 1) (func (drop (v128.load offset=4294967296 (i32.const 0)))) `), |
| 341 |
`offset out of range`, |
| 342 |
); |
| 343 |
|
| 344 |
// ./test/core/simd/simd_address.wast:151 |
| 345 |
assert_invalid( |
| 346 |
() => instantiate(`(memory 1) (func (v128.store offset=4294967296 (i32.const 0) (v128.const i32x4 0 0 0 0))) `), |
| 347 |
`offset out of range`, |
| 348 |
); |