v8/test/mjsunit/compiler/bigint-divide.js
Qifan Pan 6fb86b9788 [turbofan] Support BigIntDivide
Bug: v8:9407
Change-Id: I29f8f5ec68f09e8631b59d3a6a2926bab3b3bcd3
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3845638
Reviewed-by: Nico Hartmann <nicohartmann@chromium.org>
Commit-Queue: Qifan Pan <panq@google.com>
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82741}
2022-08-26 08:51:36 +00:00

47 lines
1.0 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 OptimizeAndTest() {
function fn(a, b) {
return a / b;
}
%PrepareFunctionForOptimization(fn);
assertEquals(0n, fn(3n, 4n));
assertEquals(3n, fn(3n, 1n));
assertEquals(4n, fn(30n, 7n));
%OptimizeFunctionOnNextCall(fn);
assertEquals(0n, fn(3n, 4n));
assertEquals(3n, fn(3n, 1n));
assertEquals(4n, fn(30n, 7n));
assertOptimized(fn);
assertEquals(5, fn(30, 6));
assertUnoptimized(fn);
}
function OptimizeAndTestDivZero() {
function fn(a, b) {
return a / b;
}
%PrepareFunctionForOptimization(fn);
assertEquals(0n, fn(3n, 4n));
assertEquals(4n, fn(30n, 7n));
%OptimizeFunctionOnNextCall(fn);
assertEquals(4n, fn(30n, 7n));
assertOptimized(fn);
assertThrows(() => fn(3n, 0n), RangeError);
assertUnoptimized(fn);
}
OptimizeAndTest();
OptimizeAndTestDivZero();