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

Unified Diff: src/heap/embedder-tracing.cc

Issue 2576453002: [heap] Create a thin wrapper around wrapper tracing in V8 to avoid misuse (Closed)
Patch Set: Include Created 4 years 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 | « src/heap/embedder-tracing.h ('k') | src/heap/heap.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/embedder-tracing.cc
diff --git a/src/heap/embedder-tracing.cc b/src/heap/embedder-tracing.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8d5e54090f93e9d660f2525ef20eb3b23579fb18
--- /dev/null
+++ b/src/heap/embedder-tracing.cc
@@ -0,0 +1,71 @@
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/heap/embedder-tracing.h"
+
+#include "src/base/logging.h"
+
+namespace v8 {
+namespace internal {
+
+void LocalEmbedderHeapTracer::TracePrologue() {
+ if (!InUse()) return;
+
+ CHECK(cached_wrappers_to_trace_.empty());
+ remote_tracer_->TracePrologue();
+}
+
+void LocalEmbedderHeapTracer::TraceEpilogue() {
+ if (!InUse()) return;
+
+ CHECK(cached_wrappers_to_trace_.empty());
+ remote_tracer_->TraceEpilogue();
+}
+
+void LocalEmbedderHeapTracer::AbortTracing() {
+ if (!InUse()) return;
+
+ cached_wrappers_to_trace_.clear();
+ remote_tracer_->AbortTracing();
+}
+
+void LocalEmbedderHeapTracer::EnterFinalPause() {
+ if (!InUse()) return;
+
+ remote_tracer_->EnterFinalPause();
+}
+
+bool LocalEmbedderHeapTracer::Trace(
+ double deadline, EmbedderHeapTracer::AdvanceTracingActions actions) {
+ if (!InUse()) return false;
+
+ RegisterWrappersWithRemoteTracer();
+ return remote_tracer_->AdvanceTracing(deadline, actions);
+}
+
+size_t LocalEmbedderHeapTracer::NumberOfWrappersToTrace() {
+ return (InUse())
+ ? cached_wrappers_to_trace_.size() +
+ remote_tracer_->NumberOfWrappersToTrace()
+ : 0;
+}
+
+void LocalEmbedderHeapTracer::RegisterWrappersWithRemoteTracer() {
+ if (!InUse()) return;
+
+ if (cached_wrappers_to_trace_.empty()) {
+ return;
+ }
+
+ remote_tracer_->RegisterV8References(cached_wrappers_to_trace_);
+ cached_wrappers_to_trace_.clear();
+}
+
+bool LocalEmbedderHeapTracer::RequiresImmediateWrapperProcessing() {
+ const size_t kTooManyWrappers = 16000;
+ return cached_wrappers_to_trace_.size() > kTooManyWrappers;
+}
+
+} // namespace internal
+} // namespace v8
« no previous file with comments | « src/heap/embedder-tracing.h ('k') | src/heap/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698