Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(476)

Side by Side Diff: src/global-handles.cc

Issue 1659433002: Don't schedule second pass callbacks if there are no callbacks (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/v8.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 799 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 object_groups_.Rewind(last); 810 object_groups_.Rewind(last);
811 return any_group_was_visited; 811 return any_group_was_visited;
812 } 812 }
813 813
814 814
815 void GlobalHandles::InvokeSecondPassPhantomCallbacks( 815 void GlobalHandles::InvokeSecondPassPhantomCallbacks(
816 List<PendingPhantomCallback>* callbacks, Isolate* isolate) { 816 List<PendingPhantomCallback>* callbacks, Isolate* isolate) {
817 while (callbacks->length() != 0) { 817 while (callbacks->length() != 0) {
818 auto callback = callbacks->RemoveLast(); 818 auto callback = callbacks->RemoveLast();
819 DCHECK(callback.node() == nullptr); 819 DCHECK(callback.node() == nullptr);
820 // No second pass callback required.
821 if (callback.callback() == nullptr) continue;
822 // Fire second pass callback 820 // Fire second pass callback
823 callback.Invoke(isolate); 821 callback.Invoke(isolate);
824 } 822 }
825 } 823 }
826 824
827 825
828 int GlobalHandles::PostScavengeProcessing( 826 int GlobalHandles::PostScavengeProcessing(
829 const int initial_post_gc_processing_count) { 827 const int initial_post_gc_processing_count) {
830 int freed_nodes = 0; 828 int freed_nodes = 0;
831 for (int i = 0; i < new_space_nodes_.length(); ++i) { 829 for (int i = 0; i < new_space_nodes_.length(); ++i) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 } 915 }
918 } 916 }
919 new_space_nodes_.Rewind(last); 917 new_space_nodes_.Rewind(last);
920 new_space_nodes_.Trim(); 918 new_space_nodes_.Trim();
921 } 919 }
922 920
923 921
924 int GlobalHandles::DispatchPendingPhantomCallbacks( 922 int GlobalHandles::DispatchPendingPhantomCallbacks(
925 bool synchronous_second_pass) { 923 bool synchronous_second_pass) {
926 int freed_nodes = 0; 924 int freed_nodes = 0;
925 List<PendingPhantomCallback> second_pass_callbacks;
927 { 926 {
928 // The initial pass callbacks must simply clear the nodes. 927 // The initial pass callbacks must simply clear the nodes.
929 for (auto i = pending_phantom_callbacks_.begin(); 928 for (auto i = pending_phantom_callbacks_.begin();
930 i != pending_phantom_callbacks_.end(); ++i) { 929 i != pending_phantom_callbacks_.end(); ++i) {
931 auto callback = i; 930 auto callback = i;
932 // Skip callbacks that have already been processed once. 931 // Skip callbacks that have already been processed once.
933 if (callback->node() == nullptr) continue; 932 if (callback->node() == nullptr) continue;
934 callback->Invoke(isolate()); 933 callback->Invoke(isolate());
934 if (callback->callback()) second_pass_callbacks.Add(*callback);
935 freed_nodes++; 935 freed_nodes++;
936 } 936 }
937 } 937 }
938 if (pending_phantom_callbacks_.length() > 0) { 938 pending_phantom_callbacks_.Clear();
939 if (second_pass_callbacks.length() > 0) {
939 if (FLAG_optimize_for_size || FLAG_predictable || synchronous_second_pass) { 940 if (FLAG_optimize_for_size || FLAG_predictable || synchronous_second_pass) {
940 isolate()->heap()->CallGCPrologueCallbacks( 941 isolate()->heap()->CallGCPrologueCallbacks(
941 GCType::kGCTypeProcessWeakCallbacks, kNoGCCallbackFlags); 942 GCType::kGCTypeProcessWeakCallbacks, kNoGCCallbackFlags);
942 InvokeSecondPassPhantomCallbacks(&pending_phantom_callbacks_, isolate()); 943 InvokeSecondPassPhantomCallbacks(&second_pass_callbacks, isolate());
943 isolate()->heap()->CallGCEpilogueCallbacks( 944 isolate()->heap()->CallGCEpilogueCallbacks(
944 GCType::kGCTypeProcessWeakCallbacks, kNoGCCallbackFlags); 945 GCType::kGCTypeProcessWeakCallbacks, kNoGCCallbackFlags);
945 } else { 946 } else {
946 auto task = new PendingPhantomCallbacksSecondPassTask( 947 auto task = new PendingPhantomCallbacksSecondPassTask(
947 &pending_phantom_callbacks_, isolate()); 948 &second_pass_callbacks, isolate());
948 V8::GetCurrentPlatform()->CallOnForegroundThread( 949 V8::GetCurrentPlatform()->CallOnForegroundThread(
949 reinterpret_cast<v8::Isolate*>(isolate()), task); 950 reinterpret_cast<v8::Isolate*>(isolate()), task);
950 } 951 }
951 } 952 }
952 pending_phantom_callbacks_.Clear();
953 return freed_nodes; 953 return freed_nodes;
954 } 954 }
955 955
956 956
957 void GlobalHandles::PendingPhantomCallback::Invoke(Isolate* isolate) { 957 void GlobalHandles::PendingPhantomCallback::Invoke(Isolate* isolate) {
958 Data::Callback* callback_addr = nullptr; 958 Data::Callback* callback_addr = nullptr;
959 if (node_ != nullptr) { 959 if (node_ != nullptr) {
960 // Initialize for first pass callback. 960 // Initialize for first pass callback.
961 DCHECK(node_->state() == Node::NEAR_DEATH); 961 DCHECK(node_->state() == Node::NEAR_DEATH);
962 callback_addr = &callback_; 962 callback_addr = &callback_;
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
1377 blocks_[block][offset] = object; 1377 blocks_[block][offset] = object;
1378 if (isolate->heap()->InNewSpace(object)) { 1378 if (isolate->heap()->InNewSpace(object)) {
1379 new_space_indices_.Add(size_); 1379 new_space_indices_.Add(size_);
1380 } 1380 }
1381 *index = size_++; 1381 *index = size_++;
1382 } 1382 }
1383 1383
1384 1384
1385 } // namespace internal 1385 } // namespace internal
1386 } // namespace v8 1386 } // namespace v8
OLDNEW
« no previous file with comments | « include/v8.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698