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

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

Issue 2481873005: clang-format runtime/vm (Closed)
Patch Set: Merge Created 4 years, 1 month 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/heap.h ('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 21 matching lines...) Expand all
32 intptr_t max_external_words) 32 intptr_t max_external_words)
33 : isolate_(isolate), 33 : isolate_(isolate),
34 new_space_(this, max_new_gen_semi_words, kNewObjectAlignmentOffset), 34 new_space_(this, max_new_gen_semi_words, kNewObjectAlignmentOffset),
35 old_space_(this, max_old_gen_words, max_external_words), 35 old_space_(this, max_old_gen_words, max_external_words),
36 barrier_(new Monitor()), 36 barrier_(new Monitor()),
37 barrier_done_(new Monitor()), 37 barrier_done_(new Monitor()),
38 read_only_(false), 38 read_only_(false),
39 gc_new_space_in_progress_(false), 39 gc_new_space_in_progress_(false),
40 gc_old_space_in_progress_(false) { 40 gc_old_space_in_progress_(false) {
41 UpdateGlobalMaxUsed(); 41 UpdateGlobalMaxUsed();
42 for (int sel = 0; 42 for (int sel = 0; sel < kNumWeakSelectors; sel++) {
43 sel < kNumWeakSelectors;
44 sel++) {
45 new_weak_tables_[sel] = new WeakTable(); 43 new_weak_tables_[sel] = new WeakTable();
46 old_weak_tables_[sel] = new WeakTable(); 44 old_weak_tables_[sel] = new WeakTable();
47 } 45 }
48 stats_.num_ = 0; 46 stats_.num_ = 0;
49 } 47 }
50 48
51 49
52 Heap::~Heap() { 50 Heap::~Heap() {
53 delete barrier_; 51 delete barrier_;
54 delete barrier_done_; 52 delete barrier_done_;
55 53
56 for (int sel = 0; 54 for (int sel = 0; sel < kNumWeakSelectors; sel++) {
57 sel < kNumWeakSelectors;
58 sel++) {
59 delete new_weak_tables_[sel]; 55 delete new_weak_tables_[sel];
60 delete old_weak_tables_[sel]; 56 delete old_weak_tables_[sel];
61 } 57 }
62 } 58 }
63 59
64 60
65 uword Heap::AllocateNew(intptr_t size) { 61 uword Heap::AllocateNew(intptr_t size) {
66 ASSERT(Thread::Current()->no_safepoint_scope_depth() == 0); 62 ASSERT(Thread::Current()->no_safepoint_scope_depth() == 0);
67 // Currently, only the Dart thread may allocate in new space. 63 // Currently, only the Dart thread may allocate in new space.
68 isolate()->AssertCurrentThreadIsMutator(); 64 isolate()->AssertCurrentThreadIsMutator();
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 while (old_space_.tasks() > 0) { 128 while (old_space_.tasks() > 0) {
133 ml.WaitWithSafepointCheck(thread); 129 ml.WaitWithSafepointCheck(thread);
134 } 130 }
135 } 131 }
136 } 132 }
137 addr = old_space_.TryAllocate(size, type, PageSpace::kForceGrowth); 133 addr = old_space_.TryAllocate(size, type, PageSpace::kForceGrowth);
138 if (addr != 0) { 134 if (addr != 0) {
139 return addr; 135 return addr;
140 } 136 }
141 // Give up allocating this object. 137 // Give up allocating this object.
142 OS::PrintErr( 138 OS::PrintErr("Exhausted heap space, trying to allocate %" Pd " bytes.\n",
143 "Exhausted heap space, trying to allocate %" Pd " bytes.\n", size); 139 size);
144 return 0; 140 return 0;
145 } 141 }
146 142
147 143
148 void Heap::AllocateExternal(intptr_t size, Space space) { 144 void Heap::AllocateExternal(intptr_t size, Space space) {
149 ASSERT(Thread::Current()->no_safepoint_scope_depth() == 0); 145 ASSERT(Thread::Current()->no_safepoint_scope_depth() == 0);
150 if (space == kNew) { 146 if (space == kNew) {
151 isolate()->AssertCurrentThreadIsMutator(); 147 isolate()->AssertCurrentThreadIsMutator();
152 new_space_.AllocateExternal(size); 148 new_space_.AllocateExternal(size);
153 if (new_space_.ExternalInWords() > (FLAG_new_gen_ext_limit * MBInWords)) { 149 if (new_space_.ExternalInWords() > (FLAG_new_gen_ext_limit * MBInWords)) {
(...skipping 18 matching lines...) Expand all
172 old_space_.FreeExternal(size); 168 old_space_.FreeExternal(size);
173 } 169 }
174 } 170 }
175 171
176 void Heap::PromoteExternal(intptr_t size) { 172 void Heap::PromoteExternal(intptr_t size) {
177 new_space_.FreeExternal(size); 173 new_space_.FreeExternal(size);
178 old_space_.AllocateExternal(size); 174 old_space_.AllocateExternal(size);
179 } 175 }
180 176
181 bool Heap::Contains(uword addr) const { 177 bool Heap::Contains(uword addr) const {
182 return new_space_.Contains(addr) || 178 return new_space_.Contains(addr) || old_space_.Contains(addr);
183 old_space_.Contains(addr);
184 } 179 }
185 180
186 181
187 bool Heap::NewContains(uword addr) const { 182 bool Heap::NewContains(uword addr) const {
188 return new_space_.Contains(addr); 183 return new_space_.Contains(addr);
189 } 184 }
190 185
191 186
192 bool Heap::OldContains(uword addr) const { 187 bool Heap::OldContains(uword addr) const {
193 return old_space_.Contains(addr); 188 return old_space_.Contains(addr);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 return raw_obj; 291 return raw_obj;
297 } 292 }
298 raw_obj = FindObjectInCodeSpace(visitor); 293 raw_obj = FindObjectInCodeSpace(visitor);
299 return raw_obj; 294 return raw_obj;
300 } 295 }
301 296
302 297
303 bool Heap::BeginNewSpaceGC(Thread* thread) { 298 bool Heap::BeginNewSpaceGC(Thread* thread) {
304 MonitorLocker ml(&gc_in_progress_monitor_); 299 MonitorLocker ml(&gc_in_progress_monitor_);
305 bool start_gc_on_thread = true; 300 bool start_gc_on_thread = true;
306 while (gc_new_space_in_progress_ || 301 while (gc_new_space_in_progress_ || gc_old_space_in_progress_) {
307 gc_old_space_in_progress_) {
308 start_gc_on_thread = !gc_new_space_in_progress_; 302 start_gc_on_thread = !gc_new_space_in_progress_;
309 ml.WaitWithSafepointCheck(thread); 303 ml.WaitWithSafepointCheck(thread);
310 } 304 }
311 if (start_gc_on_thread) { 305 if (start_gc_on_thread) {
312 gc_new_space_in_progress_ = true; 306 gc_new_space_in_progress_ = true;
313 return true; 307 return true;
314 } 308 }
315 return false; 309 return false;
316 } 310 }
317 311
318 312
319 void Heap::EndNewSpaceGC() { 313 void Heap::EndNewSpaceGC() {
320 MonitorLocker ml(&gc_in_progress_monitor_); 314 MonitorLocker ml(&gc_in_progress_monitor_);
321 ASSERT(gc_new_space_in_progress_); 315 ASSERT(gc_new_space_in_progress_);
322 gc_new_space_in_progress_ = false; 316 gc_new_space_in_progress_ = false;
323 ml.NotifyAll(); 317 ml.NotifyAll();
324 } 318 }
325 319
326 320
327 bool Heap::BeginOldSpaceGC(Thread* thread) { 321 bool Heap::BeginOldSpaceGC(Thread* thread) {
328 MonitorLocker ml(&gc_in_progress_monitor_); 322 MonitorLocker ml(&gc_in_progress_monitor_);
329 bool start_gc_on_thread = true; 323 bool start_gc_on_thread = true;
330 while (gc_new_space_in_progress_ || 324 while (gc_new_space_in_progress_ || gc_old_space_in_progress_) {
331 gc_old_space_in_progress_) {
332 start_gc_on_thread = !gc_old_space_in_progress_; 325 start_gc_on_thread = !gc_old_space_in_progress_;
333 ml.WaitWithSafepointCheck(thread); 326 ml.WaitWithSafepointCheck(thread);
334 } 327 }
335 if (start_gc_on_thread) { 328 if (start_gc_on_thread) {
336 gc_old_space_in_progress_ = true; 329 gc_old_space_in_progress_ = true;
337 return true; 330 return true;
338 } 331 }
339 return false; 332 return false;
340 } 333 }
341 334
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 return OFFSET_OF(Heap, old_space_) + PageSpace::end_offset(); 497 return OFFSET_OF(Heap, old_space_) + PageSpace::end_offset();
505 } 498 }
506 } 499 }
507 500
508 501
509 void Heap::Init(Isolate* isolate, 502 void Heap::Init(Isolate* isolate,
510 intptr_t max_new_gen_words, 503 intptr_t max_new_gen_words,
511 intptr_t max_old_gen_words, 504 intptr_t max_old_gen_words,
512 intptr_t max_external_words) { 505 intptr_t max_external_words) {
513 ASSERT(isolate->heap() == NULL); 506 ASSERT(isolate->heap() == NULL);
514 Heap* heap = new Heap(isolate, 507 Heap* heap = new Heap(isolate, max_new_gen_words, max_old_gen_words,
515 max_new_gen_words,
516 max_old_gen_words,
517 max_external_words); 508 max_external_words);
518 isolate->set_heap(heap); 509 isolate->set_heap(heap);
519 } 510 }
520 511
521 512
522 void Heap::AddRegionsToObjectSet(ObjectSet* set) const { 513 void Heap::AddRegionsToObjectSet(ObjectSet* set) const {
523 new_space_.AddRegionsToObjectSet(set); 514 new_space_.AddRegionsToObjectSet(set);
524 old_space_.AddRegionsToObjectSet(set); 515 old_space_.AddRegionsToObjectSet(set);
525 } 516 }
526 517
527 518
528 ObjectSet* Heap::CreateAllocatedObjectSet( 519 ObjectSet* Heap::CreateAllocatedObjectSet(
529 Zone* zone, 520 Zone* zone,
530 MarkExpectation mark_expectation) const { 521 MarkExpectation mark_expectation) const {
531 ObjectSet* allocated_set = new(zone) ObjectSet(zone); 522 ObjectSet* allocated_set = new (zone) ObjectSet(zone);
532 523
533 this->AddRegionsToObjectSet(allocated_set); 524 this->AddRegionsToObjectSet(allocated_set);
534 { 525 {
535 VerifyObjectVisitor object_visitor( 526 VerifyObjectVisitor object_visitor(isolate(), allocated_set,
536 isolate(), allocated_set, mark_expectation); 527 mark_expectation);
537 this->VisitObjects(&object_visitor); 528 this->VisitObjects(&object_visitor);
538 } 529 }
539 530
540 Isolate* vm_isolate = Dart::vm_isolate(); 531 Isolate* vm_isolate = Dart::vm_isolate();
541 vm_isolate->heap()->AddRegionsToObjectSet(allocated_set); 532 vm_isolate->heap()->AddRegionsToObjectSet(allocated_set);
542 { 533 {
543 // VM isolate heap is premarked. 534 // VM isolate heap is premarked.
544 VerifyObjectVisitor vm_object_visitor( 535 VerifyObjectVisitor vm_object_visitor(isolate(), allocated_set,
545 isolate(), allocated_set, kRequireMarked); 536 kRequireMarked);
546 vm_isolate->heap()->VisitObjects(&vm_object_visitor); 537 vm_isolate->heap()->VisitObjects(&vm_object_visitor);
547 } 538 }
548 539
549 return allocated_set; 540 return allocated_set;
550 } 541 }
551 542
552 543
553 bool Heap::Verify(MarkExpectation mark_expectation) const { 544 bool Heap::Verify(MarkExpectation mark_expectation) const {
554 HeapIterationScope heap_iteration_scope; 545 HeapIterationScope heap_iteration_scope;
555 return VerifyGC(mark_expectation); 546 return VerifyGC(mark_expectation);
556 } 547 }
557 548
558 549
559 bool Heap::VerifyGC(MarkExpectation mark_expectation) const { 550 bool Heap::VerifyGC(MarkExpectation mark_expectation) const {
560 StackZone stack_zone(Thread::Current()); 551 StackZone stack_zone(Thread::Current());
561 ObjectSet* allocated_set = CreateAllocatedObjectSet(stack_zone.GetZone(), 552 ObjectSet* allocated_set =
562 mark_expectation); 553 CreateAllocatedObjectSet(stack_zone.GetZone(), mark_expectation);
563 VerifyPointersVisitor visitor(isolate(), allocated_set); 554 VerifyPointersVisitor visitor(isolate(), allocated_set);
564 VisitObjectPointers(&visitor); 555 VisitObjectPointers(&visitor);
565 556
566 // Only returning a value so that Heap::Validate can be called from an ASSERT. 557 // Only returning a value so that Heap::Validate can be called from an ASSERT.
567 return true; 558 return true;
568 } 559 }
569 560
570 561
571 void Heap::PrintSizes() const { 562 void Heap::PrintSizes() const {
572 OS::PrintErr("New space (%" Pd64 "k of %" Pd64 "k) " 563 OS::PrintErr(
573 "Old space (%" Pd64 "k of %" Pd64 "k)\n", 564 "New space (%" Pd64 "k of %" Pd64
574 (UsedInWords(kNew) / KBInWords), 565 "k) "
575 (CapacityInWords(kNew) / KBInWords), 566 "Old space (%" Pd64 "k of %" Pd64 "k)\n",
576 (UsedInWords(kOld) / KBInWords), 567 (UsedInWords(kNew) / KBInWords), (CapacityInWords(kNew) / KBInWords),
577 (CapacityInWords(kOld) / KBInWords)); 568 (UsedInWords(kOld) / KBInWords), (CapacityInWords(kOld) / KBInWords));
578 } 569 }
579 570
580 571
581 int64_t Heap::UsedInWords(Space space) const { 572 int64_t Heap::UsedInWords(Space space) const {
582 return space == kNew ? new_space_.UsedInWords() : old_space_.UsedInWords(); 573 return space == kNew ? new_space_.UsedInWords() : old_space_.UsedInWords();
583 } 574 }
584 575
585 576
586 int64_t Heap::CapacityInWords(Space space) const { 577 int64_t Heap::CapacityInWords(Space space) const {
587 return space == kNew ? new_space_.CapacityInWords() : 578 return space == kNew ? new_space_.CapacityInWords()
588 old_space_.CapacityInWords(); 579 : old_space_.CapacityInWords();
589 } 580 }
590 581
591 582
592 int64_t Heap::ExternalInWords(Space space) const { 583 int64_t Heap::ExternalInWords(Space space) const {
593 return space == kNew ? new_space_.ExternalInWords() : 584 return space == kNew ? new_space_.ExternalInWords()
594 old_space_.ExternalInWords(); 585 : old_space_.ExternalInWords();
595 } 586 }
596 587
597 588
598 int64_t Heap::GCTimeInMicros(Space space) const { 589 int64_t Heap::GCTimeInMicros(Space space) const {
599 if (space == kNew) { 590 if (space == kNew) {
600 return new_space_.gc_time_micros(); 591 return new_space_.gc_time_micros();
601 } 592 }
602 return old_space_.gc_time_micros(); 593 return old_space_.gc_time_micros();
603 } 594 }
604 595
(...skipping 27 matching lines...) Expand all
632 } 623 }
633 624
634 625
635 int64_t Heap::PeerCount() const { 626 int64_t Heap::PeerCount() const {
636 return new_weak_tables_[kPeers]->count() + old_weak_tables_[kPeers]->count(); 627 return new_weak_tables_[kPeers]->count() + old_weak_tables_[kPeers]->count();
637 } 628 }
638 629
639 630
640 int64_t Heap::HashCount() const { 631 int64_t Heap::HashCount() const {
641 return new_weak_tables_[kHashes]->count() + 632 return new_weak_tables_[kHashes]->count() +
642 old_weak_tables_[kHashes]->count(); 633 old_weak_tables_[kHashes]->count();
643 } 634 }
644 635
645 636
646 int64_t Heap::ObjectIdCount() const { 637 int64_t Heap::ObjectIdCount() const {
647 return new_weak_tables_[kObjectIds]->count() + 638 return new_weak_tables_[kObjectIds]->count() +
648 old_weak_tables_[kObjectIds]->count(); 639 old_weak_tables_[kObjectIds]->count();
649 } 640 }
650 641
651 642
652 void Heap::ResetObjectIdTable() { 643 void Heap::ResetObjectIdTable() {
653 new_weak_tables_[kObjectIds]->Reset(); 644 new_weak_tables_[kObjectIds]->Reset();
654 old_weak_tables_[kObjectIds]->Reset(); 645 old_weak_tables_[kObjectIds]->Reset();
655 } 646 }
656 647
657 648
658 intptr_t Heap::GetWeakEntry(RawObject* raw_obj, WeakSelector sel) const { 649 intptr_t Heap::GetWeakEntry(RawObject* raw_obj, WeakSelector sel) const {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 } 718 }
728 #endif // !PRODUCT 719 #endif // !PRODUCT
729 } 720 }
730 721
731 722
732 void Heap::PrintStats() { 723 void Heap::PrintStats() {
733 if (!FLAG_verbose_gc) return; 724 if (!FLAG_verbose_gc) return;
734 725
735 if ((FLAG_verbose_gc_hdr != 0) && 726 if ((FLAG_verbose_gc_hdr != 0) &&
736 (((stats_.num_ - 1) % FLAG_verbose_gc_hdr) == 0)) { 727 (((stats_.num_ - 1) % FLAG_verbose_gc_hdr) == 0)) {
737 OS::PrintErr("[ GC | space | count | start | gc time | " 728 OS::PrintErr(
738 "new gen (KB) | old gen (KB) | timers | data ]\n" 729 "[ GC | space | count | start | gc time | "
739 "[ (isolate)| (reason)| | (s) | (ms) | " 730 "new gen (KB) | old gen (KB) | timers | data ]\n"
740 "used,cap,ext | used,cap,ext | (ms) | ]\n"); 731 "[ (isolate)| (reason)| | (s) | (ms) | "
732 "used,cap,ext | used,cap,ext | (ms) | ]\n");
741 } 733 }
742 734
735 // clang-format off
743 const char* space_str = stats_.space_ == kNew ? "Scavenge" : "Mark-Sweep"; 736 const char* space_str = stats_.space_ == kNew ? "Scavenge" : "Mark-Sweep";
744 OS::PrintErr( 737 OS::PrintErr(
745 "[ GC(%" Pd64 "): %s(%s), " // GC(isolate), space(reason) 738 "[ GC(%" Pd64 "): %s(%s), " // GC(isolate), space(reason)
746 "%" Pd ", " // count 739 "%" Pd ", " // count
747 "%.3f, " // start time 740 "%.3f, " // start time
748 "%.3f, " // total time 741 "%.3f, " // total time
749 "%" Pd ", %" Pd ", " // new gen: in use before/after 742 "%" Pd ", %" Pd ", " // new gen: in use before/after
750 "%" Pd ", %" Pd ", " // new gen: capacity before/after 743 "%" Pd ", %" Pd ", " // new gen: capacity before/after
751 "%" Pd ", %" Pd ", " // new gen: external before/after 744 "%" Pd ", %" Pd ", " // new gen: external before/after
752 "%" Pd ", %" Pd ", " // old gen: in use before/after 745 "%" Pd ", %" Pd ", " // old gen: in use before/after
(...skipping 20 matching lines...) Expand all
773 RoundWordsToKB(stats_.before_.old_.external_in_words), 766 RoundWordsToKB(stats_.before_.old_.external_in_words),
774 RoundWordsToKB(stats_.after_.old_.external_in_words), 767 RoundWordsToKB(stats_.after_.old_.external_in_words),
775 MicrosecondsToMilliseconds(stats_.times_[0]), 768 MicrosecondsToMilliseconds(stats_.times_[0]),
776 MicrosecondsToMilliseconds(stats_.times_[1]), 769 MicrosecondsToMilliseconds(stats_.times_[1]),
777 MicrosecondsToMilliseconds(stats_.times_[2]), 770 MicrosecondsToMilliseconds(stats_.times_[2]),
778 MicrosecondsToMilliseconds(stats_.times_[3]), 771 MicrosecondsToMilliseconds(stats_.times_[3]),
779 stats_.data_[0], 772 stats_.data_[0],
780 stats_.data_[1], 773 stats_.data_[1],
781 stats_.data_[2], 774 stats_.data_[2],
782 stats_.data_[3]); 775 stats_.data_[3]);
776 // clang-format on
783 } 777 }
784 778
785 779
786 void Heap::PrintStatsToTimeline(TimelineEventScope* event) { 780 void Heap::PrintStatsToTimeline(TimelineEventScope* event) {
787 #if !defined(PRODUCT) 781 #if !defined(PRODUCT)
788 if ((event == NULL) || !event->enabled()) { 782 if ((event == NULL) || !event->enabled()) {
789 return; 783 return;
790 } 784 }
791 event->SetNumArguments(12); 785 event->SetNumArguments(12);
792 event->FormatArgument(0, 786 event->FormatArgument(0, "Before.New.Used (kB)", "%" Pd "",
793 "Before.New.Used (kB)",
794 "%" Pd "",
795 RoundWordsToKB(stats_.before_.new_.used_in_words)); 787 RoundWordsToKB(stats_.before_.new_.used_in_words));
796 event->FormatArgument(1, 788 event->FormatArgument(1, "After.New.Used (kB)", "%" Pd "",
797 "After.New.Used (kB)",
798 "%" Pd "",
799 RoundWordsToKB(stats_.after_.new_.used_in_words)); 789 RoundWordsToKB(stats_.after_.new_.used_in_words));
800 event->FormatArgument(2, 790 event->FormatArgument(2, "Before.Old.Used (kB)", "%" Pd "",
801 "Before.Old.Used (kB)",
802 "%" Pd "",
803 RoundWordsToKB(stats_.before_.old_.used_in_words)); 791 RoundWordsToKB(stats_.before_.old_.used_in_words));
804 event->FormatArgument(3, 792 event->FormatArgument(3, "After.Old.Used (kB)", "%" Pd "",
805 "After.Old.Used (kB)",
806 "%" Pd "",
807 RoundWordsToKB(stats_.after_.old_.used_in_words)); 793 RoundWordsToKB(stats_.after_.old_.used_in_words));
808 794
809 event->FormatArgument(4, 795 event->FormatArgument(4, "Before.New.Capacity (kB)", "%" Pd "",
810 "Before.New.Capacity (kB)",
811 "%" Pd "",
812 RoundWordsToKB(stats_.before_.new_.capacity_in_words)); 796 RoundWordsToKB(stats_.before_.new_.capacity_in_words));
813 event->FormatArgument(5, 797 event->FormatArgument(5, "After.New.Capacity (kB)", "%" Pd "",
814 "After.New.Capacity (kB)",
815 "%" Pd "",
816 RoundWordsToKB(stats_.after_.new_.capacity_in_words)); 798 RoundWordsToKB(stats_.after_.new_.capacity_in_words));
817 event->FormatArgument(6, 799 event->FormatArgument(6, "Before.Old.Capacity (kB)", "%" Pd "",
818 "Before.Old.Capacity (kB)",
819 "%" Pd "",
820 RoundWordsToKB(stats_.before_.old_.capacity_in_words)); 800 RoundWordsToKB(stats_.before_.old_.capacity_in_words));
821 event->FormatArgument(7, 801 event->FormatArgument(7, "After.Old.Capacity (kB)", "%" Pd "",
822 "After.Old.Capacity (kB)",
823 "%" Pd "",
824 RoundWordsToKB(stats_.after_.old_.capacity_in_words)); 802 RoundWordsToKB(stats_.after_.old_.capacity_in_words));
825 803
826 event->FormatArgument(8, 804 event->FormatArgument(8, "Before.New.External (kB)", "%" Pd "",
827 "Before.New.External (kB)",
828 "%" Pd "",
829 RoundWordsToKB(stats_.before_.new_.external_in_words)); 805 RoundWordsToKB(stats_.before_.new_.external_in_words));
830 event->FormatArgument(9, 806 event->FormatArgument(9, "After.New.External (kB)", "%" Pd "",
831 "After.New.External (kB)",
832 "%" Pd "",
833 RoundWordsToKB(stats_.after_.new_.external_in_words)); 807 RoundWordsToKB(stats_.after_.new_.external_in_words));
834 event->FormatArgument(10, 808 event->FormatArgument(10, "Before.Old.External (kB)", "%" Pd "",
835 "Before.Old.External (kB)",
836 "%" Pd "",
837 RoundWordsToKB(stats_.before_.old_.external_in_words)); 809 RoundWordsToKB(stats_.before_.old_.external_in_words));
838 event->FormatArgument(11, 810 event->FormatArgument(11, "After.Old.External (kB)", "%" Pd "",
839 "After.Old.External (kB)",
840 "%" Pd "",
841 RoundWordsToKB(stats_.after_.old_.external_in_words)); 811 RoundWordsToKB(stats_.after_.old_.external_in_words));
842 #endif // !defined(PRODUCT) 812 #endif // !defined(PRODUCT)
843 } 813 }
844 814
845 815
846 NoHeapGrowthControlScope::NoHeapGrowthControlScope() 816 NoHeapGrowthControlScope::NoHeapGrowthControlScope()
847 : StackResource(Thread::Current()) { 817 : StackResource(Thread::Current()) {
848 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap(); 818 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap();
849 current_growth_controller_state_ = heap->GrowthControlState(); 819 current_growth_controller_state_ = heap->GrowthControlState();
850 heap->DisableGrowthControl(); 820 heap->DisableGrowthControl();
851 } 821 }
852 822
853 823
854 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() { 824 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() {
855 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap(); 825 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap();
856 heap->SetGrowthControlState(current_growth_controller_state_); 826 heap->SetGrowthControlState(current_growth_controller_state_);
857 } 827 }
858 828
859 829
860 WritableVMIsolateScope::WritableVMIsolateScope(Thread* thread) 830 WritableVMIsolateScope::WritableVMIsolateScope(Thread* thread)
861 : StackResource(thread) { 831 : StackResource(thread) {
862 Dart::vm_isolate()->heap()->WriteProtect(false); 832 Dart::vm_isolate()->heap()->WriteProtect(false);
863 } 833 }
864 834
865 835
866 WritableVMIsolateScope::~WritableVMIsolateScope() { 836 WritableVMIsolateScope::~WritableVMIsolateScope() {
867 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0); 837 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0);
868 Dart::vm_isolate()->heap()->WriteProtect(true); 838 Dart::vm_isolate()->heap()->WriteProtect(true);
869 } 839 }
870 840
871 } // namespace dart 841 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/heap.h ('k') | runtime/vm/heap_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698