OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 // should be impossible right now. | 266 // should be impossible right now. |
267 HEAP->CollectAllGarbage(Heap::kForceCompactionMask); | 267 HEAP->CollectAllGarbage(Heap::kForceCompactionMask); |
268 // And now map pointers should be encodable again. | 268 // And now map pointers should be encodable again. |
269 CHECK(HEAP->map_space()->MapPointersEncodable()); | 269 CHECK(HEAP->map_space()->MapPointersEncodable()); |
270 } | 270 } |
271 #endif | 271 #endif |
272 | 272 |
273 static int gc_starts = 0; | 273 static int gc_starts = 0; |
274 static int gc_ends = 0; | 274 static int gc_ends = 0; |
275 | 275 |
276 static void GCPrologueCallbackFunc() { | 276 static void GCPrologueCallbackFunc(v8::GCType type, |
| 277 v8::GCCallbackFlags flags) { |
277 CHECK(gc_starts == gc_ends); | 278 CHECK(gc_starts == gc_ends); |
278 gc_starts++; | 279 gc_starts++; |
279 } | 280 } |
280 | 281 |
281 | 282 |
282 static void GCEpilogueCallbackFunc() { | 283 static void GCEpilogueCallbackFunc(v8::GCType type, |
| 284 v8::GCCallbackFlags flags) { |
283 CHECK(gc_starts == gc_ends + 1); | 285 CHECK(gc_starts == gc_ends + 1); |
284 gc_ends++; | 286 gc_ends++; |
285 } | 287 } |
286 | 288 |
287 | 289 |
288 TEST(GCCallback) { | 290 TEST(GCCallback) { |
289 InitializeVM(); | 291 InitializeVM(); |
290 | 292 |
291 HEAP->SetGlobalGCPrologueCallback(&GCPrologueCallbackFunc); | 293 HEAP->AddGCPrologueCallback(&GCPrologueCallbackFunc, |
292 HEAP->SetGlobalGCEpilogueCallback(&GCEpilogueCallbackFunc); | 294 v8::kGCTypeMarkSweepCompact); |
| 295 HEAP->AddGCEpilogueCallback(&GCEpilogueCallbackFunc, |
| 296 v8::kGCTypeMarkSweepCompact); |
293 | 297 |
294 // Scavenge does not call GC callback functions. | 298 // Scavenge does not call GC callback functions. |
295 HEAP->PerformScavenge(); | 299 HEAP->PerformScavenge(); |
296 | 300 |
297 CHECK_EQ(0, gc_starts); | 301 CHECK_EQ(0, gc_starts); |
298 CHECK_EQ(gc_ends, gc_starts); | 302 CHECK_EQ(gc_ends, gc_starts); |
299 | 303 |
300 HEAP->CollectGarbage(OLD_POINTER_SPACE); | 304 HEAP->CollectGarbage(OLD_POINTER_SPACE); |
301 CHECK_EQ(1, gc_starts); | 305 CHECK_EQ(1, gc_starts); |
302 CHECK_EQ(gc_ends, gc_starts); | 306 CHECK_EQ(gc_ends, gc_starts); |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 if (v8::internal::Snapshot::IsEnabled()) { | 557 if (v8::internal::Snapshot::IsEnabled()) { |
554 CHECK_LE(delta, 2600 * 1024); | 558 CHECK_LE(delta, 2600 * 1024); |
555 } else { | 559 } else { |
556 CHECK_LE(delta, 3000 * 1024); | 560 CHECK_LE(delta, 3000 * 1024); |
557 } | 561 } |
558 } | 562 } |
559 } | 563 } |
560 } | 564 } |
561 | 565 |
562 #endif // __linux__ and !USE_SIMULATOR | 566 #endif // __linux__ and !USE_SIMULATOR |
OLD | NEW |