| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 | 372 |
| 373 int post_gc_processing_count = 0; | 373 int post_gc_processing_count = 0; |
| 374 | 374 |
| 375 bool GlobalHandles::PostGarbageCollectionProcessing() { | 375 bool GlobalHandles::PostGarbageCollectionProcessing() { |
| 376 // Process weak global handle callbacks. This must be done after the | 376 // Process weak global handle callbacks. This must be done after the |
| 377 // GC is completely done, because the callbacks may invoke arbitrary | 377 // GC is completely done, because the callbacks may invoke arbitrary |
| 378 // API functions. | 378 // API functions. |
| 379 // At the same time deallocate all DESTROYED nodes. | 379 // At the same time deallocate all DESTROYED nodes. |
| 380 ASSERT(Heap::gc_state() == Heap::NOT_IN_GC); | 380 ASSERT(Heap::gc_state() == Heap::NOT_IN_GC); |
| 381 const int initial_post_gc_processing_count = ++post_gc_processing_count; | 381 const int initial_post_gc_processing_count = ++post_gc_processing_count; |
| 382 bool next_gc_could_collect_more = false; | 382 bool next_gc_likely_to_collect_more = false; |
| 383 Node** p = &head_; | 383 Node** p = &head_; |
| 384 while (*p != NULL) { | 384 while (*p != NULL) { |
| 385 if ((*p)->PostGarbageCollectionProcessing()) { | 385 if ((*p)->PostGarbageCollectionProcessing()) { |
| 386 if (initial_post_gc_processing_count != post_gc_processing_count) { | 386 if (initial_post_gc_processing_count != post_gc_processing_count) { |
| 387 // Weak callback triggered another GC and another round of | 387 // Weak callback triggered another GC and another round of |
| 388 // PostGarbageCollection processing. The current node might | 388 // PostGarbageCollection processing. The current node might |
| 389 // have been deleted in that round, so we need to bail out (or | 389 // have been deleted in that round, so we need to bail out (or |
| 390 // restart the processing). | 390 // restart the processing). |
| 391 break; | 391 break; |
| 392 } | 392 } |
| 393 } | 393 } |
| 394 if ((*p)->state_ == Node::DESTROYED) { | 394 if ((*p)->state_ == Node::DESTROYED) { |
| 395 // Delete the link. | 395 // Delete the link. |
| 396 Node* node = *p; | 396 Node* node = *p; |
| 397 *p = node->next(); // Update the link. | 397 *p = node->next(); // Update the link. |
| 398 if (first_deallocated()) { | 398 if (first_deallocated()) { |
| 399 first_deallocated()->set_next(node); | 399 first_deallocated()->set_next(node); |
| 400 } | 400 } |
| 401 node->set_next_free(first_deallocated()); | 401 node->set_next_free(first_deallocated()); |
| 402 set_first_deallocated(node); | 402 set_first_deallocated(node); |
| 403 next_gc_could_collect_more = true; | 403 next_gc_likely_to_collect_more = true; |
| 404 } else { | 404 } else { |
| 405 p = (*p)->next_addr(); | 405 p = (*p)->next_addr(); |
| 406 } | 406 } |
| 407 } | 407 } |
| 408 set_first_free(NULL); | 408 set_first_free(NULL); |
| 409 if (first_deallocated()) { | 409 if (first_deallocated()) { |
| 410 first_deallocated()->set_next(head()); | 410 first_deallocated()->set_next(head()); |
| 411 } | 411 } |
| 412 | 412 |
| 413 return next_gc_could_collect_more; | 413 return next_gc_likely_to_collect_more; |
| 414 } | 414 } |
| 415 | 415 |
| 416 | 416 |
| 417 void GlobalHandles::IterateStrongRoots(ObjectVisitor* v) { | 417 void GlobalHandles::IterateStrongRoots(ObjectVisitor* v) { |
| 418 // Traversal of global handles marked as NORMAL. | 418 // Traversal of global handles marked as NORMAL. |
| 419 for (Node* current = head_; current != NULL; current = current->next()) { | 419 for (Node* current = head_; current != NULL; current = current->next()) { |
| 420 if (current->state_ == Node::NORMAL) { | 420 if (current->state_ == Node::NORMAL) { |
| 421 v->VisitPointer(¤t->object_); | 421 v->VisitPointer(¤t->object_); |
| 422 } | 422 } |
| 423 } | 423 } |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 | 523 |
| 524 void GlobalHandles::RemoveObjectGroups() { | 524 void GlobalHandles::RemoveObjectGroups() { |
| 525 List<ObjectGroup*>* object_groups = ObjectGroups(); | 525 List<ObjectGroup*>* object_groups = ObjectGroups(); |
| 526 for (int i = 0; i< object_groups->length(); i++) { | 526 for (int i = 0; i< object_groups->length(); i++) { |
| 527 delete object_groups->at(i); | 527 delete object_groups->at(i); |
| 528 } | 528 } |
| 529 object_groups->Clear(); | 529 object_groups->Clear(); |
| 530 } | 530 } |
| 531 | 531 |
| 532 } } // namespace v8::internal | 532 } } // namespace v8::internal |
| OLD | NEW |