Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: src/heap/gc-idle-time-handler-unittest.cc

Issue 577573002: Introduce DONE state in idle notification handler. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/heap/gc-idle-time-handler.cc ('k') | src/heap/heap.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <limits> 5 #include <limits>
6 6
7 #include "src/heap/gc-idle-time-handler.h" 7 #include "src/heap/gc-idle-time-handler.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 heap_state.incremental_marking_stopped = true; 175 heap_state.incremental_marking_stopped = true;
176 heap_state.can_start_incremental_marking = false; 176 heap_state.can_start_incremental_marking = false;
177 size_t speed = heap_state.mark_compact_speed_in_bytes_per_ms; 177 size_t speed = heap_state.mark_compact_speed_in_bytes_per_ms;
178 int idle_time_ms = static_cast<int>(heap_state.size_of_objects / speed + 1); 178 int idle_time_ms = static_cast<int>(heap_state.size_of_objects / speed + 1);
179 for (int i = 0; i < GCIdleTimeHandler::kMaxMarkCompactsInIdleRound; i++) { 179 for (int i = 0; i < GCIdleTimeHandler::kMaxMarkCompactsInIdleRound; i++) {
180 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); 180 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
181 EXPECT_EQ(DO_FULL_GC, action.type); 181 EXPECT_EQ(DO_FULL_GC, action.type);
182 handler()->NotifyIdleMarkCompact(); 182 handler()->NotifyIdleMarkCompact();
183 } 183 }
184 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); 184 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
185 EXPECT_EQ(DO_NOTHING, action.type); 185 EXPECT_EQ(DONE, action.type);
186 } 186 }
187 187
188 188
189 TEST_F(GCIdleTimeHandlerTest, StopEventually2) { 189 TEST_F(GCIdleTimeHandlerTest, StopEventually2) {
190 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); 190 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState();
191 int idle_time_ms = 10; 191 int idle_time_ms = 10;
192 for (int i = 0; i < GCIdleTimeHandler::kMaxMarkCompactsInIdleRound; i++) { 192 for (int i = 0; i < GCIdleTimeHandler::kMaxMarkCompactsInIdleRound; i++) {
193 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); 193 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
194 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type); 194 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type);
195 handler()->NotifyIdleMarkCompact(); 195 handler()->NotifyIdleMarkCompact();
196 } 196 }
197 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); 197 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
198 EXPECT_EQ(DO_NOTHING, action.type); 198 EXPECT_EQ(DONE, action.type);
199 } 199 }
200 200
201 201
202 TEST_F(GCIdleTimeHandlerTest, ContinueAfterStop1) { 202 TEST_F(GCIdleTimeHandlerTest, ContinueAfterStop1) {
203 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); 203 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState();
204 heap_state.incremental_marking_stopped = true; 204 heap_state.incremental_marking_stopped = true;
205 heap_state.can_start_incremental_marking = false; 205 heap_state.can_start_incremental_marking = false;
206 size_t speed = heap_state.mark_compact_speed_in_bytes_per_ms; 206 size_t speed = heap_state.mark_compact_speed_in_bytes_per_ms;
207 int idle_time_ms = static_cast<int>(heap_state.size_of_objects / speed + 1); 207 int idle_time_ms = static_cast<int>(heap_state.size_of_objects / speed + 1);
208 for (int i = 0; i < GCIdleTimeHandler::kMaxMarkCompactsInIdleRound; i++) { 208 for (int i = 0; i < GCIdleTimeHandler::kMaxMarkCompactsInIdleRound; i++) {
209 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); 209 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
210 EXPECT_EQ(DO_FULL_GC, action.type); 210 EXPECT_EQ(DO_FULL_GC, action.type);
211 handler()->NotifyIdleMarkCompact(); 211 handler()->NotifyIdleMarkCompact();
212 } 212 }
213 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); 213 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
214 EXPECT_EQ(DO_NOTHING, action.type); 214 EXPECT_EQ(DONE, action.type);
215 // Emulate mutator work. 215 // Emulate mutator work.
216 for (int i = 0; i < GCIdleTimeHandler::kIdleScavengeThreshold; i++) { 216 for (int i = 0; i < GCIdleTimeHandler::kIdleScavengeThreshold; i++) {
217 handler()->NotifyScavenge(); 217 handler()->NotifyScavenge();
218 } 218 }
219 action = handler()->Compute(idle_time_ms, heap_state); 219 action = handler()->Compute(idle_time_ms, heap_state);
220 EXPECT_EQ(DO_FULL_GC, action.type); 220 EXPECT_EQ(DO_FULL_GC, action.type);
221 } 221 }
222 222
223 223
224 TEST_F(GCIdleTimeHandlerTest, ContinueAfterStop2) { 224 TEST_F(GCIdleTimeHandlerTest, ContinueAfterStop2) {
225 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); 225 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState();
226 int idle_time_ms = 10; 226 int idle_time_ms = 10;
227 for (int i = 0; i < GCIdleTimeHandler::kMaxMarkCompactsInIdleRound; i++) { 227 for (int i = 0; i < GCIdleTimeHandler::kMaxMarkCompactsInIdleRound; i++) {
228 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); 228 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
229 if (action.type == DO_NOTHING) break; 229 if (action.type == DONE) break;
230 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type); 230 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type);
231 handler()->NotifyIdleMarkCompact(); 231 handler()->NotifyIdleMarkCompact();
232 } 232 }
233 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); 233 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
234 EXPECT_EQ(DO_NOTHING, action.type); 234 EXPECT_EQ(DONE, action.type);
235 // Emulate mutator work. 235 // Emulate mutator work.
236 for (int i = 0; i < GCIdleTimeHandler::kIdleScavengeThreshold; i++) { 236 for (int i = 0; i < GCIdleTimeHandler::kIdleScavengeThreshold; i++) {
237 handler()->NotifyScavenge(); 237 handler()->NotifyScavenge();
238 } 238 }
239 action = handler()->Compute(idle_time_ms, heap_state); 239 action = handler()->Compute(idle_time_ms, heap_state);
240 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type); 240 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type);
241 } 241 }
242 242
243 } // namespace internal 243 } // namespace internal
244 } // namespace v8 244 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/gc-idle-time-handler.cc ('k') | src/heap/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698