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), num_v8_marking_deque_was_empty_(0) {} |
21 | 22 |
22 void SetRemoteTracer(EmbedderHeapTracer* tracer) { remote_tracer_ = tracer; } | 23 void SetRemoteTracer(EmbedderHeapTracer* tracer) { remote_tracer_ = tracer; } |
23 bool InUse() { return remote_tracer_ != nullptr; } | 24 bool InUse() { return remote_tracer_ != nullptr; } |
24 | 25 |
25 void TracePrologue(); | 26 void TracePrologue(); |
26 void TraceEpilogue(); | 27 void TraceEpilogue(); |
27 void AbortTracing(); | 28 void AbortTracing(); |
28 void EnterFinalPause(); | 29 void EnterFinalPause(); |
29 bool Trace(double deadline, | 30 bool Trace(double deadline, |
30 EmbedderHeapTracer::AdvanceTracingActions actions); | 31 EmbedderHeapTracer::AdvanceTracingActions actions); |
31 | 32 |
32 size_t NumberOfWrappersToTrace(); | 33 size_t NumberOfWrappersToTrace(); |
33 size_t NumberOfCachedWrappersToTrace() { | 34 size_t NumberOfCachedWrappersToTrace() { |
34 return cached_wrappers_to_trace_.size(); | 35 return cached_wrappers_to_trace_.size(); |
35 } | 36 } |
36 void AddWrapperToTrace(WrapperInfo entry) { | 37 void AddWrapperToTrace(WrapperInfo entry) { |
37 cached_wrappers_to_trace_.push_back(entry); | 38 cached_wrappers_to_trace_.push_back(entry); |
38 } | 39 } |
39 void ClearCachedWrappersToTrace() { cached_wrappers_to_trace_.clear(); } | 40 void ClearCachedWrappersToTrace() { cached_wrappers_to_trace_.clear(); } |
40 void RegisterWrappersWithRemoteTracer(); | 41 void RegisterWrappersWithRemoteTracer(); |
41 | 42 |
42 // In order to avoid running out of memory we force tracing wrappers if there | 43 // In order to avoid running out of memory we force tracing wrappers if there |
43 // are too many of them. | 44 // are too many of them. |
44 bool RequiresImmediateWrapperProcessing(); | 45 bool RequiresImmediateWrapperProcessing(); |
45 | 46 |
| 47 void NotifyV8MarkingDequeWasEmpty() { num_v8_marking_deque_was_empty_++; } |
| 48 bool ShouldFinalizeIncrementalMarking() { |
| 49 static const size_t kMaxIncrementalFixpointRounds = 3; |
| 50 return !FLAG_incremental_marking_wrappers || !InUse() || |
| 51 NumberOfWrappersToTrace() == 0 || |
| 52 num_v8_marking_deque_was_empty_ > kMaxIncrementalFixpointRounds; |
| 53 } |
| 54 |
46 private: | 55 private: |
47 typedef std::vector<WrapperInfo> WrapperCache; | 56 typedef std::vector<WrapperInfo> WrapperCache; |
48 | 57 |
49 EmbedderHeapTracer* remote_tracer_; | 58 EmbedderHeapTracer* remote_tracer_; |
50 WrapperCache cached_wrappers_to_trace_; | 59 WrapperCache cached_wrappers_to_trace_; |
| 60 size_t num_v8_marking_deque_was_empty_; |
51 }; | 61 }; |
52 | 62 |
53 } // namespace internal | 63 } // namespace internal |
54 } // namespace v8 | 64 } // namespace v8 |
55 | 65 |
56 #endif // V8_HEAP_EMBEDDER_TRACING_H_ | 66 #endif // V8_HEAP_EMBEDDER_TRACING_H_ |
OLD | NEW |