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 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 | 362 |
363 void Heap::CollectNewSpaceGarbage(Thread* thread, | 363 void Heap::CollectNewSpaceGarbage(Thread* thread, |
364 ApiCallbacks api_callbacks, | 364 ApiCallbacks api_callbacks, |
365 GCReason reason) { | 365 GCReason reason) { |
366 if (BeginNewSpaceGC(thread)) { | 366 if (BeginNewSpaceGC(thread)) { |
367 bool invoke_api_callbacks = (api_callbacks == kInvokeApiCallbacks); | 367 bool invoke_api_callbacks = (api_callbacks == kInvokeApiCallbacks); |
368 RecordBeforeGC(kNew, reason); | 368 RecordBeforeGC(kNew, reason); |
369 VMTagScope tagScope(thread, VMTag::kGCNewSpaceTagId); | 369 VMTagScope tagScope(thread, VMTag::kGCNewSpaceTagId); |
370 #ifndef PRODUCT | 370 #ifndef PRODUCT |
371 TimelineDurationScope tds(thread, | 371 TimelineDurationScope tds(thread, |
372 isolate()->GetGCStream(), | 372 Timeline::GetGCStream(), |
373 "CollectNewGeneration"); | 373 "CollectNewGeneration"); |
374 #endif // !PRODUCT | 374 #endif // !PRODUCT |
375 UpdateClassHeapStatsBeforeGC(kNew); | 375 UpdateClassHeapStatsBeforeGC(kNew); |
376 new_space_.Scavenge(invoke_api_callbacks); | 376 new_space_.Scavenge(invoke_api_callbacks); |
377 isolate()->class_table()->UpdatePromoted(); | 377 isolate()->class_table()->UpdatePromoted(); |
378 UpdatePretenurePolicy(); | 378 UpdatePretenurePolicy(); |
379 RecordAfterGC(kNew); | 379 RecordAfterGC(kNew); |
380 PrintStats(); | 380 PrintStats(); |
381 EndNewSpaceGC(); | 381 EndNewSpaceGC(); |
382 if (old_space_.NeedsGarbageCollection()) { | 382 if (old_space_.NeedsGarbageCollection()) { |
383 // Old collections should call the API callbacks. | 383 // Old collections should call the API callbacks. |
384 CollectOldSpaceGarbage(thread, kInvokeApiCallbacks, kPromotion); | 384 CollectOldSpaceGarbage(thread, kInvokeApiCallbacks, kPromotion); |
385 } | 385 } |
386 } | 386 } |
387 } | 387 } |
388 | 388 |
389 | 389 |
390 void Heap::CollectOldSpaceGarbage(Thread* thread, | 390 void Heap::CollectOldSpaceGarbage(Thread* thread, |
391 ApiCallbacks api_callbacks, | 391 ApiCallbacks api_callbacks, |
392 GCReason reason) { | 392 GCReason reason) { |
393 if (BeginOldSpaceGC(thread)) { | 393 if (BeginOldSpaceGC(thread)) { |
394 bool invoke_api_callbacks = (api_callbacks == kInvokeApiCallbacks); | 394 bool invoke_api_callbacks = (api_callbacks == kInvokeApiCallbacks); |
395 RecordBeforeGC(kOld, reason); | 395 RecordBeforeGC(kOld, reason); |
396 VMTagScope tagScope(thread, VMTag::kGCOldSpaceTagId); | 396 VMTagScope tagScope(thread, VMTag::kGCOldSpaceTagId); |
397 #ifndef PRODUCT | 397 #ifndef PRODUCT |
398 TimelineDurationScope tds(thread, | 398 TimelineDurationScope tds(thread, |
399 isolate()->GetGCStream(), | 399 Timeline::GetGCStream(), |
400 "CollectOldGeneration"); | 400 "CollectOldGeneration"); |
401 #endif // !PRODUCT | 401 #endif // !PRODUCT |
402 UpdateClassHeapStatsBeforeGC(kOld); | 402 UpdateClassHeapStatsBeforeGC(kOld); |
403 old_space_.MarkSweep(invoke_api_callbacks); | 403 old_space_.MarkSweep(invoke_api_callbacks); |
404 RecordAfterGC(kOld); | 404 RecordAfterGC(kOld); |
405 PrintStats(); | 405 PrintStats(); |
406 EndOldSpaceGC(); | 406 EndOldSpaceGC(); |
407 } | 407 } |
408 } | 408 } |
409 | 409 |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
854 Dart::vm_isolate()->heap()->WriteProtect(false, include_code_pages_); | 854 Dart::vm_isolate()->heap()->WriteProtect(false, include_code_pages_); |
855 } | 855 } |
856 | 856 |
857 | 857 |
858 WritableVMIsolateScope::~WritableVMIsolateScope() { | 858 WritableVMIsolateScope::~WritableVMIsolateScope() { |
859 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0); | 859 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0); |
860 Dart::vm_isolate()->heap()->WriteProtect(true, include_code_pages_); | 860 Dart::vm_isolate()->heap()->WriteProtect(true, include_code_pages_); |
861 } | 861 } |
862 | 862 |
863 } // namespace dart | 863 } // namespace dart |
OLD | NEW |