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 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 438 } | 438 } |
| 439 | 439 |
| 440 void Heap::WaitForSweeperTasks(Thread* thread) { | 440 void Heap::WaitForSweeperTasks(Thread* thread) { |
| 441 MonitorLocker ml(old_space_.tasks_lock()); | 441 MonitorLocker ml(old_space_.tasks_lock()); |
| 442 while (old_space_.tasks() > 0) { | 442 while (old_space_.tasks() > 0) { |
| 443 ml.WaitWithSafepointCheck(thread); | 443 ml.WaitWithSafepointCheck(thread); |
| 444 } | 444 } |
| 445 } | 445 } |
| 446 | 446 |
| 447 void Heap::UpdateGlobalMaxUsed() { | 447 void Heap::UpdateGlobalMaxUsed() { |
| 448 #if !defined(PRODUCT) | |
| 448 ASSERT(isolate_ != NULL); | 449 ASSERT(isolate_ != NULL); |
| 449 // We are accessing the used in words count for both new and old space | 450 // We are accessing the used in words count for both new and old space |
| 450 // without synchronizing. The value of this metric is approximate. | 451 // without synchronizing. The value of this metric is approximate. |
| 451 isolate_->GetHeapGlobalUsedMaxMetric()->SetValue( | 452 isolate_->GetHeapGlobalUsedMaxMetric()->SetValue( |
| 452 (UsedInWords(Heap::kNew) * kWordSize) + | 453 (UsedInWords(Heap::kNew) * kWordSize) + |
| 453 (UsedInWords(Heap::kOld) * kWordSize)); | 454 (UsedInWords(Heap::kOld) * kWordSize)); |
| 455 #endif // !defined(PRODUCT) | |
| 454 } | 456 } |
| 455 | 457 |
| 456 void Heap::InitGrowthControl() { | 458 void Heap::InitGrowthControl() { |
| 457 old_space_.InitGrowthControl(); | 459 old_space_.InitGrowthControl(); |
| 458 } | 460 } |
| 459 | 461 |
| 460 void Heap::SetGrowthControlState(bool state) { | 462 void Heap::SetGrowthControlState(bool state) { |
| 461 old_space_.SetGrowthControlState(state); | 463 old_space_.SetGrowthControlState(state); |
| 462 } | 464 } |
| 463 | 465 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 475 intptr_t max_new_gen_words, | 477 intptr_t max_new_gen_words, |
| 476 intptr_t max_old_gen_words, | 478 intptr_t max_old_gen_words, |
| 477 intptr_t max_external_words) { | 479 intptr_t max_external_words) { |
| 478 ASSERT(isolate->heap() == NULL); | 480 ASSERT(isolate->heap() == NULL); |
| 479 Heap* heap = new Heap(isolate, max_new_gen_words, max_old_gen_words, | 481 Heap* heap = new Heap(isolate, max_new_gen_words, max_old_gen_words, |
| 480 max_external_words); | 482 max_external_words); |
| 481 isolate->set_heap(heap); | 483 isolate->set_heap(heap); |
| 482 } | 484 } |
| 483 | 485 |
| 484 void Heap::RegionName(Heap* heap, Space space, char* name, intptr_t name_size) { | 486 void Heap::RegionName(Heap* heap, Space space, char* name, intptr_t name_size) { |
| 487 #if defined(PRODUCT) | |
| 488 const char* isolate_name = "<unknown>"; | |
|
rmacnak
2017/07/24 19:10:36
Maybe use the regular name field?
zra
2017/07/24 20:21:53
Done.
| |
| 489 #else | |
| 485 const bool no_isolate_name = (heap == NULL) || (heap->isolate() == NULL) || | 490 const bool no_isolate_name = (heap == NULL) || (heap->isolate() == NULL) || |
| 486 (heap->isolate()->debugger_name() == NULL); | 491 (heap->isolate()->debugger_name() == NULL); |
| 487 const char* isolate_name = | 492 const char* isolate_name = |
| 488 no_isolate_name ? "<unknown>" : heap->isolate()->debugger_name(); | 493 no_isolate_name ? "<unknown>" : heap->isolate()->debugger_name(); |
| 494 #endif // !defined(PRODUCT) | |
| 489 const char* space_name = NULL; | 495 const char* space_name = NULL; |
| 490 switch (space) { | 496 switch (space) { |
| 491 case kNew: | 497 case kNew: |
| 492 space_name = "newspace"; | 498 space_name = "newspace"; |
| 493 break; | 499 break; |
| 494 case kOld: | 500 case kOld: |
| 495 space_name = "oldspace"; | 501 space_name = "oldspace"; |
| 496 break; | 502 break; |
| 497 case kCode: | 503 case kCode: |
| 498 space_name = "codespace"; | 504 space_name = "codespace"; |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 695 if (FLAG_support_service && Service::gc_stream.enabled() && | 701 if (FLAG_support_service && Service::gc_stream.enabled() && |
| 696 !ServiceIsolate::IsServiceIsolateDescendant(Isolate::Current())) { | 702 !ServiceIsolate::IsServiceIsolateDescendant(Isolate::Current())) { |
| 697 ServiceEvent event(Isolate::Current(), ServiceEvent::kGC); | 703 ServiceEvent event(Isolate::Current(), ServiceEvent::kGC); |
| 698 event.set_gc_stats(&stats_); | 704 event.set_gc_stats(&stats_); |
| 699 Service::HandleEvent(&event); | 705 Service::HandleEvent(&event); |
| 700 } | 706 } |
| 701 #endif // !PRODUCT | 707 #endif // !PRODUCT |
| 702 } | 708 } |
| 703 | 709 |
| 704 void Heap::PrintStats() { | 710 void Heap::PrintStats() { |
| 711 #if !defined(PRODUCT) | |
| 705 if (!FLAG_verbose_gc) return; | 712 if (!FLAG_verbose_gc) return; |
| 706 | 713 |
| 707 if ((FLAG_verbose_gc_hdr != 0) && | 714 if ((FLAG_verbose_gc_hdr != 0) && |
| 708 (((stats_.num_ - 1) % FLAG_verbose_gc_hdr) == 0)) { | 715 (((stats_.num_ - 1) % FLAG_verbose_gc_hdr) == 0)) { |
| 709 OS::PrintErr( | 716 OS::PrintErr( |
| 710 "[ | | | | " | 717 "[ | | | | " |
| 711 "| new gen | new gen | new gen " | 718 "| new gen | new gen | new gen " |
| 712 "| old gen | old gen | old gen " | 719 "| old gen | old gen | old gen " |
| 713 "| sweep | safe- | roots/| stbuf/| tospc/| weaks/| ]\n" | 720 "| sweep | safe- | roots/| stbuf/| tospc/| weaks/| ]\n" |
| 714 "[ GC isolate | space (reason) | GC# | start | time " | 721 "[ GC isolate | space (reason) | GC# | start | time " |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 758 MicrosecondsToMilliseconds(stats_.times_[1]), | 765 MicrosecondsToMilliseconds(stats_.times_[1]), |
| 759 MicrosecondsToMilliseconds(stats_.times_[2]), | 766 MicrosecondsToMilliseconds(stats_.times_[2]), |
| 760 MicrosecondsToMilliseconds(stats_.times_[3]), | 767 MicrosecondsToMilliseconds(stats_.times_[3]), |
| 761 MicrosecondsToMilliseconds(stats_.times_[4]), | 768 MicrosecondsToMilliseconds(stats_.times_[4]), |
| 762 MicrosecondsToMilliseconds(stats_.times_[5]), | 769 MicrosecondsToMilliseconds(stats_.times_[5]), |
| 763 stats_.data_[0], | 770 stats_.data_[0], |
| 764 stats_.data_[1], | 771 stats_.data_[1], |
| 765 stats_.data_[2], | 772 stats_.data_[2], |
| 766 stats_.data_[3]); | 773 stats_.data_[3]); |
| 767 // clang-format on | 774 // clang-format on |
| 775 #endif // !defined(PRODUCT) | |
| 768 } | 776 } |
| 769 | 777 |
| 770 void Heap::PrintStatsToTimeline(TimelineEventScope* event) { | 778 void Heap::PrintStatsToTimeline(TimelineEventScope* event) { |
| 771 #if !defined(PRODUCT) | 779 #if !defined(PRODUCT) |
| 772 if ((event == NULL) || !event->enabled()) { | 780 if ((event == NULL) || !event->enabled()) { |
| 773 return; | 781 return; |
| 774 } | 782 } |
| 775 event->SetNumArguments(12); | 783 event->SetNumArguments(12); |
| 776 event->FormatArgument(0, "Before.New.Used (kB)", "%" Pd "", | 784 event->FormatArgument(0, "Before.New.Used (kB)", "%" Pd "", |
| 777 RoundWordsToKB(stats_.before_.new_.used_in_words)); | 785 RoundWordsToKB(stats_.before_.new_.used_in_words)); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 818 : StackResource(thread) { | 826 : StackResource(thread) { |
| 819 Dart::vm_isolate()->heap()->WriteProtect(false); | 827 Dart::vm_isolate()->heap()->WriteProtect(false); |
| 820 } | 828 } |
| 821 | 829 |
| 822 WritableVMIsolateScope::~WritableVMIsolateScope() { | 830 WritableVMIsolateScope::~WritableVMIsolateScope() { |
| 823 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0); | 831 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0); |
| 824 Dart::vm_isolate()->heap()->WriteProtect(true); | 832 Dart::vm_isolate()->heap()->WriteProtect(true); |
| 825 } | 833 } |
| 826 | 834 |
| 827 } // namespace dart | 835 } // namespace dart |
| OLD | NEW |