|
| 1 | +// Copyright 2021 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: --wasm-staging |
| 6 | + |
| 7 | +// This is a fuzzer-generated test case that exposed a bug in Liftoff that only |
| 8 | +// affects ARM, where the fp register aliasing is different from other archs. |
| 9 | +// We were inncorrectly clearing the the high fp register in a LiftoffRegList |
| 10 | +// indicating registers to load, hitting a DCHECK. |
| 11 | +load('test/mjsunit/wasm/wasm-module-builder.js'); |
| 12 | + |
| 13 | +const builder = new WasmModuleBuilder(); |
| 14 | +builder.addMemory(19, 32, false); |
| 15 | +builder.addGlobal(kWasmI32, 0); |
| 16 | +builder.addType(makeSig([], [])); |
| 17 | +builder.addType(makeSig([kWasmI64, kWasmS128, kWasmF32], [kWasmI32])); |
| 18 | +// Generate function 1 (out of 5). |
| 19 | +builder.addFunction(undefined, 0 /* sig */) |
| 20 | + .addBodyWithEnd([ |
| 21 | +// signature: v_v |
| 22 | +// body: |
| 23 | +kExprI32Const, 0x05, // i32.const |
| 24 | +kExprReturn, // return |
| 25 | +kExprUnreachable, // unreachable |
| 26 | +kExprEnd, // end @5 |
| 27 | +]); |
| 28 | +// Generate function 4 (out of 5). |
| 29 | +builder.addFunction(undefined, 1 /* sig */) |
| 30 | + .addBodyWithEnd([ |
| 31 | +// signature: i_lsf |
| 32 | +// body: |
| 33 | +kExprLocalGet, 0x01, // local.get |
| 34 | +kExprLocalGet, 0x01, // local.get |
| 35 | +kExprGlobalGet, 0x00, // global.get |
| 36 | +kExprDrop, // drop |
| 37 | +kExprLoop, kWasmStmt, // loop @8 |
| 38 | + kExprLoop, 0x00, // loop @10 |
| 39 | + kExprI32Const, 0x01, // i32.const |
| 40 | + kExprMemoryGrow, 0x00, // memory.grow |
| 41 | + kExprI64LoadMem8U, 0x00, 0x70, // i64.load8_u |
| 42 | + kExprLoop, 0x00, // loop @19 |
| 43 | + kExprCallFunction, 0x00, // call function #0: v_v |
| 44 | + kExprEnd, // end @23 |
| 45 | + kExprI64Const, 0xf1, 0x24, // i64.const |
| 46 | + kExprGlobalGet, 0x00, // global.get |
| 47 | + kExprDrop, // drop |
| 48 | + kExprBr, 0x00, // br depth=0 |
| 49 | + kExprEnd, // end @32 |
| 50 | + kExprEnd, // end @33 |
| 51 | +kExprI32Const, 0x5b, // i32.const |
| 52 | +kExprReturn, // return |
| 53 | +kExprEnd, // end @37 |
| 54 | +]); |
| 55 | +// Instantiation is enough to cause a crash. |
| 56 | +const instance = builder.instantiate(); |
0 commit comments