OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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_GLOBAL_HANDLES_H_ | 5 #ifndef V8_GLOBAL_HANDLES_H_ |
6 #define V8_GLOBAL_HANDLES_H_ | 6 #define V8_GLOBAL_HANDLES_H_ |
7 | 7 |
8 #include "include/v8.h" | 8 #include "include/v8.h" |
9 #include "include/v8-profiler.h" | 9 #include "include/v8-profiler.h" |
10 | 10 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 // embedder gets a null pointer instead. | 106 // embedder gets a null pointer instead. |
107 PHANTOM_WEAK, | 107 PHANTOM_WEAK, |
108 PHANTOM_WEAK_2_INTERNAL_FIELDS, | 108 PHANTOM_WEAK_2_INTERNAL_FIELDS, |
109 // The handle is automatically reset by the garbage collector when | 109 // The handle is automatically reset by the garbage collector when |
110 // the object is no longer reachable. | 110 // the object is no longer reachable. |
111 PHANTOM_WEAK_RESET_HANDLE | 111 PHANTOM_WEAK_RESET_HANDLE |
112 }; | 112 }; |
113 | 113 |
114 class GlobalHandles { | 114 class GlobalHandles { |
115 public: | 115 public: |
| 116 enum IterationMode { |
| 117 HANDLE_PHANTOM_NODES_VISIT_OTHERS, |
| 118 VISIT_OTHERS, |
| 119 HANDLE_PHANTOM_NODES |
| 120 }; |
| 121 |
116 ~GlobalHandles(); | 122 ~GlobalHandles(); |
117 | 123 |
118 // Creates a new global handle that is alive until Destroy is called. | 124 // Creates a new global handle that is alive until Destroy is called. |
119 Handle<Object> Create(Object* value); | 125 Handle<Object> Create(Object* value); |
120 | 126 |
121 // Copy a global handle | 127 // Copy a global handle |
122 static Handle<Object> CopyGlobal(Object** location); | 128 static Handle<Object> CopyGlobal(Object** location); |
123 | 129 |
124 // Destroy a global handle. | 130 // Destroy a global handle. |
125 static void Destroy(Object** location); | 131 static void Destroy(Object** location); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 // See the note above. | 226 // See the note above. |
221 void IterateNewSpaceWeakIndependentRoots(ObjectVisitor* v); | 227 void IterateNewSpaceWeakIndependentRoots(ObjectVisitor* v); |
222 | 228 |
223 // Finds weak independent or unmodified handles satisfying | 229 // Finds weak independent or unmodified handles satisfying |
224 // the callback predicate and marks them as pending. See the note above. | 230 // the callback predicate and marks them as pending. See the note above. |
225 void MarkNewSpaceWeakUnmodifiedObjectsPending( | 231 void MarkNewSpaceWeakUnmodifiedObjectsPending( |
226 WeakSlotCallbackWithHeap is_unscavenged); | 232 WeakSlotCallbackWithHeap is_unscavenged); |
227 | 233 |
228 // Iterates over weak independent or unmodified handles. | 234 // Iterates over weak independent or unmodified handles. |
229 // See the note above. | 235 // See the note above. |
| 236 template <IterationMode mode> |
230 void IterateNewSpaceWeakUnmodifiedRoots(ObjectVisitor* v); | 237 void IterateNewSpaceWeakUnmodifiedRoots(ObjectVisitor* v); |
231 | 238 |
232 // Identify unmodified objects that are in weak state and marks them | 239 // Identify unmodified objects that are in weak state and marks them |
233 // unmodified | 240 // unmodified |
234 void IdentifyWeakUnmodifiedObjects(WeakSlotCallback is_unmodified); | 241 void IdentifyWeakUnmodifiedObjects(WeakSlotCallback is_unmodified); |
235 | 242 |
236 // Iterate over objects in object groups that have at least one object | 243 // Iterate over objects in object groups that have at least one object |
237 // which requires visiting. The callback has to return true if objects | 244 // which requires visiting. The callback has to return true if objects |
238 // can be skipped and false otherwise. | 245 // can be skipped and false otherwise. |
239 bool IterateObjectGroups(ObjectVisitor* v, WeakSlotCallbackWithHeap can_skip); | 246 bool IterateObjectGroups(ObjectVisitor* v, WeakSlotCallbackWithHeap can_skip); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 void RemoveImplicitRefGroups(); | 290 void RemoveImplicitRefGroups(); |
284 | 291 |
285 // Tear down the global handle structure. | 292 // Tear down the global handle structure. |
286 void TearDown(); | 293 void TearDown(); |
287 | 294 |
288 Isolate* isolate() { return isolate_; } | 295 Isolate* isolate() { return isolate_; } |
289 | 296 |
290 #ifdef DEBUG | 297 #ifdef DEBUG |
291 void PrintStats(); | 298 void PrintStats(); |
292 void Print(); | 299 void Print(); |
293 #endif | 300 #endif // DEBUG |
294 | 301 |
295 private: | 302 private: |
296 explicit GlobalHandles(Isolate* isolate); | 303 explicit GlobalHandles(Isolate* isolate); |
297 | 304 |
298 // Migrates data from the internal representation (object_group_connections_, | 305 // Migrates data from the internal representation (object_group_connections_, |
299 // retainer_infos_ and implicit_ref_connections_) to the public and more | 306 // retainer_infos_ and implicit_ref_connections_) to the public and more |
300 // efficient representation (object_groups_ and implicit_ref_groups_). | 307 // efficient representation (object_groups_ and implicit_ref_groups_). |
301 void ComputeObjectGroupsAndImplicitReferences(); | 308 void ComputeObjectGroupsAndImplicitReferences(); |
302 | 309 |
303 // v8::internal::List is inefficient even for small number of elements, if we | 310 // v8::internal::List is inefficient even for small number of elements, if we |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 int singleton_handles_[NUMBER_OF_SINGLETON_HANDLES]; | 460 int singleton_handles_[NUMBER_OF_SINGLETON_HANDLES]; |
454 | 461 |
455 DISALLOW_COPY_AND_ASSIGN(EternalHandles); | 462 DISALLOW_COPY_AND_ASSIGN(EternalHandles); |
456 }; | 463 }; |
457 | 464 |
458 | 465 |
459 } // namespace internal | 466 } // namespace internal |
460 } // namespace v8 | 467 } // namespace v8 |
461 | 468 |
462 #endif // V8_GLOBAL_HANDLES_H_ | 469 #endif // V8_GLOBAL_HANDLES_H_ |
OLD | NEW |