Commit 72766829 authored by Ng Zhi An's avatar Ng Zhi An Committed by Commit Bot

[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: 's avatarDeepti Gandluri <gdeepti@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64256}
parent 4c1e09a4
......@@ -16,7 +16,7 @@ namespace wasm {
void TraceMemoryOperation(ExecutionTier tier, const MemoryTracingInfo* info,
int func_index, int position, uint8_t* mem_start) {
EmbeddedVector<char, 64> value;
EmbeddedVector<char, 91> value;
auto mem_rep = static_cast<MachineRepresentation>(info->mem_rep);
switch (mem_rep) {
#define TRACE_TYPE(rep, str, format, ctype1, ctype2) \
......@@ -34,6 +34,25 @@ void TraceMemoryOperation(ExecutionTier tier, const MemoryTracingInfo* info,
TRACE_TYPE(kFloat32, "f32", "%f / %08x", float, uint32_t)
TRACE_TYPE(kFloat64, "f64", "%f / %016" PRIx64, double, uint64_t)
#undef TRACE_TYPE
case MachineRepresentation::kSimd128:
SNPrintF(value, "s128:%d %d %d %d / %08x %08x %08x %08x",
base::ReadLittleEndianValue<uint32_t>(
reinterpret_cast<Address>(mem_start) + info->address),
base::ReadLittleEndianValue<uint32_t>(
reinterpret_cast<Address>(mem_start) + info->address + 4),
base::ReadLittleEndianValue<uint32_t>(
reinterpret_cast<Address>(mem_start) + info->address + 8),
base::ReadLittleEndianValue<uint32_t>(
reinterpret_cast<Address>(mem_start) + info->address + 12),
base::ReadLittleEndianValue<uint32_t>(
reinterpret_cast<Address>(mem_start) + info->address),
base::ReadLittleEndianValue<uint32_t>(
reinterpret_cast<Address>(mem_start) + info->address + 4),
base::ReadLittleEndianValue<uint32_t>(
reinterpret_cast<Address>(mem_start) + info->address + 8),
base::ReadLittleEndianValue<uint32_t>(
reinterpret_cast<Address>(mem_start) + info->address + 12));
break;
default:
SNPrintF(value, "???");
}
......
......@@ -3,5 +3,6 @@
// found in the LICENSE file.
// Flags: --no-stress-opt --expose-wasm --trace-wasm-memory --wasm-interpret-all
// Flags: --experimental-wasm-simd
load("test/message/wasm-trace-memory.js");
......@@ -7,3 +7,5 @@ interpreter func: 2+0x3 load from 00000002 val: f32:68169720922112.00000
interpreter func: 4+0x5 store to 00000004 val: i8:171 / ab
interpreter func: 0+0x3 load from 00000002 val: i32:1454047232 / 56ab0000
interpreter func: 2+0x3 load from 00000002 val: f32:94008244174848.000000 / 56ab0000
interpreter func: 6+0x7 store to 00000004 val: s128:48879 48879 48879 48879 / 0000beef 0000beef 0000beef 0000beef
interpreter func: 5+0x3 load from 00000002 val: s128:-1091633152 -1091633152 -1091633152 -1091633152 / beef0000 beef0000 beef0000 beef0000
......@@ -3,6 +3,8 @@
// found in the LICENSE file.
// Flags: --no-stress-opt --trace-wasm-memory --liftoff --no-future
// Flags: --no-wasm-tier-up
// Flags: --no-wasm-tier-up --experimental-wasm-simd
// liftoff does not support simd128, so the s128 load and store traces are in
// the turbofan tier and not liftoff
load("test/message/wasm-trace-memory.js");
......@@ -7,3 +7,5 @@ liftoff func: 2+0x3 load from 00000002 val: f32:68169720922112.00000
liftoff func: 4+0x5 store to 00000004 val: i8:171 / ab
liftoff func: 0+0x3 load from 00000002 val: i32:1454047232 / 56ab0000
liftoff func: 2+0x3 load from 00000002 val: f32:94008244174848.000000 / 56ab0000
turbofan func: 6+0x7 store to 00000004 val: s128:48879 48879 48879 48879 / 0000beef 0000beef 0000beef 0000beef
turbofan func: 5+0x3 load from 00000002 val: s128:-1091633152 -1091633152 -1091633152 -1091633152 / beef0000 beef0000 beef0000 beef0000
......@@ -3,7 +3,7 @@
// found in the LICENSE file.
// Flags: --no-stress-opt --trace-wasm-memory --no-liftoff --no-future
// Flags: --no-wasm-tier-up
// Flags: --no-wasm-tier-up --experimental-wasm-simd
load("test/mjsunit/wasm/wasm-module-builder.js");
......@@ -24,6 +24,13 @@ builder.addFunction('store', kSig_v_ii)
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);
......@@ -35,3 +42,5 @@ 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);
......@@ -7,3 +7,5 @@ turbofan func: 2+0x3 load from 00000002 val: f32:68169720922112.00000
turbofan func: 4+0x5 store to 00000004 val: i8:171 / ab
turbofan func: 0+0x3 load from 00000002 val: i32:1454047232 / 56ab0000
turbofan func: 2+0x3 load from 00000002 val: f32:94008244174848.000000 / 56ab0000
turbofan func: 6+0x7 store to 00000004 val: s128:48879 48879 48879 48879 / 0000beef 0000beef 0000beef 0000beef
turbofan func: 5+0x3 load from 00000002 val: s128:-1091633152 -1091633152 -1091633152 -1091633152 / beef0000 beef0000 beef0000 beef0000
......@@ -8,7 +8,6 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
// Non-standard opcodes.
let kSig_s_v = makeSig([], [kWasmS128]);
let kExprS128LoadMem = 0xc0;
(function() {
"use asm";
......
......@@ -4,10 +4,6 @@
load("test/mjsunit/wasm/wasm-module-builder.js");
// Non-standard opcodes.
let kSig_s_v = makeSig([], [kWasmS128]);
let kExprS128LoadMem = 0xc0;
(function() {
"use asm";
var builder = new WasmModuleBuilder();
......
......@@ -465,6 +465,9 @@ let kExprI64AtomicCompareExchange16U = 0x4d;
let kExprI64AtomicCompareExchange32U = 0x4e;
// Simd opcodes.
let kExprS128LoadMem = 0x00;
let kExprS128StoreMem = 0x01;
let kExprI32x4Splat = 0x0c;
let kExprF32x4Min = 0x9e;
// Compilation hint constants.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment