OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
149 | 149 |
150 // Returns the current number of weak handles to global objects. | 150 // Returns the current number of weak handles to global objects. |
151 // These handles are also included in NumberOfWeakHandles(). | 151 // These handles are also included in NumberOfWeakHandles(). |
152 int NumberOfGlobalObjectWeakHandles(); | 152 int NumberOfGlobalObjectWeakHandles(); |
153 | 153 |
154 // Returns the current number of handles to global objects. | 154 // Returns the current number of handles to global objects. |
155 int global_handles_count() const { | 155 int global_handles_count() const { |
156 return number_of_global_handles_; | 156 return number_of_global_handles_; |
157 } | 157 } |
158 | 158 |
159 // Returns the current number of allocated blocks | |
160 int block_count() const { return number_of_blocks_; } | |
161 | |
159 // Clear the weakness of a global handle. | 162 // Clear the weakness of a global handle. |
160 static void ClearWeakness(Object** location); | 163 static void ClearWeakness(Object** location); |
161 | 164 |
162 // Clear the weakness of a global handle. | 165 // Clear the weakness of a global handle. |
163 static void MarkIndependent(Object** location); | 166 static void MarkIndependent(Object** location); |
164 | 167 |
165 // Mark the reference to this object externaly unreachable. | 168 // Mark the reference to this object externaly unreachable. |
166 static void MarkPartiallyDependent(Object** location); | 169 static void MarkPartiallyDependent(Object** location); |
167 | 170 |
168 static bool IsIndependent(Object** location); | 171 static bool IsIndependent(Object** location); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
268 void RemoveImplicitRefGroups(); | 271 void RemoveImplicitRefGroups(); |
269 | 272 |
270 // Tear down the global handle structure. | 273 // Tear down the global handle structure. |
271 void TearDown(); | 274 void TearDown(); |
272 | 275 |
273 Isolate* isolate() { return isolate_; } | 276 Isolate* isolate() { return isolate_; } |
274 | 277 |
275 #ifdef DEBUG | 278 #ifdef DEBUG |
276 void PrintStats(); | 279 void PrintStats(); |
277 void Print(); | 280 void Print(); |
281 void VerifyBlockInvariants(); | |
278 #endif | 282 #endif |
279 | 283 |
280 private: | 284 private: |
281 explicit GlobalHandles(Isolate* isolate); | 285 explicit GlobalHandles(Isolate* isolate); |
282 | 286 |
287 void SortBlocks(bool shouldPrune); | |
288 | |
283 // Migrates data from the internal representation (object_group_connections_, | 289 // Migrates data from the internal representation (object_group_connections_, |
284 // retainer_infos_ and implicit_ref_connections_) to the public and more | 290 // retainer_infos_ and implicit_ref_connections_) to the public and more |
285 // efficient representation (object_groups_ and implicit_ref_groups_). | 291 // efficient representation (object_groups_ and implicit_ref_groups_). |
286 void ComputeObjectGroupsAndImplicitReferences(); | 292 void ComputeObjectGroupsAndImplicitReferences(); |
287 | 293 |
288 // v8::internal::List is inefficient even for small number of elements, if we | 294 // v8::internal::List is inefficient even for small number of elements, if we |
289 // don't assign any initial capacity. | 295 // don't assign any initial capacity. |
290 static const int kObjectGroupConnectionsCapacity = 20; | 296 static const int kObjectGroupConnectionsCapacity = 20; |
291 | 297 |
292 // Internal node structures. | 298 // Internal node structures. |
293 class Node; | 299 class Node; |
294 class NodeBlock; | 300 class NodeBlock; |
295 class NodeIterator; | 301 class NodeIterator; |
302 class BlockListIterator; | |
303 // Base class for NodeBlock | |
304 class BlockList { | |
305 public: | |
306 BlockList(); | |
307 ~BlockList() { ASSERT(IsDetached()); } | |
308 void Detach(); | |
309 void InsertAsHead(BlockList* block) { | |
310 ASSERT(IsAnchor()); | |
311 InsertAsNext(block); | |
312 } | |
313 void InsertAsTail(BlockList* block) { | |
314 ASSERT(IsAnchor()); | |
315 prev_block_->InsertAsNext(block); | |
316 } | |
317 inline bool IsAnchor() { return first_free_ == NULL && used_nodes_ == 0; } | |
318 inline bool IsDetached() { | |
319 ASSERT_EQ(prev_block_ == this, next_block_ == this); | |
320 return prev_block_ == this; | |
321 } | |
322 bool HasAtLeastLength(int length); | |
323 bool IsUnused() { return used_nodes_ == 0; } | |
324 int used_nodes() const { return used_nodes_; } | |
325 BlockList* next() { return next_block_; } | |
326 BlockList* prev() { return prev_block_; } | |
327 #ifdef DEBUG | |
328 int LengthOfFreeList(); | |
Michael Starzinger
2013/08/02 11:59:51
nit: Indentation is off.
| |
329 #endif | |
330 static void SortBlocks(GlobalHandles* global_handles, bool prune); | |
331 | |
332 protected: | |
333 BlockList* prev_block_; | |
334 BlockList* next_block_; | |
335 Node* first_free_; | |
336 int used_nodes_; | |
337 | |
338 private: | |
339 // Needed for quicksort | |
340 static int CompareBlocks(const void* a, const void* b); | |
341 void InsertAsNext(BlockList* block); | |
342 DISALLOW_COPY_AND_ASSIGN(BlockList); | |
343 }; | |
296 | 344 |
297 Isolate* isolate_; | 345 Isolate* isolate_; |
298 | 346 |
347 // Field always containing the number of blocks allocated. | |
348 int number_of_blocks_; | |
299 // Field always containing the number of handles to global objects. | 349 // Field always containing the number of handles to global objects. |
300 int number_of_global_handles_; | 350 int number_of_global_handles_; |
301 | 351 |
302 // List of all allocated node blocks. | 352 // Anchors for doubly linked lists of blocks |
303 NodeBlock* first_block_; | 353 BlockList full_blocks_; |
304 | 354 BlockList non_full_blocks_; |
305 // List of node blocks with used nodes. | |
306 NodeBlock* first_used_block_; | |
307 | |
308 // Free list of nodes. | |
309 Node* first_free_; | |
310 | 355 |
311 // Contains all nodes holding new space objects. Note: when the list | 356 // Contains all nodes holding new space objects. Note: when the list |
312 // is accessed, some of the objects may have been promoted already. | 357 // is accessed, some of the objects may have been promoted already. |
313 List<Node*> new_space_nodes_; | 358 List<Node*> new_space_nodes_; |
314 | 359 |
315 int post_gc_processing_count_; | 360 int post_gc_processing_count_; |
316 | 361 |
317 // Object groups and implicit references, public and more efficient | 362 // Object groups and implicit references, public and more efficient |
318 // representation. | 363 // representation. |
319 List<ObjectGroup*> object_groups_; | 364 List<ObjectGroup*> object_groups_; |
320 List<ImplicitRefGroup*> implicit_ref_groups_; | 365 List<ImplicitRefGroup*> implicit_ref_groups_; |
321 | 366 |
322 // Object groups and implicit references, temporary representation while | 367 // Object groups and implicit references, temporary representation while |
323 // constructing the groups. | 368 // constructing the groups. |
324 List<ObjectGroupConnection> object_group_connections_; | 369 List<ObjectGroupConnection> object_group_connections_; |
325 List<ObjectGroupRetainerInfo> retainer_infos_; | 370 List<ObjectGroupRetainerInfo> retainer_infos_; |
326 List<ObjectGroupConnection> implicit_ref_connections_; | 371 List<ObjectGroupConnection> implicit_ref_connections_; |
327 | 372 |
328 friend class Isolate; | 373 friend class Isolate; |
329 | 374 |
330 DISALLOW_COPY_AND_ASSIGN(GlobalHandles); | 375 DISALLOW_COPY_AND_ASSIGN(GlobalHandles); |
331 }; | 376 }; |
332 | 377 |
333 | 378 |
334 } } // namespace v8::internal | 379 } } // namespace v8::internal |
335 | 380 |
336 #endif // V8_GLOBAL_HANDLES_H_ | 381 #endif // V8_GLOBAL_HANDLES_H_ |
OLD | NEW |