| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/raw_object.h" | 5 #include "vm/raw_object.h" |
| 6 | 6 |
| 7 #include "vm/class_table.h" | 7 #include "vm/class_table.h" |
| 8 #include "vm/freelist.h" | 8 #include "vm/freelist.h" |
| 9 #include "vm/isolate.h" | 9 #include "vm/isolate.h" |
| 10 #include "vm/object.h" | 10 #include "vm/object.h" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 instance_size = FourByteString::InstanceSize(string_length); | 116 instance_size = FourByteString::InstanceSize(string_length); |
| 117 break; | 117 break; |
| 118 } | 118 } |
| 119 case kArray: | 119 case kArray: |
| 120 case kImmutableArray: { | 120 case kImmutableArray: { |
| 121 const RawArray* raw_array = reinterpret_cast<const RawArray*>(this); | 121 const RawArray* raw_array = reinterpret_cast<const RawArray*>(this); |
| 122 intptr_t array_length = Smi::Value(raw_array->ptr()->length_); | 122 intptr_t array_length = Smi::Value(raw_array->ptr()->length_); |
| 123 instance_size = Array::InstanceSize(array_length); | 123 instance_size = Array::InstanceSize(array_length); |
| 124 break; | 124 break; |
| 125 } | 125 } |
| 126 case kInt8Array: { | 126 case kInternalByteArray: { |
| 127 const RawInt8Array* raw_byte_array = | 127 const RawInternalByteArray* raw_byte_array = |
| 128 reinterpret_cast<const RawInt8Array*>(this); | 128 reinterpret_cast<const RawInternalByteArray*>(this); |
| 129 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); | 129 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); |
| 130 instance_size = Int8Array::InstanceSize(byte_array_length); | 130 instance_size = InternalByteArray::InstanceSize(byte_array_length); |
| 131 break; | |
| 132 } | |
| 133 case kUint8Array: { | |
| 134 const RawUint8Array* raw_byte_array = | |
| 135 reinterpret_cast<const RawUint8Array*>(this); | |
| 136 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); | |
| 137 instance_size = Uint8Array::InstanceSize(byte_array_length); | |
| 138 break; | |
| 139 } | |
| 140 case kInt16Array: { | |
| 141 const RawInt16Array* raw_byte_array = | |
| 142 reinterpret_cast<const RawInt16Array*>(this); | |
| 143 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); | |
| 144 instance_size = Int16Array::InstanceSize(byte_array_length); | |
| 145 break; | |
| 146 } | |
| 147 case kUint16Array: { | |
| 148 const RawUint16Array* raw_byte_array = | |
| 149 reinterpret_cast<const RawUint16Array*>(this); | |
| 150 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); | |
| 151 instance_size = Uint16Array::InstanceSize(byte_array_length); | |
| 152 break; | |
| 153 } | |
| 154 case kInt32Array: { | |
| 155 const RawInt32Array* raw_byte_array = | |
| 156 reinterpret_cast<const RawInt32Array*>(this); | |
| 157 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); | |
| 158 instance_size = Int32Array::InstanceSize(byte_array_length); | |
| 159 break; | |
| 160 } | |
| 161 case kUint32Array: { | |
| 162 const RawUint32Array* raw_byte_array = | |
| 163 reinterpret_cast<const RawUint32Array*>(this); | |
| 164 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); | |
| 165 instance_size = Uint32Array::InstanceSize(byte_array_length); | |
| 166 break; | |
| 167 } | |
| 168 case kInt64Array: { | |
| 169 const RawInt64Array* raw_byte_array = | |
| 170 reinterpret_cast<const RawInt64Array*>(this); | |
| 171 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); | |
| 172 instance_size = Int64Array::InstanceSize(byte_array_length); | |
| 173 break; | |
| 174 } | |
| 175 case kUint64Array: { | |
| 176 const RawUint64Array* raw_byte_array = | |
| 177 reinterpret_cast<const RawUint64Array*>(this); | |
| 178 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); | |
| 179 instance_size = Uint64Array::InstanceSize(byte_array_length); | |
| 180 break; | |
| 181 } | |
| 182 case kFloat32Array: { | |
| 183 const RawFloat32Array* raw_byte_array = | |
| 184 reinterpret_cast<const RawFloat32Array*>(this); | |
| 185 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); | |
| 186 instance_size = Float32Array::InstanceSize(byte_array_length); | |
| 187 break; | |
| 188 } | |
| 189 case kFloat64Array: { | |
| 190 const RawFloat64Array* raw_byte_array = | |
| 191 reinterpret_cast<const RawFloat64Array*>(this); | |
| 192 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); | |
| 193 instance_size = Float64Array::InstanceSize(byte_array_length); | |
| 194 break; | 131 break; |
| 195 } | 132 } |
| 196 case kTypeArguments: { | 133 case kTypeArguments: { |
| 197 const RawTypeArguments* raw_array = | 134 const RawTypeArguments* raw_array = |
| 198 reinterpret_cast<const RawTypeArguments*>(this); | 135 reinterpret_cast<const RawTypeArguments*>(this); |
| 199 intptr_t array_length = Smi::Value(raw_array->ptr()->length_); | 136 intptr_t array_length = Smi::Value(raw_array->ptr()->length_); |
| 200 instance_size = TypeArguments::InstanceSize(array_length); | 137 instance_size = TypeArguments::InstanceSize(array_length); |
| 201 break; | 138 break; |
| 202 } | 139 } |
| 203 case kPcDescriptors: { | 140 case kPcDescriptors: { |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 | 661 |
| 725 | 662 |
| 726 intptr_t RawByteArray::VisitByteArrayPointers(RawByteArray* raw_obj, | 663 intptr_t RawByteArray::VisitByteArrayPointers(RawByteArray* raw_obj, |
| 727 ObjectPointerVisitor* visitor) { | 664 ObjectPointerVisitor* visitor) { |
| 728 // ByteArray is an abstract class. | 665 // ByteArray is an abstract class. |
| 729 UNREACHABLE(); | 666 UNREACHABLE(); |
| 730 return 0; | 667 return 0; |
| 731 } | 668 } |
| 732 | 669 |
| 733 | 670 |
| 734 intptr_t RawInt8Array::VisitInt8ArrayPointers( | 671 intptr_t RawInternalByteArray::VisitInternalByteArrayPointers( |
| 735 RawInt8Array *raw_obj, ObjectPointerVisitor* visitor) { | 672 RawInternalByteArray* raw_obj, ObjectPointerVisitor* visitor) { |
| 736 // Make sure that we got here with the tagged pointer as this. | 673 // Make sure that we got here with the tagged pointer as this. |
| 737 ASSERT(raw_obj->IsHeapObject()); | 674 ASSERT(raw_obj->IsHeapObject()); |
| 738 intptr_t length = Smi::Value(raw_obj->ptr()->length_); | 675 intptr_t length = Smi::Value(raw_obj->ptr()->length_); |
| 739 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 676 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
| 740 return Int8Array::InstanceSize(length); | 677 return InternalByteArray::InstanceSize(length); |
| 741 } | 678 } |
| 742 | 679 |
| 743 | 680 |
| 744 intptr_t RawUint8Array::VisitUint8ArrayPointers( | 681 intptr_t RawExternalByteArray::VisitExternalByteArrayPointers( |
| 745 RawUint8Array *raw_obj, ObjectPointerVisitor* visitor) { | 682 RawExternalByteArray* raw_obj, ObjectPointerVisitor* visitor) { |
| 746 // Make sure that we got here with the tagged pointer as this. | 683 // Make sure that we got here with the tagged pointer as this. |
| 747 ASSERT(raw_obj->IsHeapObject()); | 684 ASSERT(raw_obj->IsHeapObject()); |
| 748 intptr_t length = Smi::Value(raw_obj->ptr()->length_); | |
| 749 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 685 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
| 750 return Uint8Array::InstanceSize(length); | 686 return ExternalByteArray::InstanceSize(); |
| 751 } | 687 } |
| 752 | 688 |
| 753 | 689 |
| 754 intptr_t RawInt16Array::VisitInt16ArrayPointers( | |
| 755 RawInt16Array *raw_obj, ObjectPointerVisitor* visitor) { | |
| 756 // Make sure that we got here with the tagged pointer as this. | |
| 757 ASSERT(raw_obj->IsHeapObject()); | |
| 758 intptr_t length = Smi::Value(raw_obj->ptr()->length_); | |
| 759 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
| 760 return Int16Array::InstanceSize(length); | |
| 761 } | |
| 762 | |
| 763 | |
| 764 intptr_t RawUint16Array::VisitUint16ArrayPointers( | |
| 765 RawUint16Array *raw_obj, ObjectPointerVisitor* visitor) { | |
| 766 // Make sure that we got here with the tagged pointer as this. | |
| 767 ASSERT(raw_obj->IsHeapObject()); | |
| 768 intptr_t length = Smi::Value(raw_obj->ptr()->length_); | |
| 769 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
| 770 return Uint16Array::InstanceSize(length); | |
| 771 } | |
| 772 | |
| 773 | |
| 774 intptr_t RawInt32Array::VisitInt32ArrayPointers( | |
| 775 RawInt32Array *raw_obj, ObjectPointerVisitor* visitor) { | |
| 776 // Make sure that we got here with the tagged pointer as this. | |
| 777 ASSERT(raw_obj->IsHeapObject()); | |
| 778 intptr_t length = Smi::Value(raw_obj->ptr()->length_); | |
| 779 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
| 780 return Int32Array::InstanceSize(length); | |
| 781 } | |
| 782 | |
| 783 | |
| 784 intptr_t RawUint32Array::VisitUint32ArrayPointers( | |
| 785 RawUint32Array *raw_obj, ObjectPointerVisitor* visitor) { | |
| 786 // Make sure that we got here with the tagged pointer as this. | |
| 787 ASSERT(raw_obj->IsHeapObject()); | |
| 788 intptr_t length = Smi::Value(raw_obj->ptr()->length_); | |
| 789 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
| 790 return Uint32Array::InstanceSize(length); | |
| 791 } | |
| 792 | |
| 793 | |
| 794 intptr_t RawInt64Array::VisitInt64ArrayPointers( | |
| 795 RawInt64Array *raw_obj, ObjectPointerVisitor* visitor) { | |
| 796 // Make sure that we got here with the tagged pointer as this. | |
| 797 ASSERT(raw_obj->IsHeapObject()); | |
| 798 intptr_t length = Smi::Value(raw_obj->ptr()->length_); | |
| 799 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
| 800 return Int64Array::InstanceSize(length); | |
| 801 } | |
| 802 | |
| 803 | |
| 804 intptr_t RawUint64Array::VisitUint64ArrayPointers( | |
| 805 RawUint64Array *raw_obj, ObjectPointerVisitor* visitor) { | |
| 806 // Make sure that we got here with the tagged pointer as this. | |
| 807 ASSERT(raw_obj->IsHeapObject()); | |
| 808 intptr_t length = Smi::Value(raw_obj->ptr()->length_); | |
| 809 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
| 810 return Uint64Array::InstanceSize(length); | |
| 811 } | |
| 812 | |
| 813 | |
| 814 intptr_t RawFloat32Array::VisitFloat32ArrayPointers( | |
| 815 RawFloat32Array *raw_obj, ObjectPointerVisitor* visitor) { | |
| 816 // Make sure that we got here with the tagged pointer as this. | |
| 817 ASSERT(raw_obj->IsHeapObject()); | |
| 818 intptr_t length = Smi::Value(raw_obj->ptr()->length_); | |
| 819 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
| 820 return Float32Array::InstanceSize(length); | |
| 821 } | |
| 822 | |
| 823 | |
| 824 intptr_t RawFloat64Array::VisitFloat64ArrayPointers( | |
| 825 RawFloat64Array *raw_obj, ObjectPointerVisitor* visitor) { | |
| 826 // Make sure that we got here with the tagged pointer as this. | |
| 827 ASSERT(raw_obj->IsHeapObject()); | |
| 828 intptr_t length = Smi::Value(raw_obj->ptr()->length_); | |
| 829 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
| 830 return Float64Array::InstanceSize(length); | |
| 831 } | |
| 832 | |
| 833 | |
| 834 intptr_t RawExternalInt8Array::VisitExternalInt8ArrayPointers( | |
| 835 RawExternalInt8Array* raw_obj, ObjectPointerVisitor* visitor) { | |
| 836 // Make sure that we got here with the tagged pointer as this. | |
| 837 ASSERT(raw_obj->IsHeapObject()); | |
| 838 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
| 839 return ExternalInt8Array::InstanceSize(); | |
| 840 } | |
| 841 | |
| 842 | |
| 843 intptr_t RawExternalUint8Array::VisitExternalUint8ArrayPointers( | |
| 844 RawExternalUint8Array* raw_obj, ObjectPointerVisitor* visitor) { | |
| 845 // Make sure that we got here with the tagged pointer as this. | |
| 846 ASSERT(raw_obj->IsHeapObject()); | |
| 847 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
| 848 return ExternalUint8Array::InstanceSize(); | |
| 849 } | |
| 850 | |
| 851 | |
| 852 intptr_t RawExternalInt16Array::VisitExternalInt16ArrayPointers( | |
| 853 RawExternalInt16Array* raw_obj, ObjectPointerVisitor* visitor) { | |
| 854 // Make sure that we got here with the tagged pointer as this. | |
| 855 ASSERT(raw_obj->IsHeapObject()); | |
| 856 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
| 857 return ExternalInt16Array::InstanceSize(); | |
| 858 } | |
| 859 | |
| 860 | |
| 861 intptr_t RawExternalUint16Array::VisitExternalUint16ArrayPointers( | |
| 862 RawExternalUint16Array* raw_obj, ObjectPointerVisitor* visitor) { | |
| 863 // Make sure that we got here with the tagged pointer as this. | |
| 864 ASSERT(raw_obj->IsHeapObject()); | |
| 865 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
| 866 return ExternalUint16Array::InstanceSize(); | |
| 867 } | |
| 868 | |
| 869 | |
| 870 intptr_t RawExternalInt32Array::VisitExternalInt32ArrayPointers( | |
| 871 RawExternalInt32Array* raw_obj, ObjectPointerVisitor* visitor) { | |
| 872 // Make sure that we got here with the tagged pointer as this. | |
| 873 ASSERT(raw_obj->IsHeapObject()); | |
| 874 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
| 875 return ExternalInt32Array::InstanceSize(); | |
| 876 } | |
| 877 | |
| 878 | |
| 879 intptr_t RawExternalUint32Array::VisitExternalUint32ArrayPointers( | |
| 880 RawExternalUint32Array* raw_obj, ObjectPointerVisitor* visitor) { | |
| 881 // Make sure that we got here with the tagged pointer as this. | |
| 882 ASSERT(raw_obj->IsHeapObject()); | |
| 883 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
| 884 return ExternalUint32Array::InstanceSize(); | |
| 885 } | |
| 886 | |
| 887 | |
| 888 intptr_t RawExternalInt64Array::VisitExternalInt64ArrayPointers( | |
| 889 RawExternalInt64Array* raw_obj, ObjectPointerVisitor* visitor) { | |
| 890 // Make sure that we got here with the tagged pointer as this. | |
| 891 ASSERT(raw_obj->IsHeapObject()); | |
| 892 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
| 893 return ExternalInt64Array::InstanceSize(); | |
| 894 } | |
| 895 | |
| 896 | |
| 897 intptr_t RawExternalUint64Array::VisitExternalUint64ArrayPointers( | |
| 898 RawExternalUint64Array* raw_obj, ObjectPointerVisitor* visitor) { | |
| 899 // Make sure that we got here with the tagged pointer as this. | |
| 900 ASSERT(raw_obj->IsHeapObject()); | |
| 901 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
| 902 return ExternalUint64Array::InstanceSize(); | |
| 903 } | |
| 904 | |
| 905 | |
| 906 intptr_t RawExternalFloat32Array::VisitExternalFloat32ArrayPointers( | |
| 907 RawExternalFloat32Array* raw_obj, ObjectPointerVisitor* visitor) { | |
| 908 // Make sure that we got here with the tagged pointer as this. | |
| 909 ASSERT(raw_obj->IsHeapObject()); | |
| 910 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
| 911 return ExternalFloat32Array::InstanceSize(); | |
| 912 } | |
| 913 | |
| 914 | |
| 915 intptr_t RawExternalFloat64Array::VisitExternalFloat64ArrayPointers( | |
| 916 RawExternalFloat64Array* raw_obj, ObjectPointerVisitor* visitor) { | |
| 917 // Make sure that we got here with the tagged pointer as this. | |
| 918 ASSERT(raw_obj->IsHeapObject()); | |
| 919 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
| 920 return ExternalFloat64Array::InstanceSize(); | |
| 921 } | |
| 922 | |
| 923 | |
| 924 intptr_t RawClosure::VisitClosurePointers(RawClosure* raw_obj, | 690 intptr_t RawClosure::VisitClosurePointers(RawClosure* raw_obj, |
| 925 ObjectPointerVisitor* visitor) { | 691 ObjectPointerVisitor* visitor) { |
| 926 // Make sure that we got here with the tagged pointer as this. | 692 // Make sure that we got here with the tagged pointer as this. |
| 927 ASSERT(raw_obj->IsHeapObject()); | 693 ASSERT(raw_obj->IsHeapObject()); |
| 928 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 694 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
| 929 return Closure::InstanceSize(); | 695 return Closure::InstanceSize(); |
| 930 } | 696 } |
| 931 | 697 |
| 932 | 698 |
| 933 intptr_t RawStacktrace::VisitStacktracePointers(RawStacktrace* raw_obj, | 699 intptr_t RawStacktrace::VisitStacktracePointers(RawStacktrace* raw_obj, |
| 934 ObjectPointerVisitor* visitor) { | 700 ObjectPointerVisitor* visitor) { |
| 935 // Make sure that we got here with the tagged pointer as this. | 701 // Make sure that we got here with the tagged pointer as this. |
| 936 ASSERT(raw_obj->IsHeapObject()); | 702 ASSERT(raw_obj->IsHeapObject()); |
| 937 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 703 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
| 938 return Stacktrace::InstanceSize(); | 704 return Stacktrace::InstanceSize(); |
| 939 } | 705 } |
| 940 | 706 |
| 941 | 707 |
| 942 intptr_t RawJSRegExp::VisitJSRegExpPointers(RawJSRegExp* raw_obj, | 708 intptr_t RawJSRegExp::VisitJSRegExpPointers(RawJSRegExp* raw_obj, |
| 943 ObjectPointerVisitor* visitor) { | 709 ObjectPointerVisitor* visitor) { |
| 944 // Make sure that we got here with the tagged pointer as this. | 710 // Make sure that we got here with the tagged pointer as this. |
| 945 ASSERT(raw_obj->IsHeapObject()); | 711 ASSERT(raw_obj->IsHeapObject()); |
| 946 intptr_t length = Smi::Value(raw_obj->ptr()->data_length_); | 712 intptr_t length = Smi::Value(raw_obj->ptr()->data_length_); |
| 947 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 713 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
| 948 return JSRegExp::InstanceSize(length); | 714 return JSRegExp::InstanceSize(length); |
| 949 } | 715 } |
| 950 | 716 |
| 951 } // namespace dart | 717 } // namespace dart |
| OLD | NEW |