OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_HEAP_H_ | 5 #ifndef V8_HEAP_H_ |
6 #define V8_HEAP_H_ | 6 #define V8_HEAP_H_ |
7 | 7 |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "allocation.h" | 10 #include "allocation.h" |
(...skipping 2699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2710 // Helper class for tracing paths to a search target Object from all roots. | 2710 // Helper class for tracing paths to a search target Object from all roots. |
2711 // The TracePathFrom() method can be used to trace paths from a specific | 2711 // The TracePathFrom() method can be used to trace paths from a specific |
2712 // object to the search target object. | 2712 // object to the search target object. |
2713 class PathTracer : public ObjectVisitor { | 2713 class PathTracer : public ObjectVisitor { |
2714 public: | 2714 public: |
2715 enum WhatToFind { | 2715 enum WhatToFind { |
2716 FIND_ALL, // Will find all matches. | 2716 FIND_ALL, // Will find all matches. |
2717 FIND_FIRST // Will stop the search after first match. | 2717 FIND_FIRST // Will stop the search after first match. |
2718 }; | 2718 }; |
2719 | 2719 |
| 2720 // Tags 0, 1, and 3 are used. Use 2 for marking visited HeapObject. |
| 2721 static const int kMarkTag = 2; |
| 2722 |
2720 // For the WhatToFind arg, if FIND_FIRST is specified, tracing will stop | 2723 // For the WhatToFind arg, if FIND_FIRST is specified, tracing will stop |
2721 // after the first match. If FIND_ALL is specified, then tracing will be | 2724 // after the first match. If FIND_ALL is specified, then tracing will be |
2722 // done for all matches. | 2725 // done for all matches. |
2723 PathTracer(Object* search_target, | 2726 PathTracer(Object* search_target, |
2724 WhatToFind what_to_find, | 2727 WhatToFind what_to_find, |
2725 VisitMode visit_mode) | 2728 VisitMode visit_mode) |
2726 : search_target_(search_target), | 2729 : search_target_(search_target), |
2727 found_target_(false), | 2730 found_target_(false), |
2728 found_target_in_trace_(false), | 2731 found_target_in_trace_(false), |
2729 what_to_find_(what_to_find), | 2732 what_to_find_(what_to_find), |
(...skipping 11 matching lines...) Expand all Loading... |
2741 static Object* const kAnyGlobalObject; | 2744 static Object* const kAnyGlobalObject; |
2742 | 2745 |
2743 protected: | 2746 protected: |
2744 class MarkVisitor; | 2747 class MarkVisitor; |
2745 class UnmarkVisitor; | 2748 class UnmarkVisitor; |
2746 | 2749 |
2747 void MarkRecursively(Object** p, MarkVisitor* mark_visitor); | 2750 void MarkRecursively(Object** p, MarkVisitor* mark_visitor); |
2748 void UnmarkRecursively(Object** p, UnmarkVisitor* unmark_visitor); | 2751 void UnmarkRecursively(Object** p, UnmarkVisitor* unmark_visitor); |
2749 virtual void ProcessResults(); | 2752 virtual void ProcessResults(); |
2750 | 2753 |
2751 // Tags 0, 1, and 3 are used. Use 2 for marking visited HeapObject. | |
2752 static const int kMarkTag = 2; | |
2753 | |
2754 Object* search_target_; | 2754 Object* search_target_; |
2755 bool found_target_; | 2755 bool found_target_; |
2756 bool found_target_in_trace_; | 2756 bool found_target_in_trace_; |
2757 WhatToFind what_to_find_; | 2757 WhatToFind what_to_find_; |
2758 VisitMode visit_mode_; | 2758 VisitMode visit_mode_; |
2759 List<Object*> object_stack_; | 2759 List<Object*> object_stack_; |
2760 | 2760 |
2761 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. | 2761 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. |
2762 | 2762 |
2763 private: | 2763 private: |
2764 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2764 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
2765 }; | 2765 }; |
2766 #endif // DEBUG | 2766 #endif // DEBUG |
2767 | 2767 |
2768 } } // namespace v8::internal | 2768 } } // namespace v8::internal |
2769 | 2769 |
2770 #endif // V8_HEAP_H_ | 2770 #endif // V8_HEAP_H_ |
OLD | NEW |