Chromium Code Reviews| 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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 356 #ifndef PRODUCT | 356 #ifndef PRODUCT |
| 357 void Heap::UpdateClassHeapStatsBeforeGC(Heap::Space space) { | 357 void Heap::UpdateClassHeapStatsBeforeGC(Heap::Space space) { |
| 358 ClassTable* class_table = isolate()->class_table(); | 358 ClassTable* class_table = isolate()->class_table(); |
| 359 if (space == kNew) { | 359 if (space == kNew) { |
| 360 class_table->ResetCountersNew(); | 360 class_table->ResetCountersNew(); |
| 361 } else { | 361 } else { |
| 362 class_table->ResetCountersOld(); | 362 class_table->ResetCountersOld(); |
| 363 } | 363 } |
| 364 } | 364 } |
| 365 #endif | 365 #endif |
| 366 | 366 |
|
rmacnak
2017/06/30 22:24:56
Two lines between functions (clang-format doesn't
danunez
2017/06/30 22:33:58
Done.
| |
| 367 void Heap::EvacuateNewSpaceGarbage(Thread* thread, GCReason reason) { | |
| 368 ASSERT(reason == kFull); | |
| 369 if (BeginNewSpaceGC(thread)) { | |
| 370 RecordBeforeGC(kNew, kFull); | |
| 371 VMTagScope tagScope(thread, VMTag::kGCNewSpaceTagId); | |
| 372 TIMELINE_FUNCTION_GC_DURATION(thread, "CollectNewGeneration"); | |
|
rmacnak
2017/06/30 22:24:56
"EvacuateNewGeneration"
danunez
2017/06/30 22:33:58
Done.
| |
| 373 NOT_IN_PRODUCT(UpdateClassHeapStatsBeforeGC(kNew)); | |
| 374 new_space_.Evacuate(); | |
| 375 NOT_IN_PRODUCT(isolate()->class_table()->UpdatePromoted()); | |
| 376 RecordAfterGC(kNew); | |
| 377 PrintStats(); | |
| 378 NOT_IN_PRODUCT(PrintStatsToTimeline(&tds)); | |
| 379 EndNewSpaceGC(); | |
| 380 } | |
| 381 } | |
| 367 | 382 |
|
rmacnak
2017/06/30 22:24:56
Two lines
danunez
2017/06/30 22:33:58
Done.
| |
| 368 void Heap::CollectNewSpaceGarbage(Thread* thread, | 383 void Heap::CollectNewSpaceGarbage(Thread* thread, |
| 369 ApiCallbacks api_callbacks, | 384 ApiCallbacks api_callbacks, |
| 370 GCReason reason) { | 385 GCReason reason) { |
| 371 ASSERT((reason == kNewSpace) || (reason == kFull)); | 386 ASSERT((reason == kNewSpace) || (reason == kFull)); |
| 372 if (BeginNewSpaceGC(thread)) { | 387 if (BeginNewSpaceGC(thread)) { |
| 373 bool invoke_api_callbacks = (api_callbacks == kInvokeApiCallbacks); | 388 bool invoke_api_callbacks = (api_callbacks == kInvokeApiCallbacks); |
| 374 RecordBeforeGC(kNew, reason); | 389 RecordBeforeGC(kNew, reason); |
| 375 VMTagScope tagScope(thread, VMTag::kGCNewSpaceTagId); | 390 VMTagScope tagScope(thread, VMTag::kGCNewSpaceTagId); |
| 376 TIMELINE_FUNCTION_GC_DURATION(thread, "CollectNewGeneration"); | 391 TIMELINE_FUNCTION_GC_DURATION(thread, "CollectNewGeneration"); |
| 377 NOT_IN_PRODUCT(UpdateClassHeapStatsBeforeGC(kNew)); | 392 NOT_IN_PRODUCT(UpdateClassHeapStatsBeforeGC(kNew)); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 437 CollectOldSpaceGarbage(thread, kInvokeApiCallbacks, kOldSpace); | 452 CollectOldSpaceGarbage(thread, kInvokeApiCallbacks, kOldSpace); |
| 438 } else { | 453 } else { |
| 439 ASSERT(space == kNew); | 454 ASSERT(space == kNew); |
| 440 CollectNewSpaceGarbage(thread, kInvokeApiCallbacks, kNewSpace); | 455 CollectNewSpaceGarbage(thread, kInvokeApiCallbacks, kNewSpace); |
| 441 } | 456 } |
| 442 } | 457 } |
| 443 | 458 |
| 444 | 459 |
| 445 void Heap::CollectAllGarbage() { | 460 void Heap::CollectAllGarbage() { |
| 446 Thread* thread = Thread::Current(); | 461 Thread* thread = Thread::Current(); |
| 447 CollectNewSpaceGarbage(thread, kInvokeApiCallbacks, kFull); | 462 |
| 463 // New space is evacuated so this GC will collect all dead objects | |
| 464 // kept alive by a cross-generational pointer. | |
| 465 EvacuateNewSpaceGarbage(thread, kFull); | |
| 448 CollectOldSpaceGarbage(thread, kInvokeApiCallbacks, kFull); | 466 CollectOldSpaceGarbage(thread, kInvokeApiCallbacks, kFull); |
| 449 } | 467 } |
| 450 | 468 |
| 451 | 469 |
| 452 void Heap::WaitForSweeperTasks(Thread* thread) { | 470 void Heap::WaitForSweeperTasks(Thread* thread) { |
| 453 MonitorLocker ml(old_space_.tasks_lock()); | 471 MonitorLocker ml(old_space_.tasks_lock()); |
| 454 while (old_space_.tasks() > 0) { | 472 while (old_space_.tasks() > 0) { |
| 455 ml.WaitWithSafepointCheck(thread); | 473 ml.WaitWithSafepointCheck(thread); |
| 456 } | 474 } |
| 457 } | 475 } |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 877 Dart::vm_isolate()->heap()->WriteProtect(false); | 895 Dart::vm_isolate()->heap()->WriteProtect(false); |
| 878 } | 896 } |
| 879 | 897 |
| 880 | 898 |
| 881 WritableVMIsolateScope::~WritableVMIsolateScope() { | 899 WritableVMIsolateScope::~WritableVMIsolateScope() { |
| 882 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0); | 900 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0); |
| 883 Dart::vm_isolate()->heap()->WriteProtect(true); | 901 Dart::vm_isolate()->heap()->WriteProtect(true); |
| 884 } | 902 } |
| 885 | 903 |
| 886 } // namespace dart | 904 } // namespace dart |
| OLD | NEW |