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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 current->state_ = Node::PENDING; | 365 current->state_ = Node::PENDING; |
366 LOG(HandleEvent("GlobalHandle::Pending", current->handle().location())); | 366 LOG(HandleEvent("GlobalHandle::Pending", current->handle().location())); |
367 } | 367 } |
368 } | 368 } |
369 } | 369 } |
370 } | 370 } |
371 | 371 |
372 | 372 |
373 int post_gc_processing_count = 0; | 373 int post_gc_processing_count = 0; |
374 | 374 |
375 void 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 Node** p = &head_; | 383 Node** p = &head_; |
383 while (*p != NULL) { | 384 while (*p != NULL) { |
384 if ((*p)->PostGarbageCollectionProcessing()) { | 385 if ((*p)->PostGarbageCollectionProcessing()) { |
385 if (initial_post_gc_processing_count != post_gc_processing_count) { | 386 if (initial_post_gc_processing_count != post_gc_processing_count) { |
386 // Weak callback triggered another GC and another round of | 387 // Weak callback triggered another GC and another round of |
387 // PostGarbageCollection processing. The current node might | 388 // PostGarbageCollection processing. The current node might |
388 // 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 |
389 // restart the processing). | 390 // restart the processing). |
390 break; | 391 break; |
391 } | 392 } |
392 } | 393 } |
393 if ((*p)->state_ == Node::DESTROYED) { | 394 if ((*p)->state_ == Node::DESTROYED) { |
394 // Delete the link. | 395 // Delete the link. |
395 Node* node = *p; | 396 Node* node = *p; |
396 *p = node->next(); // Update the link. | 397 *p = node->next(); // Update the link. |
397 if (first_deallocated()) { | 398 if (first_deallocated()) { |
398 first_deallocated()->set_next(node); | 399 first_deallocated()->set_next(node); |
399 } | 400 } |
400 node->set_next_free(first_deallocated()); | 401 node->set_next_free(first_deallocated()); |
401 set_first_deallocated(node); | 402 set_first_deallocated(node); |
| 403 next_gc_could_collect_more = true; |
402 } else { | 404 } else { |
403 p = (*p)->next_addr(); | 405 p = (*p)->next_addr(); |
404 } | 406 } |
405 } | 407 } |
406 set_first_free(NULL); | 408 set_first_free(NULL); |
407 if (first_deallocated()) { | 409 if (first_deallocated()) { |
408 first_deallocated()->set_next(head()); | 410 first_deallocated()->set_next(head()); |
409 } | 411 } |
| 412 |
| 413 return next_gc_could_collect_more; |
410 } | 414 } |
411 | 415 |
412 | 416 |
413 void GlobalHandles::IterateStrongRoots(ObjectVisitor* v) { | 417 void GlobalHandles::IterateStrongRoots(ObjectVisitor* v) { |
414 // Traversal of global handles marked as NORMAL. | 418 // Traversal of global handles marked as NORMAL. |
415 for (Node* current = head_; current != NULL; current = current->next()) { | 419 for (Node* current = head_; current != NULL; current = current->next()) { |
416 if (current->state_ == Node::NORMAL) { | 420 if (current->state_ == Node::NORMAL) { |
417 v->VisitPointer(¤t->object_); | 421 v->VisitPointer(¤t->object_); |
418 } | 422 } |
419 } | 423 } |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 | 523 |
520 void GlobalHandles::RemoveObjectGroups() { | 524 void GlobalHandles::RemoveObjectGroups() { |
521 List<ObjectGroup*>* object_groups = ObjectGroups(); | 525 List<ObjectGroup*>* object_groups = ObjectGroups(); |
522 for (int i = 0; i< object_groups->length(); i++) { | 526 for (int i = 0; i< object_groups->length(); i++) { |
523 delete object_groups->at(i); | 527 delete object_groups->at(i); |
524 } | 528 } |
525 object_groups->Clear(); | 529 object_groups->Clear(); |
526 } | 530 } |
527 | 531 |
528 } } // namespace v8::internal | 532 } } // namespace v8::internal |
OLD | NEW |