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

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

Issue 70993002: - Convert heap sizes to words from bytes. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month 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
« runtime/vm/pages.cc ('K') | « runtime/vm/scavenger.h ('k') | no next file » | 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/scavenger.h" 5 #include "vm/scavenger.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 } 296 }
297 } 297 }
298 298
299 private: 299 private:
300 MemoryRegion* to_; 300 MemoryRegion* to_;
301 301
302 DISALLOW_COPY_AND_ASSIGN(VerifyStoreBufferPointerVisitor); 302 DISALLOW_COPY_AND_ASSIGN(VerifyStoreBufferPointerVisitor);
303 }; 303 };
304 304
305 305
306 Scavenger::Scavenger(Heap* heap, intptr_t max_capacity, uword object_alignment) 306 Scavenger::Scavenger(Heap* heap,
307 intptr_t max_capacity_in_words,
308 uword object_alignment)
307 : heap_(heap), 309 : heap_(heap),
308 object_alignment_(object_alignment), 310 object_alignment_(object_alignment),
309 scavenging_(false) { 311 scavenging_(false) {
310 // Verify assumptions about the first word in objects which the scavenger is 312 // Verify assumptions about the first word in objects which the scavenger is
311 // going to use for forwarding pointers. 313 // going to use for forwarding pointers.
312 ASSERT(Object::tags_offset() == 0); 314 ASSERT(Object::tags_offset() == 0);
313 315
314 // Allocate the virtual memory for this scavenge heap. 316 // Allocate the virtual memory for this scavenge heap.
315 space_ = VirtualMemory::Reserve(max_capacity); 317 space_ = VirtualMemory::Reserve(max_capacity_in_words << kWordSizeLog2);
316 if (space_ == NULL) { 318 if (space_ == NULL) {
317 FATAL("Out of memory.\n"); 319 FATAL("Out of memory.\n");
318 } 320 }
319 321
320 // Allocate the entire space at the beginning. 322 // Allocate the entire space at the beginning.
321 space_->Commit(false); 323 space_->Commit(false);
322 324
323 // Setup the semi spaces. 325 // Setup the semi spaces.
324 uword semi_space_size = space_->size() / 2; 326 uword semi_space_size = space_->size() / 2;
325 ASSERT((semi_space_size & (VirtualMemory::PageSize() - 1)) == 0); 327 ASSERT((semi_space_size & (VirtualMemory::PageSize() - 1)) == 0);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 ScavengerVisitor* visitor, 434 ScavengerVisitor* visitor,
433 bool visit_prologue_weak_persistent_handles) { 435 bool visit_prologue_weak_persistent_handles) {
434 int64_t start = OS::GetCurrentTimeMicros(); 436 int64_t start = OS::GetCurrentTimeMicros();
435 isolate->VisitObjectPointers(visitor, 437 isolate->VisitObjectPointers(visitor,
436 visit_prologue_weak_persistent_handles, 438 visit_prologue_weak_persistent_handles,
437 StackFrameIterator::kDontValidateFrames); 439 StackFrameIterator::kDontValidateFrames);
438 int64_t middle = OS::GetCurrentTimeMicros(); 440 int64_t middle = OS::GetCurrentTimeMicros();
439 IterateStoreBuffers(isolate, visitor); 441 IterateStoreBuffers(isolate, visitor);
440 IterateObjectIdTable(isolate, visitor); 442 IterateObjectIdTable(isolate, visitor);
441 int64_t end = OS::GetCurrentTimeMicros(); 443 int64_t end = OS::GetCurrentTimeMicros();
442 heap_->RecordData(kToKBAfterStoreBuffer, (in_use() + (KB >> 1)) >> KBLog2); 444 heap_->RecordData(kToKBAfterStoreBuffer, RoundWordsToKB(UsedInWords()));
443 heap_->RecordTime(kVisitIsolateRoots, middle - start); 445 heap_->RecordTime(kVisitIsolateRoots, middle - start);
444 heap_->RecordTime(kIterateStoreBuffers, end - middle); 446 heap_->RecordTime(kIterateStoreBuffers, end - middle);
445 } 447 }
446 448
447 449
448 bool Scavenger::IsUnreachable(RawObject** p) { 450 bool Scavenger::IsUnreachable(RawObject** p) {
449 RawObject* raw_obj = *p; 451 RawObject* raw_obj = *p;
450 if (!raw_obj->IsHeapObject()) { 452 if (!raw_obj->IsHeapObject()) {
451 return false; 453 return false;
452 } 454 }
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 } 687 }
686 688
687 689
688 void Scavenger::WriteProtect(bool read_only) { 690 void Scavenger::WriteProtect(bool read_only) {
689 space_->Protect( 691 space_->Protect(
690 read_only ? VirtualMemory::kReadOnly : VirtualMemory::kReadWrite); 692 read_only ? VirtualMemory::kReadOnly : VirtualMemory::kReadWrite);
691 } 693 }
692 694
693 695
694 } // namespace dart 696 } // namespace dart
OLDNEW
« runtime/vm/pages.cc ('K') | « runtime/vm/scavenger.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698