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 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 if (collector->is_code_flushing_enabled()) { | 442 if (collector->is_code_flushing_enabled()) { |
443 if (IsFlushable(heap, shared)) { | 443 if (IsFlushable(heap, shared)) { |
444 // This function's code looks flushable. But we have to postpone | 444 // This function's code looks flushable. But we have to postpone |
445 // the decision until we see all functions that point to the same | 445 // the decision until we see all functions that point to the same |
446 // SharedFunctionInfo because some of them might be optimized. | 446 // SharedFunctionInfo because some of them might be optimized. |
447 // That would also make the non-optimized version of the code | 447 // That would also make the non-optimized version of the code |
448 // non-flushable, because it is required for bailing out from | 448 // non-flushable, because it is required for bailing out from |
449 // optimized code. | 449 // optimized code. |
450 collector->code_flusher()->AddCandidate(shared); | 450 collector->code_flusher()->AddCandidate(shared); |
451 // Treat the reference to the code object weakly. | 451 // Treat the reference to the code object weakly. |
452 VisitSharedFunctionInfoWeakCode(heap, object); | 452 VisitSharedFunctionInfoWeakCode(map, object); |
453 return; | 453 return; |
454 } | 454 } |
455 } | 455 } |
456 VisitSharedFunctionInfoStrongCode(heap, object); | 456 VisitSharedFunctionInfoStrongCode(map, object); |
457 } | 457 } |
458 | 458 |
459 | 459 |
460 template <typename StaticVisitor> | 460 template <typename StaticVisitor> |
461 void StaticMarkingVisitor<StaticVisitor>::VisitJSFunction(Map* map, | 461 void StaticMarkingVisitor<StaticVisitor>::VisitJSFunction(Map* map, |
462 HeapObject* object) { | 462 HeapObject* object) { |
463 Heap* heap = map->GetHeap(); | 463 Heap* heap = map->GetHeap(); |
464 JSFunction* function = JSFunction::cast(object); | 464 JSFunction* function = JSFunction::cast(object); |
465 if (FLAG_cleanup_code_caches_at_gc) { | 465 if (FLAG_cleanup_code_caches_at_gc) { |
466 function->ClearTypeFeedbackInfoAtGCTime(); | 466 function->ClearTypeFeedbackInfoAtGCTime(); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 } | 614 } |
615 | 615 |
616 // Check age of code. If code aging is disabled we never flush. | 616 // Check age of code. If code aging is disabled we never flush. |
617 if (!FLAG_age_code || !shared_info->code()->IsOld()) { | 617 if (!FLAG_age_code || !shared_info->code()->IsOld()) { |
618 return false; | 618 return false; |
619 } | 619 } |
620 | 620 |
621 return true; | 621 return true; |
622 } | 622 } |
623 | 623 |
624 | |
625 template <typename StaticVisitor> | 624 template <typename StaticVisitor> |
626 void StaticMarkingVisitor<StaticVisitor>::VisitSharedFunctionInfoStrongCode( | 625 void StaticMarkingVisitor<StaticVisitor>::VisitSharedFunctionInfoStrongCode( |
627 Heap* heap, HeapObject* object) { | 626 Map* map, HeapObject* object) { |
628 Object** start_slot = HeapObject::RawField( | 627 FixedBodyVisitor<StaticVisitor, SharedFunctionInfo::BodyDescriptor, |
629 object, SharedFunctionInfo::BodyDescriptor::kStartOffset); | 628 void>::Visit(map, object); |
630 Object** end_slot = HeapObject::RawField( | |
631 object, SharedFunctionInfo::BodyDescriptor::kEndOffset); | |
632 StaticVisitor::VisitPointers(heap, object, start_slot, end_slot); | |
633 } | 629 } |
634 | 630 |
635 | |
636 template <typename StaticVisitor> | 631 template <typename StaticVisitor> |
637 void StaticMarkingVisitor<StaticVisitor>::VisitSharedFunctionInfoWeakCode( | 632 void StaticMarkingVisitor<StaticVisitor>::VisitSharedFunctionInfoWeakCode( |
638 Heap* heap, HeapObject* object) { | 633 Map* map, HeapObject* object) { |
639 Object** name_slot = | |
640 HeapObject::RawField(object, SharedFunctionInfo::kNameOffset); | |
641 StaticVisitor::VisitPointer(heap, object, name_slot); | |
642 | |
643 // Skip visiting kCodeOffset as it is treated weakly here. | 634 // Skip visiting kCodeOffset as it is treated weakly here. |
644 STATIC_ASSERT(SharedFunctionInfo::kNameOffset + kPointerSize == | 635 STATIC_ASSERT(SharedFunctionInfo::kCodeOffset < |
645 SharedFunctionInfo::kCodeOffset); | 636 SharedFunctionInfo::BodyDescriptorWeakCode::kStartOffset); |
646 STATIC_ASSERT(SharedFunctionInfo::kCodeOffset + kPointerSize == | 637 FixedBodyVisitor<StaticVisitor, SharedFunctionInfo::BodyDescriptorWeakCode, |
647 SharedFunctionInfo::kOptimizedCodeMapOffset); | 638 void>::Visit(map, object); |
648 | |
649 Object** start_slot = | |
650 HeapObject::RawField(object, SharedFunctionInfo::kOptimizedCodeMapOffset); | |
651 Object** end_slot = HeapObject::RawField( | |
652 object, SharedFunctionInfo::BodyDescriptor::kEndOffset); | |
653 StaticVisitor::VisitPointers(heap, object, start_slot, end_slot); | |
654 } | 639 } |
655 | 640 |
656 | |
657 template <typename StaticVisitor> | 641 template <typename StaticVisitor> |
658 void StaticMarkingVisitor<StaticVisitor>::VisitJSFunctionStrongCode( | 642 void StaticMarkingVisitor<StaticVisitor>::VisitJSFunctionStrongCode( |
659 Map* map, HeapObject* object) { | 643 Map* map, HeapObject* object) { |
660 typedef FlexibleBodyVisitor<StaticVisitor, | 644 typedef FlexibleBodyVisitor<StaticVisitor, |
661 JSFunction::BodyDescriptorStrongCode, | 645 JSFunction::BodyDescriptorStrongCode, |
662 void> JSFunctionStrongCodeBodyVisitor; | 646 void> JSFunctionStrongCodeBodyVisitor; |
663 JSFunctionStrongCodeBodyVisitor::Visit(map, object); | 647 JSFunctionStrongCodeBodyVisitor::Visit(map, object); |
664 } | 648 } |
665 | 649 |
666 | 650 |
667 template <typename StaticVisitor> | 651 template <typename StaticVisitor> |
668 void StaticMarkingVisitor<StaticVisitor>::VisitJSFunctionWeakCode( | 652 void StaticMarkingVisitor<StaticVisitor>::VisitJSFunctionWeakCode( |
669 Map* map, HeapObject* object) { | 653 Map* map, HeapObject* object) { |
670 typedef FlexibleBodyVisitor<StaticVisitor, JSFunction::BodyDescriptorWeakCode, | 654 typedef FlexibleBodyVisitor<StaticVisitor, JSFunction::BodyDescriptorWeakCode, |
671 void> JSFunctionWeakCodeBodyVisitor; | 655 void> JSFunctionWeakCodeBodyVisitor; |
672 JSFunctionWeakCodeBodyVisitor::Visit(map, object); | 656 JSFunctionWeakCodeBodyVisitor::Visit(map, object); |
673 } | 657 } |
674 | 658 |
675 | 659 |
676 } // namespace internal | 660 } // namespace internal |
677 } // namespace v8 | 661 } // namespace v8 |
678 | 662 |
679 #endif // V8_OBJECTS_VISITING_INL_H_ | 663 #endif // V8_OBJECTS_VISITING_INL_H_ |
OLD | NEW |