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

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

Issue 2002013002: [heap] Pass a force_promotion flag to the evacuation routine in the scavenger. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase. Created 4 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 | « 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 void Scavenger::ScavengeObject(HeapObject** p, HeapObject* object,
14 PromotionMode promotion_mode) {
14 DCHECK(object->GetIsolate()->heap()->InFromSpace(object)); 15 DCHECK(object->GetIsolate()->heap()->InFromSpace(object));
15 16
16 // 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
17 // object to record the forwarding pointer. A forwarding pointer can 18 // object to record the forwarding pointer. A forwarding pointer can
18 // 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
19 // generation. 20 // generation.
20 MapWord first_word = object->map_word(); 21 MapWord first_word = object->map_word();
21 22
22 // 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
23 // copied. 24 // copied.
24 if (first_word.IsForwardingAddress()) { 25 if (first_word.IsForwardingAddress()) {
25 HeapObject* dest = first_word.ToForwardingAddress(); 26 HeapObject* dest = first_word.ToForwardingAddress();
26 DCHECK(object->GetIsolate()->heap()->InFromSpace(*p)); 27 DCHECK(object->GetIsolate()->heap()->InFromSpace(*p));
27 *p = dest; 28 *p = dest;
28 return; 29 return;
29 } 30 }
30 31
31 object->GetHeap()->UpdateAllocationSite<Heap::kGlobal>( 32 object->GetHeap()->UpdateAllocationSite<Heap::kGlobal>(
32 object, object->GetHeap()->global_pretenuring_feedback_); 33 object, object->GetHeap()->global_pretenuring_feedback_);
33 34
34 // AllocationMementos are unrooted and shouldn't survive a scavenge 35 // AllocationMementos are unrooted and shouldn't survive a scavenge
35 DCHECK(object->map() != object->GetHeap()->allocation_memento_map()); 36 DCHECK(object->map() != object->GetHeap()->allocation_memento_map());
36 // Call the slow part of scavenge object. 37 // Call the slow part of scavenge object.
37 return ScavengeObjectSlow(p, object); 38 return ScavengeObjectSlow(p, object, promotion_mode);
38 } 39 }
39 40
40 SlotCallbackResult Scavenger::CheckAndScavengeObject(Heap* heap, 41 SlotCallbackResult Scavenger::CheckAndScavengeObject(
41 Address slot_address) { 42 Heap* heap, Address slot_address, PromotionMode promotion_mode) {
42 Object** slot = reinterpret_cast<Object**>(slot_address); 43 Object** slot = reinterpret_cast<Object**>(slot_address);
43 Object* object = *slot; 44 Object* object = *slot;
44 if (heap->InFromSpace(object)) { 45 if (heap->InFromSpace(object)) {
45 HeapObject* heap_object = reinterpret_cast<HeapObject*>(object); 46 HeapObject* heap_object = reinterpret_cast<HeapObject*>(object);
46 DCHECK(heap_object->IsHeapObject()); 47 DCHECK(heap_object->IsHeapObject());
47 48
48 ScavengeObject(reinterpret_cast<HeapObject**>(slot), heap_object); 49 ScavengeObject(reinterpret_cast<HeapObject**>(slot), heap_object,
50 promotion_mode);
49 51
50 object = *slot; 52 object = *slot;
51 // If the object was in from space before and is after executing the 53 // If the object was in from space before and is after executing the
52 // callback in to space, the object is still live. 54 // callback in to space, the object is still live.
53 // Unfortunately, we do not know about the slot. It could be in a 55 // Unfortunately, we do not know about the slot. It could be in a
54 // just freed free space object. 56 // just freed free space object.
55 if (heap->InToSpace(object)) { 57 if (heap->InToSpace(object)) {
56 return KEEP_SLOT; 58 return KEEP_SLOT;
57 } 59 }
58 } else { 60 } else {
59 DCHECK(!heap->InNewSpace(object)); 61 DCHECK(!heap->InNewSpace(object));
60 } 62 }
61 return REMOVE_SLOT; 63 return REMOVE_SLOT;
62 } 64 }
63 65
64 // static 66 // static
65 void StaticScavengeVisitor::VisitPointer(Heap* heap, HeapObject* obj, 67 void StaticScavengeVisitor::VisitPointer(Heap* heap, HeapObject* obj,
66 Object** p) { 68 Object** p) {
67 Object* object = *p; 69 Object* object = *p;
68 if (!heap->InNewSpace(object)) return; 70 if (!heap->InNewSpace(object)) return;
69 Scavenger::ScavengeObject(reinterpret_cast<HeapObject**>(p), 71 Scavenger::ScavengeObject(reinterpret_cast<HeapObject**>(p),
70 reinterpret_cast<HeapObject*>(object)); 72 reinterpret_cast<HeapObject*>(object),
73 DEFAULT_PROMOTION);
71 } 74 }
72 75
73 } // namespace internal 76 } // namespace internal
74 } // namespace v8 77 } // namespace v8
75 78
76 #endif // V8_HEAP_SCAVENGER_INL_H_ 79 #endif // V8_HEAP_SCAVENGER_INL_H_
OLDNEW
« no previous file with comments | « src/heap/scavenger.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698