v8/test/message/wasm-trace-memory.js
Ng Zhi An 727668298e [wasm-simd] Implement memory tracing for kSimd128 data types
Increase the embedded vector size to 91 as that is the max size needed to print
a s128 as a 32x4.

- max value of uint32_t has 10 digits in decimal, 1 for a potential sign,
  3 spaces in between 4 of them -> 3 + 4 * 11 = 47
- max value of uint32_t has 8 digits in hex, 3 spaces in between -> 3 + 4 * 8 = 35
- the prefix "v128:" -> 5
- " / " to separate the decimal and hex representation -> 3
- null byte

47 + 35 + 5 + 3 + 1 = 91

Bug: v8:9754
Change-Id: I153c30738fa8862b44fb5103cbe62ea0bcea9718
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1814885
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Reviewed-by: Deepti Gandluri <gdeepti@chromium.org>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64256}
2019-10-11 20:45:21 +00:00

47 lines
1.7 KiB
JavaScript

// 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.
// Flags: --no-stress-opt --trace-wasm-memory --no-liftoff --no-future
// Flags: --no-wasm-tier-up --experimental-wasm-simd
load("test/mjsunit/wasm/wasm-module-builder.js");
var builder = new WasmModuleBuilder();
builder.addMemory(1);
builder.addFunction('load', kSig_v_i)
.addBody([kExprLocalGet, 0, kExprI32LoadMem, 0, 0, kExprDrop])
.exportFunc();
builder.addFunction('load8', kSig_v_i)
.addBody([kExprLocalGet, 0, kExprI32LoadMem8U, 0, 0, kExprDrop])
.exportFunc();
builder.addFunction('loadf', kSig_v_i)
.addBody([kExprLocalGet, 0, kExprF32LoadMem, 0, 0, kExprDrop])
.exportFunc();
builder.addFunction('store', kSig_v_ii)
.addBody([kExprLocalGet, 0, kExprLocalGet, 1, kExprI32StoreMem, 0, 0])
.exportFunc();
builder.addFunction('store8', kSig_v_ii)
.addBody([kExprLocalGet, 0, kExprLocalGet, 1, kExprI32StoreMem8, 0, 0])
.exportFunc();
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();
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);
module.exports.store128(4, 0xbeef);
module.exports.load128(2);