[bigint] Implement BigIntShortPrint

For an improved debugging experience.

Bug: v8:6791
Change-Id: Id4f7fea47036e4520e7b24edf34f210b664672bc
Reviewed-on: https://chromium-review.googlesource.com/699427
Reviewed-by: Adam Klein <adamk@chromium.org>
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48272}
This commit is contained in:
Jakob Kummerow 2017-10-03 16:07:50 -07:00 committed by Commit Bot
parent f701d99ba9
commit d96463a2bf
3 changed files with 18 additions and 0 deletions

View File

@ -3424,6 +3424,12 @@ void HeapObject::HeapObjectShortPrint(std::ostream& os) { // NOLINT
os << '>';
break;
}
case BIGINT_TYPE: {
os << "<BigInt ";
BigInt::cast(this)->BigIntShortPrint(os);
os << ">";
break;
}
case JS_PROXY_TYPE:
os << "<JSProxy>";
break;

View File

@ -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.
Handle<BigInt> BigInt::AbsoluteAdd(Handle<BigInt> x, Handle<BigInt> y,

View File

@ -51,6 +51,7 @@ class BigInt : public HeapObject {
DECL_CAST(BigInt)
DECL_VERIFIER(BigInt)
DECL_PRINTER(BigInt)
void BigIntShortPrint(std::ostream& os);
// TODO(jkummerow): Do we need {synchronized_length} for GC purposes?
DECL_INT_ACCESSORS(length)