Commit 78f8cb23 authored by Qifan Pan's avatar Qifan Pan Committed by V8 LUCI CQ

[TurboFan] Avoid temporary BigInt objects for wasm calls with i64 arguments

Bug: v8:9407
Change-Id: Id7a04bbdd795bd91a62f3984b760a7f42db96a7f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3803225Reviewed-by: 's avatarNico Hartmann <nicohartmann@chromium.org>
Commit-Queue: Qifan Pan <panq@google.com>
Cr-Commit-Position: refs/heads/main@{#82307}
parent 6953b555
......@@ -2001,7 +2001,7 @@ class RepresentationSelector {
case wasm::kI32:
return UseInfo::CheckedNumberOrOddballAsWord32(feedback);
case wasm::kI64:
return UseInfo::AnyTagged();
return UseInfo::CheckedBigIntTruncatingWord64(feedback);
case wasm::kF32:
case wasm::kF64:
// For Float32, TruncateFloat64ToFloat32 will be inserted later in
......
......@@ -123,8 +123,8 @@ JSWasmCallData::JSWasmCallData(const wasm::FunctionSig* wasm_signature)
wasm::kI64) {
arg_needs_conversion_.resize(wasm_signature->parameter_count());
for (size_t i = 0; i < wasm_signature->parameter_count(); i++) {
wasm::ValueType type = wasm_signature->GetParam(i);
arg_needs_conversion_[i] = type.kind() == wasm::kI64;
// TODO(panq): Remove JSWasmCallData if conversion is not needed anymore
arg_needs_conversion_[i] = false;
}
}
......
......@@ -490,6 +490,7 @@
'wasm/grow-huge-memory': [SKIP],
'wasm/huge-memory': [SKIP],
'wasm/huge-typedarray': [SKIP],
'wasm/bigint-opt': [SKIP],
}], # 'arch in (ia32, arm, mips, mipsel, riscv32)'
##############################################################################
......@@ -1354,6 +1355,7 @@
# which in turn can lead to different deopt behavior.
'compiler/number-abs': [SKIP],
'compiler/number-toboolean': [SKIP],
'wasm/bigint-opt': [SKIP],
}], # variant == assert_types
##############################################################################
......@@ -1539,6 +1541,7 @@
# Skip baseline for no-lazy-feedback-allocation
['variant == no_lfa or variant == stress_concurrent_inlining', {
'baseline/*': [SKIP],
'wasm/bigint-opt': [SKIP],
}], # variant == no_lfa or variant == stress_concurrent_inlining
##############################################################################
......@@ -1790,4 +1793,10 @@
'shared-memory/*': [SKIP],
}], # 'no_js_shared_memory'
##############################################################################
['variant == always_sparkplug', {
# Tests that rely on turbofan
'wasm/bigint-opt': [SKIP],
}], # variant == always_sparkplug
]
// Copyright 2022 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: --allow-natives-syntax --turbofan --no-always-turbofan --turbo-inline-js-wasm-calls
d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
let builder = new WasmModuleBuilder();
builder
.addFunction("f", kSig_v_l) // i64 -> ()
.addBody([])
.exportFunc();
let module = builder.instantiate();
function TestBigIntTruncatedToWord64(x) {
return module.exports.f(x + x);
}
let bi = (2n ** (2n ** 29n + 2n ** 29n - 1n));
// Expect BigIntTooBig for adding bi to itself
assertThrows(() => TestBigIntTruncatedToWord64(bi), RangeError);
%PrepareFunctionForOptimization(TestBigIntTruncatedToWord64);
TestBigIntTruncatedToWord64(1n);
TestBigIntTruncatedToWord64(2n);
%OptimizeFunctionOnNextCall(TestBigIntTruncatedToWord64);
// After optimization, bi should be checked as BigInt and
// truncated to Word64, which is then passed to Int64Add.
// Thus no BigIntTooBig exception is expected.
TestBigIntTruncatedToWord64(bi);
assertOptimized(TestBigIntTruncatedToWord64);
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