| OLD | NEW |
| 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/pages.h" | 5 #include "vm/pages.h" |
| 6 | 6 |
| 7 #include "vm/assert.h" | 7 #include "vm/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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 } | 135 } |
| 136 | 136 |
| 137 | 137 |
| 138 uword PageSpace::TryAllocate(intptr_t size) { | 138 uword PageSpace::TryAllocate(intptr_t size) { |
| 139 ASSERT(size >= kObjectAlignment); | 139 ASSERT(size >= kObjectAlignment); |
| 140 ASSERT(Utils::IsAligned(size, kObjectAlignment)); | 140 ASSERT(Utils::IsAligned(size, kObjectAlignment)); |
| 141 uword result = 0; | 141 uword result = 0; |
| 142 if (size < kAllocatablePageSize) { | 142 if (size < kAllocatablePageSize) { |
| 143 result = TryBumpAllocate(size); | 143 result = TryBumpAllocate(size); |
| 144 if (result == 0) { | 144 if (result == 0) { |
| 145 if (CanIncreaseCapacity(kPageSize)) { | 145 result = freelist_.TryAllocate(size); |
| 146 if ((result == 0) && CanIncreaseCapacity(kPageSize)) { |
| 146 AllocatePage(); | 147 AllocatePage(); |
| 147 result = TryBumpAllocate(size); | 148 result = TryBumpAllocate(size); |
| 148 ASSERT(result != 0); | 149 ASSERT(result != 0); |
| 149 } | 150 } |
| 150 } | 151 } |
| 151 } else { | 152 } else { |
| 152 // Large page allocation. | 153 // Large page allocation. |
| 153 intptr_t page_size = LargePageSizeFor(size); | 154 intptr_t page_size = LargePageSizeFor(size); |
| 154 if (page_size < size) { | 155 if (page_size < size) { |
| 155 // On overflow we fail to allocate. | 156 // On overflow we fail to allocate. |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 OS::PrintErr(" done.\n"); | 273 OS::PrintErr(" done.\n"); |
| 273 } | 274 } |
| 274 | 275 |
| 275 count_++; | 276 count_++; |
| 276 // Done, reset the marker. | 277 // Done, reset the marker. |
| 277 ASSERT(sweeping_); | 278 ASSERT(sweeping_); |
| 278 sweeping_ = false; | 279 sweeping_ = false; |
| 279 } | 280 } |
| 280 | 281 |
| 281 } // namespace dart | 282 } // namespace dart |
| OLD | NEW |