Commit 8c057f17 authored by Jakob Kummerow's avatar Jakob Kummerow Committed by V8 LUCI CQ

[bigint] Define V8_ADVANCED_BIGINT_ALGORITHMS everywhere

It was previously only passed to compilation units in src/bigint/,
but inconsistencies arise when it's not passed to other compilation
units that #include src/bigint/bigint.h.

Fixed: chromium:1233397
Change-Id: Idb310d8c13bad12766699086574aa2c3869eb56c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3056452Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75941}
parent 8d3d0dbf
......@@ -621,8 +621,8 @@ config("external_config") {
defines += [ "USING_V8_SHARED" ]
}
if(current_cpu == "riscv64") {
libs = [ "atomic"]
if (current_cpu == "riscv64") {
libs = [ "atomic" ]
}
}
......@@ -926,6 +926,9 @@ config("features") {
if (v8_allocation_site_tracking) {
defines += [ "V8_ALLOCATION_SITE_TRACKING" ]
}
if (v8_advanced_bigint_algorithms) {
defines += [ "V8_ADVANCED_BIGINT_ALGORITHMS" ]
}
}
config("toolchain") {
......@@ -5012,8 +5015,6 @@ v8_source_set("v8_bigint") {
"src/bigint/mul-fft.cc",
"src/bigint/mul-toom.cc",
]
defines = [ "V8_ADVANCED_BIGINT_ALGORITHMS" ]
}
configs = [ ":internal_config" ]
......
......@@ -7,6 +7,15 @@
namespace v8 {
namespace bigint {
// Used for checking consistency between library and public header.
#if DEBUG
#if V8_ADVANCED_BIGINT_ALGORITHMS
bool kAdvancedAlgorithmsEnabledInLibrary = true;
#else
bool kAdvancedAlgorithmsEnabledInLibrary = false;
#endif // V8_ADVANCED_BIGINT_ALGORITHMS
#endif // DEBUG
ProcessorImpl::ProcessorImpl(Platform* platform) : platform_(platform) {}
ProcessorImpl::~ProcessorImpl() { delete platform_; }
......
......@@ -23,6 +23,8 @@ namespace bigint {
std::cerr << "Assertion failed: " #cond "\n"; \
abort(); \
}
extern bool kAdvancedAlgorithmsEnabledInLibrary;
#else
#define BIGINT_H_DCHECK(cond) (void(0))
#endif
......@@ -277,9 +279,13 @@ inline int MultiplyResultLength(Digits X, Digits Y) {
constexpr int kBarrettThreshold = 13310;
inline int DivideResultLength(Digits A, Digits B) {
#if V8_ADVANCED_BIGINT_ALGORITHMS
BIGINT_H_DCHECK(kAdvancedAlgorithmsEnabledInLibrary);
// The Barrett division algorithm needs one extra digit for temporary use.
int kBarrettExtraScratch = B.len() >= kBarrettThreshold ? 1 : 0;
#else
// If this fails, set -DV8_ADVANCED_BIGINT_ALGORITHMS in any compilation unit
// that #includes this header.
BIGINT_H_DCHECK(!kAdvancedAlgorithmsEnabledInLibrary);
constexpr int kBarrettExtraScratch = 0;
#endif
return A.len() - B.len() + 1 + kBarrettExtraScratch;
......
......@@ -22,8 +22,4 @@ v8_executable("bigint_shell") {
configs = [ "../..:internal_config_base" ]
sources = [ "bigint-shell.cc" ]
if (v8_advanced_bigint_algorithms) {
defines = [ "V8_ADVANCED_BIGINT_ALGORITHMS" ]
}
}
// 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.
// Regression test for crbug.com/1233397.
let y_power = 13311n * 64n; // Large enough to choose the Barrett algorithm.
// A couple of digits and a couple of intra-digit bits larger.
let x_power = y_power + 50n * 64n + 30n;
let x = 2n ** x_power;
let y = 2n ** y_power;
let q = x / y;
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