| 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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 return result; | 184 return result; |
| 185 } | 185 } |
| 186 bump_page_ = bump_page_->next(); | 186 bump_page_ = bump_page_->next(); |
| 187 } | 187 } |
| 188 // Ran through all of the pages trying to bump allocate: Give up. | 188 // Ran through all of the pages trying to bump allocate: Give up. |
| 189 return 0; | 189 return 0; |
| 190 } | 190 } |
| 191 | 191 |
| 192 | 192 |
| 193 uword PageSpace::TryAllocate(intptr_t size) { | 193 uword PageSpace::TryAllocate(intptr_t size) { |
| 194 return TryAllocate(size, kControlGrowth); |
| 195 } |
| 196 |
| 197 |
| 198 uword PageSpace::TryAllocate(intptr_t size, GrowthPolicy growth_policy) { |
| 194 ASSERT(size >= kObjectAlignment); | 199 ASSERT(size >= kObjectAlignment); |
| 195 ASSERT(Utils::IsAligned(size, kObjectAlignment)); | 200 ASSERT(Utils::IsAligned(size, kObjectAlignment)); |
| 196 uword result = 0; | 201 uword result = 0; |
| 197 if (size < kAllocatablePageSize) { | 202 if (size < kAllocatablePageSize) { |
| 198 result = TryBumpAllocate(size); | 203 result = TryBumpAllocate(size); |
| 199 if (result == 0) { | 204 if (result == 0) { |
| 200 result = freelist_.TryAllocate(size); | 205 result = freelist_.TryAllocate(size); |
| 201 if ((result == 0) && | 206 if ((result == 0) && |
| 202 (page_space_controller_.CanGrowPageSpace(size) || | 207 (page_space_controller_.CanGrowPageSpace(size) || |
| 203 (size < (capacity() - in_use()))) && // Fragmentation | 208 growth_policy == kForceGrowth) && |
| 204 CanIncreaseCapacity(kPageSize)) { | 209 CanIncreaseCapacity(kPageSize)) { |
| 205 AllocatePage(); | 210 AllocatePage(); |
| 206 result = TryBumpAllocate(size); | 211 result = TryBumpAllocate(size); |
| 207 ASSERT(result != 0); | 212 ASSERT(result != 0); |
| 208 } | 213 } |
| 209 } | 214 } |
| 210 } else { | 215 } else { |
| 211 // Large page allocation. | 216 // Large page allocation. |
| 212 intptr_t page_size = LargePageSizeFor(size); | 217 intptr_t page_size = LargePageSizeFor(size); |
| 213 if (page_size < size) { | 218 if (page_size < size) { |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 } | 468 } |
| 464 if (total_time == 0) { | 469 if (total_time == 0) { |
| 465 return 0; | 470 return 0; |
| 466 } else { | 471 } else { |
| 467 return static_cast<int>((static_cast<double>(gc_time) / | 472 return static_cast<int>((static_cast<double>(gc_time) / |
| 468 static_cast<double>(total_time))*100); | 473 static_cast<double>(total_time))*100); |
| 469 } | 474 } |
| 470 } | 475 } |
| 471 | 476 |
| 472 } // namespace dart | 477 } // namespace dart |
| OLD | NEW |