| 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 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 } | 460 } |
| 461 | 461 |
| 462 | 462 |
| 463 void GlobalHandles::IterateWeakRoots(ObjectVisitor* v) { | 463 void GlobalHandles::IterateWeakRoots(ObjectVisitor* v) { |
| 464 for (NodeIterator it(this); !it.done(); it.Advance()) { | 464 for (NodeIterator it(this); !it.done(); it.Advance()) { |
| 465 if (it.node()->IsWeakRetainer()) v->VisitPointer(it.node()->location()); | 465 if (it.node()->IsWeakRetainer()) v->VisitPointer(it.node()->location()); |
| 466 } | 466 } |
| 467 } | 467 } |
| 468 | 468 |
| 469 | 469 |
| 470 void GlobalHandles::IterateNewSpaceWeakIndependentRoots(ObjectVisitor* v) { | |
| 471 for (int i = 0; i < new_space_nodes_.length(); ++i) { | |
| 472 Node* node = new_space_nodes_[i]; | |
| 473 ASSERT(node->is_in_new_space_list()); | |
| 474 if (node->is_independent() && node->IsWeakRetainer()) { | |
| 475 v->VisitPointer(node->location()); | |
| 476 } | |
| 477 } | |
| 478 } | |
| 479 | |
| 480 | |
| 481 void GlobalHandles::IterateWeakRoots(WeakReferenceGuest f, | 470 void GlobalHandles::IterateWeakRoots(WeakReferenceGuest f, |
| 482 WeakReferenceCallback callback) { | 471 WeakReferenceCallback callback) { |
| 483 for (NodeIterator it(this); !it.done(); it.Advance()) { | 472 for (NodeIterator it(this); !it.done(); it.Advance()) { |
| 484 if (it.node()->IsWeak() && it.node()->callback() == callback) { | 473 if (it.node()->IsWeak() && it.node()->callback() == callback) { |
| 485 f(it.node()->object(), it.node()->parameter()); | 474 f(it.node()->object(), it.node()->parameter()); |
| 486 } | 475 } |
| 487 } | 476 } |
| 488 } | 477 } |
| 489 | 478 |
| 490 | 479 |
| 491 void GlobalHandles::IdentifyWeakHandles(WeakSlotCallback f) { | 480 void GlobalHandles::IdentifyWeakHandles(WeakSlotCallback f) { |
| 492 for (NodeIterator it(this); !it.done(); it.Advance()) { | 481 for (NodeIterator it(this); !it.done(); it.Advance()) { |
| 493 if (it.node()->IsWeak() && f(it.node()->location())) { | 482 if (it.node()->IsWeak() && f(it.node()->location())) { |
| 494 it.node()->MarkPending(); | 483 it.node()->MarkPending(); |
| 495 } | 484 } |
| 496 } | 485 } |
| 497 } | 486 } |
| 498 | 487 |
| 499 | 488 |
| 489 void GlobalHandles::IterateNewSpaceStrongAndDependentRoots(ObjectVisitor* v) { |
| 490 for (int i = 0; i < new_space_nodes_.length(); ++i) { |
| 491 Node* node = new_space_nodes_[i]; |
| 492 if (node->IsStrongRetainer() || |
| 493 (node->IsWeakRetainer() && !node->is_independent())) { |
| 494 v->VisitPointer(node->location()); |
| 495 } |
| 496 } |
| 497 } |
| 498 |
| 499 |
| 500 void GlobalHandles::IdentifyNewSpaceWeakIndependentHandles( | 500 void GlobalHandles::IdentifyNewSpaceWeakIndependentHandles( |
| 501 WeakSlotCallbackWithHeap f) { | 501 WeakSlotCallbackWithHeap f) { |
| 502 for (int i = 0; i < new_space_nodes_.length(); ++i) { | 502 for (int i = 0; i < new_space_nodes_.length(); ++i) { |
| 503 Node* node = new_space_nodes_[i]; | 503 Node* node = new_space_nodes_[i]; |
| 504 ASSERT(node->is_in_new_space_list()); | 504 ASSERT(node->is_in_new_space_list()); |
| 505 if (node->is_independent() && node->IsWeak() && | 505 if (node->is_independent() && node->IsWeak() && |
| 506 f(isolate_->heap(), node->location())) { | 506 f(isolate_->heap(), node->location())) { |
| 507 node->MarkPending(); | 507 node->MarkPending(); |
| 508 } | 508 } |
| 509 } | 509 } |
| 510 } | 510 } |
| 511 | 511 |
| 512 | 512 |
| 513 void GlobalHandles::IterateNewSpaceWeakIndependentRoots(ObjectVisitor* v) { |
| 514 for (int i = 0; i < new_space_nodes_.length(); ++i) { |
| 515 Node* node = new_space_nodes_[i]; |
| 516 ASSERT(node->is_in_new_space_list()); |
| 517 if (node->is_independent() && node->IsWeakRetainer()) { |
| 518 v->VisitPointer(node->location()); |
| 519 } |
| 520 } |
| 521 } |
| 522 |
| 523 |
| 513 bool GlobalHandles::PostGarbageCollectionProcessing( | 524 bool GlobalHandles::PostGarbageCollectionProcessing( |
| 514 GarbageCollector collector) { | 525 GarbageCollector collector) { |
| 515 // Process weak global handle callbacks. This must be done after the | 526 // Process weak global handle callbacks. This must be done after the |
| 516 // GC is completely done, because the callbacks may invoke arbitrary | 527 // GC is completely done, because the callbacks may invoke arbitrary |
| 517 // API functions. | 528 // API functions. |
| 518 ASSERT(isolate_->heap()->gc_state() == Heap::NOT_IN_GC); | 529 ASSERT(isolate_->heap()->gc_state() == Heap::NOT_IN_GC); |
| 519 const int initial_post_gc_processing_count = ++post_gc_processing_count_; | 530 const int initial_post_gc_processing_count = ++post_gc_processing_count_; |
| 520 bool next_gc_likely_to_collect_more = false; | 531 bool next_gc_likely_to_collect_more = false; |
| 521 if (collector == SCAVENGER) { | 532 if (collector == SCAVENGER) { |
| 522 for (int i = 0; i < new_space_nodes_.length(); ++i) { | 533 for (int i = 0; i < new_space_nodes_.length(); ++i) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 | 590 |
| 580 void GlobalHandles::IterateAllRoots(ObjectVisitor* v) { | 591 void GlobalHandles::IterateAllRoots(ObjectVisitor* v) { |
| 581 for (NodeIterator it(this); !it.done(); it.Advance()) { | 592 for (NodeIterator it(this); !it.done(); it.Advance()) { |
| 582 if (it.node()->IsRetainer()) { | 593 if (it.node()->IsRetainer()) { |
| 583 v->VisitPointer(it.node()->location()); | 594 v->VisitPointer(it.node()->location()); |
| 584 } | 595 } |
| 585 } | 596 } |
| 586 } | 597 } |
| 587 | 598 |
| 588 | 599 |
| 589 void GlobalHandles::IterateNewSpaceStrongAndDependentRoots(ObjectVisitor* v) { | |
| 590 for (int i = 0; i < new_space_nodes_.length(); ++i) { | |
| 591 Node* node = new_space_nodes_[i]; | |
| 592 if (node->IsStrongRetainer() || | |
| 593 (node->IsWeakRetainer() && !node->is_independent())) { | |
| 594 v->VisitPointer(node->location()); | |
| 595 } | |
| 596 } | |
| 597 } | |
| 598 | |
| 599 | |
| 600 void GlobalHandles::IterateAllRootsWithClassIds(ObjectVisitor* v) { | 600 void GlobalHandles::IterateAllRootsWithClassIds(ObjectVisitor* v) { |
| 601 for (NodeIterator it(this); !it.done(); it.Advance()) { | 601 for (NodeIterator it(this); !it.done(); it.Advance()) { |
| 602 if (it.node()->has_wrapper_class_id() && it.node()->IsRetainer()) { | 602 if (it.node()->has_wrapper_class_id() && it.node()->IsRetainer()) { |
| 603 v->VisitEmbedderReference(it.node()->location(), | 603 v->VisitEmbedderReference(it.node()->location(), |
| 604 it.node()->wrapper_class_id()); | 604 it.node()->wrapper_class_id()); |
| 605 } | 605 } |
| 606 } | 606 } |
| 607 } | 607 } |
| 608 | 608 |
| 609 | 609 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 implicit_ref_groups_.Clear(); | 712 implicit_ref_groups_.Clear(); |
| 713 } | 713 } |
| 714 | 714 |
| 715 | 715 |
| 716 void GlobalHandles::TearDown() { | 716 void GlobalHandles::TearDown() { |
| 717 // TODO(1428): invoke weak callbacks. | 717 // TODO(1428): invoke weak callbacks. |
| 718 } | 718 } |
| 719 | 719 |
| 720 | 720 |
| 721 } } // namespace v8::internal | 721 } } // namespace v8::internal |
| OLD | NEW |