regress-1145135.js 1.34 KB
Newer Older
1 2 3 4 5 6
// Copyright 2021 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Flags: --wasm-staging

7
d8.file.execute('test/mjsunit/wasm/wasm-module-builder.js');
8 9 10 11 12 13 14 15 16 17 18 19 20 21

const builder = new WasmModuleBuilder();
builder.addMemory(1, 1, false, true);
builder.addGlobal(kWasmI32, 1);
builder.addFunction(undefined, kSig_v_i)
  .addLocals(kWasmI32, 5)
  .addBody([
// signature: v_i
// body:
kExprGlobalGet, 0x00,  // global.get
kExprI32Const, 0x10,  // i32.const
kExprI32Sub,  // i32.sub
kExprLocalTee, 0x02,  // local.tee
kExprGlobalSet, 0x00,  // global.set
22
kExprBlock, kWasmVoid,  // block @12
23 24 25
  kExprLocalGet, 0x00,  // local.get
  kExprI32LoadMem, 0x02, 0x00,  // i32.load
  kExprI32Eqz,  // i32.eqz
26
  kExprIf, kWasmVoid,  // if @20
27 28 29 30 31 32 33 34 35 36 37 38 39
    kExprLocalGet, 0x02,  // local.get
    kExprI32Const, 0x00,  // i32.const
    kExprI32StoreMem, 0x02, 0x0c,  // i32.store
    kExprLocalGet, 0x00,  // local.get
    kExprI32Const, 0x20,  // i32.const
    kExprI32Add,  // i32.add
    kExprLocalSet, 0x05,  // local.set
    kExprLocalGet, 0x00,  // local.get
    kExprI32Const, 0x00,  // i32.const
    kExprI32Const, 0x01,  // i32.const
    kAtomicPrefix, kExprI32AtomicCompareExchange, 0x02, 0x20,  // i32.atomic.cmpxchng32
]);
assertThrows(() => builder.toModule(), WebAssembly.CompileError);