| 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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 if ((result == 0) && | 213 if ((result == 0) && |
| 214 (page_space_controller_.CanGrowPageSpace(size) || | 214 (page_space_controller_.CanGrowPageSpace(size) || |
| 215 growth_policy == kForceGrowth) && | 215 growth_policy == kForceGrowth) && |
| 216 CanIncreaseCapacity(kPageSize)) { | 216 CanIncreaseCapacity(kPageSize)) { |
| 217 HeapPage* page = AllocatePage(type); | 217 HeapPage* page = AllocatePage(type); |
| 218 ASSERT(page != NULL); | 218 ASSERT(page != NULL); |
| 219 // Start of the newly allocated page is the allocated object. | 219 // Start of the newly allocated page is the allocated object. |
| 220 result = page->object_start(); | 220 result = page->object_start(); |
| 221 // Enqueue the remainder in the free list. | 221 // Enqueue the remainder in the free list. |
| 222 uword free_start = result + size; | 222 uword free_start = result + size; |
| 223 freelist_[type].Free(free_start, page->object_end() - free_start); | 223 intptr_t free_size = page->object_end() - free_start; |
| 224 if (free_size > 0) { |
| 225 freelist_[type].Free(free_start, free_size); |
| 226 } |
| 224 } | 227 } |
| 225 } else { | 228 } else { |
| 226 // Large page allocation. | 229 // Large page allocation. |
| 227 intptr_t page_size = LargePageSizeFor(size); | 230 intptr_t page_size = LargePageSizeFor(size); |
| 228 if (page_size < size) { | 231 if (page_size < size) { |
| 229 // On overflow we fail to allocate. | 232 // On overflow we fail to allocate. |
| 230 return 0; | 233 return 0; |
| 231 } | 234 } |
| 232 if (CanIncreaseCapacity(page_size)) { | 235 if (CanIncreaseCapacity(page_size)) { |
| 233 HeapPage* page = AllocateLargePage(size, type); | 236 HeapPage* page = AllocateLargePage(size, type); |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 return 0; | 626 return 0; |
| 624 } else { | 627 } else { |
| 625 ASSERT(total_time >= gc_time); | 628 ASSERT(total_time >= gc_time); |
| 626 int result= static_cast<int>((static_cast<double>(gc_time) / | 629 int result= static_cast<int>((static_cast<double>(gc_time) / |
| 627 static_cast<double>(total_time)) * 100); | 630 static_cast<double>(total_time)) * 100); |
| 628 return result; | 631 return result; |
| 629 } | 632 } |
| 630 } | 633 } |
| 631 | 634 |
| 632 } // namespace dart | 635 } // namespace dart |
| OLD | NEW |