3cbe36a753
Using uint8_t[] causes decay to pointer issue, which manifests in copying garbage values in the call to WriteLittleEndianValue. Change it to use a std::array, which doesn't have the decaying behavior. Also add a regression test from comment#6 of the linked bug. Bug: v8:10731 Change-Id: I4a1ca69fe99806642e9931625ca7aeab6663f955 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2316465 Reviewed-by: Clemens Backes <clemensb@chromium.org> Reviewed-by: Bill Budge <bbudge@chromium.org> Commit-Queue: Zhi An Ng <zhin@chromium.org> Cr-Commit-Position: refs/heads/master@{#69052}
38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
// Copyright 2020 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: --experimental-wasm-simd
|
|
|
|
load("test/mjsunit/wasm/wasm-module-builder.js");
|
|
|
|
// Test for S128 global with initialization.
|
|
// This checks for a bug in copying the immediate values from the
|
|
// initialization expression into the globals area of the module.
|
|
(function TestS128() {
|
|
var builder = new WasmModuleBuilder();
|
|
var g = builder.addGlobal(kWasmS128);
|
|
g.init = [1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0];
|
|
|
|
// Check that all lanes have the right values by creating 4 functions that
|
|
// extract each lane.
|
|
function addGetFunction(i) {
|
|
builder.addFunction(`get${i}`, kSig_i_v)
|
|
.addBody([
|
|
kExprGlobalGet, g.index,
|
|
kSimdPrefix, kExprI32x4ExtractLane, i])
|
|
.exportAs(`get${i}`);
|
|
}
|
|
|
|
for (let i = 0; i < 4; i++) {
|
|
addGetFunction(i);
|
|
}
|
|
|
|
var instance = builder.instantiate();
|
|
|
|
for (let i = 0; i < 4; i++) {
|
|
// get0 will get lane0, which has value 1
|
|
assertEquals(i+1, instance.exports[`get${i}`]());
|
|
}
|
|
})();
|