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

Side by Side Diff: src/spaces.cc

Issue 12177017: Fixed IsSweepingComplete and EnsureSweeperProgress helper functions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 10 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 | « src/spaces.h ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 2507 matching lines...) Expand 10 before | Expand all | Expand 10 after
2518 // You have to call this last, since the implementation from PagedSpace 2518 // You have to call this last, since the implementation from PagedSpace
2519 // doesn't know that memory was 'promised' to large object space. 2519 // doesn't know that memory was 'promised' to large object space.
2520 bool LargeObjectSpace::ReserveSpace(int bytes) { 2520 bool LargeObjectSpace::ReserveSpace(int bytes) {
2521 return heap()->OldGenerationCapacityAvailable() >= bytes && 2521 return heap()->OldGenerationCapacityAvailable() >= bytes &&
2522 (!heap()->incremental_marking()->IsStopped() || 2522 (!heap()->incremental_marking()->IsStopped() ||
2523 heap()->OldGenerationSpaceAvailable() >= bytes); 2523 heap()->OldGenerationSpaceAvailable() >= bytes);
2524 } 2524 }
2525 2525
2526 2526
2527 bool PagedSpace::AdvanceSweeper(intptr_t bytes_to_sweep) { 2527 bool PagedSpace::AdvanceSweeper(intptr_t bytes_to_sweep) {
2528 if (IsSweepingComplete()) return true; 2528 if (IsLazySweepingComplete()) return true;
2529 2529
2530 intptr_t freed_bytes = 0; 2530 intptr_t freed_bytes = 0;
2531 Page* p = first_unswept_page_; 2531 Page* p = first_unswept_page_;
2532 do { 2532 do {
2533 Page* next_page = p->next_page(); 2533 Page* next_page = p->next_page();
2534 if (ShouldBeSweptLazily(p)) { 2534 if (ShouldBeSweptLazily(p)) {
2535 if (FLAG_gc_verbose) { 2535 if (FLAG_gc_verbose) {
2536 PrintF("Sweeping 0x%" V8PRIxPTR " lazily advanced.\n", 2536 PrintF("Sweeping 0x%" V8PRIxPTR " lazily advanced.\n",
2537 reinterpret_cast<intptr_t>(p)); 2537 reinterpret_cast<intptr_t>(p));
2538 } 2538 }
2539 DecreaseUnsweptFreeBytes(p); 2539 DecreaseUnsweptFreeBytes(p);
2540 freed_bytes += 2540 freed_bytes +=
2541 MarkCompactCollector:: 2541 MarkCompactCollector::
2542 SweepConservatively<MarkCompactCollector::SWEEP_SEQUENTIALLY>( 2542 SweepConservatively<MarkCompactCollector::SWEEP_SEQUENTIALLY>(
2543 this, NULL, p); 2543 this, NULL, p);
2544 } 2544 }
2545 p = next_page; 2545 p = next_page;
2546 } while (p != anchor() && freed_bytes < bytes_to_sweep); 2546 } while (p != anchor() && freed_bytes < bytes_to_sweep);
2547 2547
2548 if (p == anchor()) { 2548 if (p == anchor()) {
2549 first_unswept_page_ = Page::FromAddress(NULL); 2549 first_unswept_page_ = Page::FromAddress(NULL);
2550 } else { 2550 } else {
2551 first_unswept_page_ = p; 2551 first_unswept_page_ = p;
2552 } 2552 }
2553 2553
2554 heap()->FreeQueuedChunks(); 2554 heap()->FreeQueuedChunks();
2555 2555
2556 return IsSweepingComplete(); 2556 return IsLazySweepingComplete();
2557 } 2557 }
2558 2558
2559 2559
2560 void PagedSpace::EvictEvacuationCandidatesFromFreeLists() { 2560 void PagedSpace::EvictEvacuationCandidatesFromFreeLists() {
2561 if (allocation_info_.top >= allocation_info_.limit) return; 2561 if (allocation_info_.top >= allocation_info_.limit) return;
2562 2562
2563 if (Page::FromAllocationTop(allocation_info_.top)->IsEvacuationCandidate()) { 2563 if (Page::FromAllocationTop(allocation_info_.top)->IsEvacuationCandidate()) {
2564 // Create filler object to keep page iterable if it was iterable. 2564 // Create filler object to keep page iterable if it was iterable.
2565 int remaining = 2565 int remaining =
2566 static_cast<int>(allocation_info_.limit - allocation_info_.top); 2566 static_cast<int>(allocation_info_.limit - allocation_info_.top);
2567 heap()->CreateFillerObjectAt(allocation_info_.top, remaining); 2567 heap()->CreateFillerObjectAt(allocation_info_.top, remaining);
2568 2568
2569 allocation_info_.top = NULL; 2569 allocation_info_.top = NULL;
2570 allocation_info_.limit = NULL; 2570 allocation_info_.limit = NULL;
2571 } 2571 }
2572 } 2572 }
2573 2573
2574 2574
2575 bool PagedSpace::EnsureSweeperProgress(intptr_t size_in_bytes) { 2575 bool PagedSpace::EnsureSweeperProgress(intptr_t size_in_bytes) {
2576 MarkCompactCollector* collector = heap()->mark_compact_collector(); 2576 MarkCompactCollector* collector = heap()->mark_compact_collector();
2577 if (collector->AreSweeperThreadsActivated()) { 2577 if (collector->AreSweeperThreadsActivated()) {
2578 if (FLAG_concurrent_sweeping && 2578 if (FLAG_concurrent_sweeping) {
2579 collector->StealMemoryFromSweeperThreads(this) < size_in_bytes) { 2579 if (collector->StealMemoryFromSweeperThreads(this) < size_in_bytes) {
2580 collector->WaitUntilSweepingCompleted(); 2580 collector->WaitUntilSweepingCompleted();
2581 return true; 2581 return true;
2582 }
2583 return false;
2582 } 2584 }
2583 return false; 2585 return true;
2584 } else { 2586 } else {
2585 return AdvanceSweeper(size_in_bytes); 2587 return AdvanceSweeper(size_in_bytes);
2586 } 2588 }
2587 } 2589 }
2588 2590
2589 2591
2590 HeapObject* PagedSpace::SlowAllocateRaw(int size_in_bytes) { 2592 HeapObject* PagedSpace::SlowAllocateRaw(int size_in_bytes) {
2591 // Allocation in this space has failed. 2593 // Allocation in this space has failed.
2592 2594
2593 // If there are unswept pages advance lazy sweeper a bounded number of times 2595 // If there are unswept pages advance lazy sweeper a bounded number of times
(...skipping 17 matching lines...) Expand all
2611 return NULL; 2613 return NULL;
2612 } 2614 }
2613 2615
2614 // Try to expand the space and allocate in the new next page. 2616 // Try to expand the space and allocate in the new next page.
2615 if (Expand()) { 2617 if (Expand()) {
2616 return free_list_.Allocate(size_in_bytes); 2618 return free_list_.Allocate(size_in_bytes);
2617 } 2619 }
2618 2620
2619 // Last ditch, sweep all the remaining pages to try to find space. This may 2621 // Last ditch, sweep all the remaining pages to try to find space. This may
2620 // cause a pause. 2622 // cause a pause.
2621 if (!IsSweepingComplete()) { 2623 if (!IsLazySweepingComplete()) {
2622 EnsureSweeperProgress(kMaxInt); 2624 EnsureSweeperProgress(kMaxInt);
2623 2625
2624 // Retry the free list allocation. 2626 // Retry the free list allocation.
2625 HeapObject* object = free_list_.Allocate(size_in_bytes); 2627 HeapObject* object = free_list_.Allocate(size_in_bytes);
2626 if (object != NULL) return object; 2628 if (object != NULL) return object;
2627 } 2629 }
2628 2630
2629 // Finally, fail. 2631 // Finally, fail.
2630 return NULL; 2632 return NULL;
2631 } 2633 }
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
3149 object->ShortPrint(); 3151 object->ShortPrint();
3150 PrintF("\n"); 3152 PrintF("\n");
3151 } 3153 }
3152 printf(" --------------------------------------\n"); 3154 printf(" --------------------------------------\n");
3153 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); 3155 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes());
3154 } 3156 }
3155 3157
3156 #endif // DEBUG 3158 #endif // DEBUG
3157 3159
3158 } } // namespace v8::internal 3160 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/spaces.h ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698