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

[bigint] Fix length of '0' sequences in fast .toString()

Bug: v8:11515
Change-Id: I1353726c9e81c3601258202fe56c05ffd16a4a25
Fixed: chromium:1232733
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3054112Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75927}
parent 14941067
...@@ -425,7 +425,7 @@ char* ToStringFormatter::ProcessLevel(RecursionLevel* level, Digits chunk, ...@@ -425,7 +425,7 @@ char* ToStringFormatter::ProcessLevel(RecursionLevel* level, Digits chunk,
// Fill up with zeros up to the character count expected to be generated // Fill up with zeros up to the character count expected to be generated
// on this level; unless this is the left edge of the result. // on this level; unless this is the left edge of the result.
if (is_last_on_level) return out; if (is_last_on_level) return out;
int chunk_chars = level == nullptr ? chunk_chars_ : level->char_count_; int chunk_chars = level == nullptr ? chunk_chars_ : level->char_count_ * 2;
char* end = prev_cursor - chunk_chars; char* end = prev_cursor - chunk_chars;
while (out != end) { while (out != end) {
*(--out) = '0'; *(--out) = '0';
......
// 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/1232733
let big = 10n ** 900n;
let expected = "1" + "0".repeat(900);
assertEquals(expected, big.toString());
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