OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 <cmath> | 5 #include <cmath> |
6 #include <limits> | 6 #include <limits> |
7 | 7 |
8 #include "src/globals.h" | 8 #include "src/globals.h" |
9 #include "src/heap/gc-tracer.h" | 9 #include "src/heap/gc-tracer.h" |
10 #include "src/isolate.h" | 10 #include "src/isolate.h" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 tracer->AddScopeSample(GCTracer::Scope::MC_INCREMENTAL_FINALIZE, 100); | 176 tracer->AddScopeSample(GCTracer::Scope::MC_INCREMENTAL_FINALIZE, 100); |
177 tracer->Start(MARK_COMPACTOR, "gc unittest", "collector unittest"); | 177 tracer->Start(MARK_COMPACTOR, "gc unittest", "collector unittest"); |
178 // Switch to incremental MC to enable writing back incremental scopes. | 178 // Switch to incremental MC to enable writing back incremental scopes. |
179 tracer->current_.type = GCTracer::Event::INCREMENTAL_MARK_COMPACTOR; | 179 tracer->current_.type = GCTracer::Event::INCREMENTAL_MARK_COMPACTOR; |
180 tracer->AddScopeSample(GCTracer::Scope::MC_INCREMENTAL_FINALIZE, 100); | 180 tracer->AddScopeSample(GCTracer::Scope::MC_INCREMENTAL_FINALIZE, 100); |
181 tracer->Stop(MARK_COMPACTOR); | 181 tracer->Stop(MARK_COMPACTOR); |
182 EXPECT_DOUBLE_EQ( | 182 EXPECT_DOUBLE_EQ( |
183 200.0, tracer->current_.scopes[GCTracer::Scope::MC_INCREMENTAL_FINALIZE]); | 183 200.0, tracer->current_.scopes[GCTracer::Scope::MC_INCREMENTAL_FINALIZE]); |
184 } | 184 } |
185 | 185 |
| 186 TEST_F(GCTracerTest, IncrementalMarkingDetails) { |
| 187 GCTracer* tracer = i_isolate()->heap()->tracer(); |
| 188 tracer->ResetForTesting(); |
| 189 |
| 190 // Round 1. |
| 191 tracer->AddScopeSample(GCTracer::Scope::MC_INCREMENTAL_FINALIZE, 50); |
| 192 tracer->Start(MARK_COMPACTOR, "gc unittest", "collector unittest"); |
| 193 // Switch to incremental MC to enable writing back incremental scopes. |
| 194 tracer->current_.type = GCTracer::Event::INCREMENTAL_MARK_COMPACTOR; |
| 195 tracer->AddScopeSample(GCTracer::Scope::MC_INCREMENTAL_FINALIZE, 100); |
| 196 tracer->Stop(MARK_COMPACTOR); |
| 197 EXPECT_DOUBLE_EQ( |
| 198 100, |
| 199 tracer->current_ |
| 200 .incremental_marking_scopes[GCTracer::Scope::MC_INCREMENTAL_FINALIZE] |
| 201 .longest_step); |
| 202 EXPECT_EQ( |
| 203 2, |
| 204 tracer->current_ |
| 205 .incremental_marking_scopes[GCTracer::Scope::MC_INCREMENTAL_FINALIZE] |
| 206 .steps); |
| 207 EXPECT_DOUBLE_EQ( |
| 208 150, |
| 209 tracer->current_ |
| 210 .incremental_marking_scopes[GCTracer::Scope::MC_INCREMENTAL_FINALIZE] |
| 211 .cumulative_duration); |
| 212 |
| 213 // Round 2. Cumulative numbers should add up, others should be reset. |
| 214 tracer->AddScopeSample(GCTracer::Scope::MC_INCREMENTAL_FINALIZE, 13); |
| 215 tracer->AddScopeSample(GCTracer::Scope::MC_INCREMENTAL_FINALIZE, 15); |
| 216 tracer->Start(MARK_COMPACTOR, "gc unittest", "collector unittest"); |
| 217 // Switch to incremental MC to enable writing back incremental scopes. |
| 218 tracer->current_.type = GCTracer::Event::INCREMENTAL_MARK_COMPACTOR; |
| 219 tracer->AddScopeSample(GCTracer::Scope::MC_INCREMENTAL_FINALIZE, 122); |
| 220 tracer->Stop(MARK_COMPACTOR); |
| 221 EXPECT_DOUBLE_EQ( |
| 222 122, |
| 223 tracer->current_ |
| 224 .incremental_marking_scopes[GCTracer::Scope::MC_INCREMENTAL_FINALIZE] |
| 225 .longest_step); |
| 226 EXPECT_EQ( |
| 227 3, |
| 228 tracer->current_ |
| 229 .incremental_marking_scopes[GCTracer::Scope::MC_INCREMENTAL_FINALIZE] |
| 230 .steps); |
| 231 EXPECT_DOUBLE_EQ( |
| 232 300, |
| 233 tracer->current_ |
| 234 .incremental_marking_scopes[GCTracer::Scope::MC_INCREMENTAL_FINALIZE] |
| 235 .cumulative_duration); |
| 236 } |
| 237 |
186 } // namespace internal | 238 } // namespace internal |
187 } // namespace v8 | 239 } // namespace v8 |
OLD | NEW |