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

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

Issue 1016503005: Rename NoGCScope -> NoSafepointScope. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 9 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 | Annotate | Revision Log
« 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 for (int sel = 0; 69 for (int sel = 0;
70 sel < kNumWeakSelectors; 70 sel < kNumWeakSelectors;
71 sel++) { 71 sel++) {
72 delete new_weak_tables_[sel]; 72 delete new_weak_tables_[sel];
73 delete old_weak_tables_[sel]; 73 delete old_weak_tables_[sel];
74 } 74 }
75 } 75 }
76 76
77 77
78 uword Heap::AllocateNew(intptr_t size) { 78 uword Heap::AllocateNew(intptr_t size) {
79 ASSERT(isolate()->no_gc_scope_depth() == 0); 79 ASSERT(isolate()->no_safepoint_scope_depth() == 0);
80 uword addr = new_space_->TryAllocate(size); 80 uword addr = new_space_->TryAllocate(size);
81 if (addr == 0) { 81 if (addr == 0) {
82 CollectGarbage(kNew); 82 CollectGarbage(kNew);
83 addr = new_space_->TryAllocate(size); 83 addr = new_space_->TryAllocate(size);
84 if (addr == 0) { 84 if (addr == 0) {
85 return AllocateOld(size, HeapPage::kData); 85 return AllocateOld(size, HeapPage::kData);
86 } 86 }
87 } 87 }
88 return addr; 88 return addr;
89 } 89 }
90 90
91 91
92 uword Heap::AllocateOld(intptr_t size, HeapPage::PageType type) { 92 uword Heap::AllocateOld(intptr_t size, HeapPage::PageType type) {
93 ASSERT(isolate()->no_gc_scope_depth() == 0); 93 ASSERT(isolate()->no_safepoint_scope_depth() == 0);
94 uword addr = old_space_->TryAllocate(size, type); 94 uword addr = old_space_->TryAllocate(size, type);
95 if (addr != 0) { 95 if (addr != 0) {
96 return addr; 96 return addr;
97 } 97 }
98 // If we are in the process of running a sweep wait for the sweeper to free 98 // If we are in the process of running a sweep wait for the sweeper to free
99 // memory. 99 // memory.
100 { 100 {
101 MonitorLocker ml(old_space_->tasks_lock()); 101 MonitorLocker ml(old_space_->tasks_lock());
102 addr = old_space_->TryAllocate(size, type); 102 addr = old_space_->TryAllocate(size, type);
103 while ((addr == 0) && (old_space_->tasks() > 0)) { 103 while ((addr == 0) && (old_space_->tasks() > 0)) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 return addr; 144 return addr;
145 } 145 }
146 // Give up allocating this object. 146 // Give up allocating this object.
147 OS::PrintErr( 147 OS::PrintErr(
148 "Exhausted heap space, trying to allocate %" Pd " bytes.\n", size); 148 "Exhausted heap space, trying to allocate %" Pd " bytes.\n", size);
149 return 0; 149 return 0;
150 } 150 }
151 151
152 152
153 uword Heap::AllocatePretenured(intptr_t size) { 153 uword Heap::AllocatePretenured(intptr_t size) {
154 ASSERT(isolate()->no_gc_scope_depth() == 0); 154 ASSERT(isolate()->no_safepoint_scope_depth() == 0);
155 uword addr = old_space_->TryAllocateDataBump(size, PageSpace::kControlGrowth); 155 uword addr = old_space_->TryAllocateDataBump(size, PageSpace::kControlGrowth);
156 if (addr != 0) return addr; 156 if (addr != 0) return addr;
157 return AllocateOld(size, HeapPage::kData); 157 return AllocateOld(size, HeapPage::kData);
158 } 158 }
159 159
160 160
161 void Heap::AllocateExternal(intptr_t size, Space space) { 161 void Heap::AllocateExternal(intptr_t size, Space space) {
162 ASSERT(isolate()->no_gc_scope_depth() == 0); 162 ASSERT(isolate()->no_safepoint_scope_depth() == 0);
163 if (space == kNew) { 163 if (space == kNew) {
164 new_space_->AllocateExternal(size); 164 new_space_->AllocateExternal(size);
165 if (new_space_->ExternalInWords() > (FLAG_new_gen_ext_limit * MBInWords)) { 165 if (new_space_->ExternalInWords() > (FLAG_new_gen_ext_limit * MBInWords)) {
166 // Attempt to free some external allocation by a scavenge. (If the total 166 // Attempt to free some external allocation by a scavenge. (If the total
167 // remains above the limit, next external alloc will trigger another.) 167 // remains above the limit, next external alloc will trigger another.)
168 CollectGarbage(kNew); 168 CollectGarbage(kNew);
169 } 169 }
170 } else { 170 } else {
171 ASSERT(space == kOld); 171 ASSERT(space == kOld);
172 old_space_->AllocateExternal(size); 172 old_space_->AllocateExternal(size);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 return old_space_->FindObject(visitor, HeapPage::kData); 261 return old_space_->FindObject(visitor, HeapPage::kData);
262 } 262 }
263 263
264 264
265 RawObject* Heap::FindNewObject(FindObjectVisitor* visitor) const { 265 RawObject* Heap::FindNewObject(FindObjectVisitor* visitor) const {
266 return new_space_->FindObject(visitor); 266 return new_space_->FindObject(visitor);
267 } 267 }
268 268
269 269
270 RawObject* Heap::FindObject(FindObjectVisitor* visitor) const { 270 RawObject* Heap::FindObject(FindObjectVisitor* visitor) const {
271 ASSERT(isolate()->no_gc_scope_depth() != 0); 271 ASSERT(isolate()->no_safepoint_scope_depth() != 0);
272 RawObject* raw_obj = FindNewObject(visitor); 272 RawObject* raw_obj = FindNewObject(visitor);
273 if (raw_obj != Object::null()) { 273 if (raw_obj != Object::null()) {
274 return raw_obj; 274 return raw_obj;
275 } 275 }
276 raw_obj = FindOldObject(visitor); 276 raw_obj = FindOldObject(visitor);
277 if (raw_obj != Object::null()) { 277 if (raw_obj != Object::null()) {
278 return raw_obj; 278 return raw_obj;
279 } 279 }
280 raw_obj = FindObjectInCodeSpace(visitor); 280 raw_obj = FindObjectInCodeSpace(visitor);
281 return raw_obj; 281 return raw_obj;
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 jsobj.AddProperty("eventType", "GC"); // TODO(koda): "GarbageCollected" 709 jsobj.AddProperty("eventType", "GC"); // TODO(koda): "GarbageCollected"
710 jsobj.AddProperty("isolate", isolate); 710 jsobj.AddProperty("isolate", isolate);
711 jsobj.AddProperty("reason", Heap::GCReasonToString(stats_.reason_)); 711 jsobj.AddProperty("reason", Heap::GCReasonToString(stats_.reason_));
712 isolate->heap()->PrintToJSONObject(Heap::kNew, &jsobj); 712 isolate->heap()->PrintToJSONObject(Heap::kNew, &jsobj);
713 isolate->heap()->PrintToJSONObject(Heap::kOld, &jsobj); 713 isolate->heap()->PrintToJSONObject(Heap::kOld, &jsobj);
714 } 714 }
715 } 715 }
716 716
717 717
718 #if defined(DEBUG) 718 #if defined(DEBUG)
719 NoGCScope::NoGCScope() : StackResource(Isolate::Current()) { 719 NoSafepointScope::NoSafepointScope() : StackResource(Isolate::Current()) {
720 isolate()->IncrementNoGCScopeDepth(); 720 isolate()->IncrementNoSafepointScopeDepth();
721 } 721 }
722 722
723 723
724 NoGCScope::~NoGCScope() { 724 NoSafepointScope::~NoSafepointScope() {
725 isolate()->DecrementNoGCScopeDepth(); 725 isolate()->DecrementNoSafepointScopeDepth();
726 } 726 }
727 #endif // defined(DEBUG) 727 #endif // defined(DEBUG)
728 728
729 729
730 NoHeapGrowthControlScope::NoHeapGrowthControlScope() 730 NoHeapGrowthControlScope::NoHeapGrowthControlScope()
731 : StackResource(Isolate::Current()) { 731 : StackResource(Isolate::Current()) {
732 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap(); 732 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap();
733 current_growth_controller_state_ = heap->GrowthControlState(); 733 current_growth_controller_state_ = heap->GrowthControlState();
734 heap->DisableGrowthControl(); 734 heap->DisableGrowthControl();
735 } 735 }
736 736
737 737
738 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() { 738 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() {
739 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap(); 739 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap();
740 heap->SetGrowthControlState(current_growth_controller_state_); 740 heap->SetGrowthControlState(current_growth_controller_state_);
741 } 741 }
742 742
743 } // namespace dart 743 } // 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