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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 instance_size = TwoByteString::InstanceSize(string_length); | 112 instance_size = TwoByteString::InstanceSize(string_length); |
113 break; | 113 break; |
114 } | 114 } |
115 case kArrayCid: | 115 case kArrayCid: |
116 case kImmutableArrayCid: { | 116 case kImmutableArrayCid: { |
117 const RawArray* raw_array = reinterpret_cast<const RawArray*>(this); | 117 const RawArray* raw_array = reinterpret_cast<const RawArray*>(this); |
118 intptr_t array_length = Smi::Value(raw_array->ptr()->length_); | 118 intptr_t array_length = Smi::Value(raw_array->ptr()->length_); |
119 instance_size = Array::InstanceSize(array_length); | 119 instance_size = Array::InstanceSize(array_length); |
120 break; | 120 break; |
121 } | 121 } |
122 case kInt8ArrayCid: { | |
123 const RawInt8Array* raw_byte_array = | |
124 reinterpret_cast<const RawInt8Array*>(this); | |
125 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); | |
126 instance_size = Int8Array::InstanceSize(byte_array_length); | |
127 break; | |
128 } | |
129 case kUint8ArrayCid: { | |
130 const RawUint8Array* raw_byte_array = | |
131 reinterpret_cast<const RawUint8Array*>(this); | |
132 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); | |
133 instance_size = Uint8Array::InstanceSize(byte_array_length); | |
134 break; | |
135 } | |
136 case kUint8ClampedArrayCid: { | |
137 const RawUint8ClampedArray* raw_byte_array = | |
138 reinterpret_cast<const RawUint8ClampedArray*>(this); | |
139 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); | |
140 instance_size = Uint8ClampedArray::InstanceSize(byte_array_length); | |
141 break; | |
142 } | |
143 case kInt16ArrayCid: { | |
144 const RawInt16Array* raw_byte_array = | |
145 reinterpret_cast<const RawInt16Array*>(this); | |
146 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); | |
147 instance_size = Int16Array::InstanceSize(byte_array_length); | |
148 break; | |
149 } | |
150 case kUint16ArrayCid: { | |
151 const RawUint16Array* raw_byte_array = | |
152 reinterpret_cast<const RawUint16Array*>(this); | |
153 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); | |
154 instance_size = Uint16Array::InstanceSize(byte_array_length); | |
155 break; | |
156 } | |
157 case kInt32ArrayCid: { | |
158 const RawInt32Array* raw_byte_array = | |
159 reinterpret_cast<const RawInt32Array*>(this); | |
160 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); | |
161 instance_size = Int32Array::InstanceSize(byte_array_length); | |
162 break; | |
163 } | |
164 case kUint32ArrayCid: { | |
165 const RawUint32Array* raw_byte_array = | |
166 reinterpret_cast<const RawUint32Array*>(this); | |
167 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); | |
168 instance_size = Uint32Array::InstanceSize(byte_array_length); | |
169 break; | |
170 } | |
171 case kInt64ArrayCid: { | |
172 const RawInt64Array* raw_byte_array = | |
173 reinterpret_cast<const RawInt64Array*>(this); | |
174 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); | |
175 instance_size = Int64Array::InstanceSize(byte_array_length); | |
176 break; | |
177 } | |
178 case kUint64ArrayCid: { | |
179 const RawUint64Array* raw_byte_array = | |
180 reinterpret_cast<const RawUint64Array*>(this); | |
181 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); | |
182 instance_size = Uint64Array::InstanceSize(byte_array_length); | |
183 break; | |
184 } | |
185 case kFloat32ArrayCid: { | |
186 const RawFloat32Array* raw_byte_array = | |
187 reinterpret_cast<const RawFloat32Array*>(this); | |
188 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); | |
189 instance_size = Float32Array::InstanceSize(byte_array_length); | |
190 break; | |
191 } | |
192 case kFloat64ArrayCid: { | |
193 const RawFloat64Array* raw_byte_array = | |
194 reinterpret_cast<const RawFloat64Array*>(this); | |
195 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); | |
196 instance_size = Float64Array::InstanceSize(byte_array_length); | |
197 break; | |
198 } | |
199 #define SIZE_FROM_CLASS(clazz) \ | 122 #define SIZE_FROM_CLASS(clazz) \ |
200 case kTypedData##clazz##Cid: | 123 case kTypedData##clazz##Cid: |
201 CLASS_LIST_TYPED_DATA(SIZE_FROM_CLASS) { | 124 CLASS_LIST_TYPED_DATA(SIZE_FROM_CLASS) { |
202 const RawTypedData* raw_obj = | 125 const RawTypedData* raw_obj = |
203 reinterpret_cast<const RawTypedData*>(this); | 126 reinterpret_cast<const RawTypedData*>(this); |
204 intptr_t cid = raw_obj->GetClassId(); | 127 intptr_t cid = raw_obj->GetClassId(); |
205 intptr_t array_len = Smi::Value(raw_obj->ptr()->length_); | 128 intptr_t array_len = Smi::Value(raw_obj->ptr()->length_); |
206 intptr_t lengthInBytes = array_len * TypedData::ElementSizeInBytes(cid); | 129 intptr_t lengthInBytes = array_len * TypedData::ElementSizeInBytes(cid); |
207 instance_size = TypedData::InstanceSize(lengthInBytes); | 130 instance_size = TypedData::InstanceSize(lengthInBytes); |
208 break; | 131 break; |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 | 746 |
824 | 747 |
825 intptr_t RawUint32x4::VisitUint32x4Pointers( | 748 intptr_t RawUint32x4::VisitUint32x4Pointers( |
826 RawUint32x4* raw_obj, | 749 RawUint32x4* raw_obj, |
827 ObjectPointerVisitor* visitor) { | 750 ObjectPointerVisitor* visitor) { |
828 ASSERT(raw_obj->IsHeapObject()); | 751 ASSERT(raw_obj->IsHeapObject()); |
829 return Uint32x4::InstanceSize(); | 752 return Uint32x4::InstanceSize(); |
830 } | 753 } |
831 | 754 |
832 | 755 |
833 intptr_t RawByteArray::VisitByteArrayPointers(RawByteArray* raw_obj, | |
834 ObjectPointerVisitor* visitor) { | |
835 // ByteArray is an abstract class. | |
836 UNREACHABLE(); | |
837 return 0; | |
838 } | |
839 | |
840 | |
841 intptr_t RawInt8Array::VisitInt8ArrayPointers( | |
842 RawInt8Array *raw_obj, ObjectPointerVisitor* visitor) { | |
843 // Make sure that we got here with the tagged pointer as this. | |
844 ASSERT(raw_obj->IsHeapObject()); | |
845 intptr_t length = Smi::Value(raw_obj->ptr()->length_); | |
846 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
847 return Int8Array::InstanceSize(length); | |
848 } | |
849 | |
850 | |
851 intptr_t RawUint8Array::VisitUint8ArrayPointers( | |
852 RawUint8Array *raw_obj, ObjectPointerVisitor* visitor) { | |
853 // Make sure that we got here with the tagged pointer as this. | |
854 ASSERT(raw_obj->IsHeapObject()); | |
855 intptr_t length = Smi::Value(raw_obj->ptr()->length_); | |
856 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
857 return Uint8Array::InstanceSize(length); | |
858 } | |
859 | |
860 | |
861 intptr_t RawUint8ClampedArray::VisitUint8ClampedArrayPointers( | |
862 RawUint8ClampedArray *raw_obj, ObjectPointerVisitor* visitor) { | |
863 // Make sure that we got here with the tagged pointer as this. | |
864 ASSERT(raw_obj->IsHeapObject()); | |
865 intptr_t length = Smi::Value(raw_obj->ptr()->length_); | |
866 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
867 return Uint8ClampedArray::InstanceSize(length); | |
868 } | |
869 | |
870 | |
871 intptr_t RawInt16Array::VisitInt16ArrayPointers( | |
872 RawInt16Array *raw_obj, ObjectPointerVisitor* visitor) { | |
873 // Make sure that we got here with the tagged pointer as this. | |
874 ASSERT(raw_obj->IsHeapObject()); | |
875 intptr_t length = Smi::Value(raw_obj->ptr()->length_); | |
876 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
877 return Int16Array::InstanceSize(length); | |
878 } | |
879 | |
880 | |
881 intptr_t RawUint16Array::VisitUint16ArrayPointers( | |
882 RawUint16Array *raw_obj, ObjectPointerVisitor* visitor) { | |
883 // Make sure that we got here with the tagged pointer as this. | |
884 ASSERT(raw_obj->IsHeapObject()); | |
885 intptr_t length = Smi::Value(raw_obj->ptr()->length_); | |
886 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
887 return Uint16Array::InstanceSize(length); | |
888 } | |
889 | |
890 | |
891 intptr_t RawInt32Array::VisitInt32ArrayPointers( | |
892 RawInt32Array *raw_obj, ObjectPointerVisitor* visitor) { | |
893 // Make sure that we got here with the tagged pointer as this. | |
894 ASSERT(raw_obj->IsHeapObject()); | |
895 intptr_t length = Smi::Value(raw_obj->ptr()->length_); | |
896 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
897 return Int32Array::InstanceSize(length); | |
898 } | |
899 | |
900 | |
901 intptr_t RawUint32Array::VisitUint32ArrayPointers( | |
902 RawUint32Array *raw_obj, ObjectPointerVisitor* visitor) { | |
903 // Make sure that we got here with the tagged pointer as this. | |
904 ASSERT(raw_obj->IsHeapObject()); | |
905 intptr_t length = Smi::Value(raw_obj->ptr()->length_); | |
906 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
907 return Uint32Array::InstanceSize(length); | |
908 } | |
909 | |
910 | |
911 intptr_t RawInt64Array::VisitInt64ArrayPointers( | |
912 RawInt64Array *raw_obj, ObjectPointerVisitor* visitor) { | |
913 // Make sure that we got here with the tagged pointer as this. | |
914 ASSERT(raw_obj->IsHeapObject()); | |
915 intptr_t length = Smi::Value(raw_obj->ptr()->length_); | |
916 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
917 return Int64Array::InstanceSize(length); | |
918 } | |
919 | |
920 | |
921 intptr_t RawUint64Array::VisitUint64ArrayPointers( | |
922 RawUint64Array *raw_obj, ObjectPointerVisitor* visitor) { | |
923 // Make sure that we got here with the tagged pointer as this. | |
924 ASSERT(raw_obj->IsHeapObject()); | |
925 intptr_t length = Smi::Value(raw_obj->ptr()->length_); | |
926 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
927 return Uint64Array::InstanceSize(length); | |
928 } | |
929 | |
930 intptr_t RawFloat32Array::VisitFloat32ArrayPointers( | |
931 RawFloat32Array *raw_obj, ObjectPointerVisitor* visitor) { | |
932 // Make sure that we got here with the tagged pointer as this. | |
933 ASSERT(raw_obj->IsHeapObject()); | |
934 intptr_t length = Smi::Value(raw_obj->ptr()->length_); | |
935 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
936 return Float32Array::InstanceSize(length); | |
937 } | |
938 | |
939 | |
940 intptr_t RawFloat64Array::VisitFloat64ArrayPointers( | |
941 RawFloat64Array *raw_obj, ObjectPointerVisitor* visitor) { | |
942 // Make sure that we got here with the tagged pointer as this. | |
943 ASSERT(raw_obj->IsHeapObject()); | |
944 intptr_t length = Smi::Value(raw_obj->ptr()->length_); | |
945 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
946 return Float64Array::InstanceSize(length); | |
947 } | |
948 | |
949 | |
950 intptr_t RawExternalInt8Array::VisitExternalInt8ArrayPointers( | |
951 RawExternalInt8Array* raw_obj, ObjectPointerVisitor* visitor) { | |
952 // Make sure that we got here with the tagged pointer as this. | |
953 ASSERT(raw_obj->IsHeapObject()); | |
954 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
955 return ExternalInt8Array::InstanceSize(); | |
956 } | |
957 | |
958 | |
959 intptr_t RawExternalUint8Array::VisitExternalUint8ArrayPointers( | |
960 RawExternalUint8Array* raw_obj, ObjectPointerVisitor* visitor) { | |
961 // Make sure that we got here with the tagged pointer as this. | |
962 ASSERT(raw_obj->IsHeapObject()); | |
963 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
964 return ExternalUint8Array::InstanceSize(); | |
965 } | |
966 | |
967 | |
968 intptr_t RawExternalUint8ClampedArray::VisitExternalUint8ClampedArrayPointers( | |
969 RawExternalUint8ClampedArray* raw_obj, ObjectPointerVisitor* visitor) { | |
970 // Make sure that we got here with the tagged pointer as this. | |
971 ASSERT(raw_obj->IsHeapObject()); | |
972 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
973 return ExternalUint8ClampedArray::InstanceSize(); | |
974 } | |
975 | |
976 | |
977 intptr_t RawExternalInt16Array::VisitExternalInt16ArrayPointers( | |
978 RawExternalInt16Array* raw_obj, ObjectPointerVisitor* visitor) { | |
979 // Make sure that we got here with the tagged pointer as this. | |
980 ASSERT(raw_obj->IsHeapObject()); | |
981 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
982 return ExternalInt16Array::InstanceSize(); | |
983 } | |
984 | |
985 | |
986 intptr_t RawExternalUint16Array::VisitExternalUint16ArrayPointers( | |
987 RawExternalUint16Array* raw_obj, ObjectPointerVisitor* visitor) { | |
988 // Make sure that we got here with the tagged pointer as this. | |
989 ASSERT(raw_obj->IsHeapObject()); | |
990 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
991 return ExternalUint16Array::InstanceSize(); | |
992 } | |
993 | |
994 | |
995 intptr_t RawExternalInt32Array::VisitExternalInt32ArrayPointers( | |
996 RawExternalInt32Array* raw_obj, ObjectPointerVisitor* visitor) { | |
997 // Make sure that we got here with the tagged pointer as this. | |
998 ASSERT(raw_obj->IsHeapObject()); | |
999 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
1000 return ExternalInt32Array::InstanceSize(); | |
1001 } | |
1002 | |
1003 | |
1004 intptr_t RawExternalUint32Array::VisitExternalUint32ArrayPointers( | |
1005 RawExternalUint32Array* raw_obj, ObjectPointerVisitor* visitor) { | |
1006 // Make sure that we got here with the tagged pointer as this. | |
1007 ASSERT(raw_obj->IsHeapObject()); | |
1008 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
1009 return ExternalUint32Array::InstanceSize(); | |
1010 } | |
1011 | |
1012 | |
1013 intptr_t RawExternalInt64Array::VisitExternalInt64ArrayPointers( | |
1014 RawExternalInt64Array* raw_obj, ObjectPointerVisitor* visitor) { | |
1015 // Make sure that we got here with the tagged pointer as this. | |
1016 ASSERT(raw_obj->IsHeapObject()); | |
1017 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
1018 return ExternalInt64Array::InstanceSize(); | |
1019 } | |
1020 | |
1021 | |
1022 intptr_t RawExternalUint64Array::VisitExternalUint64ArrayPointers( | |
1023 RawExternalUint64Array* raw_obj, ObjectPointerVisitor* visitor) { | |
1024 // Make sure that we got here with the tagged pointer as this. | |
1025 ASSERT(raw_obj->IsHeapObject()); | |
1026 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
1027 return ExternalUint64Array::InstanceSize(); | |
1028 } | |
1029 | |
1030 | |
1031 intptr_t RawExternalFloat32Array::VisitExternalFloat32ArrayPointers( | |
1032 RawExternalFloat32Array* raw_obj, ObjectPointerVisitor* visitor) { | |
1033 // Make sure that we got here with the tagged pointer as this. | |
1034 ASSERT(raw_obj->IsHeapObject()); | |
1035 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
1036 return ExternalFloat32Array::InstanceSize(); | |
1037 } | |
1038 | |
1039 | |
1040 intptr_t RawExternalFloat64Array::VisitExternalFloat64ArrayPointers( | |
1041 RawExternalFloat64Array* raw_obj, ObjectPointerVisitor* visitor) { | |
1042 // Make sure that we got here with the tagged pointer as this. | |
1043 ASSERT(raw_obj->IsHeapObject()); | |
1044 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
1045 return ExternalFloat64Array::InstanceSize(); | |
1046 } | |
1047 | |
1048 | |
1049 intptr_t RawTypedData::VisitTypedDataPointers( | 756 intptr_t RawTypedData::VisitTypedDataPointers( |
1050 RawTypedData* raw_obj, ObjectPointerVisitor* visitor) { | 757 RawTypedData* raw_obj, ObjectPointerVisitor* visitor) { |
1051 // Make sure that we got here with the tagged pointer as this. | 758 // Make sure that we got here with the tagged pointer as this. |
1052 ASSERT(raw_obj->IsHeapObject()); | 759 ASSERT(raw_obj->IsHeapObject()); |
1053 intptr_t cid = raw_obj->GetClassId(); | 760 intptr_t cid = raw_obj->GetClassId(); |
1054 intptr_t array_len = Smi::Value(raw_obj->ptr()->length_); | 761 intptr_t array_len = Smi::Value(raw_obj->ptr()->length_); |
1055 intptr_t lengthInBytes = array_len * TypedData::ElementSizeInBytes(cid); | 762 intptr_t lengthInBytes = array_len * TypedData::ElementSizeInBytes(cid); |
1056 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 763 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
1057 return TypedData::InstanceSize(lengthInBytes); | 764 return TypedData::InstanceSize(lengthInBytes); |
1058 } | 765 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1096 | 803 |
1097 intptr_t RawWeakProperty::VisitWeakPropertyPointers( | 804 intptr_t RawWeakProperty::VisitWeakPropertyPointers( |
1098 RawWeakProperty* raw_obj, ObjectPointerVisitor* visitor) { | 805 RawWeakProperty* raw_obj, ObjectPointerVisitor* visitor) { |
1099 // Make sure that we got here with the tagged pointer as this. | 806 // Make sure that we got here with the tagged pointer as this. |
1100 ASSERT(raw_obj->IsHeapObject()); | 807 ASSERT(raw_obj->IsHeapObject()); |
1101 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 808 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
1102 return WeakProperty::InstanceSize(); | 809 return WeakProperty::InstanceSize(); |
1103 } | 810 } |
1104 | 811 |
1105 } // namespace dart | 812 } // namespace dart |
OLD | NEW |