Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_HEAP_H_ | 28 #ifndef V8_HEAP_H_ |
| 29 #define V8_HEAP_H_ | 29 #define V8_HEAP_H_ |
| 30 | 30 |
| 31 #include <math.h> | 31 #include <math.h> |
| 32 | 32 |
| 33 #include "globals.h" | |
| 34 #include "list.h" | |
| 33 #include "spaces.h" | 35 #include "spaces.h" |
| 34 #include "splay-tree-inl.h" | 36 #include "splay-tree-inl.h" |
| 35 #include "v8-counters.h" | 37 #include "v8-counters.h" |
| 36 | 38 |
| 37 namespace v8 { | 39 namespace v8 { |
| 38 namespace internal { | 40 namespace internal { |
| 39 | 41 |
| 40 | 42 |
| 41 // Defines all the roots in Heap. | 43 // Defines all the roots in Heap. |
| 42 #define UNCONDITIONAL_STRONG_ROOT_LIST(V) \ | 44 #define UNCONDITIONAL_STRONG_ROOT_LIST(V) \ |
| (...skipping 2102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2145 public: | 2147 public: |
| 2146 virtual ~WeakObjectRetainer() {} | 2148 virtual ~WeakObjectRetainer() {} |
| 2147 | 2149 |
| 2148 // Return whether this object should be retained. If NULL is returned the | 2150 // Return whether this object should be retained. If NULL is returned the |
| 2149 // object has no references. Otherwise the address of the retained object | 2151 // object has no references. Otherwise the address of the retained object |
| 2150 // should be returned as in some GC situations the object has been moved. | 2152 // should be returned as in some GC situations the object has been moved. |
| 2151 virtual Object* RetainAs(Object* object) = 0; | 2153 virtual Object* RetainAs(Object* object) = 0; |
| 2152 }; | 2154 }; |
| 2153 | 2155 |
| 2154 | 2156 |
| 2157 #if defined(DEBUG) || defined(LIVE_OBJECT_LIST) | |
| 2158 // Helper class for tracing paths to a search target Object from all roots. | |
| 2159 // The TracePathFrom() method can be used to trace paths from a specific | |
| 2160 // object to the search target object. | |
| 2161 class PathTracer : public ObjectVisitor { | |
| 2162 public: | |
| 2163 enum WhatToFind { | |
|
Søren Thygesen Gjesse
2011/02/22 08:13:24
Going forward we should try to use names if the fo
| |
| 2164 FIND_ALL, // Will find all matches. | |
| 2165 FIND_FIRST // Will stop the search after first match. | |
| 2166 }; | |
| 2167 | |
| 2168 // For the WhatToFind arg, if FIND_FIRST is specified, tracing will stop | |
| 2169 // after the first match. If FIND_ALL is specified, then tracing will be | |
| 2170 // done for all matches. | |
| 2171 PathTracer(Object* search_target, | |
| 2172 WhatToFind what_to_find, | |
| 2173 VisitMode visit_mode) | |
| 2174 : search_target_(search_target), | |
| 2175 found_target_(false), | |
| 2176 found_target_in_trace_(false), | |
| 2177 what_to_find_(what_to_find), | |
| 2178 visit_mode_(visit_mode), | |
| 2179 object_stack_(20), | |
| 2180 no_alloc() {} | |
| 2181 | |
| 2182 virtual void VisitPointers(Object** start, Object** end); | |
| 2183 | |
| 2184 void Reset(); | |
| 2185 void TracePathFrom(Object** root); | |
| 2186 | |
| 2187 bool found() const { return found_target_; } | |
| 2188 | |
| 2189 static Object* const kAnyGlobalObject; | |
| 2190 | |
| 2191 protected: | |
| 2192 class MarkVisitor; | |
| 2193 class UnmarkVisitor; | |
| 2194 | |
| 2195 void MarkRecursively(Object** p, MarkVisitor* mark_visitor); | |
| 2196 void UnmarkRecursively(Object** p, UnmarkVisitor* unmark_visitor); | |
| 2197 virtual void ProcessResults(); | |
| 2198 | |
| 2199 // Tags 0, 1, and 3 are used. Use 2 for marking visited HeapObject. | |
| 2200 static const int kMarkTag = 2; | |
| 2201 | |
| 2202 Object* search_target_; | |
| 2203 bool found_target_; | |
| 2204 bool found_target_in_trace_; | |
| 2205 WhatToFind what_to_find_; | |
| 2206 VisitMode visit_mode_; | |
| 2207 List<Object*> object_stack_; | |
| 2208 | |
| 2209 AssertNoAllocation no_alloc; // i.e. no gc allowed. | |
| 2210 | |
| 2211 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | |
| 2212 }; | |
| 2213 #endif // DEBUG || LIVE_OBJECT_LIST | |
| 2214 | |
| 2215 | |
| 2155 } } // namespace v8::internal | 2216 } } // namespace v8::internal |
| 2156 | 2217 |
| 2157 #endif // V8_HEAP_H_ | 2218 #endif // V8_HEAP_H_ |
| OLD | NEW |