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 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 } | 363 } |
364 } | 364 } |
365 #endif | 365 #endif |
366 | 366 |
367 | 367 |
368 void Heap::EvacuateNewSpace(Thread* thread, GCReason reason) { | 368 void Heap::EvacuateNewSpace(Thread* thread, GCReason reason) { |
369 ASSERT(reason == kFull); | 369 ASSERT(reason == kFull); |
370 if (BeginNewSpaceGC(thread)) { | 370 if (BeginNewSpaceGC(thread)) { |
371 RecordBeforeGC(kNew, kFull); | 371 RecordBeforeGC(kNew, kFull); |
372 VMTagScope tagScope(thread, VMTag::kGCNewSpaceTagId); | 372 VMTagScope tagScope(thread, VMTag::kGCNewSpaceTagId); |
373 TIMELINE_FUNCTION_GC_DURATION(thread, "CollectNewGeneration"); | 373 TIMELINE_FUNCTION_GC_DURATION(thread, "EvacuateNewGeneration"); |
374 NOT_IN_PRODUCT(UpdateClassHeapStatsBeforeGC(kNew)); | 374 NOT_IN_PRODUCT(UpdateClassHeapStatsBeforeGC(kNew)); |
375 new_space_.Evacuate(); | 375 new_space_.Evacuate(); |
376 NOT_IN_PRODUCT(isolate()->class_table()->UpdatePromoted()); | 376 NOT_IN_PRODUCT(isolate()->class_table()->UpdatePromoted()); |
377 RecordAfterGC(kNew); | 377 RecordAfterGC(kNew); |
378 PrintStats(); | 378 PrintStats(); |
379 NOT_IN_PRODUCT(PrintStatsToTimeline(&tds)); | 379 NOT_IN_PRODUCT(PrintStatsToTimeline(&tds)); |
380 EndNewSpaceGC(); | 380 EndNewSpaceGC(); |
381 } | 381 } |
382 } | 382 } |
383 | 383 |
384 | 384 |
385 void Heap::CollectNewSpaceGarbage(Thread* thread, | 385 void Heap::CollectNewSpaceGarbage(Thread* thread, |
386 ApiCallbacks api_callbacks, | 386 ApiCallbacks api_callbacks, |
387 GCReason reason) { | 387 GCReason reason) { |
388 ASSERT((reason == kNewSpace) || (reason == kFull)); | 388 ASSERT((reason == kNewSpace) || (reason == kFull)); |
389 if (BeginNewSpaceGC(thread)) { | 389 if (BeginNewSpaceGC(thread)) { |
390 bool invoke_api_callbacks = (api_callbacks == kInvokeApiCallbacks); | 390 bool invoke_api_callbacks = (api_callbacks == kInvokeApiCallbacks); |
391 RecordBeforeGC(kNew, reason); | 391 RecordBeforeGC(kNew, reason); |
392 VMTagScope tagScope(thread, VMTag::kGCNewSpaceTagId); | 392 VMTagScope tagScope(thread, VMTag::kGCNewSpaceTagId); |
393 TIMELINE_FUNCTION_GC_DURATION(thread, "EvacuateNewGeneration"); | 393 TIMELINE_FUNCTION_GC_DURATION(thread, "CollectNewGeneration"); |
394 NOT_IN_PRODUCT(UpdateClassHeapStatsBeforeGC(kNew)); | 394 NOT_IN_PRODUCT(UpdateClassHeapStatsBeforeGC(kNew)); |
395 new_space_.Scavenge(invoke_api_callbacks); | 395 new_space_.Scavenge(invoke_api_callbacks); |
396 NOT_IN_PRODUCT(isolate()->class_table()->UpdatePromoted()); | 396 NOT_IN_PRODUCT(isolate()->class_table()->UpdatePromoted()); |
397 RecordAfterGC(kNew); | 397 RecordAfterGC(kNew); |
398 PrintStats(); | 398 PrintStats(); |
399 NOT_IN_PRODUCT(PrintStatsToTimeline(&tds)); | 399 NOT_IN_PRODUCT(PrintStatsToTimeline(&tds)); |
400 EndNewSpaceGC(); | 400 EndNewSpaceGC(); |
401 if ((reason == kNewSpace) && old_space_.NeedsGarbageCollection()) { | 401 if ((reason == kNewSpace) && old_space_.NeedsGarbageCollection()) { |
402 // Old collections should call the API callbacks. | 402 // Old collections should call the API callbacks. |
403 CollectOldSpaceGarbage(thread, kInvokeApiCallbacks, kPromotion); | 403 CollectOldSpaceGarbage(thread, kInvokeApiCallbacks, kPromotion); |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
898 Dart::vm_isolate()->heap()->WriteProtect(false); | 898 Dart::vm_isolate()->heap()->WriteProtect(false); |
899 } | 899 } |
900 | 900 |
901 | 901 |
902 WritableVMIsolateScope::~WritableVMIsolateScope() { | 902 WritableVMIsolateScope::~WritableVMIsolateScope() { |
903 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0); | 903 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0); |
904 Dart::vm_isolate()->heap()->WriteProtect(true); | 904 Dart::vm_isolate()->heap()->WriteProtect(true); |
905 } | 905 } |
906 | 906 |
907 } // namespace dart | 907 } // namespace dart |
OLD | NEW |