| 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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 return raw_obj; | 305 return raw_obj; |
| 306 } | 306 } |
| 307 raw_obj = FindObjectInCodeSpace(visitor); | 307 raw_obj = FindObjectInCodeSpace(visitor); |
| 308 return raw_obj; | 308 return raw_obj; |
| 309 } | 309 } |
| 310 | 310 |
| 311 | 311 |
| 312 void Heap::CollectGarbage(Space space, | 312 void Heap::CollectGarbage(Space space, |
| 313 ApiCallbacks api_callbacks, | 313 ApiCallbacks api_callbacks, |
| 314 GCReason reason) { | 314 GCReason reason) { |
| 315 Thread* thread = Thread::Current(); |
| 315 TIMERSCOPE(isolate(), time_gc); | 316 TIMERSCOPE(isolate(), time_gc); |
| 316 bool invoke_api_callbacks = (api_callbacks == kInvokeApiCallbacks); | 317 bool invoke_api_callbacks = (api_callbacks == kInvokeApiCallbacks); |
| 317 switch (space) { | 318 switch (space) { |
| 318 case kNew: { | 319 case kNew: { |
| 319 VMTagScope tagScope(isolate(), VMTag::kGCNewSpaceTagId); | 320 VMTagScope tagScope(thread, VMTag::kGCNewSpaceTagId); |
| 320 TimelineDurationScope tds(isolate(), | 321 TimelineDurationScope tds(isolate(), |
| 321 isolate()->GetGCStream(), | 322 isolate()->GetGCStream(), |
| 322 "CollectNewGeneration"); | 323 "CollectNewGeneration"); |
| 323 RecordBeforeGC(kNew, reason); | 324 RecordBeforeGC(kNew, reason); |
| 324 UpdateClassHeapStatsBeforeGC(kNew); | 325 UpdateClassHeapStatsBeforeGC(kNew); |
| 325 new_space_.Scavenge(invoke_api_callbacks); | 326 new_space_.Scavenge(invoke_api_callbacks); |
| 326 isolate()->class_table()->UpdatePromoted(); | 327 isolate()->class_table()->UpdatePromoted(); |
| 327 UpdatePretenurePolicy(); | 328 UpdatePretenurePolicy(); |
| 328 RecordAfterGC(); | 329 RecordAfterGC(); |
| 329 PrintStats(); | 330 PrintStats(); |
| 330 if (old_space_.NeedsGarbageCollection()) { | 331 if (old_space_.NeedsGarbageCollection()) { |
| 331 // Old collections should call the API callbacks. | 332 // Old collections should call the API callbacks. |
| 332 CollectGarbage(kOld, kInvokeApiCallbacks, kPromotion); | 333 CollectGarbage(kOld, kInvokeApiCallbacks, kPromotion); |
| 333 } | 334 } |
| 334 break; | 335 break; |
| 335 } | 336 } |
| 336 case kOld: | 337 case kOld: |
| 337 case kCode: { | 338 case kCode: { |
| 338 VMTagScope tagScope(isolate(), VMTag::kGCOldSpaceTagId); | 339 VMTagScope tagScope(thread, VMTag::kGCOldSpaceTagId); |
| 339 TimelineDurationScope tds(isolate(), | 340 TimelineDurationScope tds(isolate(), |
| 340 isolate()->GetGCStream(), | 341 isolate()->GetGCStream(), |
| 341 "CollectOldGeneration"); | 342 "CollectOldGeneration"); |
| 342 RecordBeforeGC(kOld, reason); | 343 RecordBeforeGC(kOld, reason); |
| 343 UpdateClassHeapStatsBeforeGC(kOld); | 344 UpdateClassHeapStatsBeforeGC(kOld); |
| 344 old_space_.MarkSweep(invoke_api_callbacks); | 345 old_space_.MarkSweep(invoke_api_callbacks); |
| 345 RecordAfterGC(); | 346 RecordAfterGC(); |
| 346 PrintStats(); | 347 PrintStats(); |
| 347 break; | 348 break; |
| 348 } | 349 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 366 if (space == kOld) { | 367 if (space == kOld) { |
| 367 CollectGarbage(space, kInvokeApiCallbacks, kOldSpace); | 368 CollectGarbage(space, kInvokeApiCallbacks, kOldSpace); |
| 368 } else { | 369 } else { |
| 369 ASSERT(space == kNew); | 370 ASSERT(space == kNew); |
| 370 CollectGarbage(space, kInvokeApiCallbacks, kNewSpace); | 371 CollectGarbage(space, kInvokeApiCallbacks, kNewSpace); |
| 371 } | 372 } |
| 372 } | 373 } |
| 373 | 374 |
| 374 | 375 |
| 375 void Heap::CollectAllGarbage() { | 376 void Heap::CollectAllGarbage() { |
| 377 Thread* thread = Thread::Current(); |
| 376 TIMERSCOPE(isolate(), time_gc); | 378 TIMERSCOPE(isolate(), time_gc); |
| 377 { | 379 { |
| 378 VMTagScope tagScope(isolate(), VMTag::kGCNewSpaceTagId); | 380 VMTagScope tagScope(thread, VMTag::kGCNewSpaceTagId); |
| 379 TimelineDurationScope tds(isolate(), | 381 TimelineDurationScope tds(isolate(), |
| 380 isolate()->GetGCStream(), | 382 isolate()->GetGCStream(), |
| 381 "CollectNewGeneration"); | 383 "CollectNewGeneration"); |
| 382 RecordBeforeGC(kNew, kFull); | 384 RecordBeforeGC(kNew, kFull); |
| 383 UpdateClassHeapStatsBeforeGC(kNew); | 385 UpdateClassHeapStatsBeforeGC(kNew); |
| 384 new_space_.Scavenge(kInvokeApiCallbacks); | 386 new_space_.Scavenge(kInvokeApiCallbacks); |
| 385 isolate()->class_table()->UpdatePromoted(); | 387 isolate()->class_table()->UpdatePromoted(); |
| 386 UpdatePretenurePolicy(); | 388 UpdatePretenurePolicy(); |
| 387 RecordAfterGC(); | 389 RecordAfterGC(); |
| 388 PrintStats(); | 390 PrintStats(); |
| 389 } | 391 } |
| 390 { | 392 { |
| 391 VMTagScope tagScope(isolate(), VMTag::kGCOldSpaceTagId); | 393 VMTagScope tagScope(thread, VMTag::kGCOldSpaceTagId); |
| 392 TimelineDurationScope tds(isolate(), | 394 TimelineDurationScope tds(isolate(), |
| 393 isolate()->GetGCStream(), | 395 isolate()->GetGCStream(), |
| 394 "CollectOldGeneration"); | 396 "CollectOldGeneration"); |
| 395 RecordBeforeGC(kOld, kFull); | 397 RecordBeforeGC(kOld, kFull); |
| 396 UpdateClassHeapStatsBeforeGC(kOld); | 398 UpdateClassHeapStatsBeforeGC(kOld); |
| 397 old_space_.MarkSweep(kInvokeApiCallbacks); | 399 old_space_.MarkSweep(kInvokeApiCallbacks); |
| 398 RecordAfterGC(); | 400 RecordAfterGC(); |
| 399 PrintStats(); | 401 PrintStats(); |
| 400 } | 402 } |
| 401 } | 403 } |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 heap->DisableGrowthControl(); | 767 heap->DisableGrowthControl(); |
| 766 } | 768 } |
| 767 | 769 |
| 768 | 770 |
| 769 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() { | 771 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() { |
| 770 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap(); | 772 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap(); |
| 771 heap->SetGrowthControlState(current_growth_controller_state_); | 773 heap->SetGrowthControlState(current_growth_controller_state_); |
| 772 } | 774 } |
| 773 | 775 |
| 774 } // namespace dart | 776 } // namespace dart |
| OLD | NEW |