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

Side by Side Diff: src/heap/incremental-marking.cc

Issue 894703002: Add a flag to over approximate the weak closure during GC (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 5 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
« no previous file with comments | « src/heap/incremental-marking.h ('k') | src/heap/mark-compact.h » ('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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/heap/incremental-marking.h" 7 #include "src/heap/incremental-marking.h"
8 8
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/compilation-cache.h" 10 #include "src/compilation-cache.h"
(...skipping 10 matching lines...) Expand all
21 state_(STOPPED), 21 state_(STOPPED),
22 steps_count_(0), 22 steps_count_(0),
23 old_generation_space_available_at_start_of_incremental_(0), 23 old_generation_space_available_at_start_of_incremental_(0),
24 old_generation_space_used_at_start_of_incremental_(0), 24 old_generation_space_used_at_start_of_incremental_(0),
25 should_hurry_(false), 25 should_hurry_(false),
26 marking_speed_(0), 26 marking_speed_(0),
27 allocated_(0), 27 allocated_(0),
28 idle_marking_delay_counter_(0), 28 idle_marking_delay_counter_(0),
29 no_marking_scope_depth_(0), 29 no_marking_scope_depth_(0),
30 unscanned_bytes_of_large_object_(0), 30 unscanned_bytes_of_large_object_(0),
31 was_activated_(false) {} 31 was_activated_(false),
32 weak_closure_was_overapproximated_(false),
33 request_type_(COMPLETE_MARKING) {}
32 34
33 35
34 void IncrementalMarking::RecordWriteSlow(HeapObject* obj, Object** slot, 36 void IncrementalMarking::RecordWriteSlow(HeapObject* obj, Object** slot,
35 Object* value) { 37 Object* value) {
36 if (BaseRecordWrite(obj, slot, value) && slot != NULL) { 38 if (BaseRecordWrite(obj, slot, value) && slot != NULL) {
37 MarkBit obj_bit = Marking::MarkBitFrom(obj); 39 MarkBit obj_bit = Marking::MarkBitFrom(obj);
38 if (Marking::IsBlack(obj_bit)) { 40 if (Marking::IsBlack(obj_bit)) {
39 // Object is not going to be rescanned we need to record the slot. 41 // Object is not going to be rescanned we need to record the slot.
40 heap_->mark_compact_collector()->RecordSlot(HeapObject::RawField(obj, 0), 42 heap_->mark_compact_collector()->RecordSlot(HeapObject::RawField(obj, 0),
41 slot, value); 43 slot, value);
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 IncrementalMarking::set_should_hurry(false); 766 IncrementalMarking::set_should_hurry(false);
765 ResetStepCounters(); 767 ResetStepCounters();
766 PatchIncrementalMarkingRecordWriteStubs(heap_, 768 PatchIncrementalMarkingRecordWriteStubs(heap_,
767 RecordWriteStub::STORE_BUFFER_ONLY); 769 RecordWriteStub::STORE_BUFFER_ONLY);
768 DeactivateIncrementalWriteBarrier(); 770 DeactivateIncrementalWriteBarrier();
769 DCHECK(heap_->mark_compact_collector()->marking_deque()->IsEmpty()); 771 DCHECK(heap_->mark_compact_collector()->marking_deque()->IsEmpty());
770 heap_->isolate()->stack_guard()->ClearGC(); 772 heap_->isolate()->stack_guard()->ClearGC();
771 } 773 }
772 774
773 775
776 void IncrementalMarking::OverApproximateWeakClosure() {
777 DCHECK(FLAG_overapproximate_weak_closure);
778 DCHECK(!weak_closure_was_overapproximated_);
779 if (FLAG_trace_incremental_marking) {
780 PrintF("[IncrementalMarking] requesting weak closure overapproximation.\n");
781 }
782 set_should_hurry(true);
783 request_type_ = OVERAPPROXIMATION;
784 heap_->isolate()->stack_guard()->RequestGC();
785 }
786
787
774 void IncrementalMarking::MarkingComplete(CompletionAction action) { 788 void IncrementalMarking::MarkingComplete(CompletionAction action) {
775 state_ = COMPLETE; 789 state_ = COMPLETE;
776 // We will set the stack guard to request a GC now. This will mean the rest 790 // We will set the stack guard to request a GC now. This will mean the rest
777 // of the GC gets performed as soon as possible (we can't do a GC here in a 791 // of the GC gets performed as soon as possible (we can't do a GC here in a
778 // record-write context). If a few things get allocated between now and then 792 // record-write context). If a few things get allocated between now and then
779 // that shouldn't make us do a scavenge and keep being incremental, so we set 793 // that shouldn't make us do a scavenge and keep being incremental, so we set
780 // the should-hurry flag to indicate that there can't be much work left to do. 794 // the should-hurry flag to indicate that there can't be much work left to do.
781 set_should_hurry(true); 795 set_should_hurry(true);
782 if (FLAG_trace_incremental_marking) { 796 if (FLAG_trace_incremental_marking) {
783 PrintF("[IncrementalMarking] Complete (normal).\n"); 797 PrintF("[IncrementalMarking] Complete (normal).\n");
784 } 798 }
785 if (action == GC_VIA_STACK_GUARD) { 799 if (action == GC_VIA_STACK_GUARD) {
800 request_type_ = COMPLETE_MARKING;
786 heap_->isolate()->stack_guard()->RequestGC(); 801 heap_->isolate()->stack_guard()->RequestGC();
787 } 802 }
788 } 803 }
789 804
790 805
791 void IncrementalMarking::Epilogue() { was_activated_ = false; } 806 void IncrementalMarking::Epilogue() {
807 was_activated_ = false;
808 weak_closure_was_overapproximated_ = false;
809 }
792 810
793 811
794 void IncrementalMarking::OldSpaceStep(intptr_t allocated) { 812 void IncrementalMarking::OldSpaceStep(intptr_t allocated) {
795 if (IsStopped() && ShouldActivate()) { 813 if (IsStopped() && ShouldActivate()) {
796 // TODO(hpayer): Let's play safe for now, but compaction should be 814 // TODO(hpayer): Let's play safe for now, but compaction should be
797 // in principle possible. 815 // in principle possible.
798 Start(PREVENT_COMPACTION); 816 Start(PREVENT_COMPACTION);
799 } else { 817 } else {
800 Step(allocated * kFastMarking / kInitialMarkingSpeed, GC_VIA_STACK_GUARD); 818 Step(allocated * kFastMarking / kInitialMarkingSpeed, GC_VIA_STACK_GUARD);
801 } 819 }
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 } 942 }
925 if (!heap_->mark_compact_collector()->sweeping_in_progress()) { 943 if (!heap_->mark_compact_collector()->sweeping_in_progress()) {
926 bytes_scanned_ = 0; 944 bytes_scanned_ = 0;
927 StartMarking(PREVENT_COMPACTION); 945 StartMarking(PREVENT_COMPACTION);
928 } 946 }
929 } else if (state_ == MARKING) { 947 } else if (state_ == MARKING) {
930 bytes_processed = ProcessMarkingDeque(bytes_to_process); 948 bytes_processed = ProcessMarkingDeque(bytes_to_process);
931 if (heap_->mark_compact_collector()->marking_deque()->IsEmpty()) { 949 if (heap_->mark_compact_collector()->marking_deque()->IsEmpty()) {
932 if (completion == FORCE_COMPLETION || 950 if (completion == FORCE_COMPLETION ||
933 IsIdleMarkingDelayCounterLimitReached()) { 951 IsIdleMarkingDelayCounterLimitReached()) {
934 MarkingComplete(action); 952 if (FLAG_overapproximate_weak_closure &&
953 !weak_closure_was_overapproximated_ &&
954 action == GC_VIA_STACK_GUARD) {
955 OverApproximateWeakClosure();
956 } else {
957 MarkingComplete(action);
958 }
935 } else { 959 } else {
936 IncrementIdleMarkingDelayCounter(); 960 IncrementIdleMarkingDelayCounter();
937 } 961 }
938 } 962 }
939 } 963 }
940 964
941 steps_count_++; 965 steps_count_++;
942 966
943 // Speed up marking if we are marking too slow or if we are almost done 967 // Speed up marking if we are marking too slow or if we are almost done
944 // with marking. 968 // with marking.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 void IncrementalMarking::IncrementIdleMarkingDelayCounter() { 1005 void IncrementalMarking::IncrementIdleMarkingDelayCounter() {
982 idle_marking_delay_counter_++; 1006 idle_marking_delay_counter_++;
983 } 1007 }
984 1008
985 1009
986 void IncrementalMarking::ClearIdleMarkingDelayCounter() { 1010 void IncrementalMarking::ClearIdleMarkingDelayCounter() {
987 idle_marking_delay_counter_ = 0; 1011 idle_marking_delay_counter_ = 0;
988 } 1012 }
989 } 1013 }
990 } // namespace v8::internal 1014 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap/incremental-marking.h ('k') | src/heap/mark-compact.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698