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

Side by Side Diff: src/heap/heap.cc

Issue 1302273002: [heap] Thread through GC flags in memory reducer and incremental marking. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix scavenger call in test Created 5 years, 4 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
« no previous file with comments | « no previous file | 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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/heap/heap.h" 5 #include "src/heap/heap.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api.h" 8 #include "src/api.h"
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/base/once.h" 10 #include "src/base/once.h"
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 } 733 }
734 // We must not compact the weak fixed list here, as we may be in the middle 734 // We must not compact the weak fixed list here, as we may be in the middle
735 // of writing to it, when the GC triggered. Instead, we reset the root value. 735 // of writing to it, when the GC triggered. Instead, we reset the root value.
736 set_weak_stack_trace_list(Smi::FromInt(0)); 736 set_weak_stack_trace_list(Smi::FromInt(0));
737 } 737 }
738 738
739 739
740 void Heap::HandleGCRequest() { 740 void Heap::HandleGCRequest() {
741 if (incremental_marking()->request_type() == 741 if (incremental_marking()->request_type() ==
742 IncrementalMarking::COMPLETE_MARKING) { 742 IncrementalMarking::COMPLETE_MARKING) {
743 CollectAllGarbage(Heap::kNoGCFlags, "GC interrupt", 743 CollectAllGarbage(current_gc_flags(), "GC interrupt",
744 incremental_marking()->CallbackFlags()); 744 incremental_marking()->CallbackFlags());
745 return; 745 return;
746 } 746 }
747 DCHECK(FLAG_overapproximate_weak_closure); 747 DCHECK(FLAG_overapproximate_weak_closure);
748 if (!incremental_marking()->weak_closure_was_overapproximated()) { 748 if (!incremental_marking()->weak_closure_was_overapproximated()) {
749 OverApproximateWeakClosure("GC interrupt"); 749 OverApproximateWeakClosure("GC interrupt");
750 } 750 }
751 } 751 }
752 752
753 753
(...skipping 3987 matching lines...) Expand 10 before | Expand all | Expand 10 after
4741 // Fragmentation is high if committed > 2 * used + kSlack. 4741 // Fragmentation is high if committed > 2 * used + kSlack.
4742 // Rewrite the exression to avoid overflow. 4742 // Rewrite the exression to avoid overflow.
4743 return committed - used > used + kSlack; 4743 return committed - used > used + kSlack;
4744 } 4744 }
4745 4745
4746 4746
4747 void Heap::ReduceNewSpaceSize() { 4747 void Heap::ReduceNewSpaceSize() {
4748 // TODO(ulan): Unify this constant with the similar constant in 4748 // TODO(ulan): Unify this constant with the similar constant in
4749 // GCIdleTimeHandler once the change is merged to 4.5. 4749 // GCIdleTimeHandler once the change is merged to 4.5.
4750 static const size_t kLowAllocationThroughput = 1000; 4750 static const size_t kLowAllocationThroughput = 1000;
4751 size_t allocation_throughput = 4751 const size_t allocation_throughput =
4752 tracer()->CurrentAllocationThroughputInBytesPerMillisecond(); 4752 tracer()->CurrentAllocationThroughputInBytesPerMillisecond();
4753 if (FLAG_predictable || allocation_throughput == 0) return; 4753
4754 if (allocation_throughput < kLowAllocationThroughput) { 4754 if (FLAG_predictable) return;
4755
4756 if (ShouldReduceMemory() ||
4757 ((allocation_throughput != 0) &&
4758 (allocation_throughput < kLowAllocationThroughput))) {
4755 new_space_.Shrink(); 4759 new_space_.Shrink();
4756 UncommitFromSpace(); 4760 UncommitFromSpace();
4757 } 4761 }
4758 } 4762 }
4759 4763
4760 4764
4761 void Heap::FinalizeIncrementalMarkingIfComplete(const char* comment) { 4765 void Heap::FinalizeIncrementalMarkingIfComplete(const char* comment) {
4762 if (FLAG_overapproximate_weak_closure && 4766 if (FLAG_overapproximate_weak_closure &&
4763 (incremental_marking()->IsReadyToOverApproximateWeakClosure() || 4767 (incremental_marking()->IsReadyToOverApproximateWeakClosure() ||
4764 (!incremental_marking()->weak_closure_was_overapproximated() && 4768 (!incremental_marking()->weak_closure_was_overapproximated() &&
4765 mark_compact_collector_.marking_deque()->IsEmpty()))) { 4769 mark_compact_collector_.marking_deque()->IsEmpty()))) {
4766 OverApproximateWeakClosure(comment); 4770 OverApproximateWeakClosure(comment);
4767 } else if (incremental_marking()->IsComplete() || 4771 } else if (incremental_marking()->IsComplete() ||
4768 (mark_compact_collector_.marking_deque()->IsEmpty())) { 4772 (mark_compact_collector_.marking_deque()->IsEmpty())) {
4769 CollectAllGarbage(kNoGCFlags, comment); 4773 CollectAllGarbage(current_gc_flags(), comment);
4770 } 4774 }
4771 } 4775 }
4772 4776
4773 4777
4774 bool Heap::TryFinalizeIdleIncrementalMarking( 4778 bool Heap::TryFinalizeIdleIncrementalMarking(
4775 double idle_time_in_ms, size_t size_of_objects, 4779 double idle_time_in_ms, size_t size_of_objects,
4776 size_t final_incremental_mark_compact_speed_in_bytes_per_ms) { 4780 size_t final_incremental_mark_compact_speed_in_bytes_per_ms) {
4777 if (FLAG_overapproximate_weak_closure && 4781 if (FLAG_overapproximate_weak_closure &&
4778 (incremental_marking()->IsReadyToOverApproximateWeakClosure() || 4782 (incremental_marking()->IsReadyToOverApproximateWeakClosure() ||
4779 (!incremental_marking()->weak_closure_was_overapproximated() && 4783 (!incremental_marking()->weak_closure_was_overapproximated() &&
4780 mark_compact_collector_.marking_deque()->IsEmpty() && 4784 mark_compact_collector_.marking_deque()->IsEmpty() &&
4781 gc_idle_time_handler_.ShouldDoOverApproximateWeakClosure( 4785 gc_idle_time_handler_.ShouldDoOverApproximateWeakClosure(
4782 static_cast<size_t>(idle_time_in_ms))))) { 4786 static_cast<size_t>(idle_time_in_ms))))) {
4783 OverApproximateWeakClosure( 4787 OverApproximateWeakClosure(
4784 "Idle notification: overapproximate weak closure"); 4788 "Idle notification: overapproximate weak closure");
4785 return true; 4789 return true;
4786 } else if (incremental_marking()->IsComplete() || 4790 } else if (incremental_marking()->IsComplete() ||
4787 (mark_compact_collector_.marking_deque()->IsEmpty() && 4791 (mark_compact_collector_.marking_deque()->IsEmpty() &&
4788 gc_idle_time_handler_.ShouldDoFinalIncrementalMarkCompact( 4792 gc_idle_time_handler_.ShouldDoFinalIncrementalMarkCompact(
4789 static_cast<size_t>(idle_time_in_ms), size_of_objects, 4793 static_cast<size_t>(idle_time_in_ms), size_of_objects,
4790 final_incremental_mark_compact_speed_in_bytes_per_ms))) { 4794 final_incremental_mark_compact_speed_in_bytes_per_ms))) {
4791 CollectAllGarbage(kNoGCFlags, "idle notification: finalize incremental"); 4795 CollectAllGarbage(current_gc_flags(),
4796 "idle notification: finalize incremental");
4792 return true; 4797 return true;
4793 } 4798 }
4794 return false; 4799 return false;
4795 } 4800 }
4796 4801
4797 4802
4798 GCIdleTimeHandler::HeapState Heap::ComputeHeapState() { 4803 GCIdleTimeHandler::HeapState Heap::ComputeHeapState() {
4799 GCIdleTimeHandler::HeapState heap_state; 4804 GCIdleTimeHandler::HeapState heap_state;
4800 heap_state.contexts_disposed = contexts_disposed_; 4805 heap_state.contexts_disposed = contexts_disposed_;
4801 heap_state.contexts_disposal_rate = 4806 heap_state.contexts_disposal_rate =
(...skipping 2070 matching lines...) Expand 10 before | Expand all | Expand 10 after
6872 *object_type = "CODE_TYPE"; \ 6877 *object_type = "CODE_TYPE"; \
6873 *object_sub_type = "CODE_AGE/" #name; \ 6878 *object_sub_type = "CODE_AGE/" #name; \
6874 return true; 6879 return true;
6875 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) 6880 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME)
6876 #undef COMPARE_AND_RETURN_NAME 6881 #undef COMPARE_AND_RETURN_NAME
6877 } 6882 }
6878 return false; 6883 return false;
6879 } 6884 }
6880 } // namespace internal 6885 } // namespace internal
6881 } // namespace v8 6886 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698