Commit 5a318a23 authored by Ilya Rezvov's avatar Ilya Rezvov Committed by V8 LUCI CQ

Port Generic JS-Wasm Wrapper for arm64

Bug: v8:10701
Change-Id: I2014f8994c74379663998e2560d1d51b98a4a9a6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3811834Reviewed-by: 's avatarJakob Linke <jgruber@chromium.org>
Commit-Queue: Ilya Rezvov <irezvov@chromium.org>
Reviewed-by: 's avatarThibaud Michaud <thibaudm@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82915}
parent a3f4caa0
This diff is collapsed.
......@@ -2842,59 +2842,35 @@ void TurboAssembler::Prologue() {
void TurboAssembler::EnterFrame(StackFrame::Type type) {
UseScratchRegisterScope temps(this);
if (type == StackFrame::INTERNAL
#if V8_ENABLE_WEBASSEMBLY
|| type == StackFrame::WASM_DEBUG_BREAK
#endif // V8_ENABLE_WEBASSEMBLY
) {
Register type_reg = temps.AcquireX();
Mov(type_reg, StackFrame::TypeToMarker(type));
Push<TurboAssembler::kSignLR>(lr, fp, type_reg, padreg);
const int kFrameSize =
TypedFrameConstants::kFixedFrameSizeFromFp + kSystemPointerSize;
Add(fp, sp, kFrameSize);
// sp[3] : lr
// sp[2] : fp
// sp[1] : type
// sp[0] : for alignment
#if V8_ENABLE_WEBASSEMBLY
} else if (type == StackFrame::WASM ||
type == StackFrame::WASM_COMPILE_LAZY ||
type == StackFrame::WASM_EXIT) {
Register type_reg = temps.AcquireX();
Mov(type_reg, StackFrame::TypeToMarker(type));
Push<TurboAssembler::kSignLR>(lr, fp);
Mov(fp, sp);
Push(type_reg, kWasmInstanceRegister);
// sp[3] : lr
// sp[2] : fp
// sp[1] : type
// sp[0] : wasm instance
#endif // V8_ENABLE_WEBASSEMBLY
} else if (type == StackFrame::CONSTRUCT) {
Register type_reg = temps.AcquireX();
Mov(type_reg, StackFrame::TypeToMarker(type));
// Users of this frame type push a context pointer after the type field,
// so do it here to keep the stack pointer aligned.
Push<TurboAssembler::kSignLR>(lr, fp, type_reg, cp);
// The context pointer isn't part of the fixed frame, so add an extra slot
// to account for it.
Add(fp, sp,
TypedFrameConstants::kFixedFrameSizeFromFp + kSystemPointerSize);
// sp[3] : lr
// sp[2] : fp
// sp[1] : type
// sp[0] : cp
} else {
DCHECK(StackFrame::IsJavaScript(type));
if (StackFrame::IsJavaScript(type)) {
// Just push a minimal "machine frame", saving the frame pointer and return
// address, without any markers.
Push<TurboAssembler::kSignLR>(lr, fp);
Mov(fp, sp);
// sp[1] : lr
// sp[0] : fp
} else {
Register type_reg = temps.AcquireX();
Mov(type_reg, StackFrame::TypeToMarker(type));
Register fourth_reg = no_reg;
if (type == StackFrame::CONSTRUCT) {
fourth_reg = cp;
#if V8_ENABLE_WEBASSEMBLY
} else if (type == StackFrame::WASM ||
type == StackFrame::WASM_COMPILE_LAZY ||
type == StackFrame::WASM_EXIT) {
fourth_reg = kWasmInstanceRegister;
#endif // V8_ENABLE_WEBASSEMBLY
} else {
fourth_reg = padreg;
}
Push<TurboAssembler::kSignLR>(lr, fp, type_reg, fourth_reg);
static constexpr int kSPToFPDelta = 2 * kSystemPointerSize;
Add(fp, sp, kSPToFPDelta);
// sp[3] : lr
// sp[2] : fp
// sp[1] : type
// sp[0] : cp | wasm instance | for alignment
}
}
......
......@@ -959,6 +959,10 @@ DEFINE_VALUE_IMPLICATION(optimize_for_size, max_semi_space_size, size_t{1})
DEFINE_BOOL(wasm_generic_wrapper, true,
"allow use of the generic js-to-wasm wrapper instead of "
"per-signature wrappers")
DEFINE_BOOL(enable_wasm_arm64_generic_wrapper, false,
"allow use of the generic js-to-wasm wrapper instead of "
"per-signature wrappers on arm64")
DEFINE_WEAK_IMPLICATION(future, enable_wasm_arm64_generic_wrapper)
DEFINE_BOOL(expose_wasm, true, "expose wasm interface to JavaScript")
DEFINE_INT(wasm_num_compilation_tasks, 128,
"maximum number of parallel compilation tasks for wasm")
......
......@@ -169,7 +169,12 @@ void WasmCompilationUnit::CompileWasmFunction(Isolate* isolate,
namespace {
bool UseGenericWrapper(const FunctionSig* sig) {
#if V8_TARGET_ARCH_X64
#if V8_TARGET_ARCH_ARM64
if (!v8_flags.enable_wasm_arm64_generic_wrapper) {
return false;
}
#endif
#if (V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64)
if (sig->returns().size() > 1) {
return false;
}
......
......@@ -17,7 +17,7 @@ namespace test_run_wasm_wrappers {
using testing::CompileAndInstantiateForTesting;
#ifdef V8_TARGET_ARCH_X64
#if (V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64)
namespace {
Handle<WasmInstanceObject> CompileModule(Zone* zone, Isolate* isolate,
WasmModuleBuilder* builder) {
......@@ -69,6 +69,9 @@ TEST(WrapperBudget) {
// This test assumes use of the generic wrapper.
FlagScope<bool> use_wasm_generic_wrapper(&v8_flags.wasm_generic_wrapper,
true);
FlagScope<bool> use_enable_wasm_arm64_generic_wrapper(
&v8_flags.enable_wasm_arm64_generic_wrapper,
true);
// Initialize the environment and create a module builder.
AccountingAllocator allocator;
......@@ -116,6 +119,9 @@ TEST(WrapperReplacement) {
// This test assumes use of the generic wrapper.
FlagScope<bool> use_wasm_generic_wrapper(&v8_flags.wasm_generic_wrapper,
true);
FlagScope<bool> use_enable_wasm_arm64_generic_wrapper(
&v8_flags.enable_wasm_arm64_generic_wrapper,
true);
// Initialize the environment and create a module builder.
AccountingAllocator allocator;
......@@ -185,6 +191,9 @@ TEST(EagerWrapperReplacement) {
// This test assumes use of the generic wrapper.
FlagScope<bool> use_wasm_generic_wrapper(&v8_flags.wasm_generic_wrapper,
true);
FlagScope<bool> use_enable_wasm_arm64_generic_wrapper(
&v8_flags.enable_wasm_arm64_generic_wrapper,
true);
// Initialize the environment and create a module builder.
AccountingAllocator allocator;
......@@ -290,6 +299,9 @@ TEST(WrapperReplacement_IndirectExport) {
// This test assumes use of the generic wrapper.
FlagScope<bool> use_wasm_generic_wrapper(&v8_flags.wasm_generic_wrapper,
true);
FlagScope<bool> use_enable_wasm_arm64_generic_wrapper(
&v8_flags.enable_wasm_arm64_generic_wrapper,
true);
// Initialize the environment and create a module builder.
AccountingAllocator allocator;
......
......@@ -3,6 +3,7 @@
// found in the LICENSE file.
// Flags: --wasm-generic-wrapper --expose-gc --allow-natives-syntax
// Flags: --enable-wasm-arm64-generic-wrapper
d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
......
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