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