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

Unified Diff: src/objects-debug.cc

Issue 879273004: Verify that code stubs and full code do not have pointers that can retain (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add comment Created 5 years, 11 months 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 | « src/objects.h ('k') | 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 a8cbe9cf153dd91d01a6e20a02f006648f83cb06..c31a79d08fe87c813f46ad7bd425e3cafc8e9088 100644
--- a/src/objects-debug.cc
+++ b/src/objects-debug.cc
@@ -1236,20 +1236,41 @@ bool TransitionArray::IsConsistentWithBackPointers(Map* current_map) {
}
-void Code::VerifyEmbeddedObjectsInFullCode() {
- // Check that no context-specific object has been embedded.
+// Estimates if there is a path from the object to a context.
+// This function is not precise, and can return false even if
+// there is a path to a context.
+bool CanLeak(Object* obj, Heap* heap, bool skip_weak_cell) {
+ if (!obj->IsHeapObject()) return false;
+ if (obj->IsWeakCell()) {
+ if (skip_weak_cell) return false;
+ return CanLeak(WeakCell::cast(obj)->value(), heap, skip_weak_cell);
+ }
+ if (obj->IsCell()) {
+ return CanLeak(Cell::cast(obj)->value(), heap, skip_weak_cell);
+ }
+ if (obj->IsPropertyCell()) {
+ return CanLeak(PropertyCell::cast(obj)->value(), heap, skip_weak_cell);
+ }
+ if (obj->IsContext()) return true;
+ if (obj->IsMap()) {
+ Map* map = Map::cast(obj);
+ for (int i = 0; i < Heap::kStrongRootListLength; i++) {
+ if (map == heap->roots_array_start()[i]) return false;
+ }
+ return true;
+ }
+ return CanLeak(HeapObject::cast(obj)->map(), heap, skip_weak_cell);
+}
+
+
+void Code::VerifyEmbeddedObjects(VerifyMode mode) {
+ if (kind() == OPTIMIZED_FUNCTION) return;
Heap* heap = GetIsolate()->heap();
- int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
+ int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) |
+ RelocInfo::ModeMask(RelocInfo::CELL);
+ bool skip_weak_cell = (mode == kNoContextSpecificPointers) ? false : true;
for (RelocIterator it(this, mask); !it.done(); it.next()) {
- Object* obj = it.rinfo()->target_object();
- if (obj->IsCell()) obj = Cell::cast(obj)->value();
- if (obj->IsPropertyCell()) obj = PropertyCell::cast(obj)->value();
- if (!obj->IsHeapObject()) continue;
- Map* map = obj->IsMap() ? Map::cast(obj) : HeapObject::cast(obj)->map();
- int i = 0;
- while (map != heap->roots_array_start()[i++]) {
- CHECK_LT(i, Heap::kStrongRootListLength);
- }
+ CHECK(!CanLeak(it.rinfo()->target_object(), heap, skip_weak_cell));
}
}
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698