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

Side by Side Diff: vm/pages.cc

Issue 10030001: Resubmit change 6302 after fixing the compiler warning on older GCC compiler versions: (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 8 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 | « vm/pages.h ('k') | vm/raw_object.h » ('j') | vm/stack_frame.cc » ('J')
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/pages.h" 5 #include "vm/pages.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/gc_marker.h" 8 #include "vm/gc_marker.h"
9 #include "vm/gc_sweeper.h" 9 #include "vm/gc_sweeper.h"
10 #include "vm/object.h" 10 #include "vm/object.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 uword obj_addr = first_object_start(); 42 uword obj_addr = first_object_start();
43 uword end_addr = top(); 43 uword end_addr = top();
44 while (obj_addr < end_addr) { 44 while (obj_addr < end_addr) {
45 RawObject* raw_obj = RawObject::FromAddr(obj_addr); 45 RawObject* raw_obj = RawObject::FromAddr(obj_addr);
46 obj_addr += raw_obj->VisitPointers(visitor); 46 obj_addr += raw_obj->VisitPointers(visitor);
47 } 47 }
48 ASSERT(obj_addr == end_addr); 48 ASSERT(obj_addr == end_addr);
49 } 49 }
50 50
51 51
52 RawObject* HeapPage::FindObject(FindObjectVisitor* visitor) const {
53 uword obj_addr = first_object_start();
54 uword end_addr = top();
55 while (obj_addr < end_addr) {
56 RawObject* raw_obj = RawObject::FromAddr(obj_addr);
57 if (raw_obj->FindObject(visitor)) {
58 return raw_obj; // Found object, return it.
59 }
60 obj_addr += raw_obj->Size();
61 }
62 ASSERT(obj_addr == end_addr);
63 return Object::null();
64 }
65
66
52 PageSpace::PageSpace(Heap* heap, intptr_t max_capacity, bool is_executable) 67 PageSpace::PageSpace(Heap* heap, intptr_t max_capacity, bool is_executable)
53 : freelist_(), 68 : freelist_(),
54 heap_(heap), 69 heap_(heap),
55 pages_(NULL), 70 pages_(NULL),
56 pages_tail_(NULL), 71 pages_tail_(NULL),
57 large_pages_(NULL), 72 large_pages_(NULL),
58 max_capacity_(max_capacity), 73 max_capacity_(max_capacity),
59 capacity_(0), 74 capacity_(0),
60 in_use_(0), 75 in_use_(0),
61 count_(0), 76 count_(0),
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 } 214 }
200 215
201 page = large_pages_; 216 page = large_pages_;
202 while (page != NULL) { 217 while (page != NULL) {
203 page->VisitObjectPointers(visitor); 218 page->VisitObjectPointers(visitor);
204 page = page->next(); 219 page = page->next();
205 } 220 }
206 } 221 }
207 222
208 223
224 RawObject* PageSpace::FindObject(FindObjectVisitor* visitor) const {
225 ASSERT(Isolate::Current()->no_gc_scope_depth() != 0);
226 HeapPage* page = pages_;
227 while (page != NULL) {
228 RawObject* obj = page->FindObject(visitor);
229 if (obj != Object::null()) {
230 return obj;
231 }
232 page = page->next();
233 }
234
235 page = large_pages_;
236 while (page != NULL) {
237 RawObject* obj = page->FindObject(visitor);
238 if (obj != Object::null()) {
239 return obj;
240 }
241 page = page->next();
242 }
243 return Object::null();
244 }
245
246
209 void PageSpace::MarkSweep(bool invoke_api_callbacks) { 247 void PageSpace::MarkSweep(bool invoke_api_callbacks) {
210 // MarkSweep is not reentrant. Make sure that is the case. 248 // MarkSweep is not reentrant. Make sure that is the case.
211 ASSERT(!sweeping_); 249 ASSERT(!sweeping_);
212 sweeping_ = true; 250 sweeping_ = true;
213 Isolate* isolate = Isolate::Current(); 251 Isolate* isolate = Isolate::Current();
214 NoHandleScope no_handles(isolate); 252 NoHandleScope no_handles(isolate);
215 253
216 if (FLAG_verify_before_gc) { 254 if (FLAG_verify_before_gc) {
217 OS::PrintErr("Verifying before MarkSweep... "); 255 OS::PrintErr("Verifying before MarkSweep... ");
218 heap_->Verify(); 256 heap_->Verify();
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 OS::PrintErr(" done.\n"); 311 OS::PrintErr(" done.\n");
274 } 312 }
275 313
276 count_++; 314 count_++;
277 // Done, reset the marker. 315 // Done, reset the marker.
278 ASSERT(sweeping_); 316 ASSERT(sweeping_);
279 sweeping_ = false; 317 sweeping_ = false;
280 } 318 }
281 319
282 } // namespace dart 320 } // namespace dart
OLDNEW
« no previous file with comments | « vm/pages.h ('k') | vm/raw_object.h » ('j') | vm/stack_frame.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698