v8/test/mjsunit/compiler/fast-api-sequences-x64.js
Maya Lekova 66856bacdc Reland "[fastcall] Implement support for TypedArray arguments"
This is a reland of 84d5b027a7

It removes support for 8-byte types which were causing
unaligned reads.

Original change's description:
> [fastcall] Implement support for TypedArray arguments
>
> This CL adds TypedArrays as supported arguments for fast API calls.
> It implements "exact type" matching, i.e. if Float32Array is expected
> and e.g. Int32Array is passed instead, the generated code bails to the
> slow callback.
>
> Bug: chromium:1052746, chromium:1018624
> Change-Id: I01d4e681d2b367cbb57b06effcb591c090a23295
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2999094
> Commit-Queue: Maya Lekova <mslekova@chromium.org>
> Reviewed-by: Georg Neis <neis@chromium.org>
> Reviewed-by: Camillo Bruni <cbruni@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#75756}

Bug: chromium:1052746, chromium:1018624
Change-Id: I872716d95bde8c340cf04990a3e4ae8ec8cd74a2
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3035090
Reviewed-by: Georg Neis <neis@chromium.org>
Reviewed-by: Camillo Bruni <cbruni@chromium.org>
Commit-Queue: Maya Lekova <mslekova@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75877}
2021-07-23 09:19:04 +00:00

56 lines
2.0 KiB
JavaScript

// Copyright 2021 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.
// This file adds x64 specific tests to the ones in fast-api-sequence.js.
// Flags: --turbo-fast-api-calls --allow-natives-syntax --opt
// --always-opt is disabled because we rely on particular feedback for
// optimizing to the fastest path.
// Flags: --no-always-opt
// The test relies on optimizing/deoptimizing at predictable moments, so
// it's not suitable for deoptimization fuzzing.
// Flags: --deopt-every-n-times=0
d8.file.execute('test/mjsunit/compiler/fast-api-helpers.js');
const fast_c_api = new d8.test.FastCAPI();
assertTrue(fast_c_api.supports_fp_params);
(function () {
const max_safe_float = 2 ** 24 - 1;
const add_all_result = -42 + 45 +
Number.MIN_SAFE_INTEGER + Number.MAX_SAFE_INTEGER +
max_safe_float * 0.5 + Math.PI;
function add_all_sequence() {
const arr = [-42, 45,
Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER,
max_safe_float * 0.5, Math.PI];
return fast_c_api.add_all_sequence(false /* should_fallback */, arr);
}
ExpectFastCall(add_all_sequence, add_all_result);
})();
const max_safe_as_bigint = BigInt(Number.MAX_SAFE_INTEGER);
(function () {
function int64_test(should_fallback = false) {
let typed_array = new BigInt64Array([-42n, 1n, max_safe_as_bigint]);
return fast_c_api.add_all_int64_typed_array(false /* should_fallback */,
typed_array);
}
const expected = Number(BigInt.asIntN(64, -42n + 1n + max_safe_as_bigint));
ExpectSlowCall(int64_test, expected);
})();
(function () {
function uint64_test(should_fallback = false) {
let typed_array = new BigUint64Array([max_safe_as_bigint, 1n, 2n]);
return fast_c_api.add_all_uint64_typed_array(false /* should_fallback */,
typed_array);
}
const expected = Number(BigInt.asUintN(64, max_safe_as_bigint + 1n + 2n));
ExpectSlowCall(uint64_test, expected);
})();