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

Side by Side Diff: src/heap/scavenger-inl.h

Issue 2005173003: Immediatelly promote marked objects (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove FORCE_PROMOTION Created 4 years, 6 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
« src/heap/heap.cc ('K') | « src/heap/scavenger.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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 #ifndef V8_HEAP_SCAVENGER_INL_H_ 5 #ifndef V8_HEAP_SCAVENGER_INL_H_
6 #define V8_HEAP_SCAVENGER_INL_H_ 6 #define V8_HEAP_SCAVENGER_INL_H_
7 7
8 #include "src/heap/scavenger.h" 8 #include "src/heap/scavenger.h"
9 9
10 namespace v8 { 10 namespace v8 {
11 namespace internal { 11 namespace internal {
12 12
13 void Scavenger::ScavengeObject(HeapObject** p, HeapObject* object, 13 template <PromotionMode promotion_mode>
14 PromotionMode promotion_mode) { 14 void Scavenger::ScavengeObject(HeapObject** p, HeapObject* object) {
15 DCHECK(object->GetIsolate()->heap()->InFromSpace(object)); 15 DCHECK(object->GetIsolate()->heap()->InFromSpace(object));
16 16
17 // We use the first word (where the map pointer usually is) of a heap 17 // We use the first word (where the map pointer usually is) of a heap
18 // object to record the forwarding pointer. A forwarding pointer can 18 // object to record the forwarding pointer. A forwarding pointer can
19 // point to an old space, the code space, or the to space of the new 19 // point to an old space, the code space, or the to space of the new
20 // generation. 20 // generation.
21 MapWord first_word = object->map_word(); 21 MapWord first_word = object->map_word();
22 22
23 // If the first word is a forwarding address, the object has already been 23 // If the first word is a forwarding address, the object has already been
24 // copied. 24 // copied.
25 if (first_word.IsForwardingAddress()) { 25 if (first_word.IsForwardingAddress()) {
26 HeapObject* dest = first_word.ToForwardingAddress(); 26 HeapObject* dest = first_word.ToForwardingAddress();
27 DCHECK(object->GetIsolate()->heap()->InFromSpace(*p)); 27 DCHECK(object->GetIsolate()->heap()->InFromSpace(*p));
28 *p = dest; 28 *p = dest;
29 return; 29 return;
30 } 30 }
31 31
32 object->GetHeap()->UpdateAllocationSite<Heap::kGlobal>( 32 object->GetHeap()->UpdateAllocationSite<Heap::kGlobal>(
33 object, object->GetHeap()->global_pretenuring_feedback_); 33 object, object->GetHeap()->global_pretenuring_feedback_);
34 34
35 // AllocationMementos are unrooted and shouldn't survive a scavenge 35 // AllocationMementos are unrooted and shouldn't survive a scavenge
36 DCHECK(object->map() != object->GetHeap()->allocation_memento_map()); 36 DCHECK(object->map() != object->GetHeap()->allocation_memento_map());
37 // Call the slow part of scavenge object. 37 // Call the slow part of scavenge object.
38 return ScavengeObjectSlow(p, object, promotion_mode); 38 return ScavengeObjectSlow<promotion_mode>(p, object);
39 } 39 }
40 40
41 SlotCallbackResult Scavenger::CheckAndScavengeObject( 41 // static
42 Heap* heap, Address slot_address, PromotionMode promotion_mode) { 42 template <PromotionMode promotion_mode>
ulan 2016/05/30 16:09:06 Since the promotion_mode is not used, I would drop
43 void Scavenger::ScavengeObjectSlow(HeapObject** p, HeapObject* object) {
44 SLOW_DCHECK(object->GetIsolate()->heap()->InFromSpace(object));
45 MapWord first_word = object->map_word();
46 SLOW_DCHECK(!first_word.IsForwardingAddress());
47 Map* map = first_word.ToMap();
48 Scavenger* scavenger = map->GetHeap()->scavenge_collector_;
49 scavenger->scavenging_visitors_table_.GetVisitor(map)(map, p, object);
50 }
51
52 template <PromotionMode promotion_mode>
53 SlotCallbackResult Scavenger::CheckAndScavengeObject(Heap* heap,
54 Address slot_address) {
43 Object** slot = reinterpret_cast<Object**>(slot_address); 55 Object** slot = reinterpret_cast<Object**>(slot_address);
44 Object* object = *slot; 56 Object* object = *slot;
45 if (heap->InFromSpace(object)) { 57 if (heap->InFromSpace(object)) {
46 HeapObject* heap_object = reinterpret_cast<HeapObject*>(object); 58 HeapObject* heap_object = reinterpret_cast<HeapObject*>(object);
47 DCHECK(heap_object->IsHeapObject()); 59 DCHECK(heap_object->IsHeapObject());
48 60
49 ScavengeObject(reinterpret_cast<HeapObject**>(slot), heap_object, 61 ScavengeObject<promotion_mode>(reinterpret_cast<HeapObject**>(slot),
50 promotion_mode); 62 heap_object);
51 63
52 object = *slot; 64 object = *slot;
53 // If the object was in from space before and is after executing the 65 // If the object was in from space before and is after executing the
54 // callback in to space, the object is still live. 66 // callback in to space, the object is still live.
55 // Unfortunately, we do not know about the slot. It could be in a 67 // Unfortunately, we do not know about the slot. It could be in a
56 // just freed free space object. 68 // just freed free space object.
57 if (heap->InToSpace(object)) { 69 if (heap->InToSpace(object)) {
58 return KEEP_SLOT; 70 return KEEP_SLOT;
59 } 71 }
60 } else { 72 } else {
61 DCHECK(!heap->InNewSpace(object)); 73 DCHECK(!heap->InNewSpace(object));
62 } 74 }
63 return REMOVE_SLOT; 75 return REMOVE_SLOT;
64 } 76 }
65 77
66 // static 78 // static
67 void StaticScavengeVisitor::VisitPointer(Heap* heap, HeapObject* obj, 79 template <PromotionMode promotion_mode>
68 Object** p) { 80 void StaticScavengeVisitor<promotion_mode>::VisitPointer(Heap* heap,
81 HeapObject* obj,
82 Object** p) {
69 Object* object = *p; 83 Object* object = *p;
70 if (!heap->InNewSpace(object)) return; 84 if (!heap->InNewSpace(object)) return;
71 Scavenger::ScavengeObject(reinterpret_cast<HeapObject**>(p), 85 Scavenger::ScavengeObject<promotion_mode>(
72 reinterpret_cast<HeapObject*>(object), 86 reinterpret_cast<HeapObject**>(p), reinterpret_cast<HeapObject*>(object));
73 DEFAULT_PROMOTION); 87 }
88
89 template <PromotionMode promotion_mode>
90 void ScavengeVisitor<promotion_mode>::VisitPointer(Object** p) {
91 ScavengePointer(p);
92 }
93
94 template <PromotionMode promotion_mode>
95 void ScavengeVisitor<promotion_mode>::VisitPointers(Object** start,
96 Object** end) {
97 // Copy all HeapObject pointers in [start, end)
98 for (Object** p = start; p < end; p++) ScavengePointer(p);
99 }
100
101 template <PromotionMode promotion_mode>
102 void ScavengeVisitor<promotion_mode>::ScavengePointer(Object** p) {
103 Object* object = *p;
104 if (!heap_->InNewSpace(object)) return;
105 Scavenger::ScavengeObject<promotion_mode>(
106 reinterpret_cast<HeapObject**>(p), reinterpret_cast<HeapObject*>(object));
74 } 107 }
75 108
76 } // namespace internal 109 } // namespace internal
77 } // namespace v8 110 } // namespace v8
78 111
79 #endif // V8_HEAP_SCAVENGER_INL_H_ 112 #endif // V8_HEAP_SCAVENGER_INL_H_
OLDNEW
« src/heap/heap.cc ('K') | « src/heap/scavenger.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698