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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 if (raw_obj->FindObject(visitor)) { | 80 if (raw_obj->FindObject(visitor)) { |
81 return raw_obj; // Found object, return it. | 81 return raw_obj; // Found object, return it. |
82 } | 82 } |
83 obj_addr += raw_obj->Size(); | 83 obj_addr += raw_obj->Size(); |
84 } | 84 } |
85 ASSERT(obj_addr == end_addr); | 85 ASSERT(obj_addr == end_addr); |
86 return Object::null(); | 86 return Object::null(); |
87 } | 87 } |
88 | 88 |
89 | 89 |
| 90 void HeapPage::WriteProtect(bool read_only) { |
| 91 memory_->Protect( |
| 92 read_only ? VirtualMemory::kReadOnly : VirtualMemory::kReadWrite); |
| 93 } |
| 94 |
| 95 |
90 PageSpace::PageSpace(Heap* heap, intptr_t max_capacity, bool is_executable) | 96 PageSpace::PageSpace(Heap* heap, intptr_t max_capacity, bool is_executable) |
91 : freelist_(), | 97 : freelist_(), |
92 heap_(heap), | 98 heap_(heap), |
93 pages_(NULL), | 99 pages_(NULL), |
94 pages_tail_(NULL), | 100 pages_tail_(NULL), |
95 large_pages_(NULL), | 101 large_pages_(NULL), |
96 bump_page_(NULL), | 102 bump_page_(NULL), |
97 max_capacity_(max_capacity), | 103 max_capacity_(max_capacity), |
98 capacity_(0), | 104 capacity_(0), |
99 in_use_(0), | 105 in_use_(0), |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 RawObject* obj = page->FindObject(visitor); | 339 RawObject* obj = page->FindObject(visitor); |
334 if (obj != Object::null()) { | 340 if (obj != Object::null()) { |
335 return obj; | 341 return obj; |
336 } | 342 } |
337 page = page->next(); | 343 page = page->next(); |
338 } | 344 } |
339 return Object::null(); | 345 return Object::null(); |
340 } | 346 } |
341 | 347 |
342 | 348 |
| 349 void PageSpace::WriteProtect(bool read_only) { |
| 350 HeapPage* page = pages_; |
| 351 while (page != NULL) { |
| 352 page->WriteProtect(read_only); |
| 353 page = page->next(); |
| 354 } |
| 355 page = large_pages_; |
| 356 while (page != NULL) { |
| 357 page->WriteProtect(read_only); |
| 358 page = page->next(); |
| 359 } |
| 360 } |
| 361 |
| 362 |
343 void PageSpace::MarkSweep(bool invoke_api_callbacks) { | 363 void PageSpace::MarkSweep(bool invoke_api_callbacks) { |
344 // MarkSweep is not reentrant. Make sure that is the case. | 364 // MarkSweep is not reentrant. Make sure that is the case. |
345 ASSERT(!sweeping_); | 365 ASSERT(!sweeping_); |
346 sweeping_ = true; | 366 sweeping_ = true; |
347 Isolate* isolate = Isolate::Current(); | 367 Isolate* isolate = Isolate::Current(); |
348 NoHandleScope no_handles(isolate); | 368 NoHandleScope no_handles(isolate); |
349 | 369 |
350 if (FLAG_print_free_list_before_gc) { | 370 if (FLAG_print_free_list_before_gc) { |
351 freelist_.Print(); | 371 freelist_.Print(); |
352 } | 372 } |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 return 0; | 567 return 0; |
548 } else { | 568 } else { |
549 ASSERT(total_time >= gc_time); | 569 ASSERT(total_time >= gc_time); |
550 int result= static_cast<int>((static_cast<double>(gc_time) / | 570 int result= static_cast<int>((static_cast<double>(gc_time) / |
551 static_cast<double>(total_time)) * 100); | 571 static_cast<double>(total_time)) * 100); |
552 return result; | 572 return result; |
553 } | 573 } |
554 } | 574 } |
555 | 575 |
556 } // namespace dart | 576 } // namespace dart |
OLD | NEW |