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/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 Loading... | |
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 Loading... | |
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 HeapPage* page = pages_; | |
226 while (page != NULL) { | |
227 RawObject* obj = page->FindObject(visitor); | |
srdjan
2012/03/28 21:56:36
Add NoGC after call to FindObject.
siva
2012/03/29 19:01:27
I have added an assertion that this function shoul
| |
228 if (obj != Object::null()) { | |
229 return obj; | |
230 } | |
231 page = page->next(); | |
232 } | |
233 | |
234 page = large_pages_; | |
235 while (page != NULL) { | |
236 RawObject* obj = page->FindObject(visitor); | |
srdjan
2012/03/28 21:56:36
ditto
siva
2012/03/29 19:01:27
ditto.
On 2012/03/28 21:56:36, srdjan wrote:
| |
237 if (obj != Object::null()) { | |
238 return obj; | |
239 } | |
240 page = page->next(); | |
241 } | |
242 return Object::null(); | |
243 } | |
244 | |
245 | |
209 void PageSpace::MarkSweep(bool invoke_api_callbacks) { | 246 void PageSpace::MarkSweep(bool invoke_api_callbacks) { |
210 // MarkSweep is not reentrant. Make sure that is the case. | 247 // MarkSweep is not reentrant. Make sure that is the case. |
211 ASSERT(!sweeping_); | 248 ASSERT(!sweeping_); |
212 sweeping_ = true; | 249 sweeping_ = true; |
213 Isolate* isolate = Isolate::Current(); | 250 Isolate* isolate = Isolate::Current(); |
214 NoHandleScope no_handles(isolate); | 251 NoHandleScope no_handles(isolate); |
215 | 252 |
216 if (FLAG_verify_before_gc) { | 253 if (FLAG_verify_before_gc) { |
217 OS::PrintErr("Verifying before MarkSweep... "); | 254 OS::PrintErr("Verifying before MarkSweep... "); |
218 heap_->Verify(); | 255 heap_->Verify(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
273 OS::PrintErr(" done.\n"); | 310 OS::PrintErr(" done.\n"); |
274 } | 311 } |
275 | 312 |
276 count_++; | 313 count_++; |
277 // Done, reset the marker. | 314 // Done, reset the marker. |
278 ASSERT(sweeping_); | 315 ASSERT(sweeping_); |
279 sweeping_ = false; | 316 sweeping_ = false; |
280 } | 317 } |
281 | 318 |
282 } // namespace dart | 319 } // namespace dart |
OLD | NEW |