| 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, &EvacuateJSArrayBuffer); | 39 table_.Register(kVisitJSArrayBuffer, |
| 40 &ObjectEvacuationStrategy<POINTER_OBJECT>::Visit); |
| 40 | 41 |
| 41 table_.Register( | 42 table_.Register( |
| 42 kVisitNativeContext, | 43 kVisitNativeContext, |
| 43 &ObjectEvacuationStrategy<POINTER_OBJECT>::template VisitSpecialized< | 44 &ObjectEvacuationStrategy<POINTER_OBJECT>::template VisitSpecialized< |
| 44 Context::kSize>); | 45 Context::kSize>); |
| 45 | 46 |
| 46 table_.Register( | 47 table_.Register( |
| 47 kVisitConsString, | 48 kVisitConsString, |
| 48 &ObjectEvacuationStrategy<POINTER_OBJECT>::template VisitSpecialized< | 49 &ObjectEvacuationStrategy<POINTER_OBJECT>::template VisitSpecialized< |
| 49 ConsString::kSize>); | 50 ConsString::kSize>); |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 object_size); | 275 object_size); |
| 275 } | 276 } |
| 276 | 277 |
| 277 static inline void EvacuateFixedFloat64Array(Map* map, HeapObject** slot, | 278 static inline void EvacuateFixedFloat64Array(Map* map, HeapObject** slot, |
| 278 HeapObject* object) { | 279 HeapObject* object) { |
| 279 int object_size = reinterpret_cast<FixedFloat64Array*>(object)->size(); | 280 int object_size = reinterpret_cast<FixedFloat64Array*>(object)->size(); |
| 280 EvacuateObject<POINTER_OBJECT, kDoubleAligned>(map, slot, object, | 281 EvacuateObject<POINTER_OBJECT, kDoubleAligned>(map, slot, object, |
| 281 object_size); | 282 object_size); |
| 282 } | 283 } |
| 283 | 284 |
| 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 | |
| 297 static inline void EvacuateByteArray(Map* map, HeapObject** slot, | 285 static inline void EvacuateByteArray(Map* map, HeapObject** slot, |
| 298 HeapObject* object) { | 286 HeapObject* object) { |
| 299 int object_size = reinterpret_cast<ByteArray*>(object)->ByteArraySize(); | 287 int object_size = reinterpret_cast<ByteArray*>(object)->ByteArraySize(); |
| 300 EvacuateObject<DATA_OBJECT, kWordAligned>(map, slot, object, object_size); | 288 EvacuateObject<DATA_OBJECT, kWordAligned>(map, slot, object, object_size); |
| 301 } | 289 } |
| 302 | 290 |
| 303 static inline void EvacuateSeqOneByteString(Map* map, HeapObject** slot, | 291 static inline void EvacuateSeqOneByteString(Map* map, HeapObject** slot, |
| 304 HeapObject* object) { | 292 HeapObject* object) { |
| 305 int object_size = SeqOneByteString::cast(object) | 293 int object_size = SeqOneByteString::cast(object) |
| 306 ->SeqOneByteStringSize(map->instance_type()); | 294 ->SeqOneByteStringSize(map->instance_type()); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 | 444 |
| 457 void ScavengeVisitor::ScavengePointer(Object** p) { | 445 void ScavengeVisitor::ScavengePointer(Object** p) { |
| 458 Object* object = *p; | 446 Object* object = *p; |
| 459 if (!heap_->InNewSpace(object)) return; | 447 if (!heap_->InNewSpace(object)) return; |
| 460 Scavenger::ScavengeObject(reinterpret_cast<HeapObject**>(p), | 448 Scavenger::ScavengeObject(reinterpret_cast<HeapObject**>(p), |
| 461 reinterpret_cast<HeapObject*>(object)); | 449 reinterpret_cast<HeapObject*>(object)); |
| 462 } | 450 } |
| 463 | 451 |
| 464 } // namespace internal | 452 } // namespace internal |
| 465 } // namespace v8 | 453 } // namespace v8 |
| OLD | NEW |