| 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/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/api.h" | 7 #include "src/api.h" |
| 8 #include "src/global-handles.h" | 8 #include "src/global-handles.h" |
| 9 | 9 |
| 10 #include "src/vm-state-inl.h" | 10 #include "src/vm-state-inl.h" |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 | 589 |
| 590 bool GlobalHandles::IsWeak(Object** location) { | 590 bool GlobalHandles::IsWeak(Object** location) { |
| 591 return Node::FromLocation(location)->IsWeak(); | 591 return Node::FromLocation(location)->IsWeak(); |
| 592 } | 592 } |
| 593 | 593 |
| 594 | 594 |
| 595 void GlobalHandles::IterateWeakRoots(ObjectVisitor* v) { | 595 void GlobalHandles::IterateWeakRoots(ObjectVisitor* v) { |
| 596 for (NodeIterator it(this); !it.done(); it.Advance()) { | 596 for (NodeIterator it(this); !it.done(); it.Advance()) { |
| 597 Node* node = it.node(); | 597 Node* node = it.node(); |
| 598 if (node->IsWeakRetainer()) { | 598 if (node->IsWeakRetainer()) { |
| 599 // Weakness type can be normal or phantom, with or without internal | 599 // Pending weak phantom handles die immediately. Everything else survives. |
| 600 // fields). For normal weakness we mark through the handle so that the | 600 if (node->state() == Node::PENDING && |
| 601 // object and things reachable from it are available to the callback. | 601 node->weakness_type() != NORMAL_WEAK) { |
| 602 if (node->state() == Node::PENDING) { | |
| 603 if (node->weakness_type() == NORMAL_WEAK) { | |
| 604 v->VisitPointer(node->location()); | |
| 605 } else { | |
| 606 node->CollectPhantomCallbackData(isolate(), | 602 node->CollectPhantomCallbackData(isolate(), |
| 607 &pending_phantom_callbacks_); | 603 &pending_phantom_callbacks_); |
| 608 } | |
| 609 } else { | 604 } else { |
| 610 // Node is not pending, so that means the object survived. We still | |
| 611 // need to visit the pointer in case the object moved, eg. because of | |
| 612 // compaction. | |
| 613 v->VisitPointer(node->location()); | 605 v->VisitPointer(node->location()); |
| 614 } | 606 } |
| 615 } | 607 } |
| 616 } | 608 } |
| 617 } | 609 } |
| 618 | 610 |
| 619 | 611 |
| 620 void GlobalHandles::IdentifyWeakHandles(WeakSlotCallback f) { | 612 void GlobalHandles::IdentifyWeakHandles(WeakSlotCallback f) { |
| 621 for (NodeIterator it(this); !it.done(); it.Advance()) { | 613 for (NodeIterator it(this); !it.done(); it.Advance()) { |
| 622 if (it.node()->IsWeak() && f(it.node()->location())) { | 614 if (it.node()->IsWeak() && f(it.node()->location())) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 650 } | 642 } |
| 651 } | 643 } |
| 652 | 644 |
| 653 | 645 |
| 654 void GlobalHandles::IterateNewSpaceWeakIndependentRoots(ObjectVisitor* v) { | 646 void GlobalHandles::IterateNewSpaceWeakIndependentRoots(ObjectVisitor* v) { |
| 655 for (int i = 0; i < new_space_nodes_.length(); ++i) { | 647 for (int i = 0; i < new_space_nodes_.length(); ++i) { |
| 656 Node* node = new_space_nodes_[i]; | 648 Node* node = new_space_nodes_[i]; |
| 657 DCHECK(node->is_in_new_space_list()); | 649 DCHECK(node->is_in_new_space_list()); |
| 658 if ((node->is_independent() || node->is_partially_dependent()) && | 650 if ((node->is_independent() || node->is_partially_dependent()) && |
| 659 node->IsWeakRetainer()) { | 651 node->IsWeakRetainer()) { |
| 660 if (node->weakness_type() == NORMAL_WEAK) { | 652 // Pending weak phantom handles die immediately. Everything else survives. |
| 661 v->VisitPointer(node->location()); | 653 if (node->state() == Node::PENDING && |
| 662 } else if (node->state() == Node::PENDING) { | 654 node->weakness_type() != NORMAL_WEAK) { |
| 663 node->CollectPhantomCallbackData(isolate(), | 655 node->CollectPhantomCallbackData(isolate(), |
| 664 &pending_phantom_callbacks_); | 656 &pending_phantom_callbacks_); |
| 657 } else { |
| 658 v->VisitPointer(node->location()); |
| 665 } | 659 } |
| 666 } | 660 } |
| 667 } | 661 } |
| 668 } | 662 } |
| 669 | 663 |
| 670 | 664 |
| 671 bool GlobalHandles::IterateObjectGroups(ObjectVisitor* v, | 665 bool GlobalHandles::IterateObjectGroups(ObjectVisitor* v, |
| 672 WeakSlotCallbackWithHeap can_skip) { | 666 WeakSlotCallbackWithHeap can_skip) { |
| 673 ComputeObjectGroupsAndImplicitReferences(); | 667 ComputeObjectGroupsAndImplicitReferences(); |
| 674 int last = 0; | 668 int last = 0; |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1228 DCHECK_EQ(isolate->heap()->the_hole_value(), blocks_[block][offset]); | 1222 DCHECK_EQ(isolate->heap()->the_hole_value(), blocks_[block][offset]); |
| 1229 blocks_[block][offset] = object; | 1223 blocks_[block][offset] = object; |
| 1230 if (isolate->heap()->InNewSpace(object)) { | 1224 if (isolate->heap()->InNewSpace(object)) { |
| 1231 new_space_indices_.Add(size_); | 1225 new_space_indices_.Add(size_); |
| 1232 } | 1226 } |
| 1233 *index = size_++; | 1227 *index = size_++; |
| 1234 } | 1228 } |
| 1235 | 1229 |
| 1236 | 1230 |
| 1237 } } // namespace v8::internal | 1231 } } // namespace v8::internal |
| OLD | NEW |