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> |
ulan
2016/11/15 19:57:21
mode is unused in this function.
Michael Lippautz
2016/11/16 10:25:26
Done. Worked by accident because none of our tests
| |
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 node->ResetPhantomHandle(); |
732 ++number_of_phantom_handle_resets_; | 732 ++number_of_phantom_handle_resets_; |
733 } else if (node->IsPendingPhantomCallback()) { | 733 } else if (node->IsPendingPhantomCallback()) { |
734 node->CollectPhantomCallbackData(isolate(), | 734 node->CollectPhantomCallbackData(isolate(), |
735 &pending_phantom_callbacks_); | 735 &pending_phantom_callbacks_); |
736 } else { | 736 } else { |
737 v->VisitPointer(node->location()); | 737 v->VisitPointer(node->location()); |
738 } | 738 } |
739 } | 739 } |
740 } | 740 } |
741 } | 741 } |
742 | 742 |
743 template void GlobalHandles::IterateNewSpaceWeakUnmodifiedRoots< | |
744 GlobalHandles::HANDLE_PHANTOM_NODES>(ObjectVisitor* v); | |
745 | |
746 template void GlobalHandles::IterateNewSpaceWeakUnmodifiedRoots< | |
747 GlobalHandles::DONT_HANDLE_PHANTOM_NODES>(ObjectVisitor* v); | |
748 | |
749 void GlobalHandles::ResetNewSpaceHandlesForTesting() { | |
ulan
2016/11/15 19:57:21
Would it be more robust to remember the state befo
Michael Lippautz
2016/11/16 10:25:26
Yes! Done.
| |
750 for (int i = 0; i < new_space_nodes_.length(); ++i) { | |
751 Node* node = new_space_nodes_[i]; | |
752 DCHECK(node->is_in_new_space_list()); | |
753 | |
754 if (node->IsWeak()) { | |
755 // Undo: IdentifyWeakUnmodifiedObjects. | |
756 if (node->is_active()) { | |
757 node->set_active(false); | |
758 } | |
759 // Undo: MarkNewSpaceWeakUnmodifiedObjectsPending. | |
760 if ((node->is_independent() || !node->is_active()) && | |
761 node->state() == Node::PENDING) { | |
762 node->set_state(Node::WEAK); | |
763 } | |
764 } | |
765 } | |
766 } | |
743 | 767 |
744 DISABLE_CFI_PERF | 768 DISABLE_CFI_PERF |
745 bool GlobalHandles::IterateObjectGroups(ObjectVisitor* v, | 769 bool GlobalHandles::IterateObjectGroups(ObjectVisitor* v, |
746 WeakSlotCallbackWithHeap can_skip) { | 770 WeakSlotCallbackWithHeap can_skip) { |
747 ComputeObjectGroupsAndImplicitReferences(); | 771 ComputeObjectGroupsAndImplicitReferences(); |
748 int last = 0; | 772 int last = 0; |
749 bool any_group_was_visited = false; | 773 bool any_group_was_visited = false; |
750 for (int i = 0; i < object_groups_.length(); i++) { | 774 for (int i = 0; i < object_groups_.length(); i++) { |
751 ObjectGroup* entry = object_groups_.at(i); | 775 ObjectGroup* entry = object_groups_.at(i); |
752 DCHECK(entry != NULL); | 776 DCHECK(entry != NULL); |
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1451 blocks_[block][offset] = object; | 1475 blocks_[block][offset] = object; |
1452 if (isolate->heap()->InNewSpace(object)) { | 1476 if (isolate->heap()->InNewSpace(object)) { |
1453 new_space_indices_.Add(size_); | 1477 new_space_indices_.Add(size_); |
1454 } | 1478 } |
1455 *index = size_++; | 1479 *index = size_++; |
1456 } | 1480 } |
1457 | 1481 |
1458 | 1482 |
1459 } // namespace internal | 1483 } // namespace internal |
1460 } // namespace v8 | 1484 } // namespace v8 |
OLD | NEW |