OLD | NEW |
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 #ifndef V8_OBJECTS_VISITING_INL_H_ | 5 #ifndef V8_OBJECTS_VISITING_INL_H_ |
6 #define V8_OBJECTS_VISITING_INL_H_ | 6 #define V8_OBJECTS_VISITING_INL_H_ |
7 | 7 |
8 #include "src/heap/array-buffer-tracker.h" | 8 #include "src/heap/array-buffer-tracker.h" |
9 #include "src/heap/objects-visiting.h" | 9 #include "src/heap/objects-visiting.h" |
10 #include "src/ic/ic-state.h" | 10 #include "src/ic/ic-state.h" |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 UPDATE_WEAK_WRITE_BARRIER); | 352 UPDATE_WEAK_WRITE_BARRIER); |
353 heap->set_encountered_weak_cells(weak_cell); | 353 heap->set_encountered_weak_cells(weak_cell); |
354 } | 354 } |
355 } | 355 } |
356 } | 356 } |
357 | 357 |
358 | 358 |
359 template <typename StaticVisitor> | 359 template <typename StaticVisitor> |
360 void StaticMarkingVisitor<StaticVisitor>::VisitTransitionArray( | 360 void StaticMarkingVisitor<StaticVisitor>::VisitTransitionArray( |
361 Map* map, HeapObject* object) { | 361 Map* map, HeapObject* object) { |
362 typedef FlexibleBodyVisitor<StaticVisitor, TransitionArray::BodyDescriptor, | |
363 int> TransitionArrayBodyVisitor; | |
364 TransitionArray* array = TransitionArray::cast(object); | 362 TransitionArray* array = TransitionArray::cast(object); |
| 363 Heap* heap = array->GetHeap(); |
| 364 // Visit strong references. |
| 365 if (array->HasPrototypeTransitions()) { |
| 366 StaticVisitor::VisitPointer(heap, array, |
| 367 array->GetPrototypeTransitionsSlot()); |
| 368 } |
| 369 int num_transitions = TransitionArray::NumberOfTransitions(array); |
| 370 for (int i = 0; i < num_transitions; ++i) { |
| 371 StaticVisitor::VisitPointer(heap, array, array->GetKeySlot(i)); |
| 372 } |
365 // Enqueue the array in linked list of encountered transition arrays if it is | 373 // Enqueue the array in linked list of encountered transition arrays if it is |
366 // not already in the list. | 374 // not already in the list. |
367 if (array->next_link()->IsUndefined()) { | 375 if (array->next_link()->IsUndefined()) { |
368 Heap* heap = map->GetHeap(); | 376 Heap* heap = map->GetHeap(); |
369 array->set_next_link(heap->encountered_transition_arrays(), | 377 array->set_next_link(heap->encountered_transition_arrays(), |
370 UPDATE_WEAK_WRITE_BARRIER); | 378 UPDATE_WEAK_WRITE_BARRIER); |
371 heap->set_encountered_transition_arrays(array); | 379 heap->set_encountered_transition_arrays(array); |
372 } | 380 } |
373 // TODO(ulan): Move MarkTransitionArray logic here. | |
374 TransitionArrayBodyVisitor::Visit(map, object); | |
375 } | 381 } |
376 | 382 |
377 | 383 |
378 template <typename StaticVisitor> | 384 template <typename StaticVisitor> |
379 void StaticMarkingVisitor<StaticVisitor>::VisitAllocationSite( | 385 void StaticMarkingVisitor<StaticVisitor>::VisitAllocationSite( |
380 Map* map, HeapObject* object) { | 386 Map* map, HeapObject* object) { |
381 Heap* heap = map->GetHeap(); | 387 Heap* heap = map->GetHeap(); |
382 | 388 |
383 StaticVisitor::VisitPointers( | 389 StaticVisitor::VisitPointers( |
384 heap, object, | 390 heap, object, |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 StaticVisitor::VisitPointers( | 539 StaticVisitor::VisitPointers( |
534 map->GetHeap(), object, | 540 map->GetHeap(), object, |
535 HeapObject::RawField(object, BytecodeArray::kConstantPoolOffset), | 541 HeapObject::RawField(object, BytecodeArray::kConstantPoolOffset), |
536 HeapObject::RawField(object, BytecodeArray::kHeaderSize)); | 542 HeapObject::RawField(object, BytecodeArray::kHeaderSize)); |
537 } | 543 } |
538 | 544 |
539 | 545 |
540 template <typename StaticVisitor> | 546 template <typename StaticVisitor> |
541 void StaticMarkingVisitor<StaticVisitor>::MarkMapContents(Heap* heap, | 547 void StaticMarkingVisitor<StaticVisitor>::MarkMapContents(Heap* heap, |
542 Map* map) { | 548 Map* map) { |
543 Object* raw_transitions = map->raw_transitions(); | |
544 if (TransitionArray::IsFullTransitionArray(raw_transitions)) { | |
545 MarkTransitionArray(heap, TransitionArray::cast(raw_transitions)); | |
546 } | |
547 | |
548 // Since descriptor arrays are potentially shared, ensure that only the | 549 // Since descriptor arrays are potentially shared, ensure that only the |
549 // descriptors that belong to this map are marked. The first time a non-empty | 550 // descriptors that belong to this map are marked. The first time a non-empty |
550 // descriptor array is marked, its header is also visited. The slot holding | 551 // descriptor array is marked, its header is also visited. The slot holding |
551 // the descriptor array will be implicitly recorded when the pointer fields of | 552 // the descriptor array will be implicitly recorded when the pointer fields of |
552 // this map are visited. Prototype maps don't keep track of transitions, so | 553 // this map are visited. Prototype maps don't keep track of transitions, so |
553 // just mark the entire descriptor array. | 554 // just mark the entire descriptor array. |
554 if (!map->is_prototype_map()) { | 555 if (!map->is_prototype_map()) { |
555 DescriptorArray* descriptors = map->instance_descriptors(); | 556 DescriptorArray* descriptors = map->instance_descriptors(); |
556 if (StaticVisitor::MarkObjectWithoutPush(heap, descriptors) && | 557 if (StaticVisitor::MarkObjectWithoutPush(heap, descriptors) && |
557 descriptors->length() > 0) { | 558 descriptors->length() > 0) { |
(...skipping 13 matching lines...) Expand all Loading... |
571 // Mark the pointer fields of the Map. Since the transitions array has | 572 // Mark the pointer fields of the Map. Since the transitions array has |
572 // been marked already, it is fine that one of these fields contains a | 573 // been marked already, it is fine that one of these fields contains a |
573 // pointer to it. | 574 // pointer to it. |
574 StaticVisitor::VisitPointers( | 575 StaticVisitor::VisitPointers( |
575 heap, map, HeapObject::RawField(map, Map::kPointerFieldsBeginOffset), | 576 heap, map, HeapObject::RawField(map, Map::kPointerFieldsBeginOffset), |
576 HeapObject::RawField(map, Map::kPointerFieldsEndOffset)); | 577 HeapObject::RawField(map, Map::kPointerFieldsEndOffset)); |
577 } | 578 } |
578 | 579 |
579 | 580 |
580 template <typename StaticVisitor> | 581 template <typename StaticVisitor> |
581 void StaticMarkingVisitor<StaticVisitor>::MarkTransitionArray( | |
582 Heap* heap, TransitionArray* transitions) { | |
583 if (!StaticVisitor::MarkObjectWithoutPush(heap, transitions)) return; | |
584 | |
585 if (transitions->HasPrototypeTransitions()) { | |
586 StaticVisitor::VisitPointer(heap, transitions, | |
587 transitions->GetPrototypeTransitionsSlot()); | |
588 } | |
589 | |
590 int num_transitions = TransitionArray::NumberOfTransitions(transitions); | |
591 for (int i = 0; i < num_transitions; ++i) { | |
592 StaticVisitor::VisitPointer(heap, transitions, transitions->GetKeySlot(i)); | |
593 } | |
594 } | |
595 | |
596 | |
597 template <typename StaticVisitor> | |
598 void StaticMarkingVisitor<StaticVisitor>::MarkOptimizedCodeMap( | 582 void StaticMarkingVisitor<StaticVisitor>::MarkOptimizedCodeMap( |
599 Heap* heap, FixedArray* code_map) { | 583 Heap* heap, FixedArray* code_map) { |
600 if (!StaticVisitor::MarkObjectWithoutPush(heap, code_map)) return; | 584 if (!StaticVisitor::MarkObjectWithoutPush(heap, code_map)) return; |
601 | 585 |
602 // Mark the context-independent entry in the optimized code map. Depending on | 586 // Mark the context-independent entry in the optimized code map. Depending on |
603 // the age of the code object, we treat it as a strong or a weak reference. | 587 // the age of the code object, we treat it as a strong or a weak reference. |
604 Object* shared_object = code_map->get(SharedFunctionInfo::kSharedCodeIndex); | 588 Object* shared_object = code_map->get(SharedFunctionInfo::kSharedCodeIndex); |
605 if (FLAG_turbo_preserve_shared_code && shared_object->IsCode() && | 589 if (FLAG_turbo_preserve_shared_code && shared_object->IsCode() && |
606 FLAG_age_code && !Code::cast(shared_object)->IsOld()) { | 590 FLAG_age_code && !Code::cast(shared_object)->IsOld()) { |
607 StaticVisitor::VisitPointer( | 591 StaticVisitor::VisitPointer( |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 typedef FlexibleBodyVisitor<StaticVisitor, JSFunction::BodyDescriptorWeakCode, | 744 typedef FlexibleBodyVisitor<StaticVisitor, JSFunction::BodyDescriptorWeakCode, |
761 void> JSFunctionWeakCodeBodyVisitor; | 745 void> JSFunctionWeakCodeBodyVisitor; |
762 JSFunctionWeakCodeBodyVisitor::Visit(map, object); | 746 JSFunctionWeakCodeBodyVisitor::Visit(map, object); |
763 } | 747 } |
764 | 748 |
765 | 749 |
766 } // namespace internal | 750 } // namespace internal |
767 } // namespace v8 | 751 } // namespace v8 |
768 | 752 |
769 #endif // V8_OBJECTS_VISITING_INL_H_ | 753 #endif // V8_OBJECTS_VISITING_INL_H_ |
OLD | NEW |