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 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 } else { | 779 } else { |
780 node->set_in_new_space_list(false); | 780 node->set_in_new_space_list(false); |
781 isolate_->heap()->IncrementNodesPromoted(); | 781 isolate_->heap()->IncrementNodesPromoted(); |
782 } | 782 } |
783 } else { | 783 } else { |
784 node->set_in_new_space_list(false); | 784 node->set_in_new_space_list(false); |
785 isolate_->heap()->IncrementNodesDiedInNewSpace(); | 785 isolate_->heap()->IncrementNodesDiedInNewSpace(); |
786 } | 786 } |
787 } | 787 } |
788 new_space_nodes_.Rewind(last); | 788 new_space_nodes_.Rewind(last); |
| 789 new_space_nodes_.Trim(); |
789 } | 790 } |
790 | 791 |
791 | 792 |
792 int GlobalHandles::DispatchPendingPhantomCallbacks() { | 793 int GlobalHandles::DispatchPendingPhantomCallbacks() { |
793 int freed_nodes = 0; | 794 int freed_nodes = 0; |
794 { | 795 { |
795 // The initial pass callbacks must simply clear the nodes. | 796 // The initial pass callbacks must simply clear the nodes. |
796 for (auto i = pending_phantom_callbacks_.begin(); | 797 for (auto i = pending_phantom_callbacks_.begin(); |
797 i != pending_phantom_callbacks_.end(); ++i) { | 798 i != pending_phantom_callbacks_.end(); ++i) { |
798 auto callback = i; | 799 auto callback = i; |
799 // Skip callbacks that have already been processed once. | 800 // Skip callbacks that have already been processed once. |
800 if (callback->node() == nullptr) continue; | 801 if (callback->node() == nullptr) continue; |
801 callback->Invoke(isolate()); | 802 callback->Invoke(isolate()); |
802 freed_nodes++; | 803 freed_nodes++; |
803 } | 804 } |
804 } | 805 } |
805 // The second pass empties the list. | 806 // The second pass empties the list. |
806 while (pending_phantom_callbacks_.length() != 0) { | 807 while (pending_phantom_callbacks_.length() != 0) { |
807 auto callback = pending_phantom_callbacks_.RemoveLast(); | 808 auto callback = pending_phantom_callbacks_.RemoveLast(); |
808 DCHECK(callback.node() == nullptr); | 809 DCHECK(callback.node() == nullptr); |
809 // No second pass callback required. | 810 // No second pass callback required. |
810 if (callback.callback() == nullptr) continue; | 811 if (callback.callback() == nullptr) continue; |
811 // Fire second pass callback. | 812 // Fire second pass callback. |
812 callback.Invoke(isolate()); | 813 callback.Invoke(isolate()); |
813 } | 814 } |
| 815 pending_phantom_callbacks_.Clear(); |
814 return freed_nodes; | 816 return freed_nodes; |
815 } | 817 } |
816 | 818 |
817 | 819 |
818 void GlobalHandles::PendingPhantomCallback::Invoke(Isolate* isolate) { | 820 void GlobalHandles::PendingPhantomCallback::Invoke(Isolate* isolate) { |
819 Data::Callback* callback_addr = nullptr; | 821 Data::Callback* callback_addr = nullptr; |
820 if (node_ != nullptr) { | 822 if (node_ != nullptr) { |
821 // Initialize for first pass callback. | 823 // Initialize for first pass callback. |
822 DCHECK(node_->state() == Node::NEAR_DEATH); | 824 DCHECK(node_->state() == Node::NEAR_DEATH); |
823 callback_addr = &callback_; | 825 callback_addr = &callback_; |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1222 DCHECK_EQ(isolate->heap()->the_hole_value(), blocks_[block][offset]); | 1224 DCHECK_EQ(isolate->heap()->the_hole_value(), blocks_[block][offset]); |
1223 blocks_[block][offset] = object; | 1225 blocks_[block][offset] = object; |
1224 if (isolate->heap()->InNewSpace(object)) { | 1226 if (isolate->heap()->InNewSpace(object)) { |
1225 new_space_indices_.Add(size_); | 1227 new_space_indices_.Add(size_); |
1226 } | 1228 } |
1227 *index = size_++; | 1229 *index = size_++; |
1228 } | 1230 } |
1229 | 1231 |
1230 | 1232 |
1231 } } // namespace v8::internal | 1233 } } // namespace v8::internal |
OLD | NEW |