v8/test/mjsunit/compiler/bigint-bitwise-and.js
Qifan Pan d7efb9632c [turbofan] Support BigIntBitwiseAnd
Bug: v8:9407
Change-Id: I159b2ce338ab55d8171b0892a6942c9a5144d632
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3842156
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Qifan Pan <panq@google.com>
Reviewed-by: Nico Hartmann <nicohartmann@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82622}
2022-08-22 12:56:18 +00:00

36 lines
1.1 KiB
JavaScript

// 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
function TestBitwiseAnd(a, b) {
return a & b;
}
function OptimizeAndTest(fn) {
%PrepareFunctionForOptimization(fn);
assertEquals(0b1000n, fn(0b1100n, 0b1010n));
assertEquals(-0b1000n, fn(-0b100n, -0b110n));
assertEquals(0b1000n, fn(-0b100n, 0b1010n));
assertEquals(0b1000n, fn(0b1100n, -0b110n));
// The result grows out of one digit
assertEquals(-(2n ** 64n), fn(-(2n ** 63n + 1n), -(2n ** 63n)));
%OptimizeFunctionOnNextCall(fn);
fn(0b1100n, 0b1010n);
assertOptimized(fn);
assertEquals(0b1000n, fn(0b1100n, 0b1010n));
assertEquals(-0b1000n, fn(-0b100n, -0b110n));
assertEquals(0b1000n, fn(-0b100n, 0b1010n));
assertEquals(0b1000n, fn(0b1100n, -0b110n));
// The result grows out of one digit
assertEquals(-(2n ** 64n), fn(-(2n ** 63n + 1n), -(2n ** 63n)));
assertEquals(0b1000, fn(0b1100, 0b1010));
assertUnoptimized(fn);
}
OptimizeAndTest(TestBitwiseAnd);