|
| 1 | +// Copyright 2020 the V8 project authors. All rights reserved. |
| 2 | +// Use of this source code is governed by a BSD-style license that can be |
| 3 | +// found in the LICENSE file. |
| 4 | + |
| 5 | +// Flags: --experimental-wasm-simd |
| 6 | + |
| 7 | +load('test/mjsunit/wasm/wasm-module-builder.js'); |
| 8 | + |
| 9 | +// This test is shrunk from a test case provided at https://crbug.com/v8/10831. |
| 10 | +// This exercises a aligned-load bug in ia32. Some SIMD operations were using |
| 11 | +// instructions that required aligned operands (like movaps and movapd), but we |
| 12 | +// don't have the right memory alignment yet, see https://crbug.com/v8/9198, |
| 13 | +// resulting in a SIGSEGV when running the generated code. |
| 14 | +const builder = new WasmModuleBuilder(); |
| 15 | +builder.addType(makeSig([], [kWasmI32])); |
| 16 | +// Generate function 1 (out of 1). |
| 17 | +builder.addFunction(undefined, 0 /* sig */) |
| 18 | + .addBodyWithEnd([ |
| 19 | +// signature: i_v |
| 20 | +// body: |
| 21 | +kExprI32Const, 0xfc, 0xb6, 0xed, 0x02, // i32.const |
| 22 | +kSimdPrefix, kExprI8x16Splat, // i8x16.splat |
| 23 | +kExprI32Const, 0xfc, 0x00, // i32.const |
| 24 | +kSimdPrefix, kExprI8x16Splat, // i8x16.splat |
| 25 | +kSimdPrefix, kExprI64x2Sub, 0x01, // i64x2.sub |
| 26 | +kExprI32Const, 0x00, // i32.const |
| 27 | +kSimdPrefix, kExprI8x16Splat, // i8x16.splat |
| 28 | +kExprI32Const, 0x81, 0x96, 0xf0, 0xe3, 0x07, // i32.const |
| 29 | +kSimdPrefix, kExprI8x16Splat, // i8x16.splat |
| 30 | +kSimdPrefix, kExprF64x2Max, 0x01, // f64x2.max |
| 31 | +kSimdPrefix, kExprI64x2Sub, 0x01, // i64x2.sub |
| 32 | +kExprI32Const, 0x00, // i32.const |
| 33 | +kSimdPrefix, kExprI8x16Splat, // i8x16.splat |
| 34 | +kExprI32Const, 0x00, // i32.const |
| 35 | +kExprI32Const, 0x0b, // i32.const |
| 36 | +kExprI32LtU, // i32.lt_u |
| 37 | +kSimdPrefix, kExprI8x16ReplaceLane, 0x00, // i8x16.replace_lane |
| 38 | +kExprI32Const, 0xfc, 0xf8, 0x01, // i32.const |
| 39 | +kSimdPrefix, kExprI8x16Splat, // i8x16.splat |
| 40 | +kSimdPrefix, kExprF64x2Max, 0x01, // f64x2.max |
| 41 | +kSimdPrefix, kExprI16x8MaxS, 0x01, // i16x8.max_s |
| 42 | +kSimdPrefix, kExprV8x16AllTrue, // v8x16.all_true |
| 43 | +kExprEnd, // end @70 |
| 44 | +]); |
| 45 | +builder.addExport('main', 0); |
| 46 | +const instance = builder.instantiate(); |
| 47 | +print(instance.exports.main()); |
0 commit comments