Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: runtime/vm/pages.cc

Issue 10810048: Revert "Revert "Favor free list allocation to bump pointer allocation."" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/freelist.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "vm/virtual_memory.h" 11 #include "vm/virtual_memory.h"
12 12
13 namespace dart { 13 namespace dart {
14 14
15 DEFINE_FLAG(int, heap_growth_space_ratio, 10, 15 DEFINE_FLAG(int, heap_growth_space_ratio, 10,
16 "The desired maximum percentage of free space after GC"); 16 "The desired maximum percentage of free space after GC");
17 DEFINE_FLAG(int, heap_growth_time_ratio, 3, 17 DEFINE_FLAG(int, heap_growth_time_ratio, 3,
18 "The desired maximum percentage of time spent in GC"); 18 "The desired maximum percentage of time spent in GC");
19 DEFINE_FLAG(int, heap_growth_rate, 4, 19 DEFINE_FLAG(int, heap_growth_rate, 4,
20 "The size the heap is grown, in heap pages"); 20 "The size the heap is grown, in heap pages");
21 DEFINE_FLAG(bool, print_free_list_before_gc, false,
22 "Print free list statistics before a GC");
23 DEFINE_FLAG(bool, print_free_list_after_gc, false,
24 "Print free list statistics after a GC");
21 25
22 HeapPage* HeapPage::Initialize(VirtualMemory* memory, bool is_executable) { 26 HeapPage* HeapPage::Initialize(VirtualMemory* memory, bool is_executable) {
23 ASSERT(memory->size() > VirtualMemory::PageSize()); 27 ASSERT(memory->size() > VirtualMemory::PageSize());
24 memory->Commit(is_executable); 28 memory->Commit(is_executable);
25 29
26 HeapPage* result = reinterpret_cast<HeapPage*>(memory->address()); 30 HeapPage* result = reinterpret_cast<HeapPage*>(memory->address());
27 result->memory_ = memory; 31 result->memory_ = memory;
28 result->next_ = NULL; 32 result->next_ = NULL;
29 result->used_ = 0; 33 result->used_ = 0;
30 result->top_ = result->first_object_start(); 34 result->top_ = result->first_object_start();
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 uword PageSpace::TryAllocate(intptr_t size) { 209 uword PageSpace::TryAllocate(intptr_t size) {
206 return TryAllocate(size, kControlGrowth); 210 return TryAllocate(size, kControlGrowth);
207 } 211 }
208 212
209 213
210 uword PageSpace::TryAllocate(intptr_t size, GrowthPolicy growth_policy) { 214 uword PageSpace::TryAllocate(intptr_t size, GrowthPolicy growth_policy) {
211 ASSERT(size >= kObjectAlignment); 215 ASSERT(size >= kObjectAlignment);
212 ASSERT(Utils::IsAligned(size, kObjectAlignment)); 216 ASSERT(Utils::IsAligned(size, kObjectAlignment));
213 uword result = 0; 217 uword result = 0;
214 if (size < kAllocatablePageSize) { 218 if (size < kAllocatablePageSize) {
215 result = TryBumpAllocate(size); 219 result = freelist_.TryAllocate(size);
216 if (result == 0) { 220 if (result == 0) {
217 result = freelist_.TryAllocate(size); 221 result = TryBumpAllocate(size);
218 if ((result == 0) && 222 if ((result == 0) &&
219 (page_space_controller_.CanGrowPageSpace(size) || 223 (page_space_controller_.CanGrowPageSpace(size) ||
220 growth_policy == kForceGrowth) && 224 growth_policy == kForceGrowth) &&
221 CanIncreaseCapacity(kPageSize)) { 225 CanIncreaseCapacity(kPageSize)) {
222 AllocatePage(); 226 AllocatePage();
223 result = TryBumpAllocate(size); 227 result = TryBumpAllocate(size);
224 ASSERT(result != 0); 228 ASSERT(result != 0);
225 } 229 }
226 } 230 }
227 } else { 231 } else {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 } 340 }
337 341
338 342
339 void PageSpace::MarkSweep(bool invoke_api_callbacks) { 343 void PageSpace::MarkSweep(bool invoke_api_callbacks) {
340 // MarkSweep is not reentrant. Make sure that is the case. 344 // MarkSweep is not reentrant. Make sure that is the case.
341 ASSERT(!sweeping_); 345 ASSERT(!sweeping_);
342 sweeping_ = true; 346 sweeping_ = true;
343 Isolate* isolate = Isolate::Current(); 347 Isolate* isolate = Isolate::Current();
344 NoHandleScope no_handles(isolate); 348 NoHandleScope no_handles(isolate);
345 349
350 if (FLAG_print_free_list_before_gc) {
351 freelist_.Print();
352 }
353
346 if (FLAG_verify_before_gc) { 354 if (FLAG_verify_before_gc) {
347 OS::PrintErr("Verifying before MarkSweep..."); 355 OS::PrintErr("Verifying before MarkSweep...");
348 heap_->Verify(); 356 heap_->Verify();
349 OS::PrintErr(" done.\n"); 357 OS::PrintErr(" done.\n");
350 } 358 }
351 359
352 Timer timer(true, "MarkSweep"); 360 Timer timer(true, "MarkSweep");
353 timer.Start(); 361 timer.Start();
354 int64_t start = OS::GetCurrentTimeMillis(); 362 int64_t start = OS::GetCurrentTimeMillis();
355 363
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 if (FLAG_verbose_gc) { 416 if (FLAG_verbose_gc) {
409 const intptr_t KB2 = KB / 2; 417 const intptr_t KB2 = KB / 2;
410 OS::PrintErr("Mark-Sweep[%d]: %lldus (%dK -> %dK, %dK)\n", 418 OS::PrintErr("Mark-Sweep[%d]: %lldus (%dK -> %dK, %dK)\n",
411 count_, 419 count_,
412 timer.TotalElapsedTime(), 420 timer.TotalElapsedTime(),
413 (in_use_before + (KB2)) / KB, 421 (in_use_before + (KB2)) / KB,
414 (in_use + (KB2)) / KB, 422 (in_use + (KB2)) / KB,
415 (capacity_ + KB2) / KB); 423 (capacity_ + KB2) / KB);
416 } 424 }
417 425
426 if (FLAG_print_free_list_after_gc) {
427 freelist_.Print();
428 }
429
418 if (FLAG_verify_after_gc) { 430 if (FLAG_verify_after_gc) {
419 OS::PrintErr("Verifying after MarkSweep..."); 431 OS::PrintErr("Verifying after MarkSweep...");
420 heap_->Verify(); 432 heap_->Verify();
421 OS::PrintErr(" done.\n"); 433 OS::PrintErr(" done.\n");
422 } 434 }
423 435
424 count_++; 436 count_++;
425 // Done, reset the marker. 437 // Done, reset the marker.
426 ASSERT(sweeping_); 438 ASSERT(sweeping_);
427 sweeping_ = false; 439 sweeping_ = false;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 return 0; 547 return 0;
536 } else { 548 } else {
537 ASSERT(total_time >= gc_time); 549 ASSERT(total_time >= gc_time);
538 int result= static_cast<int>((static_cast<double>(gc_time) / 550 int result= static_cast<int>((static_cast<double>(gc_time) /
539 static_cast<double>(total_time)) * 100); 551 static_cast<double>(total_time)) * 100);
540 return result; 552 return result;
541 } 553 }
542 } 554 }
543 555
544 } // namespace dart 556 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/freelist.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698