Index: src/heap.h |
=================================================================== |
--- src/heap.h (revision 6875) |
+++ src/heap.h (working copy) |
@@ -30,6 +30,8 @@ |
#include <math.h> |
+#include "globals.h" |
+#include "list.h" |
#include "spaces.h" |
#include "splay-tree-inl.h" |
#include "v8-counters.h" |
@@ -2152,6 +2154,65 @@ |
}; |
+#if defined(DEBUG) || defined(LIVE_OBJECT_LIST) |
+// Helper class for tracing paths to a search target Object from all roots. |
+// The TracePathFrom() method can be used to trace paths from a specific |
+// object to the search target object. |
+class PathTracer : public ObjectVisitor { |
+ public: |
+ enum WhatToFind { |
Søren Thygesen Gjesse
2011/02/22 08:13:24
Going forward we should try to use names if the fo
|
+ FIND_ALL, // Will find all matches. |
+ FIND_FIRST // Will stop the search after first match. |
+ }; |
+ |
+ // For the WhatToFind arg, if FIND_FIRST is specified, tracing will stop |
+ // after the first match. If FIND_ALL is specified, then tracing will be |
+ // done for all matches. |
+ PathTracer(Object* search_target, |
+ WhatToFind what_to_find, |
+ VisitMode visit_mode) |
+ : search_target_(search_target), |
+ found_target_(false), |
+ found_target_in_trace_(false), |
+ what_to_find_(what_to_find), |
+ visit_mode_(visit_mode), |
+ object_stack_(20), |
+ no_alloc() {} |
+ |
+ virtual void VisitPointers(Object** start, Object** end); |
+ |
+ void Reset(); |
+ void TracePathFrom(Object** root); |
+ |
+ bool found() const { return found_target_; } |
+ |
+ static Object* const kAnyGlobalObject; |
+ |
+ protected: |
+ class MarkVisitor; |
+ class UnmarkVisitor; |
+ |
+ void MarkRecursively(Object** p, MarkVisitor* mark_visitor); |
+ void UnmarkRecursively(Object** p, UnmarkVisitor* unmark_visitor); |
+ virtual void ProcessResults(); |
+ |
+ // Tags 0, 1, and 3 are used. Use 2 for marking visited HeapObject. |
+ static const int kMarkTag = 2; |
+ |
+ Object* search_target_; |
+ bool found_target_; |
+ bool found_target_in_trace_; |
+ WhatToFind what_to_find_; |
+ VisitMode visit_mode_; |
+ List<Object*> object_stack_; |
+ |
+ AssertNoAllocation no_alloc; // i.e. no gc allowed. |
+ |
+ DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
+}; |
+#endif // DEBUG || LIVE_OBJECT_LIST |
+ |
+ |
} } // namespace v8::internal |
#endif // V8_HEAP_H_ |