Commit 26e21fa6 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[bigint] Increase maximum length.

In a benchmark that I'm looking at, the numbers quickly overflow our
current limit.

This patch increases kMaxLength to the greatest value that's possible
without requiring further code changes.

Bug: v8:6791
Change-Id: I7a0d126dcd566d536375a294fa4dcf10b8823ed7
Reviewed-on: https://chromium-review.googlesource.com/833876
Commit-Queue: Georg Neis <neis@chromium.org>
Reviewed-by: 's avatarHannes Payer <hpayer@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50240}
parent aefc8a31
......@@ -3495,13 +3495,14 @@ void LargeObjectSpace::Verify() {
// We have only code, sequential strings, external strings (sequential
// strings that have been morphed into external strings), thin strings
// (sequential strings that have been morphed into thin strings), fixed
// arrays, fixed double arrays, byte arrays, feedback vectors and free space
// (right after allocation) in the large object space.
// arrays, fixed double arrays, byte arrays, feedback vectors, bigints and
// free space (right after allocation) in the large object space.
CHECK(object->IsAbstractCode() || object->IsSeqString() ||
object->IsExternalString() || object->IsThinString() ||
object->IsFixedArray() || object->IsFixedDoubleArray() ||
object->IsPropertyArray() || object->IsByteArray() ||
object->IsFeedbackVector() || object->IsFreeSpace());
object->IsFeedbackVector() || object->IsBigInt() ||
object->IsFreeSpace());
// The object itself should look OK.
object->ObjectVerify();
......
......@@ -24,14 +24,11 @@ class BigIntBase : public HeapObject {
return LengthBits::decode(static_cast<uint32_t>(bitfield));
}
// The maximum kMaxLength that the current implementation supports would be
// kMaxInt / kDigitBits. However, we use a lower limit for now, because
// raising it later is easier than lowering it.
// Support up to 1 million bits.
static const int kMaxLengthBits = 1024 * 1024;
// Increasing kMaxLength will require code changes.
static const int kMaxLengthBits = kMaxInt - kPointerSize * kBitsPerByte - 1;
static const int kMaxLength = kMaxLengthBits / (kPointerSize * kBitsPerByte);
static const int kLengthFieldBits = 20;
static const int kLengthFieldBits = 30;
STATIC_ASSERT(kMaxLength <= ((1 << kLengthFieldBits) - 1));
class LengthBits : public BitField<int, 0, kLengthFieldBits> {};
class SignBits : public BitField<bool, LengthBits::kNext, 1> {};
......
......@@ -40,4 +40,4 @@ assertEquals(81n, (-3n) ** 4n);
assertEquals(-243n, (-3n) ** 5n);
assertThrows(() => 3n ** -2n, RangeError); // Negative exponent.
assertThrows(() => 2n ** (1024n ** 3n), RangeError); // Too big.
assertThrows(() => 2n ** (1024n ** 4n), RangeError); // Too big.
// Copyright 2017 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: --harmony-bigint
const MAX_BIGINT_BITS = 1024 * 1024; // Matches BigInt::kMaxLengthBits
const MAX_BIGINT_CHARS = MAX_BIGINT_BITS / 4;
const TOO_MANY_ONES = Array(MAX_BIGINT_CHARS + 2).join("1") + "n";
const tooBigHex = "0x" + TOO_MANY_ONES;
assertThrows(tooBigHex, SyntaxError);
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