• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "src/heap/embedder-tracing.h"
6 
7 #include "src/base/logging.h"
8 
9 namespace v8 {
10 namespace internal {
11 
TracePrologue()12 void LocalEmbedderHeapTracer::TracePrologue() {
13   if (!InUse()) return;
14 
15   CHECK(cached_wrappers_to_trace_.empty());
16   num_v8_marking_deque_was_empty_ = 0;
17   remote_tracer_->TracePrologue();
18 }
19 
TraceEpilogue()20 void LocalEmbedderHeapTracer::TraceEpilogue() {
21   if (!InUse()) return;
22 
23   CHECK(cached_wrappers_to_trace_.empty());
24   remote_tracer_->TraceEpilogue();
25 }
26 
AbortTracing()27 void LocalEmbedderHeapTracer::AbortTracing() {
28   if (!InUse()) return;
29 
30   cached_wrappers_to_trace_.clear();
31   remote_tracer_->AbortTracing();
32 }
33 
EnterFinalPause()34 void LocalEmbedderHeapTracer::EnterFinalPause() {
35   if (!InUse()) return;
36 
37   remote_tracer_->EnterFinalPause();
38 }
39 
Trace(double deadline,EmbedderHeapTracer::AdvanceTracingActions actions)40 bool LocalEmbedderHeapTracer::Trace(
41     double deadline, EmbedderHeapTracer::AdvanceTracingActions actions) {
42   if (!InUse()) return false;
43 
44   DCHECK_EQ(0, NumberOfCachedWrappersToTrace());
45   return remote_tracer_->AdvanceTracing(deadline, actions);
46 }
47 
NumberOfWrappersToTrace()48 size_t LocalEmbedderHeapTracer::NumberOfWrappersToTrace() {
49   return (InUse())
50              ? cached_wrappers_to_trace_.size() +
51                    remote_tracer_->NumberOfWrappersToTrace()
52              : 0;
53 }
54 
RegisterWrappersWithRemoteTracer()55 void LocalEmbedderHeapTracer::RegisterWrappersWithRemoteTracer() {
56   if (!InUse()) return;
57 
58   if (cached_wrappers_to_trace_.empty()) {
59     return;
60   }
61 
62   remote_tracer_->RegisterV8References(cached_wrappers_to_trace_);
63   cached_wrappers_to_trace_.clear();
64 }
65 
RequiresImmediateWrapperProcessing()66 bool LocalEmbedderHeapTracer::RequiresImmediateWrapperProcessing() {
67   const size_t kTooManyWrappers = 16000;
68   return cached_wrappers_to_trace_.size() > kTooManyWrappers;
69 }
70 
71 }  // namespace internal
72 }  // namespace v8
73