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

Side by Side Diff: vm/heap.cc

Issue 8761006: - Implement a simple old-generation marker. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: '' Created 9 years 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 | « vm/heap.h ('k') | 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 "vm/assert.h" 7 #include "vm/assert.h"
8 #include "vm/compiler_stats.h" 8 #include "vm/compiler_stats.h"
9 #include "vm/flags.h" 9 #include "vm/flags.h"
10 #include "vm/isolate.h" 10 #include "vm/isolate.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 old_space_->Contains(addr) || 96 old_space_->Contains(addr) ||
97 code_space_->Contains(addr); 97 code_space_->Contains(addr);
98 } 98 }
99 99
100 100
101 bool Heap::CodeContains(uword addr) const { 101 bool Heap::CodeContains(uword addr) const {
102 return code_space_->Contains(addr); 102 return code_space_->Contains(addr);
103 } 103 }
104 104
105 105
106 void Heap::Init(Isolate* isolate) { 106 void Heap::IterateNewPointers(ObjectPointerVisitor* visitor) {
107 ASSERT(isolate->heap() == NULL); 107 new_space_->VisitObjectPointers(visitor);
108 Heap* heap = new Heap();
109 isolate->set_heap(heap);
110 }
111
112
113 bool Heap::Verify() const {
114 VerifyPointersVisitor visitor;
115 new_space_->VisitObjectPointers(&visitor);
116 old_space_->VisitObjectPointers(&visitor);
117 code_space_->VisitObjectPointers(&visitor);
118 // Only returning a value so that Heap::Validate can be called from an ASSERT.
119 return true;
120 } 108 }
121 109
122 110
123 void Heap::IterateOldPointers(ObjectPointerVisitor* visitor) { 111 void Heap::IterateOldPointers(ObjectPointerVisitor* visitor) {
124 old_space_->VisitObjectPointers(visitor); 112 old_space_->VisitObjectPointers(visitor);
125 code_space_->VisitObjectPointers(visitor); 113 code_space_->VisitObjectPointers(visitor);
126 } 114 }
127 115
128 116
117 void Heap::CollectGarbage(Space space) {
118 switch (space) {
119 case kNew:
120 new_space_->Scavenge();
121 break;
122 case kOld:
123 old_space_->MarkSweep();
124 break;
125 case kExecutable:
126 UNIMPLEMENTED();
127 code_space_->MarkSweep();
128 break;
129 default:
130 UNREACHABLE();
131 }
132 }
133
134
135 void Heap::CollectAllGarbage() {
136 new_space_->Scavenge();
137 old_space_->MarkSweep();
138 // TODO(iposva): Merge old and code space.
139 // code_space_->MarkSweep();
140 }
141
142
129 uword Heap::TopAddress() { 143 uword Heap::TopAddress() {
130 return reinterpret_cast<uword>(new_space_->TopAddress()); 144 return reinterpret_cast<uword>(new_space_->TopAddress());
131 } 145 }
132 146
133 147
134 uword Heap::EndAddress() { 148 uword Heap::EndAddress() {
135 return reinterpret_cast<uword>(new_space_->EndAddress()); 149 return reinterpret_cast<uword>(new_space_->EndAddress());
136 } 150 }
137 151
138 152
153 void Heap::Init(Isolate* isolate) {
154 ASSERT(isolate->heap() == NULL);
155 Heap* heap = new Heap();
156 isolate->set_heap(heap);
157 }
158
159
160 bool Heap::Verify() const {
161 VerifyPointersVisitor visitor;
162 new_space_->VisitObjectPointers(&visitor);
163 old_space_->VisitObjectPointers(&visitor);
164 code_space_->VisitObjectPointers(&visitor);
165 // Only returning a value so that Heap::Validate can be called from an ASSERT.
166 return true;
167 }
168
169
139 #if defined(DEBUG) 170 #if defined(DEBUG)
140 NoGCScope::NoGCScope() : StackResource(Isolate::Current()) { 171 NoGCScope::NoGCScope() : StackResource(Isolate::Current()) {
141 isolate()->IncrementNoGCScopeDepth(); 172 isolate()->IncrementNoGCScopeDepth();
142 } 173 }
143 174
144 175
145 NoGCScope::~NoGCScope() { 176 NoGCScope::~NoGCScope() {
146 isolate()->DecrementNoGCScopeDepth(); 177 isolate()->DecrementNoGCScopeDepth();
147 } 178 }
148 #endif // defined(DEBUG) 179 #endif // defined(DEBUG)
149 180
150 } // namespace dart 181 } // namespace dart
OLDNEW
« no previous file with comments | « vm/heap.h ('k') | vm/heap_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698