OLD | NEW |
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 #include "src/heap/scavenger.h" | 5 #include "src/heap/scavenger.h" |
6 | 6 |
7 #include "src/contexts.h" | 7 #include "src/contexts.h" |
8 #include "src/heap/heap.h" | 8 #include "src/heap/heap.h" |
9 #include "src/heap/objects-visiting-inl.h" | 9 #include "src/heap/objects-visiting-inl.h" |
10 #include "src/heap/scavenger-inl.h" | 10 #include "src/heap/scavenger-inl.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 public: | 29 public: |
30 static void Initialize() { | 30 static void Initialize() { |
31 table_.Register(kVisitSeqOneByteString, &EvacuateSeqOneByteString); | 31 table_.Register(kVisitSeqOneByteString, &EvacuateSeqOneByteString); |
32 table_.Register(kVisitSeqTwoByteString, &EvacuateSeqTwoByteString); | 32 table_.Register(kVisitSeqTwoByteString, &EvacuateSeqTwoByteString); |
33 table_.Register(kVisitShortcutCandidate, &EvacuateShortcutCandidate); | 33 table_.Register(kVisitShortcutCandidate, &EvacuateShortcutCandidate); |
34 table_.Register(kVisitByteArray, &EvacuateByteArray); | 34 table_.Register(kVisitByteArray, &EvacuateByteArray); |
35 table_.Register(kVisitFixedArray, &EvacuateFixedArray); | 35 table_.Register(kVisitFixedArray, &EvacuateFixedArray); |
36 table_.Register(kVisitFixedDoubleArray, &EvacuateFixedDoubleArray); | 36 table_.Register(kVisitFixedDoubleArray, &EvacuateFixedDoubleArray); |
37 table_.Register(kVisitFixedTypedArray, &EvacuateFixedTypedArray); | 37 table_.Register(kVisitFixedTypedArray, &EvacuateFixedTypedArray); |
38 table_.Register(kVisitFixedFloat64Array, &EvacuateFixedFloat64Array); | 38 table_.Register(kVisitFixedFloat64Array, &EvacuateFixedFloat64Array); |
39 table_.Register(kVisitJSArrayBuffer, | 39 table_.Register(kVisitJSArrayBuffer, &EvacuateJSArrayBuffer); |
40 &ObjectEvacuationStrategy<POINTER_OBJECT>::Visit); | |
41 | 40 |
42 table_.Register( | 41 table_.Register( |
43 kVisitNativeContext, | 42 kVisitNativeContext, |
44 &ObjectEvacuationStrategy<POINTER_OBJECT>::template VisitSpecialized< | 43 &ObjectEvacuationStrategy<POINTER_OBJECT>::template VisitSpecialized< |
45 Context::kSize>); | 44 Context::kSize>); |
46 | 45 |
47 table_.Register( | 46 table_.Register( |
48 kVisitConsString, | 47 kVisitConsString, |
49 &ObjectEvacuationStrategy<POINTER_OBJECT>::template VisitSpecialized< | 48 &ObjectEvacuationStrategy<POINTER_OBJECT>::template VisitSpecialized< |
50 ConsString::kSize>); | 49 ConsString::kSize>); |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 object_size); | 274 object_size); |
276 } | 275 } |
277 | 276 |
278 static inline void EvacuateFixedFloat64Array(Map* map, HeapObject** slot, | 277 static inline void EvacuateFixedFloat64Array(Map* map, HeapObject** slot, |
279 HeapObject* object) { | 278 HeapObject* object) { |
280 int object_size = reinterpret_cast<FixedFloat64Array*>(object)->size(); | 279 int object_size = reinterpret_cast<FixedFloat64Array*>(object)->size(); |
281 EvacuateObject<POINTER_OBJECT, kDoubleAligned>(map, slot, object, | 280 EvacuateObject<POINTER_OBJECT, kDoubleAligned>(map, slot, object, |
282 object_size); | 281 object_size); |
283 } | 282 } |
284 | 283 |
| 284 static inline void EvacuateJSArrayBuffer(Map* map, HeapObject** slot, |
| 285 HeapObject* object) { |
| 286 ObjectEvacuationStrategy<POINTER_OBJECT>::Visit(map, slot, object); |
| 287 |
| 288 Heap* heap = map->GetHeap(); |
| 289 MapWord map_word = object->map_word(); |
| 290 DCHECK(map_word.IsForwardingAddress()); |
| 291 HeapObject* target = map_word.ToForwardingAddress(); |
| 292 if (!heap->InNewSpace(target)) { |
| 293 heap->array_buffer_tracker()->Promote(JSArrayBuffer::cast(target)); |
| 294 } |
| 295 } |
| 296 |
285 static inline void EvacuateByteArray(Map* map, HeapObject** slot, | 297 static inline void EvacuateByteArray(Map* map, HeapObject** slot, |
286 HeapObject* object) { | 298 HeapObject* object) { |
287 int object_size = reinterpret_cast<ByteArray*>(object)->ByteArraySize(); | 299 int object_size = reinterpret_cast<ByteArray*>(object)->ByteArraySize(); |
288 EvacuateObject<DATA_OBJECT, kWordAligned>(map, slot, object, object_size); | 300 EvacuateObject<DATA_OBJECT, kWordAligned>(map, slot, object, object_size); |
289 } | 301 } |
290 | 302 |
291 static inline void EvacuateSeqOneByteString(Map* map, HeapObject** slot, | 303 static inline void EvacuateSeqOneByteString(Map* map, HeapObject** slot, |
292 HeapObject* object) { | 304 HeapObject* object) { |
293 int object_size = SeqOneByteString::cast(object) | 305 int object_size = SeqOneByteString::cast(object) |
294 ->SeqOneByteStringSize(map->instance_type()); | 306 ->SeqOneByteStringSize(map->instance_type()); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 | 456 |
445 void ScavengeVisitor::ScavengePointer(Object** p) { | 457 void ScavengeVisitor::ScavengePointer(Object** p) { |
446 Object* object = *p; | 458 Object* object = *p; |
447 if (!heap_->InNewSpace(object)) return; | 459 if (!heap_->InNewSpace(object)) return; |
448 Scavenger::ScavengeObject(reinterpret_cast<HeapObject**>(p), | 460 Scavenger::ScavengeObject(reinterpret_cast<HeapObject**>(p), |
449 reinterpret_cast<HeapObject*>(object)); | 461 reinterpret_cast<HeapObject*>(object)); |
450 } | 462 } |
451 | 463 |
452 } // namespace internal | 464 } // namespace internal |
453 } // namespace v8 | 465 } // namespace v8 |
OLD | NEW |