Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(651)

Side by Side Diff: runtime/vm/heap.cc

Issue 2143153002: Don't track allocations in product mode. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: other archs Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/gc_marker.cc ('k') | runtime/vm/heap_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 343
344 344
345 void Heap::EndOldSpaceGC() { 345 void Heap::EndOldSpaceGC() {
346 MonitorLocker ml(&gc_in_progress_monitor_); 346 MonitorLocker ml(&gc_in_progress_monitor_);
347 ASSERT(gc_old_space_in_progress_); 347 ASSERT(gc_old_space_in_progress_);
348 gc_old_space_in_progress_ = false; 348 gc_old_space_in_progress_ = false;
349 ml.NotifyAll(); 349 ml.NotifyAll();
350 } 350 }
351 351
352 352
353 #ifndef PRODUCT
353 void Heap::UpdateClassHeapStatsBeforeGC(Heap::Space space) { 354 void Heap::UpdateClassHeapStatsBeforeGC(Heap::Space space) {
354 ClassTable* class_table = isolate()->class_table(); 355 ClassTable* class_table = isolate()->class_table();
355 if (space == kNew) { 356 if (space == kNew) {
356 class_table->ResetCountersNew(); 357 class_table->ResetCountersNew();
357 } else { 358 } else {
358 class_table->ResetCountersOld(); 359 class_table->ResetCountersOld();
359 } 360 }
360 } 361 }
362 #endif
361 363
362 364
363 void Heap::CollectNewSpaceGarbage(Thread* thread, 365 void Heap::CollectNewSpaceGarbage(Thread* thread,
364 ApiCallbacks api_callbacks, 366 ApiCallbacks api_callbacks,
365 GCReason reason) { 367 GCReason reason) {
366 ASSERT((reason == kNewSpace) || (reason == kFull)); 368 ASSERT((reason == kNewSpace) || (reason == kFull));
367 if (BeginNewSpaceGC(thread)) { 369 if (BeginNewSpaceGC(thread)) {
368 bool invoke_api_callbacks = (api_callbacks == kInvokeApiCallbacks); 370 bool invoke_api_callbacks = (api_callbacks == kInvokeApiCallbacks);
369 RecordBeforeGC(kNew, reason); 371 RecordBeforeGC(kNew, reason);
370 VMTagScope tagScope(thread, VMTag::kGCNewSpaceTagId); 372 VMTagScope tagScope(thread, VMTag::kGCNewSpaceTagId);
371 TIMELINE_FUNCTION_GC_DURATION(thread, "CollectNewGeneration"); 373 TIMELINE_FUNCTION_GC_DURATION(thread, "CollectNewGeneration");
372 UpdateClassHeapStatsBeforeGC(kNew); 374 NOT_IN_PRODUCT(UpdateClassHeapStatsBeforeGC(kNew));
373 new_space_.Scavenge(invoke_api_callbacks); 375 new_space_.Scavenge(invoke_api_callbacks);
374 isolate()->class_table()->UpdatePromoted(); 376 NOT_IN_PRODUCT(isolate()->class_table()->UpdatePromoted());
375 RecordAfterGC(kNew); 377 RecordAfterGC(kNew);
376 PrintStats(); 378 PrintStats();
377 NOT_IN_PRODUCT(PrintStatsToTimeline(&tds)); 379 NOT_IN_PRODUCT(PrintStatsToTimeline(&tds));
378 EndNewSpaceGC(); 380 EndNewSpaceGC();
379 if ((reason == kNewSpace) && old_space_.NeedsGarbageCollection()) { 381 if ((reason == kNewSpace) && old_space_.NeedsGarbageCollection()) {
380 // Old collections should call the API callbacks. 382 // Old collections should call the API callbacks.
381 CollectOldSpaceGarbage(thread, kInvokeApiCallbacks, kPromotion); 383 CollectOldSpaceGarbage(thread, kInvokeApiCallbacks, kPromotion);
382 } 384 }
383 } 385 }
384 } 386 }
385 387
386 388
387 void Heap::CollectOldSpaceGarbage(Thread* thread, 389 void Heap::CollectOldSpaceGarbage(Thread* thread,
388 ApiCallbacks api_callbacks, 390 ApiCallbacks api_callbacks,
389 GCReason reason) { 391 GCReason reason) {
390 ASSERT((reason != kNewSpace)); 392 ASSERT((reason != kNewSpace));
391 if (BeginOldSpaceGC(thread)) { 393 if (BeginOldSpaceGC(thread)) {
392 bool invoke_api_callbacks = (api_callbacks == kInvokeApiCallbacks); 394 bool invoke_api_callbacks = (api_callbacks == kInvokeApiCallbacks);
393 RecordBeforeGC(kOld, reason); 395 RecordBeforeGC(kOld, reason);
394 VMTagScope tagScope(thread, VMTag::kGCOldSpaceTagId); 396 VMTagScope tagScope(thread, VMTag::kGCOldSpaceTagId);
395 TIMELINE_FUNCTION_GC_DURATION(thread, "CollectOldGeneration"); 397 TIMELINE_FUNCTION_GC_DURATION(thread, "CollectOldGeneration");
396 UpdateClassHeapStatsBeforeGC(kOld); 398 NOT_IN_PRODUCT(UpdateClassHeapStatsBeforeGC(kOld));
397 old_space_.MarkSweep(invoke_api_callbacks); 399 old_space_.MarkSweep(invoke_api_callbacks);
398 RecordAfterGC(kOld); 400 RecordAfterGC(kOld);
399 PrintStats(); 401 PrintStats();
400 NOT_IN_PRODUCT(PrintStatsToTimeline(&tds)); 402 NOT_IN_PRODUCT(PrintStatsToTimeline(&tds));
401 EndOldSpaceGC(); 403 EndOldSpaceGC();
402 } 404 }
403 } 405 }
404 406
405 407
406 void Heap::CollectGarbage(Space space, 408 void Heap::CollectGarbage(Space space,
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 Dart::vm_isolate()->heap()->WriteProtect(false); 872 Dart::vm_isolate()->heap()->WriteProtect(false);
871 } 873 }
872 874
873 875
874 WritableVMIsolateScope::~WritableVMIsolateScope() { 876 WritableVMIsolateScope::~WritableVMIsolateScope() {
875 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0); 877 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0);
876 Dart::vm_isolate()->heap()->WriteProtect(true); 878 Dart::vm_isolate()->heap()->WriteProtect(true);
877 } 879 }
878 880
879 } // namespace dart 881 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/gc_marker.cc ('k') | runtime/vm/heap_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698