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 { | |
|
mnaganov (inactive)
2011/02/21 18:08:28
nit: space needed after PathTracer
marklam
2011/02/22 03:11:15
Done. I've seen this done both ways throughout th
| |
| 2162 public: | |
| 2163 enum WhatToFind { | |
| 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, | |
|
mnaganov (inactive)
2011/02/21 18:08:28
I have an idea about constructor args. Create a co
marklam
2011/02/22 03:11:15
Done.
| |
| 2172 bool search_for_any_global, | |
| 2173 WhatToFind what_to_find, | |
| 2174 bool skip_weak_refs) | |
|
mnaganov (inactive)
2011/02/21 18:08:28
Excuse me for being annoying but I would prefer us
marklam
2011/02/22 03:11:15
Done. Sorry for missing this one the first time a
| |
| 2175 : search_target_(search_target), | |
| 2176 search_for_any_global_(search_for_any_global), | |
| 2177 found_target_(false), | |
| 2178 found_target_in_trace_(false), | |
| 2179 what_to_find_(what_to_find), | |
| 2180 skip_weak_refs_(skip_weak_refs), | |
| 2181 object_stack_(20), | |
| 2182 no_alloc() {} | |
| 2183 | |
| 2184 void VisitPointers(Object** start, Object** end) { | |
|
mnaganov (inactive)
2011/02/21 18:08:28
Does this method need to be inline?
marklam
2011/02/22 03:11:15
Done. This is a virtual method override (and I th
mnaganov (inactive)
2011/02/22 10:12:01
I'm just against having too much code in .h file.
| |
| 2185 bool done = ((what_to_find_ == FIND_FIRST) && found_target_); | |
| 2186 // Visit all HeapObject pointers in [start, end) | |
| 2187 for (Object** p = start; !done && (p < end); p++) { | |
| 2188 if ((*p)->IsHeapObject()) { | |
| 2189 TracePathFrom(p); | |
| 2190 done = ((what_to_find_ == FIND_FIRST) && found_target_); | |
| 2191 } | |
| 2192 } | |
| 2193 } | |
| 2194 | |
| 2195 void Reset() { | |
|
mnaganov (inactive)
2011/02/21 18:08:28
Does this method need to be inline?
marklam
2011/02/22 03:11:15
Done. It doesn't have to be, but I figured it was
| |
| 2196 found_target_ = false; | |
| 2197 object_stack_.Clear(); | |
| 2198 } | |
| 2199 void TracePathFrom(Object** root); | |
| 2200 | |
| 2201 bool found() const { return found_target_; } | |
| 2202 | |
| 2203 protected: | |
|
mnaganov (inactive)
2011/02/21 18:08:28
I'd prefer to use 'private:' in all cases, except
marklam
2011/02/22 03:11:15
I do intend for this class to be subclassed. That
mnaganov (inactive)
2011/02/22 10:12:01
OK, I just wanted to be sure. Sorry, I forgot the
| |
| 2204 class MarkVisitor; | |
| 2205 class UnmarkVisitor; | |
| 2206 | |
| 2207 void MarkRecursively(Object** p, MarkVisitor* mark_visitor); | |
| 2208 void UnmarkRecursively(Object** p, UnmarkVisitor* unmark_visitor); | |
| 2209 virtual void ProcessResults(); | |
| 2210 | |
| 2211 // Tags 0, 1, and 3 are used. Use 2 for marking visited HeapObject. | |
| 2212 static const int kMarkTag = 2; | |
| 2213 | |
| 2214 Object* search_target_; | |
| 2215 bool search_for_any_global_; | |
| 2216 bool found_target_; | |
| 2217 bool found_target_in_trace_; | |
| 2218 WhatToFind what_to_find_; | |
| 2219 bool skip_weak_refs_; | |
| 2220 List<Object*> object_stack_; | |
| 2221 | |
| 2222 AssertNoAllocation no_alloc; // i.e. no gc allowed. | |
| 2223 | |
| 2224 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | |
| 2225 }; | |
| 2226 #endif // DEBUG || LIVE_OBJECT_LIST | |
| 2227 | |
| 2228 | |
| 2155 } } // namespace v8::internal | 2229 } } // namespace v8::internal |
| 2156 | 2230 |
| 2157 #endif // V8_HEAP_H_ | 2231 #endif // V8_HEAP_H_ |
| OLD | NEW |