Chromium Code Reviews| 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 192 | 192 |
| 193 uword PageSpace::TryAllocate(intptr_t size) { | 193 uword PageSpace::TryAllocate(intptr_t size) { |
| 194 ASSERT(size >= kObjectAlignment); | 194 ASSERT(size >= kObjectAlignment); |
| 195 ASSERT(Utils::IsAligned(size, kObjectAlignment)); | 195 ASSERT(Utils::IsAligned(size, kObjectAlignment)); |
| 196 uword result = 0; | 196 uword result = 0; |
| 197 if (size < kAllocatablePageSize) { | 197 if (size < kAllocatablePageSize) { |
| 198 result = TryBumpAllocate(size); | 198 result = TryBumpAllocate(size); |
| 199 if (result == 0) { | 199 if (result == 0) { |
| 200 result = freelist_.TryAllocate(size); | 200 result = freelist_.TryAllocate(size); |
| 201 if ((result == 0) && | 201 if ((result == 0) && |
| 202 page_space_controller_.CanGrowPageSpace(size) && | 202 (page_space_controller_.CanGrowPageSpace(size) || |
| 203 (size < (capacity() - in_use()))) && // Fragmentation | |
|
Ivan Posva
2012/05/31 23:32:53
The problem with this solution is that it has no m
| |
| 203 CanIncreaseCapacity(kPageSize)) { | 204 CanIncreaseCapacity(kPageSize)) { |
| 204 AllocatePage(); | 205 AllocatePage(); |
| 205 result = TryBumpAllocate(size); | 206 result = TryBumpAllocate(size); |
| 206 ASSERT(result != 0); | 207 ASSERT(result != 0); |
| 207 } | 208 } |
| 208 } | 209 } |
| 209 } else { | 210 } else { |
| 210 // Large page allocation. | 211 // Large page allocation. |
| 211 intptr_t page_size = LargePageSizeFor(size); | 212 intptr_t page_size = LargePageSizeFor(size); |
| 212 if (page_size < size) { | 213 if (page_size < size) { |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 462 } | 463 } |
| 463 if (total_time == 0) { | 464 if (total_time == 0) { |
| 464 return 0; | 465 return 0; |
| 465 } else { | 466 } else { |
| 466 return static_cast<int>((static_cast<double>(gc_time) / | 467 return static_cast<int>((static_cast<double>(gc_time) / |
| 467 static_cast<double>(total_time))*100); | 468 static_cast<double>(total_time))*100); |
| 468 } | 469 } |
| 469 } | 470 } |
| 470 | 471 |
| 471 } // namespace dart | 472 } // namespace dart |
| OLD | NEW |