| 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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 UPDATE_WEAK_WRITE_BARRIER); | 339 UPDATE_WEAK_WRITE_BARRIER); |
| 340 heap->set_encountered_weak_cells(weak_cell); | 340 heap->set_encountered_weak_cells(weak_cell); |
| 341 } | 341 } |
| 342 } | 342 } |
| 343 } | 343 } |
| 344 | 344 |
| 345 | 345 |
| 346 template <typename StaticVisitor> | 346 template <typename StaticVisitor> |
| 347 void StaticMarkingVisitor<StaticVisitor>::VisitTransitionArray( | 347 void StaticMarkingVisitor<StaticVisitor>::VisitTransitionArray( |
| 348 Map* map, HeapObject* object) { | 348 Map* map, HeapObject* object) { |
| 349 typedef FlexibleBodyVisitor<StaticVisitor, TransitionArray::BodyDescriptor, | |
| 350 int> TransitionArrayBodyVisitor; | |
| 351 TransitionArray* array = TransitionArray::cast(object); | 349 TransitionArray* array = TransitionArray::cast(object); |
| 350 Heap* heap = array->GetHeap(); |
| 351 // Visit strong references. |
| 352 if (array->HasPrototypeTransitions()) { |
| 353 StaticVisitor::VisitPointer(heap, array, |
| 354 array->GetPrototypeTransitionsSlot()); |
| 355 } |
| 356 int num_transitions = TransitionArray::NumberOfTransitions(array); |
| 357 for (int i = 0; i < num_transitions; ++i) { |
| 358 StaticVisitor::VisitPointer(heap, array, array->GetKeySlot(i)); |
| 359 } |
| 352 // Enqueue the array in linked list of encountered transition arrays if it is | 360 // Enqueue the array in linked list of encountered transition arrays if it is |
| 353 // not already in the list. | 361 // not already in the list. |
| 354 if (array->next_link()->IsUndefined()) { | 362 if (array->next_link()->IsUndefined()) { |
| 355 Heap* heap = map->GetHeap(); | 363 Heap* heap = map->GetHeap(); |
| 356 array->set_next_link(heap->encountered_transition_arrays(), | 364 array->set_next_link(heap->encountered_transition_arrays(), |
| 357 UPDATE_WEAK_WRITE_BARRIER); | 365 UPDATE_WEAK_WRITE_BARRIER); |
| 358 heap->set_encountered_transition_arrays(array); | 366 heap->set_encountered_transition_arrays(array); |
| 359 } | 367 } |
| 360 // TODO(ulan): Move MarkTransitionArray logic here. | |
| 361 TransitionArrayBodyVisitor::Visit(map, object); | |
| 362 } | 368 } |
| 363 | 369 |
| 364 | 370 |
| 365 template <typename StaticVisitor> | 371 template <typename StaticVisitor> |
| 366 void StaticMarkingVisitor<StaticVisitor>::VisitAllocationSite( | 372 void StaticMarkingVisitor<StaticVisitor>::VisitAllocationSite( |
| 367 Map* map, HeapObject* object) { | 373 Map* map, HeapObject* object) { |
| 368 Heap* heap = map->GetHeap(); | 374 Heap* heap = map->GetHeap(); |
| 369 | 375 |
| 370 StaticVisitor::VisitPointers( | 376 StaticVisitor::VisitPointers( |
| 371 heap, object, | 377 heap, object, |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 StaticVisitor::VisitPointers( | 533 StaticVisitor::VisitPointers( |
| 528 map->GetHeap(), object, | 534 map->GetHeap(), object, |
| 529 HeapObject::RawField(object, BytecodeArray::kConstantPoolOffset), | 535 HeapObject::RawField(object, BytecodeArray::kConstantPoolOffset), |
| 530 HeapObject::RawField(object, BytecodeArray::kHeaderSize)); | 536 HeapObject::RawField(object, BytecodeArray::kHeaderSize)); |
| 531 } | 537 } |
| 532 | 538 |
| 533 | 539 |
| 534 template <typename StaticVisitor> | 540 template <typename StaticVisitor> |
| 535 void StaticMarkingVisitor<StaticVisitor>::MarkMapContents(Heap* heap, | 541 void StaticMarkingVisitor<StaticVisitor>::MarkMapContents(Heap* heap, |
| 536 Map* map) { | 542 Map* map) { |
| 537 Object* raw_transitions = map->raw_transitions(); | |
| 538 if (TransitionArray::IsFullTransitionArray(raw_transitions)) { | |
| 539 MarkTransitionArray(heap, TransitionArray::cast(raw_transitions)); | |
| 540 } | |
| 541 | |
| 542 // Since descriptor arrays are potentially shared, ensure that only the | 543 // Since descriptor arrays are potentially shared, ensure that only the |
| 543 // descriptors that belong to this map are marked. The first time a non-empty | 544 // descriptors that belong to this map are marked. The first time a non-empty |
| 544 // descriptor array is marked, its header is also visited. The slot holding | 545 // descriptor array is marked, its header is also visited. The slot holding |
| 545 // the descriptor array will be implicitly recorded when the pointer fields of | 546 // the descriptor array will be implicitly recorded when the pointer fields of |
| 546 // this map are visited. Prototype maps don't keep track of transitions, so | 547 // this map are visited. Prototype maps don't keep track of transitions, so |
| 547 // just mark the entire descriptor array. | 548 // just mark the entire descriptor array. |
| 548 if (!map->is_prototype_map()) { | 549 if (!map->is_prototype_map()) { |
| 549 DescriptorArray* descriptors = map->instance_descriptors(); | 550 DescriptorArray* descriptors = map->instance_descriptors(); |
| 550 if (StaticVisitor::MarkObjectWithoutPush(heap, descriptors) && | 551 if (StaticVisitor::MarkObjectWithoutPush(heap, descriptors) && |
| 551 descriptors->length() > 0) { | 552 descriptors->length() > 0) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 565 // Mark the pointer fields of the Map. Since the transitions array has | 566 // Mark the pointer fields of the Map. Since the transitions array has |
| 566 // been marked already, it is fine that one of these fields contains a | 567 // been marked already, it is fine that one of these fields contains a |
| 567 // pointer to it. | 568 // pointer to it. |
| 568 StaticVisitor::VisitPointers( | 569 StaticVisitor::VisitPointers( |
| 569 heap, map, HeapObject::RawField(map, Map::kPointerFieldsBeginOffset), | 570 heap, map, HeapObject::RawField(map, Map::kPointerFieldsBeginOffset), |
| 570 HeapObject::RawField(map, Map::kPointerFieldsEndOffset)); | 571 HeapObject::RawField(map, Map::kPointerFieldsEndOffset)); |
| 571 } | 572 } |
| 572 | 573 |
| 573 | 574 |
| 574 template <typename StaticVisitor> | 575 template <typename StaticVisitor> |
| 575 void StaticMarkingVisitor<StaticVisitor>::MarkTransitionArray( | |
| 576 Heap* heap, TransitionArray* transitions) { | |
| 577 if (!StaticVisitor::MarkObjectWithoutPush(heap, transitions)) return; | |
| 578 | |
| 579 if (transitions->HasPrototypeTransitions()) { | |
| 580 StaticVisitor::VisitPointer(heap, transitions, | |
| 581 transitions->GetPrototypeTransitionsSlot()); | |
| 582 } | |
| 583 | |
| 584 int num_transitions = TransitionArray::NumberOfTransitions(transitions); | |
| 585 for (int i = 0; i < num_transitions; ++i) { | |
| 586 StaticVisitor::VisitPointer(heap, transitions, transitions->GetKeySlot(i)); | |
| 587 } | |
| 588 } | |
| 589 | |
| 590 | |
| 591 template <typename StaticVisitor> | |
| 592 void StaticMarkingVisitor<StaticVisitor>::MarkOptimizedCodeMap( | 576 void StaticMarkingVisitor<StaticVisitor>::MarkOptimizedCodeMap( |
| 593 Heap* heap, FixedArray* code_map) { | 577 Heap* heap, FixedArray* code_map) { |
| 594 if (!StaticVisitor::MarkObjectWithoutPush(heap, code_map)) return; | 578 if (!StaticVisitor::MarkObjectWithoutPush(heap, code_map)) return; |
| 595 | 579 |
| 596 // Mark the context-independent entry in the optimized code map. Depending on | 580 // Mark the context-independent entry in the optimized code map. Depending on |
| 597 // the age of the code object, we treat it as a strong or a weak reference. | 581 // the age of the code object, we treat it as a strong or a weak reference. |
| 598 Object* shared_object = code_map->get(SharedFunctionInfo::kSharedCodeIndex); | 582 Object* shared_object = code_map->get(SharedFunctionInfo::kSharedCodeIndex); |
| 599 if (FLAG_turbo_preserve_shared_code && shared_object->IsCode() && | 583 if (FLAG_turbo_preserve_shared_code && shared_object->IsCode() && |
| 600 FLAG_age_code && !Code::cast(shared_object)->IsOld()) { | 584 FLAG_age_code && !Code::cast(shared_object)->IsOld()) { |
| 601 StaticVisitor::VisitPointer( | 585 StaticVisitor::VisitPointer( |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 typedef FlexibleBodyVisitor<StaticVisitor, JSFunction::BodyDescriptorWeakCode, | 757 typedef FlexibleBodyVisitor<StaticVisitor, JSFunction::BodyDescriptorWeakCode, |
| 774 void> JSFunctionWeakCodeBodyVisitor; | 758 void> JSFunctionWeakCodeBodyVisitor; |
| 775 JSFunctionWeakCodeBodyVisitor::Visit(map, object); | 759 JSFunctionWeakCodeBodyVisitor::Visit(map, object); |
| 776 } | 760 } |
| 777 | 761 |
| 778 | 762 |
| 779 } // namespace internal | 763 } // namespace internal |
| 780 } // namespace v8 | 764 } // namespace v8 |
| 781 | 765 |
| 782 #endif // V8_OBJECTS_VISITING_INL_H_ | 766 #endif // V8_OBJECTS_VISITING_INL_H_ |
| OLD | NEW |