| 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/mark-compact.h" | 9 #include "src/heap/mark-compact.h" |
| 10 #include "src/heap/objects-visiting.h" | 10 #include "src/heap/objects-visiting.h" |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 | 630 |
| 631 template <typename StaticVisitor> | 631 template <typename StaticVisitor> |
| 632 void StaticMarkingVisitor<StaticVisitor>::VisitJSFunctionWeakCode( | 632 void StaticMarkingVisitor<StaticVisitor>::VisitJSFunctionWeakCode( |
| 633 Map* map, HeapObject* object) { | 633 Map* map, HeapObject* object) { |
| 634 typedef FlexibleBodyVisitor<StaticVisitor, JSFunction::BodyDescriptorWeakCode, | 634 typedef FlexibleBodyVisitor<StaticVisitor, JSFunction::BodyDescriptorWeakCode, |
| 635 void> JSFunctionWeakCodeBodyVisitor; | 635 void> JSFunctionWeakCodeBodyVisitor; |
| 636 JSFunctionWeakCodeBodyVisitor::Visit(map, object); | 636 JSFunctionWeakCodeBodyVisitor::Visit(map, object); |
| 637 } | 637 } |
| 638 | 638 |
| 639 template <typename ResultType, typename ConcreteVisitor> | 639 template <typename ResultType, typename ConcreteVisitor> |
| 640 ResultType HeapVisitor<ResultType, ConcreteVisitor>::IterateBody( | 640 ResultType HeapVisitor<ResultType, ConcreteVisitor>::Visit(HeapObject* object) { |
| 641 HeapObject* object) { | |
| 642 Map* map = object->map(); | 641 Map* map = object->map(); |
| 643 ConcreteVisitor* visitor = static_cast<ConcreteVisitor*>(this); | 642 ConcreteVisitor* visitor = static_cast<ConcreteVisitor*>(this); |
| 644 switch (static_cast<VisitorId>(map->visitor_id())) { | 643 switch (static_cast<VisitorId>(map->visitor_id())) { |
| 645 #define CASE(type) \ | 644 #define CASE(type) \ |
| 646 case kVisit##type: \ | 645 case kVisit##type: \ |
| 647 return visitor->Visit##type(map, type::cast(object)); | 646 return visitor->Visit##type(map, type::cast(object)); |
| 648 TYPED_VISITOR_ID_LIST(CASE) | 647 TYPED_VISITOR_ID_LIST(CASE) |
| 649 #undef CASE | 648 #undef CASE |
| 650 case kVisitShortcutCandidate: | 649 case kVisitShortcutCandidate: |
| 651 return visitor->VisitShortcutCandidate(map, ConsString::cast(object)); | 650 return visitor->VisitShortcutCandidate(map, ConsString::cast(object)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 662 case kVisitFreeSpace: | 661 case kVisitFreeSpace: |
| 663 return visitor->VisitFreeSpace(map, FreeSpace::cast(object)); | 662 return visitor->VisitFreeSpace(map, FreeSpace::cast(object)); |
| 664 case kVisitorIdCount: | 663 case kVisitorIdCount: |
| 665 UNREACHABLE(); | 664 UNREACHABLE(); |
| 666 } | 665 } |
| 667 UNREACHABLE(); | 666 UNREACHABLE(); |
| 668 // Make the compiler happy. | 667 // Make the compiler happy. |
| 669 return ResultType(); | 668 return ResultType(); |
| 670 } | 669 } |
| 671 | 670 |
| 672 #define VISIT(type) \ | 671 template <typename ResultType, typename ConcreteVisitor> |
| 673 template <typename ResultType, typename ConcreteVisitor> \ | 672 void HeapVisitor<ResultType, ConcreteVisitor>::VisitMapPointer( |
| 674 ResultType HeapVisitor<ResultType, ConcreteVisitor>::Visit##type( \ | 673 HeapObject* host, HeapObject** map) { |
| 675 Map* map, type* object) { \ | 674 static_cast<ConcreteVisitor*>(this)->VisitPointer( |
| 676 int size = type::BodyDescriptor::SizeOf(map, object); \ | 675 host, reinterpret_cast<Object**>(map)); |
| 677 type::BodyDescriptor::IterateBody(object, size, \ | 676 } |
| 678 static_cast<ConcreteVisitor*>(this)); \ | 677 |
| 679 return static_cast<ResultType>(size); \ | 678 template <typename ResultType, typename ConcreteVisitor> |
| 679 bool HeapVisitor<ResultType, ConcreteVisitor>::ShouldVisit(HeapObject* object) { |
| 680 return true; |
| 681 } |
| 682 |
| 683 #define VISIT(type) \ |
| 684 template <typename ResultType, typename ConcreteVisitor> \ |
| 685 ResultType HeapVisitor<ResultType, ConcreteVisitor>::Visit##type( \ |
| 686 Map* map, type* object) { \ |
| 687 ConcreteVisitor* visitor = static_cast<ConcreteVisitor*>(this); \ |
| 688 if (!visitor->ShouldVisit(object)) return ResultType(); \ |
| 689 int size = type::BodyDescriptor::SizeOf(map, object); \ |
| 690 visitor->VisitMapPointer(object, object->map_slot()); \ |
| 691 type::BodyDescriptor::IterateBody(object, size, visitor); \ |
| 692 return static_cast<ResultType>(size); \ |
| 680 } | 693 } |
| 681 TYPED_VISITOR_ID_LIST(VISIT) | 694 TYPED_VISITOR_ID_LIST(VISIT) |
| 682 #undef VISIT | 695 #undef VISIT |
| 683 | 696 |
| 684 template <typename ResultType, typename ConcreteVisitor> | 697 template <typename ResultType, typename ConcreteVisitor> |
| 685 ResultType HeapVisitor<ResultType, ConcreteVisitor>::VisitShortcutCandidate( | 698 ResultType HeapVisitor<ResultType, ConcreteVisitor>::VisitShortcutCandidate( |
| 686 Map* map, ConsString* object) { | 699 Map* map, ConsString* object) { |
| 700 ConcreteVisitor* visitor = static_cast<ConcreteVisitor*>(this); |
| 701 if (!visitor->ShouldVisit(object)) return ResultType(); |
| 687 int size = ConsString::BodyDescriptor::SizeOf(map, object); | 702 int size = ConsString::BodyDescriptor::SizeOf(map, object); |
| 703 visitor->VisitMapPointer(object, object->map_slot()); |
| 688 ConsString::BodyDescriptor::IterateBody(object, size, | 704 ConsString::BodyDescriptor::IterateBody(object, size, |
| 689 static_cast<ConcreteVisitor*>(this)); | 705 static_cast<ConcreteVisitor*>(this)); |
| 690 return static_cast<ResultType>(size); | 706 return static_cast<ResultType>(size); |
| 691 } | 707 } |
| 692 | 708 |
| 693 template <typename ResultType, typename ConcreteVisitor> | 709 template <typename ResultType, typename ConcreteVisitor> |
| 694 ResultType HeapVisitor<ResultType, ConcreteVisitor>::VisitNativeContext( | 710 ResultType HeapVisitor<ResultType, ConcreteVisitor>::VisitNativeContext( |
| 695 Map* map, Context* object) { | 711 Map* map, Context* object) { |
| 712 ConcreteVisitor* visitor = static_cast<ConcreteVisitor*>(this); |
| 713 if (!visitor->ShouldVisit(object)) return ResultType(); |
| 696 int size = Context::BodyDescriptor::SizeOf(map, object); | 714 int size = Context::BodyDescriptor::SizeOf(map, object); |
| 715 visitor->VisitMapPointer(object, object->map_slot()); |
| 697 Context::BodyDescriptor::IterateBody(object, size, | 716 Context::BodyDescriptor::IterateBody(object, size, |
| 698 static_cast<ConcreteVisitor*>(this)); | 717 static_cast<ConcreteVisitor*>(this)); |
| 699 return static_cast<ResultType>(size); | 718 return static_cast<ResultType>(size); |
| 700 } | 719 } |
| 701 | 720 |
| 702 template <typename ResultType, typename ConcreteVisitor> | 721 template <typename ResultType, typename ConcreteVisitor> |
| 703 ResultType HeapVisitor<ResultType, ConcreteVisitor>::VisitDataObject( | 722 ResultType HeapVisitor<ResultType, ConcreteVisitor>::VisitDataObject( |
| 704 Map* map, HeapObject* object) { | 723 Map* map, HeapObject* object) { |
| 724 ConcreteVisitor* visitor = static_cast<ConcreteVisitor*>(this); |
| 725 if (!visitor->ShouldVisit(object)) return ResultType(); |
| 705 int size = map->instance_size(); | 726 int size = map->instance_size(); |
| 727 visitor->VisitMapPointer(object, object->map_slot()); |
| 706 return static_cast<ResultType>(size); | 728 return static_cast<ResultType>(size); |
| 707 } | 729 } |
| 708 | 730 |
| 709 template <typename ResultType, typename ConcreteVisitor> | 731 template <typename ResultType, typename ConcreteVisitor> |
| 710 ResultType HeapVisitor<ResultType, ConcreteVisitor>::VisitJSObjectFast( | 732 ResultType HeapVisitor<ResultType, ConcreteVisitor>::VisitJSObjectFast( |
| 711 Map* map, JSObject* object) { | 733 Map* map, JSObject* object) { |
| 734 ConcreteVisitor* visitor = static_cast<ConcreteVisitor*>(this); |
| 735 if (!visitor->ShouldVisit(object)) return ResultType(); |
| 712 int size = JSObject::FastBodyDescriptor::SizeOf(map, object); | 736 int size = JSObject::FastBodyDescriptor::SizeOf(map, object); |
| 737 visitor->VisitMapPointer(object, object->map_slot()); |
| 713 JSObject::FastBodyDescriptor::IterateBody( | 738 JSObject::FastBodyDescriptor::IterateBody( |
| 714 object, size, static_cast<ConcreteVisitor*>(this)); | 739 object, size, static_cast<ConcreteVisitor*>(this)); |
| 715 return static_cast<ResultType>(size); | 740 return static_cast<ResultType>(size); |
| 716 } | 741 } |
| 717 template <typename ResultType, typename ConcreteVisitor> | 742 template <typename ResultType, typename ConcreteVisitor> |
| 718 ResultType HeapVisitor<ResultType, ConcreteVisitor>::VisitJSApiObject( | 743 ResultType HeapVisitor<ResultType, ConcreteVisitor>::VisitJSApiObject( |
| 719 Map* map, JSObject* object) { | 744 Map* map, JSObject* object) { |
| 745 ConcreteVisitor* visitor = static_cast<ConcreteVisitor*>(this); |
| 746 if (!visitor->ShouldVisit(object)) return ResultType(); |
| 720 int size = JSObject::BodyDescriptor::SizeOf(map, object); | 747 int size = JSObject::BodyDescriptor::SizeOf(map, object); |
| 748 visitor->VisitMapPointer(object, object->map_slot()); |
| 721 JSObject::BodyDescriptor::IterateBody(object, size, | 749 JSObject::BodyDescriptor::IterateBody(object, size, |
| 722 static_cast<ConcreteVisitor*>(this)); | 750 static_cast<ConcreteVisitor*>(this)); |
| 723 return static_cast<ResultType>(size); | 751 return static_cast<ResultType>(size); |
| 724 } | 752 } |
| 725 template <typename ResultType, typename ConcreteVisitor> | 753 template <typename ResultType, typename ConcreteVisitor> |
| 726 ResultType HeapVisitor<ResultType, ConcreteVisitor>::VisitStruct( | 754 ResultType HeapVisitor<ResultType, ConcreteVisitor>::VisitStruct( |
| 727 Map* map, HeapObject* object) { | 755 Map* map, HeapObject* object) { |
| 756 ConcreteVisitor* visitor = static_cast<ConcreteVisitor*>(this); |
| 757 if (!visitor->ShouldVisit(object)) return ResultType(); |
| 728 int size = map->instance_size(); | 758 int size = map->instance_size(); |
| 759 visitor->VisitMapPointer(object, object->map_slot()); |
| 729 StructBodyDescriptor::IterateBody(object, size, | 760 StructBodyDescriptor::IterateBody(object, size, |
| 730 static_cast<ConcreteVisitor*>(this)); | 761 static_cast<ConcreteVisitor*>(this)); |
| 731 return static_cast<ResultType>(size); | 762 return static_cast<ResultType>(size); |
| 732 } | 763 } |
| 733 template <typename ResultType, typename ConcreteVisitor> | 764 template <typename ResultType, typename ConcreteVisitor> |
| 734 ResultType HeapVisitor<ResultType, ConcreteVisitor>::VisitFreeSpace( | 765 ResultType HeapVisitor<ResultType, ConcreteVisitor>::VisitFreeSpace( |
| 735 Map* map, FreeSpace* object) { | 766 Map* map, FreeSpace* object) { |
| 767 ConcreteVisitor* visitor = static_cast<ConcreteVisitor*>(this); |
| 768 if (!visitor->ShouldVisit(object)) return ResultType(); |
| 769 visitor->VisitMapPointer(object, object->map_slot()); |
| 736 return static_cast<ResultType>(FreeSpace::cast(object)->size()); | 770 return static_cast<ResultType>(FreeSpace::cast(object)->size()); |
| 737 } | 771 } |
| 738 | 772 |
| 739 } // namespace internal | 773 } // namespace internal |
| 740 } // namespace v8 | 774 } // namespace v8 |
| 741 | 775 |
| 742 #endif // V8_OBJECTS_VISITING_INL_H_ | 776 #endif // V8_OBJECTS_VISITING_INL_H_ |
| OLD | NEW |