Commit d96463a2 authored by Jakob Kummerow's avatar Jakob Kummerow Committed by Commit Bot

[bigint] Implement BigIntShortPrint

For an improved debugging experience.

Bug: v8:6791
Change-Id: Id4f7fea47036e4520e7b24edf34f210b664672bc
Reviewed-on: https://chromium-review.googlesource.com/699427Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48272}
parent f701d99b
...@@ -3424,6 +3424,12 @@ void HeapObject::HeapObjectShortPrint(std::ostream& os) { // NOLINT ...@@ -3424,6 +3424,12 @@ void HeapObject::HeapObjectShortPrint(std::ostream& os) { // NOLINT
os << '>'; os << '>';
break; break;
} }
case BIGINT_TYPE: {
os << "<BigInt ";
BigInt::cast(this)->BigIntShortPrint(os);
os << ">";
break;
}
case JS_PROXY_TYPE: case JS_PROXY_TYPE:
os << "<JSProxy>"; os << "<JSProxy>";
break; break;
......
...@@ -196,6 +196,17 @@ void BigInt::Initialize(int length, bool zero_initialize) { ...@@ -196,6 +196,17 @@ void BigInt::Initialize(int length, bool zero_initialize) {
} }
} }
void BigInt::BigIntShortPrint(std::ostream& os) {
if (sign()) os << "-";
int len = length();
if (len == 0) {
os << "0";
return;
}
if (len > 1) os << "...";
os << digit(0);
}
// Private helpers for public methods. // Private helpers for public methods.
Handle<BigInt> BigInt::AbsoluteAdd(Handle<BigInt> x, Handle<BigInt> y, Handle<BigInt> BigInt::AbsoluteAdd(Handle<BigInt> x, Handle<BigInt> y,
......
...@@ -51,6 +51,7 @@ class BigInt : public HeapObject { ...@@ -51,6 +51,7 @@ class BigInt : public HeapObject {
DECL_CAST(BigInt) DECL_CAST(BigInt)
DECL_VERIFIER(BigInt) DECL_VERIFIER(BigInt)
DECL_PRINTER(BigInt) DECL_PRINTER(BigInt)
void BigIntShortPrint(std::ostream& os);
// TODO(jkummerow): Do we need {synchronized_length} for GC purposes? // TODO(jkummerow): Do we need {synchronized_length} for GC purposes?
DECL_INT_ACCESSORS(length) DECL_INT_ACCESSORS(length)
......
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