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

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

Issue 10830045: - Add the ability to protect VirtualMemory. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::Protect(VirtualMemory::Protection mode) {
91 memory_->Protect(mode);
92 }
93
94
90 PageSpace::PageSpace(Heap* heap, intptr_t max_capacity, bool is_executable) 95 PageSpace::PageSpace(Heap* heap, intptr_t max_capacity, bool is_executable)
91 : freelist_(), 96 : freelist_(),
92 heap_(heap), 97 heap_(heap),
93 pages_(NULL), 98 pages_(NULL),
94 pages_tail_(NULL), 99 pages_tail_(NULL),
95 large_pages_(NULL), 100 large_pages_(NULL),
96 bump_page_(NULL), 101 bump_page_(NULL),
97 max_capacity_(max_capacity), 102 max_capacity_(max_capacity),
98 capacity_(0), 103 capacity_(0),
99 in_use_(0), 104 in_use_(0),
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 RawObject* obj = page->FindObject(visitor); 338 RawObject* obj = page->FindObject(visitor);
334 if (obj != Object::null()) { 339 if (obj != Object::null()) {
335 return obj; 340 return obj;
336 } 341 }
337 page = page->next(); 342 page = page->next();
338 } 343 }
339 return Object::null(); 344 return Object::null();
340 } 345 }
341 346
342 347
348 void PageSpace::Protect(VirtualMemory::Protection mode) {
349 HeapPage* page = pages_;
350 while (page != NULL) {
351 page->Protect(mode);
352 page = page->next();
353 }
354 page = large_pages_;
355 while (page != NULL) {
356 page->Protect(mode);
357 page = page->next();
358 }
siva 2012/07/27 01:55:00 How does this work in the face of heap growth? i.
Ivan Posva 2012/07/27 18:02:56 A read-write heap should be able to grow a read-on
359 }
360
361
343 void PageSpace::MarkSweep(bool invoke_api_callbacks) { 362 void PageSpace::MarkSweep(bool invoke_api_callbacks) {
344 // MarkSweep is not reentrant. Make sure that is the case. 363 // MarkSweep is not reentrant. Make sure that is the case.
345 ASSERT(!sweeping_); 364 ASSERT(!sweeping_);
346 sweeping_ = true; 365 sweeping_ = true;
347 Isolate* isolate = Isolate::Current(); 366 Isolate* isolate = Isolate::Current();
348 NoHandleScope no_handles(isolate); 367 NoHandleScope no_handles(isolate);
349 368
350 if (FLAG_print_free_list_before_gc) { 369 if (FLAG_print_free_list_before_gc) {
351 freelist_.Print(); 370 freelist_.Print();
352 } 371 }
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 return 0; 566 return 0;
548 } else { 567 } else {
549 ASSERT(total_time >= gc_time); 568 ASSERT(total_time >= gc_time);
550 int result= static_cast<int>((static_cast<double>(gc_time) / 569 int result= static_cast<int>((static_cast<double>(gc_time) /
551 static_cast<double>(total_time)) * 100); 570 static_cast<double>(total_time)) * 100);
552 return result; 571 return result;
553 } 572 }
554 } 573 }
555 574
556 } // namespace dart 575 } // namespace dart
OLDNEW
« runtime/vm/object.cc ('K') | « runtime/vm/pages.h ('k') | runtime/vm/scavenger.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698