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 #include "src/heap/embedder-tracing.h" | 5 #include "src/heap/embedder-tracing.h" |
6 #include "testing/gmock/include/gmock/gmock.h" | 6 #include "testing/gmock/include/gmock/gmock.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 EXPECT_EQ(1u, local_tracer.NumberOfWrappersToTrace()); | 128 EXPECT_EQ(1u, local_tracer.NumberOfWrappersToTrace()); |
129 } | 129 } |
130 | 130 |
131 TEST(LocalEmbedderHeapTracer, TraceFinishes) { | 131 TEST(LocalEmbedderHeapTracer, TraceFinishes) { |
132 LocalEmbedderHeapTracer local_tracer; | 132 LocalEmbedderHeapTracer local_tracer; |
133 StrictMock<MockEmbedderHeapTracer> remote_tracer; | 133 StrictMock<MockEmbedderHeapTracer> remote_tracer; |
134 local_tracer.SetRemoteTracer(&remote_tracer); | 134 local_tracer.SetRemoteTracer(&remote_tracer); |
135 local_tracer.AddWrapperToTrace(CreateWrapperInfo()); | 135 local_tracer.AddWrapperToTrace(CreateWrapperInfo()); |
136 EXPECT_EQ(1u, local_tracer.NumberOfCachedWrappersToTrace()); | 136 EXPECT_EQ(1u, local_tracer.NumberOfCachedWrappersToTrace()); |
137 EXPECT_CALL(remote_tracer, RegisterV8References(_)); | 137 EXPECT_CALL(remote_tracer, RegisterV8References(_)); |
| 138 local_tracer.RegisterWrappersWithRemoteTracer(); |
138 EXPECT_CALL(remote_tracer, AdvanceTracing(0, _)).WillOnce(Return(false)); | 139 EXPECT_CALL(remote_tracer, AdvanceTracing(0, _)).WillOnce(Return(false)); |
139 EXPECT_FALSE(local_tracer.Trace( | 140 EXPECT_FALSE(local_tracer.Trace( |
140 0, EmbedderHeapTracer::AdvanceTracingActions( | 141 0, EmbedderHeapTracer::AdvanceTracingActions( |
141 EmbedderHeapTracer::ForceCompletionAction::FORCE_COMPLETION))); | 142 EmbedderHeapTracer::ForceCompletionAction::FORCE_COMPLETION))); |
142 EXPECT_EQ(0u, local_tracer.NumberOfCachedWrappersToTrace()); | 143 EXPECT_EQ(0u, local_tracer.NumberOfCachedWrappersToTrace()); |
143 } | 144 } |
144 | 145 |
145 TEST(LocalEmbedderHeapTracer, TraceDoesNotFinish) { | 146 TEST(LocalEmbedderHeapTracer, TraceDoesNotFinish) { |
146 LocalEmbedderHeapTracer local_tracer; | 147 LocalEmbedderHeapTracer local_tracer; |
147 StrictMock<MockEmbedderHeapTracer> remote_tracer; | 148 StrictMock<MockEmbedderHeapTracer> remote_tracer; |
148 local_tracer.SetRemoteTracer(&remote_tracer); | 149 local_tracer.SetRemoteTracer(&remote_tracer); |
149 local_tracer.AddWrapperToTrace(CreateWrapperInfo()); | 150 local_tracer.AddWrapperToTrace(CreateWrapperInfo()); |
150 EXPECT_EQ(1u, local_tracer.NumberOfCachedWrappersToTrace()); | 151 EXPECT_EQ(1u, local_tracer.NumberOfCachedWrappersToTrace()); |
151 EXPECT_CALL(remote_tracer, RegisterV8References(_)); | 152 EXPECT_CALL(remote_tracer, RegisterV8References(_)); |
| 153 local_tracer.RegisterWrappersWithRemoteTracer(); |
152 EXPECT_CALL(remote_tracer, AdvanceTracing(0, _)).WillOnce(Return(true)); | 154 EXPECT_CALL(remote_tracer, AdvanceTracing(0, _)).WillOnce(Return(true)); |
153 EXPECT_TRUE(local_tracer.Trace( | 155 EXPECT_TRUE(local_tracer.Trace( |
154 0, EmbedderHeapTracer::AdvanceTracingActions( | 156 0, EmbedderHeapTracer::AdvanceTracingActions( |
155 EmbedderHeapTracer::ForceCompletionAction::FORCE_COMPLETION))); | 157 EmbedderHeapTracer::ForceCompletionAction::FORCE_COMPLETION))); |
156 EXPECT_EQ(0u, local_tracer.NumberOfCachedWrappersToTrace()); | 158 EXPECT_EQ(0u, local_tracer.NumberOfCachedWrappersToTrace()); |
157 } | 159 } |
158 | 160 |
159 } // namespace heap | 161 } // namespace heap |
160 } // namespace internal | 162 } // namespace internal |
161 } // namespace v8 | 163 } // namespace v8 |
OLD | NEW |