Commit 0909e5cc authored by cbruni's avatar cbruni Committed by Commit bot

Add more JSArray verification for --verify-heap

BUG=

Review-Url: https://codereview.chromium.org/2431133003
Cr-Commit-Position: refs/heads/master@{#40969}
parent 1c1edda7
......@@ -772,9 +772,26 @@ void JSArray::JSArrayVerify() {
CHECK(length()->IsNumber() || length()->IsUndefined(isolate));
// If a GC was caused while constructing this array, the elements
// pointer may point to a one pointer filler map.
if (ElementsAreSafeToExamine()) {
CHECK(elements()->IsUndefined(isolate) || elements()->IsFixedArray() ||
elements()->IsFixedDoubleArray());
if (!ElementsAreSafeToExamine()) return;
if (elements()->IsUndefined(isolate)) return;
CHECK(elements()->IsFixedArray() || elements()->IsFixedDoubleArray());
if (!length()->IsNumber()) return;
// Verify that the length and the elements backing store are in sync.
if (length()->IsSmi() && HasFastElements()) {
int size = Smi::cast(length())->value();
// Holey / Packed backing stores might have slack or might have not been
// properly initialized yet.
CHECK(size <= elements()->length() ||
elements() == isolate->heap()->empty_fixed_array());
} else {
CHECK(HasDictionaryElements());
uint32_t size;
CHECK(length()->ToArrayLength(&size));
if (size != 0) {
SeededNumberDictionary* dict = SeededNumberDictionary::cast(elements());
// The dictionary can never have more elements than the array length.
CHECK(static_cast<uint32_t>(dict->NumberOfElements()) <= size);
}
}
}
......
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