OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 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 | 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 #ifndef V8_HEAP_EMBEDDER_TRACING_H_ | 5 #ifndef V8_HEAP_EMBEDDER_TRACING_H_ |
6 #define V8_HEAP_EMBEDDER_TRACING_H_ | 6 #define V8_HEAP_EMBEDDER_TRACING_H_ |
7 | 7 |
8 #include "include/v8.h" | 8 #include "include/v8.h" |
9 #include "src/globals.h" | 9 #include "src/globals.h" |
10 | 10 |
11 namespace v8 { | 11 namespace v8 { |
12 namespace internal { | 12 namespace internal { |
13 | 13 |
14 class Heap; | 14 class Heap; |
15 | 15 |
16 class V8_EXPORT_PRIVATE LocalEmbedderHeapTracer final { | 16 class V8_EXPORT_PRIVATE LocalEmbedderHeapTracer final { |
17 public: | 17 public: |
18 typedef std::pair<void*, void*> WrapperInfo; | 18 typedef std::pair<void*, void*> WrapperInfo; |
19 | 19 |
20 LocalEmbedderHeapTracer() : remote_tracer_(nullptr) {} | 20 LocalEmbedderHeapTracer() |
| 21 : remote_tracer_(nullptr), |
| 22 num_v8_marking_deque_was_empty_(0), |
| 23 in_final_pause_(false) {} |
21 | 24 |
22 void SetRemoteTracer(EmbedderHeapTracer* tracer) { remote_tracer_ = tracer; } | 25 void SetRemoteTracer(EmbedderHeapTracer* tracer) { remote_tracer_ = tracer; } |
23 bool InUse() { return remote_tracer_ != nullptr; } | 26 bool InUse() { return remote_tracer_ != nullptr; } |
24 | 27 |
25 void TracePrologue(); | 28 void TracePrologue(); |
26 void TraceEpilogue(); | 29 void TraceEpilogue(); |
27 void AbortTracing(); | 30 void AbortTracing(); |
28 void EnterFinalPause(); | 31 void EnterFinalPause(); |
29 bool Trace(double deadline, | 32 bool Trace(double deadline, |
30 EmbedderHeapTracer::AdvanceTracingActions actions); | 33 EmbedderHeapTracer::AdvanceTracingActions actions); |
31 | 34 |
32 size_t NumberOfWrappersToTrace(); | 35 size_t NumberOfWrappersToTrace(); |
33 size_t NumberOfCachedWrappersToTrace() { | 36 size_t NumberOfCachedWrappersToTrace() { |
34 return cached_wrappers_to_trace_.size(); | 37 return cached_wrappers_to_trace_.size(); |
35 } | 38 } |
36 void AddWrapperToTrace(WrapperInfo entry) { | 39 void AddWrapperToTrace(WrapperInfo entry) { |
37 cached_wrappers_to_trace_.push_back(entry); | 40 cached_wrappers_to_trace_.push_back(entry); |
38 } | 41 } |
39 void ClearCachedWrappersToTrace() { cached_wrappers_to_trace_.clear(); } | 42 void ClearCachedWrappersToTrace() { cached_wrappers_to_trace_.clear(); } |
40 void RegisterWrappersWithRemoteTracer(); | 43 void RegisterWrappersWithRemoteTracer(); |
41 | 44 |
42 // In order to avoid running out of memory we force tracing wrappers if there | 45 // In order to avoid running out of memory we force tracing wrappers if there |
43 // are too many of them. | 46 // are too many of them. |
44 bool RequiresImmediateWrapperProcessing(); | 47 bool RequiresImmediateWrapperProcessing(); |
45 | 48 |
| 49 void NotifyV8MarkingDequeWasEmpty() { num_v8_marking_deque_was_empty_++; } |
| 50 |
46 private: | 51 private: |
47 typedef std::vector<WrapperInfo> WrapperCache; | 52 typedef std::vector<WrapperInfo> WrapperCache; |
48 | 53 |
| 54 static const size_t kMaxIncrementalMarkingRounds = 10; |
| 55 |
49 EmbedderHeapTracer* remote_tracer_; | 56 EmbedderHeapTracer* remote_tracer_; |
50 WrapperCache cached_wrappers_to_trace_; | 57 WrapperCache cached_wrappers_to_trace_; |
| 58 size_t num_v8_marking_deque_was_empty_; |
| 59 bool in_final_pause_; |
51 }; | 60 }; |
52 | 61 |
53 } // namespace internal | 62 } // namespace internal |
54 } // namespace v8 | 63 } // namespace v8 |
55 | 64 |
56 #endif // V8_HEAP_EMBEDDER_TRACING_H_ | 65 #endif // V8_HEAP_EMBEDDER_TRACING_H_ |
OLD | NEW |