| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/heap.h" | 5 #include "vm/heap.h" |
| 6 | 6 |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "platform/utils.h" | 8 #include "platform/utils.h" |
| 9 #include "vm/flags.h" | 9 #include "vm/flags.h" |
| 10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 } | 355 } |
| 356 | 356 |
| 357 | 357 |
| 358 void Heap::CollectNewSpaceGarbage(Thread* thread, | 358 void Heap::CollectNewSpaceGarbage(Thread* thread, |
| 359 ApiCallbacks api_callbacks, | 359 ApiCallbacks api_callbacks, |
| 360 GCReason reason) { | 360 GCReason reason) { |
| 361 if (BeginNewSpaceGC(thread)) { | 361 if (BeginNewSpaceGC(thread)) { |
| 362 bool invoke_api_callbacks = (api_callbacks == kInvokeApiCallbacks); | 362 bool invoke_api_callbacks = (api_callbacks == kInvokeApiCallbacks); |
| 363 RecordBeforeGC(kNew, reason); | 363 RecordBeforeGC(kNew, reason); |
| 364 VMTagScope tagScope(thread, VMTag::kGCNewSpaceTagId); | 364 VMTagScope tagScope(thread, VMTag::kGCNewSpaceTagId); |
| 365 #ifndef PRODUCT |
| 365 TimelineDurationScope tds(thread, | 366 TimelineDurationScope tds(thread, |
| 366 isolate()->GetGCStream(), | 367 isolate()->GetGCStream(), |
| 367 "CollectNewGeneration"); | 368 "CollectNewGeneration"); |
| 369 #endif // !PRODUCT |
| 368 UpdateClassHeapStatsBeforeGC(kNew); | 370 UpdateClassHeapStatsBeforeGC(kNew); |
| 369 new_space_.Scavenge(invoke_api_callbacks); | 371 new_space_.Scavenge(invoke_api_callbacks); |
| 370 isolate()->class_table()->UpdatePromoted(); | 372 isolate()->class_table()->UpdatePromoted(); |
| 371 UpdatePretenurePolicy(); | 373 UpdatePretenurePolicy(); |
| 372 RecordAfterGC(kNew); | 374 RecordAfterGC(kNew); |
| 373 PrintStats(); | 375 PrintStats(); |
| 374 EndNewSpaceGC(); | 376 EndNewSpaceGC(); |
| 375 if (old_space_.NeedsGarbageCollection()) { | 377 if (old_space_.NeedsGarbageCollection()) { |
| 376 // Old collections should call the API callbacks. | 378 // Old collections should call the API callbacks. |
| 377 CollectOldSpaceGarbage(thread, kInvokeApiCallbacks, kPromotion); | 379 CollectOldSpaceGarbage(thread, kInvokeApiCallbacks, kPromotion); |
| 378 } | 380 } |
| 379 } | 381 } |
| 380 } | 382 } |
| 381 | 383 |
| 382 | 384 |
| 383 void Heap::CollectOldSpaceGarbage(Thread* thread, | 385 void Heap::CollectOldSpaceGarbage(Thread* thread, |
| 384 ApiCallbacks api_callbacks, | 386 ApiCallbacks api_callbacks, |
| 385 GCReason reason) { | 387 GCReason reason) { |
| 386 if (BeginOldSpaceGC(thread)) { | 388 if (BeginOldSpaceGC(thread)) { |
| 387 bool invoke_api_callbacks = (api_callbacks == kInvokeApiCallbacks); | 389 bool invoke_api_callbacks = (api_callbacks == kInvokeApiCallbacks); |
| 388 RecordBeforeGC(kOld, reason); | 390 RecordBeforeGC(kOld, reason); |
| 389 VMTagScope tagScope(thread, VMTag::kGCOldSpaceTagId); | 391 VMTagScope tagScope(thread, VMTag::kGCOldSpaceTagId); |
| 392 #ifndef PRODUCT |
| 390 TimelineDurationScope tds(thread, | 393 TimelineDurationScope tds(thread, |
| 391 isolate()->GetGCStream(), | 394 isolate()->GetGCStream(), |
| 392 "CollectOldGeneration"); | 395 "CollectOldGeneration"); |
| 396 #endif // !PRODUCT |
| 393 UpdateClassHeapStatsBeforeGC(kOld); | 397 UpdateClassHeapStatsBeforeGC(kOld); |
| 394 old_space_.MarkSweep(invoke_api_callbacks); | 398 old_space_.MarkSweep(invoke_api_callbacks); |
| 395 RecordAfterGC(kOld); | 399 RecordAfterGC(kOld); |
| 396 PrintStats(); | 400 PrintStats(); |
| 397 EndOldSpaceGC(); | 401 EndOldSpaceGC(); |
| 398 } | 402 } |
| 399 } | 403 } |
| 400 | 404 |
| 401 | 405 |
| 402 void Heap::CollectGarbage(Space space, | 406 void Heap::CollectGarbage(Space space, |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 Dart::vm_isolate()->heap()->WriteProtect(false, include_code_pages_); | 831 Dart::vm_isolate()->heap()->WriteProtect(false, include_code_pages_); |
| 828 } | 832 } |
| 829 | 833 |
| 830 | 834 |
| 831 WritableVMIsolateScope::~WritableVMIsolateScope() { | 835 WritableVMIsolateScope::~WritableVMIsolateScope() { |
| 832 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0); | 836 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0); |
| 833 Dart::vm_isolate()->heap()->WriteProtect(true, include_code_pages_); | 837 Dart::vm_isolate()->heap()->WriteProtect(true, include_code_pages_); |
| 834 } | 838 } |
| 835 | 839 |
| 836 } // namespace dart | 840 } // namespace dart |
| OLD | NEW |