v8/test/mjsunit/wasm/liftoff-simd-params.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

78 lines
3.3 KiB
JavaScript
Raw Normal View History

Reland "[wasm-simd][liftoff] Add S128 case for stack movements" This relands commit 5cfe053e4520df021c1c70c1a3fe8962011ebd87. Original change's description: > [wasm-simd][liftoff] Add S128 case for stack movements > > The two cases we are fixing here are Construct and > LoadCallerFrameSlot, which are closely related. > > Construct is called during PrepareCall, where we build up > LiftoffStackSlots when we need to move an arg from caller's stack frame > into callee's stack frame. LoadCallerFrameSlot is the parallel to > this, called in ProcessParameter during decoding of the callee's > function body. > > In most cases, Construct needs a new case to handle kWasmS128, and calls > the relevant assembler to push a s128 onto the stack. > > ARM64 requires 16-byte alignment of sp, so we need to Claim the right > number of kXRegSize slots first, which requires > us traversing the list of slots to figure out how many s128 values there > are. This is a straightforward way to fix this, if efficiency is a > problem, we can change LiftOffStackSlots::Add to sum up the slot sizes. > > On IA32, pushing s128 values will require 4 calls to push. Instead, we > use a sub and two movdqu, which will generate less code in most cases. > > On x64, there is no 128-bit push, so we call push twice. > > Bug: v8:9909 > Change-Id: I3af35b8462ea9c3b9b2d90800c37d11b5e95be59 > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2015945 > Commit-Queue: Zhi An Ng <zhin@chromium.org> > Reviewed-by: Clemens Backes <clemensb@chromium.org> > Cr-Commit-Position: refs/heads/master@{#65956} Bug: v8:9909 Change-Id: Icdaead289abe13faf75bb9e049929f7fd7c59a08 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2036760 Commit-Queue: Zhi An Ng <zhin@chromium.org> Reviewed-by: Clemens Backes <clemensb@chromium.org> Cr-Commit-Position: refs/heads/master@{#66119}
2020-02-04 17:43:04 +00:00
// 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
d8.file.execute('test/mjsunit/wasm/wasm-module-builder.js');
Reland "[wasm-simd][liftoff] Add S128 case for stack movements" This relands commit 5cfe053e4520df021c1c70c1a3fe8962011ebd87. Original change's description: > [wasm-simd][liftoff] Add S128 case for stack movements > > The two cases we are fixing here are Construct and > LoadCallerFrameSlot, which are closely related. > > Construct is called during PrepareCall, where we build up > LiftoffStackSlots when we need to move an arg from caller's stack frame > into callee's stack frame. LoadCallerFrameSlot is the parallel to > this, called in ProcessParameter during decoding of the callee's > function body. > > In most cases, Construct needs a new case to handle kWasmS128, and calls > the relevant assembler to push a s128 onto the stack. > > ARM64 requires 16-byte alignment of sp, so we need to Claim the right > number of kXRegSize slots first, which requires > us traversing the list of slots to figure out how many s128 values there > are. This is a straightforward way to fix this, if efficiency is a > problem, we can change LiftOffStackSlots::Add to sum up the slot sizes. > > On IA32, pushing s128 values will require 4 calls to push. Instead, we > use a sub and two movdqu, which will generate less code in most cases. > > On x64, there is no 128-bit push, so we call push twice. > > Bug: v8:9909 > Change-Id: I3af35b8462ea9c3b9b2d90800c37d11b5e95be59 > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2015945 > Commit-Queue: Zhi An Ng <zhin@chromium.org> > Reviewed-by: Clemens Backes <clemensb@chromium.org> > Cr-Commit-Position: refs/heads/master@{#65956} Bug: v8:9909 Change-Id: Icdaead289abe13faf75bb9e049929f7fd7c59a08 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2036760 Commit-Queue: Zhi An Ng <zhin@chromium.org> Reviewed-by: Clemens Backes <clemensb@chromium.org> Cr-Commit-Position: refs/heads/master@{#66119}
2020-02-04 17:43:04 +00:00
// This test case tries to exercise SIMD stack to stack movements by creating
// a function that has many parameters.
(function() {
const builder = new WasmModuleBuilder();
// At this point we have limited support for SIMD operations, but we can load
// and store s128 values. So this memory will be used for reading and writing
// s128 values and we will assert expected values from JS.
builder.addImportedMemory('m', 'imported_mem', 1, 2);
builder.addType(makeSig(new Array(18).fill(kWasmS128), []));
builder.addFunction(undefined, makeSig([], []))
.addLocals(kWasmS128, 9)
Reland "[wasm-simd][liftoff] Add S128 case for stack movements" This relands commit 5cfe053e4520df021c1c70c1a3fe8962011ebd87. Original change's description: > [wasm-simd][liftoff] Add S128 case for stack movements > > The two cases we are fixing here are Construct and > LoadCallerFrameSlot, which are closely related. > > Construct is called during PrepareCall, where we build up > LiftoffStackSlots when we need to move an arg from caller's stack frame > into callee's stack frame. LoadCallerFrameSlot is the parallel to > this, called in ProcessParameter during decoding of the callee's > function body. > > In most cases, Construct needs a new case to handle kWasmS128, and calls > the relevant assembler to push a s128 onto the stack. > > ARM64 requires 16-byte alignment of sp, so we need to Claim the right > number of kXRegSize slots first, which requires > us traversing the list of slots to figure out how many s128 values there > are. This is a straightforward way to fix this, if efficiency is a > problem, we can change LiftOffStackSlots::Add to sum up the slot sizes. > > On IA32, pushing s128 values will require 4 calls to push. Instead, we > use a sub and two movdqu, which will generate less code in most cases. > > On x64, there is no 128-bit push, so we call push twice. > > Bug: v8:9909 > Change-Id: I3af35b8462ea9c3b9b2d90800c37d11b5e95be59 > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2015945 > Commit-Queue: Zhi An Ng <zhin@chromium.org> > Reviewed-by: Clemens Backes <clemensb@chromium.org> > Cr-Commit-Position: refs/heads/master@{#65956} Bug: v8:9909 Change-Id: Icdaead289abe13faf75bb9e049929f7fd7c59a08 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2036760 Commit-Queue: Zhi An Ng <zhin@chromium.org> Reviewed-by: Clemens Backes <clemensb@chromium.org> Cr-Commit-Position: refs/heads/master@{#66119}
2020-02-04 17:43:04 +00:00
.addBodyWithEnd([
// These will all be args to the callee.
// Load first arg from memory, this was written with values from JS.
kExprI32Const, 0, // i32.const
kSimdPrefix, kExprS128LoadMem, 0, 0, // s128.load
kExprLocalGet, 0, // local.get
kExprLocalGet, 1, // local.get
kExprLocalGet, 2, // local.get
kExprLocalGet, 3, // local.get
kExprLocalGet, 4, // local.get
kExprLocalGet, 5, // local.get
kExprLocalGet, 6, // local.get
kExprLocalGet, 7, // local.get
kExprLocalGet, 8, // local.get
kExprLocalGet, 0, // local.get
kExprLocalGet, 1, // local.get
kExprLocalGet, 2, // local.get
kExprLocalGet, 3, // local.get
kExprLocalGet, 4, // local.get
kExprLocalGet, 5, // local.get
kExprLocalGet, 6, // local.get
// Load last s128 from memory, this was written with values from JS.
kExprI32Const, 16, // i32.const
kSimdPrefix, kExprS128LoadMem, 0, 0, // s128.load
kExprCallFunction, 0x01, // call
kExprEnd, // end
]);
builder.addFunction(undefined, 0 /* sig */).addBodyWithEnd([
kExprI32Const, 32, // i32.const
kExprLocalGet, 0, // local.get
kSimdPrefix, kExprS128StoreMem, 0, 0, // s128.store
kExprI32Const, 48, // i32.const
kExprLocalGet, 17, // local.get
kSimdPrefix, kExprS128StoreMem, 0, 0, // s128.store
kExprEnd, // end
]);
builder.addExport('main', 0);
var memory = new WebAssembly.Memory({initial: 1, maximum: 2});
const instance = builder.instantiate({m: {imported_mem: memory}});
// We write sentinel values to two s128 values at the start of the memory.
// Function 1 will read these values from memory, and pass them as the first
// and last arg to function 2. Function 2 then write these values to memory
// after these two s128 values.
const arr = new Uint32Array(memory.buffer);
for (let i = 0; i < 8; i++) {
arr[0] = i * 2;
}
instance.exports.main();
for (let i = 0; i < 8; i++) {
assertEquals(arr[i], arr[i + 8]);
}
})();