Commit 05c4801d authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[bigint] Check some invariants in BigIntVerify().

R=jkummerow@chromium.org

Bug: v8:6791
Change-Id: I50cf6418f382689559b33b2c5a218435373dec64
Reviewed-on: https://chromium-review.googlesource.com/666920
Commit-Queue: Georg Neis <neis@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48827}
parent 6f028d6a
......@@ -1214,7 +1214,13 @@ void AsyncGeneratorRequest::AsyncGeneratorRequestVerify() {
next()->ObjectVerify();
}
void BigInt::BigIntVerify() { CHECK(IsBigInt()); }
void BigInt::BigIntVerify() {
CHECK(IsBigInt());
CHECK_GE(length(), 0);
CHECK_IMPLIES(is_zero(), !sign()); // There is no -0n.
// TODO(neis): Somewhere check that MSD is non-zero. Doesn't hold during some
// operations that allocate which is why we can't test it here.
}
void JSModuleNamespace::JSModuleNamespaceVerify() {
CHECK(IsJSModuleNamespace());
......
......@@ -184,10 +184,8 @@ class V8_EXPORT_PRIVATE BigInt : public HeapObject {
inline digit_t digit(int n) const;
inline void set_digit(int n, digit_t value);
bool is_zero() {
DCHECK(length() > 0 || !sign()); // There is no -0n.
return length() == 0;
}
bool is_zero() const { return length() == 0; }
static const int kBitfieldOffset = HeapObject::kHeaderSize;
static const int kDigitsOffset = kBitfieldOffset + kPointerSize;
static const int kHeaderSize = kDigitsOffset;
......
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