| 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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 void Heap::UpdateClassHeapStatsBeforeGC(Heap::Space space) { | 353 void Heap::UpdateClassHeapStatsBeforeGC(Heap::Space space) { |
| 354 ClassTable* class_table = isolate()->class_table(); | 354 ClassTable* class_table = isolate()->class_table(); |
| 355 if (space == kNew) { | 355 if (space == kNew) { |
| 356 class_table->ResetCountersNew(); | 356 class_table->ResetCountersNew(); |
| 357 } else { | 357 } else { |
| 358 class_table->ResetCountersOld(); | 358 class_table->ResetCountersOld(); |
| 359 } | 359 } |
| 360 } | 360 } |
| 361 #endif | 361 #endif |
| 362 | 362 |
| 363 void Heap::NotifyIdle(int64_t deadline) { |
| 364 if (new_space_.ShouldPerformIdleScavenge(deadline)) { |
| 365 Thread* thread = Thread::Current(); |
| 366 TIMELINE_FUNCTION_GC_DURATION(thread, "IdleGC"); |
| 367 CollectNewSpaceGarbage(thread, kIdle); |
| 368 } |
| 369 } |
| 370 |
| 363 void Heap::EvacuateNewSpace(Thread* thread, GCReason reason) { | 371 void Heap::EvacuateNewSpace(Thread* thread, GCReason reason) { |
| 364 ASSERT(reason == kFull); | 372 ASSERT(reason == kFull); |
| 365 if (BeginNewSpaceGC(thread)) { | 373 if (BeginNewSpaceGC(thread)) { |
| 366 RecordBeforeGC(kNew, kFull); | 374 RecordBeforeGC(kNew, kFull); |
| 367 VMTagScope tagScope(thread, VMTag::kGCNewSpaceTagId); | 375 VMTagScope tagScope(thread, VMTag::kGCNewSpaceTagId); |
| 368 TIMELINE_FUNCTION_GC_DURATION(thread, "EvacuateNewGeneration"); | 376 TIMELINE_FUNCTION_GC_DURATION(thread, "EvacuateNewGeneration"); |
| 369 NOT_IN_PRODUCT(UpdateClassHeapStatsBeforeGC(kNew)); | 377 NOT_IN_PRODUCT(UpdateClassHeapStatsBeforeGC(kNew)); |
| 370 new_space_.Evacuate(); | 378 new_space_.Evacuate(); |
| 371 NOT_IN_PRODUCT(isolate()->class_table()->UpdatePromoted()); | 379 NOT_IN_PRODUCT(isolate()->class_table()->UpdatePromoted()); |
| 372 RecordAfterGC(kNew); | 380 RecordAfterGC(kNew); |
| 373 PrintStats(); | 381 PrintStats(); |
| 374 NOT_IN_PRODUCT(PrintStatsToTimeline(&tds)); | 382 NOT_IN_PRODUCT(PrintStatsToTimeline(&tds)); |
| 375 EndNewSpaceGC(); | 383 EndNewSpaceGC(); |
| 376 } | 384 } |
| 377 } | 385 } |
| 378 | 386 |
| 379 void Heap::CollectNewSpaceGarbage(Thread* thread, | 387 void Heap::CollectNewSpaceGarbage(Thread* thread, |
| 380 GCReason reason) { | 388 GCReason reason) { |
| 381 ASSERT((reason == kNewSpace) || (reason == kFull)); | 389 ASSERT((reason == kNewSpace) || (reason == kFull) || (reason == kIdle)); |
| 382 if (BeginNewSpaceGC(thread)) { | 390 if (BeginNewSpaceGC(thread)) { |
| 383 RecordBeforeGC(kNew, reason); | 391 RecordBeforeGC(kNew, reason); |
| 384 { | 392 { |
| 385 VMTagScope tagScope(thread, VMTag::kGCNewSpaceTagId); | 393 VMTagScope tagScope(thread, VMTag::kGCNewSpaceTagId); |
| 386 TIMELINE_FUNCTION_GC_DURATION(thread, "CollectNewGeneration"); | 394 TIMELINE_FUNCTION_GC_DURATION(thread, "CollectNewGeneration"); |
| 387 NOT_IN_PRODUCT(UpdateClassHeapStatsBeforeGC(kNew)); | 395 NOT_IN_PRODUCT(UpdateClassHeapStatsBeforeGC(kNew)); |
| 388 new_space_.Scavenge(); | 396 new_space_.Scavenge(); |
| 389 NOT_IN_PRODUCT(isolate()->class_table()->UpdatePromoted()); | 397 NOT_IN_PRODUCT(isolate()->class_table()->UpdatePromoted()); |
| 390 RecordAfterGC(kNew); | 398 RecordAfterGC(kNew); |
| 391 PrintStats(); | 399 PrintStats(); |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 const char* Heap::GCReasonToString(GCReason gc_reason) { | 625 const char* Heap::GCReasonToString(GCReason gc_reason) { |
| 618 switch (gc_reason) { | 626 switch (gc_reason) { |
| 619 case kNewSpace: | 627 case kNewSpace: |
| 620 return "new space"; | 628 return "new space"; |
| 621 case kPromotion: | 629 case kPromotion: |
| 622 return "promotion"; | 630 return "promotion"; |
| 623 case kOldSpace: | 631 case kOldSpace: |
| 624 return "old space"; | 632 return "old space"; |
| 625 case kFull: | 633 case kFull: |
| 626 return "full"; | 634 return "full"; |
| 635 case kIdle: |
| 636 return "idle"; |
| 627 case kGCAtAlloc: | 637 case kGCAtAlloc: |
| 628 return "debugging"; | 638 return "debugging"; |
| 629 case kGCTestCase: | 639 case kGCTestCase: |
| 630 return "test case"; | 640 return "test case"; |
| 631 default: | 641 default: |
| 632 UNREACHABLE(); | 642 UNREACHABLE(); |
| 633 return ""; | 643 return ""; |
| 634 } | 644 } |
| 635 } | 645 } |
| 636 | 646 |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 : StackResource(thread) { | 850 : StackResource(thread) { |
| 841 Dart::vm_isolate()->heap()->WriteProtect(false); | 851 Dart::vm_isolate()->heap()->WriteProtect(false); |
| 842 } | 852 } |
| 843 | 853 |
| 844 WritableVMIsolateScope::~WritableVMIsolateScope() { | 854 WritableVMIsolateScope::~WritableVMIsolateScope() { |
| 845 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0); | 855 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0); |
| 846 Dart::vm_isolate()->heap()->WriteProtect(true); | 856 Dart::vm_isolate()->heap()->WriteProtect(true); |
| 847 } | 857 } |
| 848 | 858 |
| 849 } // namespace dart | 859 } // namespace dart |
| OLD | NEW |