PR-URL: https://github.com/nodejs/node/pull/54077 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
21 lines
718 B
JavaScript
21 lines
718 B
JavaScript
// 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.
|
|
|
|
d8.file.execute('test/mjsunit/wasm/wasm-module-builder.js');
|
|
|
|
const builder = new WasmModuleBuilder();
|
|
builder.addMemory(1, 1);
|
|
builder.exportMemoryAs('memory');
|
|
builder.addFunction('main', kSig_i_v)
|
|
.addBody([
|
|
kExprI32Const, 0, // i32.const
|
|
kExprI32LoadMem16S, 0, 0, // i32.load16_s
|
|
kExprI32LoadMem, 0, 0, // i32.load
|
|
])
|
|
.exportFunc();
|
|
const instance = builder.instantiate();
|
|
let mem = new Uint16Array(instance.exports.memory.buffer);
|
|
mem[0] = -1;
|
|
assertTraps(kTrapMemOutOfBounds, instance.exports.main);
|