| 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/compiler_stats.h" | 8 #include "vm/compiler_stats.h" |
| 9 #include "vm/gc_marker.h" | 9 #include "vm/gc_marker.h" |
| 10 #include "vm/gc_sweeper.h" | 10 #include "vm/gc_sweeper.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 "Print free list statistics after a GC"); | 25 "Print free list statistics after a GC"); |
| 26 | 26 |
| 27 HeapPage* HeapPage::Initialize(VirtualMemory* memory, PageType type) { | 27 HeapPage* HeapPage::Initialize(VirtualMemory* memory, PageType type) { |
| 28 ASSERT(memory->size() > VirtualMemory::PageSize()); | 28 ASSERT(memory->size() > VirtualMemory::PageSize()); |
| 29 bool is_executable = (type == kExecutable); | 29 bool is_executable = (type == kExecutable); |
| 30 memory->Commit(is_executable); | 30 memory->Commit(is_executable); |
| 31 | 31 |
| 32 HeapPage* result = reinterpret_cast<HeapPage*>(memory->address()); | 32 HeapPage* result = reinterpret_cast<HeapPage*>(memory->address()); |
| 33 result->memory_ = memory; | 33 result->memory_ = memory; |
| 34 result->next_ = NULL; | 34 result->next_ = NULL; |
| 35 result->used_ = 0; | |
| 36 result->executable_ = is_executable; | 35 result->executable_ = is_executable; |
| 37 return result; | 36 return result; |
| 38 } | 37 } |
| 39 | 38 |
| 40 | 39 |
| 41 HeapPage* HeapPage::Allocate(intptr_t size, PageType type) { | 40 HeapPage* HeapPage::Allocate(intptr_t size, PageType type) { |
| 42 VirtualMemory* memory = | 41 VirtualMemory* memory = VirtualMemory::Reserve(size); |
| 43 VirtualMemory::ReserveAligned(size, PageSpace::kPageAlignment); | |
| 44 return Initialize(memory, type); | 42 return Initialize(memory, type); |
| 45 } | 43 } |
| 46 | 44 |
| 47 | 45 |
| 48 void HeapPage::Deallocate() { | 46 void HeapPage::Deallocate() { |
| 49 // The memory for this object will become unavailable after the delete below. | 47 // The memory for this object will become unavailable after the delete below. |
| 50 delete memory_; | 48 delete memory_; |
| 51 } | 49 } |
| 52 | 50 |
| 53 | 51 |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 return 0; | 606 return 0; |
| 609 } else { | 607 } else { |
| 610 ASSERT(total_time >= gc_time); | 608 ASSERT(total_time >= gc_time); |
| 611 int result= static_cast<int>((static_cast<double>(gc_time) / | 609 int result= static_cast<int>((static_cast<double>(gc_time) / |
| 612 static_cast<double>(total_time)) * 100); | 610 static_cast<double>(total_time)) * 100); |
| 613 return result; | 611 return result; |
| 614 } | 612 } |
| 615 } | 613 } |
| 616 | 614 |
| 617 } // namespace dart | 615 } // namespace dart |
| OLD | NEW |