Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(249)

Unified Diff: src/objects-debug.cc

Issue 2431133003: Add more JSArray verification for --verify-heap (Closed)
Patch Set: maybe I get the casts right this time Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects-debug.cc
diff --git a/src/objects-debug.cc b/src/objects-debug.cc
index 179e92f21a3600054a335501344dd49b44ef47cb..071de9d155e0eb7934a4d3db4636d393f50c3bb8 100644
--- a/src/objects-debug.cc
+++ b/src/objects-debug.cc
@@ -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);
+ }
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698