2017-10-02 07:39:30 +00:00
|
|
|
// Copyright 2017 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.
|
|
|
|
|
2022-02-17 14:58:45 +00:00
|
|
|
// Flags: --trace-wasm-memory --no-liftoff
|
2020-01-09 13:00:34 +00:00
|
|
|
// Flags: --experimental-wasm-simd
|
2017-10-02 07:39:30 +00:00
|
|
|
|
2021-06-01 12:46:36 +00:00
|
|
|
d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
|
2017-10-02 07:39:30 +00:00
|
|
|
|
|
|
|
var builder = new WasmModuleBuilder();
|
|
|
|
builder.addMemory(1);
|
|
|
|
builder.addFunction('load', kSig_v_i)
|
2019-10-08 12:38:48 +00:00
|
|
|
.addBody([kExprLocalGet, 0, kExprI32LoadMem, 0, 0, kExprDrop])
|
2017-10-02 07:39:30 +00:00
|
|
|
.exportFunc();
|
|
|
|
builder.addFunction('load8', kSig_v_i)
|
2019-10-08 12:38:48 +00:00
|
|
|
.addBody([kExprLocalGet, 0, kExprI32LoadMem8U, 0, 0, kExprDrop])
|
2017-10-02 07:39:30 +00:00
|
|
|
.exportFunc();
|
|
|
|
builder.addFunction('loadf', kSig_v_i)
|
2019-10-08 12:38:48 +00:00
|
|
|
.addBody([kExprLocalGet, 0, kExprF32LoadMem, 0, 0, kExprDrop])
|
2017-10-02 07:39:30 +00:00
|
|
|
.exportFunc();
|
|
|
|
builder.addFunction('store', kSig_v_ii)
|
2019-10-08 12:38:48 +00:00
|
|
|
.addBody([kExprLocalGet, 0, kExprLocalGet, 1, kExprI32StoreMem, 0, 0])
|
2017-10-02 07:39:30 +00:00
|
|
|
.exportFunc();
|
|
|
|
builder.addFunction('store8', kSig_v_ii)
|
2019-10-08 12:38:48 +00:00
|
|
|
.addBody([kExprLocalGet, 0, kExprLocalGet, 1, kExprI32StoreMem8, 0, 0])
|
2017-10-02 07:39:30 +00:00
|
|
|
.exportFunc();
|
2019-10-10 23:56:09 +00:00
|
|
|
builder.addFunction('load128', kSig_v_i)
|
|
|
|
.addBody([kExprLocalGet, 0, kSimdPrefix, kExprS128LoadMem, 0, 0, kExprDrop])
|
|
|
|
.exportFunc();
|
|
|
|
// SIMD is not exposed to JS, so use splat to construct a s128 value.
|
|
|
|
builder.addFunction('store128', kSig_v_ii)
|
|
|
|
.addBody([kExprLocalGet, 0, kExprLocalGet, 1, kSimdPrefix, kExprI32x4Splat, kSimdPrefix, kExprS128StoreMem, 0, 0])
|
|
|
|
.exportFunc();
|
2020-03-25 20:36:12 +00:00
|
|
|
// We add functions after, rather than sorting in some order, so as to keep
|
|
|
|
// the .out changes small (due to function index).
|
|
|
|
builder.addFunction('load16', kSig_v_i)
|
|
|
|
.addBody([kExprLocalGet, 0, kExprI32LoadMem16U, 0, 0, kExprDrop])
|
|
|
|
.exportFunc();
|
|
|
|
builder.addFunction('load64', kSig_v_i)
|
|
|
|
.addBody([kExprLocalGet, 0, kExprI64LoadMem, 0, 0, kExprDrop])
|
|
|
|
.exportFunc();
|
|
|
|
builder.addFunction('loadf64', kSig_v_i)
|
|
|
|
.addBody([kExprLocalGet, 0, kExprF64LoadMem, 0, 0, kExprDrop])
|
|
|
|
.exportFunc();
|
2017-10-02 07:39:30 +00:00
|
|
|
var module = builder.instantiate();
|
|
|
|
|
|
|
|
module.exports.load(4);
|
|
|
|
module.exports.load8(1);
|
|
|
|
module.exports.store(4, 0x12345678);
|
|
|
|
module.exports.load(2);
|
|
|
|
module.exports.load8(6);
|
|
|
|
module.exports.loadf(2);
|
|
|
|
module.exports.store8(4, 0xab);
|
|
|
|
module.exports.load(2);
|
|
|
|
module.exports.loadf(2);
|
2019-10-10 23:56:09 +00:00
|
|
|
module.exports.store128(4, 0xbeef);
|
|
|
|
module.exports.load128(2);
|
2020-03-25 20:36:12 +00:00
|
|
|
module.exports.load16(4);
|
|
|
|
module.exports.load64(2);
|
|
|
|
module.exports.loadf64(2);
|