OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 #include "src/global-handles.h" | 5 #include "src/global-handles.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 #include "src/vm-state-inl.h" | 9 #include "src/vm-state-inl.h" |
10 | 10 |
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 for (int i = 0; i < new_space_nodes_.length(); ++i) { | 712 for (int i = 0; i < new_space_nodes_.length(); ++i) { |
713 Node* node = new_space_nodes_[i]; | 713 Node* node = new_space_nodes_[i]; |
714 DCHECK(node->is_in_new_space_list()); | 714 DCHECK(node->is_in_new_space_list()); |
715 if ((node->is_independent() || !node->is_active()) && node->IsWeak() && | 715 if ((node->is_independent() || !node->is_active()) && node->IsWeak() && |
716 is_unscavenged(isolate_->heap(), node->location())) { | 716 is_unscavenged(isolate_->heap(), node->location())) { |
717 node->MarkPending(); | 717 node->MarkPending(); |
718 } | 718 } |
719 } | 719 } |
720 } | 720 } |
721 | 721 |
722 | 722 template <GlobalHandles::IterationMode mode> |
723 void GlobalHandles::IterateNewSpaceWeakUnmodifiedRoots(ObjectVisitor* v) { | 723 void GlobalHandles::IterateNewSpaceWeakUnmodifiedRoots(ObjectVisitor* v) { |
724 for (int i = 0; i < new_space_nodes_.length(); ++i) { | 724 for (int i = 0; i < new_space_nodes_.length(); ++i) { |
725 Node* node = new_space_nodes_[i]; | 725 Node* node = new_space_nodes_[i]; |
726 DCHECK(node->is_in_new_space_list()); | 726 DCHECK(node->is_in_new_space_list()); |
727 if ((node->is_independent() || !node->is_active()) && | 727 if ((node->is_independent() || !node->is_active()) && |
728 node->IsWeakRetainer()) { | 728 node->IsWeakRetainer()) { |
729 // Pending weak phantom handles die immediately. Everything else survives. | 729 // Pending weak phantom handles die immediately. Everything else survives. |
730 if (node->IsPendingPhantomResetHandle()) { | 730 if (node->IsPendingPhantomResetHandle()) { |
731 node->ResetPhantomHandle(); | 731 if (mode == IterationMode::HANDLE_PHANTOM_NODES || |
732 ++number_of_phantom_handle_resets_; | 732 mode == IterationMode::HANDLE_PHANTOM_NODES_VISIT_OTHERS) { |
| 733 node->ResetPhantomHandle(); |
| 734 ++number_of_phantom_handle_resets_; |
| 735 } |
733 } else if (node->IsPendingPhantomCallback()) { | 736 } else if (node->IsPendingPhantomCallback()) { |
734 node->CollectPhantomCallbackData(isolate(), | 737 if (mode == IterationMode::HANDLE_PHANTOM_NODES || |
735 &pending_phantom_callbacks_); | 738 mode == IterationMode::HANDLE_PHANTOM_NODES_VISIT_OTHERS) { |
| 739 node->CollectPhantomCallbackData(isolate(), |
| 740 &pending_phantom_callbacks_); |
| 741 } |
736 } else { | 742 } else { |
737 v->VisitPointer(node->location()); | 743 if (mode == IterationMode::VISIT_OTHERS || |
| 744 mode == IterationMode::HANDLE_PHANTOM_NODES_VISIT_OTHERS) { |
| 745 v->VisitPointer(node->location()); |
| 746 } |
738 } | 747 } |
739 } | 748 } |
740 } | 749 } |
741 } | 750 } |
742 | 751 |
| 752 template void GlobalHandles::IterateNewSpaceWeakUnmodifiedRoots< |
| 753 GlobalHandles::HANDLE_PHANTOM_NODES>(ObjectVisitor* v); |
| 754 |
| 755 template void GlobalHandles::IterateNewSpaceWeakUnmodifiedRoots< |
| 756 GlobalHandles::VISIT_OTHERS>(ObjectVisitor* v); |
| 757 |
| 758 template void GlobalHandles::IterateNewSpaceWeakUnmodifiedRoots< |
| 759 GlobalHandles::HANDLE_PHANTOM_NODES_VISIT_OTHERS>(ObjectVisitor* v); |
743 | 760 |
744 DISABLE_CFI_PERF | 761 DISABLE_CFI_PERF |
745 bool GlobalHandles::IterateObjectGroups(ObjectVisitor* v, | 762 bool GlobalHandles::IterateObjectGroups(ObjectVisitor* v, |
746 WeakSlotCallbackWithHeap can_skip) { | 763 WeakSlotCallbackWithHeap can_skip) { |
747 ComputeObjectGroupsAndImplicitReferences(); | 764 ComputeObjectGroupsAndImplicitReferences(); |
748 int last = 0; | 765 int last = 0; |
749 bool any_group_was_visited = false; | 766 bool any_group_was_visited = false; |
750 for (int i = 0; i < object_groups_.length(); i++) { | 767 for (int i = 0; i < object_groups_.length(); i++) { |
751 ObjectGroup* entry = object_groups_.at(i); | 768 ObjectGroup* entry = object_groups_.at(i); |
752 DCHECK(entry != NULL); | 769 DCHECK(entry != NULL); |
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1451 blocks_[block][offset] = object; | 1468 blocks_[block][offset] = object; |
1452 if (isolate->heap()->InNewSpace(object)) { | 1469 if (isolate->heap()->InNewSpace(object)) { |
1453 new_space_indices_.Add(size_); | 1470 new_space_indices_.Add(size_); |
1454 } | 1471 } |
1455 *index = size_++; | 1472 *index = size_++; |
1456 } | 1473 } |
1457 | 1474 |
1458 | 1475 |
1459 } // namespace internal | 1476 } // namespace internal |
1460 } // namespace v8 | 1477 } // namespace v8 |
OLD | NEW |