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

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

Issue 2854063002: [heap] Refactor updating of marking deque after scavenge. (Closed)
Patch Set: Created 3 years, 7 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 | src/heap/sequential-marking-deque.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/heap/incremental-marking.h" 5 #include "src/heap/incremental-marking.h"
6 6
7 #include "src/code-stubs.h" 7 #include "src/code-stubs.h"
8 #include "src/compilation-cache.h" 8 #include "src/compilation-cache.h"
9 #include "src/conversions.h" 9 #include "src/conversions.h"
10 #include "src/heap/concurrent-marking.h" 10 #include "src/heap/concurrent-marking.h"
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 // TODO(hpayer): Move to an earlier point as soon as we make faster marking 756 // TODO(hpayer): Move to an earlier point as soon as we make faster marking
757 // progress. 757 // progress.
758 StartBlackAllocation(); 758 StartBlackAllocation();
759 } 759 }
760 } 760 }
761 761
762 762
763 void IncrementalMarking::UpdateMarkingDequeAfterScavenge() { 763 void IncrementalMarking::UpdateMarkingDequeAfterScavenge() {
764 if (!IsMarking()) return; 764 if (!IsMarking()) return;
765 765
766 int current = marking_deque()->bottom();
767 int mask = marking_deque()->mask();
768 int limit = marking_deque()->top();
769 HeapObject** array = marking_deque()->array();
770 int new_top = current;
771
772 Map* filler_map = heap_->one_pointer_filler_map(); 766 Map* filler_map = heap_->one_pointer_filler_map();
773 767
774 while (current != limit) { 768 marking_deque()->Update([this, filler_map](HeapObject* obj) -> HeapObject* {
775 HeapObject* obj = array[current];
776 DCHECK(obj->IsHeapObject()); 769 DCHECK(obj->IsHeapObject());
777 current = ((current + 1) & mask);
778 // Only pointers to from space have to be updated. 770 // Only pointers to from space have to be updated.
779 if (heap_->InFromSpace(obj)) { 771 if (heap_->InFromSpace(obj)) {
780 MapWord map_word = obj->map_word(); 772 MapWord map_word = obj->map_word();
781 // There may be objects on the marking deque that do not exist anymore, 773 if (!map_word.IsForwardingAddress()) {
782 // e.g. left trimmed objects or objects from the root set (frames). 774 // There may be objects on the marking deque that do not exist anymore,
783 // If these object are dead at scavenging time, their marking deque 775 // e.g. left trimmed objects or objects from the root set (frames).
784 // entries will not point to forwarding addresses. Hence, we can discard 776 // If these object are dead at scavenging time, their marking deque
785 // them. 777 // entries will not point to forwarding addresses. Hence, we can discard
786 if (map_word.IsForwardingAddress()) { 778 // them.
787 HeapObject* dest = map_word.ToForwardingAddress(); 779 return nullptr;
788 if (ObjectMarking::IsBlack(dest, marking_state(dest))) continue;
789 array[new_top] = dest;
790 new_top = ((new_top + 1) & mask);
791 DCHECK(new_top != marking_deque()->bottom());
792 DCHECK(ObjectMarking::IsGrey(obj, marking_state(obj)) ||
793 (obj->IsFiller() &&
794 ObjectMarking::IsWhite(obj, marking_state(obj))));
795 } 780 }
796 } else if (obj->map() != filler_map) { 781 HeapObject* dest = map_word.ToForwardingAddress();
797 // Skip one word filler objects that appear on the 782 if (ObjectMarking::IsBlack(dest, marking_state(dest))) {
798 // stack when we perform in place array shift. 783 // The object is already processed by the marker.
799 array[new_top] = obj; 784 return nullptr;
800 new_top = ((new_top + 1) & mask); 785 }
801 DCHECK(new_top != marking_deque()->bottom()); 786 DCHECK(
787 ObjectMarking::IsGrey(obj, marking_state(obj)) ||
788 (obj->IsFiller() && ObjectMarking::IsWhite(obj, marking_state(obj))));
789 return dest;
790 } else {
802 DCHECK(ObjectMarking::IsGrey(obj, marking_state(obj)) || 791 DCHECK(ObjectMarking::IsGrey(obj, marking_state(obj)) ||
803 (obj->IsFiller() && 792 (obj->IsFiller() &&
804 ObjectMarking::IsWhite(obj, marking_state(obj))) || 793 ObjectMarking::IsWhite(obj, marking_state(obj))) ||
805 (MemoryChunk::FromAddress(obj->address()) 794 (MemoryChunk::FromAddress(obj->address())
806 ->IsFlagSet(MemoryChunk::HAS_PROGRESS_BAR) && 795 ->IsFlagSet(MemoryChunk::HAS_PROGRESS_BAR) &&
807 ObjectMarking::IsBlack(obj, marking_state(obj)))); 796 ObjectMarking::IsBlack(obj, marking_state(obj))));
797 // Skip one word filler objects that appear on the
798 // stack when we perform in place array shift.
799 return (obj->map() == filler_map) ? nullptr : obj;
808 } 800 }
809 } 801 });
810 marking_deque()->set_top(new_top);
811 } 802 }
812 803
813 804
814 void IncrementalMarking::VisitObject(Map* map, HeapObject* obj, int size) { 805 void IncrementalMarking::VisitObject(Map* map, HeapObject* obj, int size) {
815 MarkGrey(map); 806 MarkGrey(map);
816 807
817 IncrementalMarkingMarkingVisitor::IterateBody(map, obj); 808 IncrementalMarkingMarkingVisitor::IterateBody(map, obj);
818 809
819 #if ENABLE_SLOW_DCHECKS 810 #if ENABLE_SLOW_DCHECKS
820 MarkBit mark_bit = ObjectMarking::MarkBitFrom(obj, marking_state(obj)); 811 MarkBit mark_bit = ObjectMarking::MarkBitFrom(obj, marking_state(obj));
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 idle_marking_delay_counter_++; 1168 idle_marking_delay_counter_++;
1178 } 1169 }
1179 1170
1180 1171
1181 void IncrementalMarking::ClearIdleMarkingDelayCounter() { 1172 void IncrementalMarking::ClearIdleMarkingDelayCounter() {
1182 idle_marking_delay_counter_ = 0; 1173 idle_marking_delay_counter_ = 0;
1183 } 1174 }
1184 1175
1185 } // namespace internal 1176 } // namespace internal
1186 } // namespace v8 1177 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/heap/sequential-marking-deque.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698