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

Unified 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, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/v8.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/global-handles.cc
diff --git a/src/global-handles.cc b/src/global-handles.cc
index 4a7292547f1c06b6c180bf09671abfd1492f143e..404f3ad16789c0fae684b6a496dc91b24b83a831 100644
--- a/src/global-handles.cc
+++ b/src/global-handles.cc
@@ -817,8 +817,6 @@ void GlobalHandles::InvokeSecondPassPhantomCallbacks(
while (callbacks->length() != 0) {
auto callback = callbacks->RemoveLast();
DCHECK(callback.node() == nullptr);
- // No second pass callback required.
- if (callback.callback() == nullptr) continue;
// Fire second pass callback
callback.Invoke(isolate);
}
@@ -924,6 +922,7 @@ void GlobalHandles::UpdateListOfNewSpaceNodes() {
int GlobalHandles::DispatchPendingPhantomCallbacks(
bool synchronous_second_pass) {
int freed_nodes = 0;
+ List<PendingPhantomCallback> second_pass_callbacks;
{
// The initial pass callbacks must simply clear the nodes.
for (auto i = pending_phantom_callbacks_.begin();
@@ -932,24 +931,25 @@ int GlobalHandles::DispatchPendingPhantomCallbacks(
// Skip callbacks that have already been processed once.
if (callback->node() == nullptr) continue;
callback->Invoke(isolate());
+ if (callback->callback()) second_pass_callbacks.Add(*callback);
freed_nodes++;
}
}
- if (pending_phantom_callbacks_.length() > 0) {
+ pending_phantom_callbacks_.Clear();
+ if (second_pass_callbacks.length() > 0) {
if (FLAG_optimize_for_size || FLAG_predictable || synchronous_second_pass) {
isolate()->heap()->CallGCPrologueCallbacks(
GCType::kGCTypeProcessWeakCallbacks, kNoGCCallbackFlags);
- InvokeSecondPassPhantomCallbacks(&pending_phantom_callbacks_, isolate());
+ InvokeSecondPassPhantomCallbacks(&second_pass_callbacks, isolate());
isolate()->heap()->CallGCEpilogueCallbacks(
GCType::kGCTypeProcessWeakCallbacks, kNoGCCallbackFlags);
} else {
auto task = new PendingPhantomCallbacksSecondPassTask(
- &pending_phantom_callbacks_, isolate());
+ &second_pass_callbacks, isolate());
V8::GetCurrentPlatform()->CallOnForegroundThread(
reinterpret_cast<v8::Isolate*>(isolate()), task);
}
}
- pending_phantom_callbacks_.Clear();
return freed_nodes;
}
« 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