| 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/object.h" | 5 #include "vm/object.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
| 10 #include "vm/bigint_operations.h" | 10 #include "vm/bigint_operations.h" |
| (...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 847 RegisterPrivateClass(cls, Symbols::_WeakProperty(), core_lib); | 847 RegisterPrivateClass(cls, Symbols::_WeakProperty(), core_lib); |
| 848 | 848 |
| 849 // Setup some default native field classes which can be extended for | 849 // Setup some default native field classes which can be extended for |
| 850 // specifying native fields in dart classes. | 850 // specifying native fields in dart classes. |
| 851 Library::InitNativeWrappersLibrary(isolate); | 851 Library::InitNativeWrappersLibrary(isolate); |
| 852 ASSERT(isolate->object_store()->native_wrappers_library() != Library::null()); | 852 ASSERT(isolate->object_store()->native_wrappers_library() != Library::null()); |
| 853 | 853 |
| 854 // Pre-register the scalarlist library so the native class implementations | 854 // Pre-register the scalarlist library so the native class implementations |
| 855 // can be hooked up before compiling it. | 855 // can be hooked up before compiling it. |
| 856 LOAD_LIBRARY(Scalarlist, scalarlist); | 856 LOAD_LIBRARY(Scalarlist, scalarlist); |
| 857 ASSERT(!lib.IsNull()); |
| 858 ASSERT(lib.raw() == Library::ScalarlistLibrary()); |
| 859 #define REGISTER_SCALARLIST_CLASS(name, object_store_name) \ |
| 860 cls = Class::New<name>(); \ |
| 861 object_store->set_##object_store_name##_class(cls); \ |
| 862 RegisterPrivateClass(cls, Symbols::_##name(), lib); \ |
| 857 | 863 |
| 858 Library& scalarlist_lib = Library::Handle(Library::ScalarlistLibrary()); | 864 REGISTER_SCALARLIST_CLASS(Float32x4, float32x4); |
| 859 ASSERT(!scalarlist_lib.IsNull()); | 865 REGISTER_SCALARLIST_CLASS(Uint32x4, uint32x4); |
| 866 REGISTER_SCALARLIST_CLASS(Int8Array, int8_array); |
| 867 REGISTER_SCALARLIST_CLASS(Uint8Array, uint8_array); |
| 868 REGISTER_SCALARLIST_CLASS(Uint8ClampedArray, uint8_clamped_array); |
| 869 REGISTER_SCALARLIST_CLASS(Int16Array, int16_array); |
| 870 REGISTER_SCALARLIST_CLASS(Uint16Array, uint16_array); |
| 871 REGISTER_SCALARLIST_CLASS(Int32Array, int32_array); |
| 872 REGISTER_SCALARLIST_CLASS(Uint32Array, uint32_array); |
| 873 REGISTER_SCALARLIST_CLASS(Int64Array, int64_array); |
| 874 REGISTER_SCALARLIST_CLASS(Uint64Array, uint64_array); |
| 875 REGISTER_SCALARLIST_CLASS(Float32x4Array, float32x4_array); |
| 876 REGISTER_SCALARLIST_CLASS(Float32Array, float32_array); |
| 877 REGISTER_SCALARLIST_CLASS(Float64Array, float64_array); |
| 878 REGISTER_SCALARLIST_CLASS(ExternalInt8Array, external_int8_array); |
| 879 REGISTER_SCALARLIST_CLASS(ExternalUint8Array, external_uint8_array); |
| 880 REGISTER_SCALARLIST_CLASS(ExternalUint8ClampedArray, |
| 881 external_uint8_clamped_array); |
| 882 REGISTER_SCALARLIST_CLASS(ExternalInt16Array, external_int16_array); |
| 883 REGISTER_SCALARLIST_CLASS(ExternalUint16Array, external_uint16_array); |
| 884 REGISTER_SCALARLIST_CLASS(ExternalInt32Array, external_int32_array); |
| 885 REGISTER_SCALARLIST_CLASS(ExternalUint32Array, external_uint32_array); |
| 886 REGISTER_SCALARLIST_CLASS(ExternalInt64Array, external_int64_array); |
| 887 REGISTER_SCALARLIST_CLASS(ExternalUint64Array, external_uint64_array); |
| 888 REGISTER_SCALARLIST_CLASS(ExternalFloat32x4Array, external_float32x4_array); |
| 889 REGISTER_SCALARLIST_CLASS(ExternalFloat32Array, external_float32_array); |
| 890 REGISTER_SCALARLIST_CLASS(ExternalFloat64Array, external_float64_array); |
| 891 #undef REGISTER_SCALARLIST_CLASS |
| 860 | 892 |
| 861 cls = Class::New<Float32x4>(); | 893 // Pre-register the typeddata library so the native class implementations |
| 862 object_store->set_float32x4_class(cls); | 894 // can be hooked up before compiling it. |
| 863 RegisterPrivateClass(cls, Symbols::_Float32x4(), scalarlist_lib); | 895 LOAD_LIBRARY(TypedData, typeddata); |
| 896 ASSERT(!lib.IsNull()); |
| 897 ASSERT(lib.raw() == Library::TypedDataLibrary()); |
| 898 Array& typeddata_classes = |
| 899 Array::Handle(Array::New(RawObject::NumberOfTypedDataClasses())); |
| 900 int index = 0; |
| 901 #define REGISTER_TYPED_DATA_CLASS(clazz) \ |
| 902 cls = Class::NewTypedDataClass(kTypedData##clazz##Cid); \ |
| 903 index = kTypedData##clazz##Cid - kTypedDataInt8ArrayCid; \ |
| 904 typeddata_classes.SetAt(index, cls); \ |
| 905 RegisterPrivateClass(cls, Symbols::_##clazz(), lib); \ |
| 864 | 906 |
| 865 cls = Class::New<Uint32x4>(); | 907 CLASS_LIST_TYPED_DATA(REGISTER_TYPED_DATA_CLASS); |
| 866 object_store->set_uint32x4_class(cls); | 908 #undef REGISTER_TYPED_DATA_CLASS |
| 867 RegisterPrivateClass(cls, Symbols::_Uint32x4(), scalarlist_lib); | 909 #define REGISTER_EXT_TYPED_DATA_CLASS(clazz) \ |
| 910 cls = Class::NewExternalTypedDataClass(kExternalTypedData##clazz##Cid); \ |
| 911 index = kExternalTypedData##clazz##Cid - kTypedDataInt8ArrayCid; \ |
| 912 typeddata_classes.SetAt(index, cls); \ |
| 913 RegisterPrivateClass(cls, Symbols::_External##clazz(), lib); \ |
| 868 | 914 |
| 869 cls = Class::New<Int8Array>(); | 915 CLASS_LIST_TYPED_DATA(REGISTER_EXT_TYPED_DATA_CLASS); |
| 870 object_store->set_int8_array_class(cls); | 916 #undef REGISTER_EXT_TYPED_DATA_CLASS |
| 871 RegisterPrivateClass(cls, Symbols::_Int8Array(), scalarlist_lib); | 917 object_store->set_typeddata_classes(typeddata_classes); |
| 872 | |
| 873 cls = Class::New<Uint8Array>(); | |
| 874 object_store->set_uint8_array_class(cls); | |
| 875 RegisterPrivateClass(cls, Symbols::_Uint8Array(), scalarlist_lib); | |
| 876 | |
| 877 cls = Class::New<Uint8ClampedArray>(); | |
| 878 object_store->set_uint8_clamped_array_class(cls); | |
| 879 RegisterPrivateClass(cls, Symbols::_Uint8ClampedArray(), scalarlist_lib); | |
| 880 | |
| 881 cls = Class::New<Int16Array>(); | |
| 882 object_store->set_int16_array_class(cls); | |
| 883 RegisterPrivateClass(cls, Symbols::_Int16Array(), scalarlist_lib); | |
| 884 | |
| 885 cls = Class::New<Uint16Array>(); | |
| 886 object_store->set_uint16_array_class(cls); | |
| 887 RegisterPrivateClass(cls, Symbols::_Uint16Array(), scalarlist_lib); | |
| 888 | |
| 889 cls = Class::New<Int32Array>(); | |
| 890 object_store->set_int32_array_class(cls); | |
| 891 RegisterPrivateClass(cls, Symbols::_Int32Array(), scalarlist_lib); | |
| 892 | |
| 893 cls = Class::New<Uint32Array>(); | |
| 894 object_store->set_uint32_array_class(cls); | |
| 895 RegisterPrivateClass(cls, Symbols::_Uint32Array(), scalarlist_lib); | |
| 896 | |
| 897 cls = Class::New<Int64Array>(); | |
| 898 object_store->set_int64_array_class(cls); | |
| 899 RegisterPrivateClass(cls, Symbols::_Int64Array(), scalarlist_lib); | |
| 900 | |
| 901 cls = Class::New<Uint64Array>(); | |
| 902 object_store->set_uint64_array_class(cls); | |
| 903 RegisterPrivateClass(cls, Symbols::_Uint64Array(), scalarlist_lib); | |
| 904 | |
| 905 cls = Class::New<Float32x4Array>(); | |
| 906 object_store->set_float32x4_array_class(cls); | |
| 907 RegisterPrivateClass(cls, Symbols::_Float32x4Array(), scalarlist_lib); | |
| 908 | |
| 909 cls = Class::New<Float32Array>(); | |
| 910 object_store->set_float32_array_class(cls); | |
| 911 RegisterPrivateClass(cls, Symbols::_Float32Array(), scalarlist_lib); | |
| 912 | |
| 913 cls = Class::New<Float64Array>(); | |
| 914 object_store->set_float64_array_class(cls); | |
| 915 RegisterPrivateClass(cls, Symbols::_Float64Array(), scalarlist_lib); | |
| 916 | |
| 917 cls = Class::New<ExternalInt8Array>(); | |
| 918 object_store->set_external_int8_array_class(cls); | |
| 919 RegisterPrivateClass(cls, Symbols::_ExternalInt8Array(), scalarlist_lib); | |
| 920 | |
| 921 cls = Class::New<ExternalUint8Array>(); | |
| 922 object_store->set_external_uint8_array_class(cls); | |
| 923 RegisterPrivateClass(cls, Symbols::_ExternalUint8Array(), scalarlist_lib); | |
| 924 | |
| 925 cls = Class::New<ExternalUint8ClampedArray>(); | |
| 926 object_store->set_external_uint8_clamped_array_class(cls); | |
| 927 RegisterPrivateClass(cls, | |
| 928 Symbols::_ExternalUint8ClampedArray(), | |
| 929 scalarlist_lib); | |
| 930 | |
| 931 cls = Class::New<ExternalInt16Array>(); | |
| 932 object_store->set_external_int16_array_class(cls); | |
| 933 RegisterPrivateClass(cls, Symbols::_ExternalInt16Array(), scalarlist_lib); | |
| 934 | |
| 935 cls = Class::New<ExternalUint16Array>(); | |
| 936 object_store->set_external_uint16_array_class(cls); | |
| 937 RegisterPrivateClass(cls, Symbols::_ExternalUint16Array(), scalarlist_lib); | |
| 938 | |
| 939 cls = Class::New<ExternalInt32Array>(); | |
| 940 object_store->set_external_int32_array_class(cls); | |
| 941 RegisterPrivateClass(cls, Symbols::_ExternalInt32Array(), scalarlist_lib); | |
| 942 | |
| 943 cls = Class::New<ExternalUint32Array>(); | |
| 944 object_store->set_external_uint32_array_class(cls); | |
| 945 RegisterPrivateClass(cls, Symbols::_ExternalUint32Array(), scalarlist_lib); | |
| 946 | |
| 947 cls = Class::New<ExternalInt64Array>(); | |
| 948 object_store->set_external_int64_array_class(cls); | |
| 949 RegisterPrivateClass(cls, Symbols::_ExternalInt64Array(), scalarlist_lib); | |
| 950 | |
| 951 cls = Class::New<ExternalUint64Array>(); | |
| 952 object_store->set_external_uint64_array_class(cls); | |
| 953 RegisterPrivateClass(cls, Symbols::_ExternalUint64Array(), scalarlist_lib); | |
| 954 | |
| 955 cls = Class::New<ExternalFloat32x4Array>(); | |
| 956 object_store->set_external_float32x4_array_class(cls); | |
| 957 RegisterPrivateClass(cls, Symbols::_ExternalFloat32x4Array(), | |
| 958 scalarlist_lib); | |
| 959 | |
| 960 cls = Class::New<ExternalFloat32Array>(); | |
| 961 object_store->set_external_float32_array_class(cls); | |
| 962 RegisterPrivateClass(cls, Symbols::_ExternalFloat32Array(), scalarlist_lib); | |
| 963 | |
| 964 cls = Class::New<ExternalFloat64Array>(); | |
| 965 object_store->set_external_float64_array_class(cls); | |
| 966 RegisterPrivateClass(cls, Symbols::_ExternalFloat64Array(), scalarlist_lib); | |
| 967 | 918 |
| 968 // Set the super type of class Stacktrace to Object type so that the | 919 // Set the super type of class Stacktrace to Object type so that the |
| 969 // 'toString' method is implemented. | 920 // 'toString' method is implemented. |
| 970 cls = object_store->stacktrace_class(); | 921 cls = object_store->stacktrace_class(); |
| 971 cls.set_super_type(type); | 922 cls.set_super_type(type); |
| 972 | 923 |
| 973 // Note: The abstract class Function is represented by VM class | 924 // Note: The abstract class Function is represented by VM class |
| 974 // DartFunction, not VM class Function. | 925 // DartFunction, not VM class Function. |
| 975 cls = Class::New<DartFunction>(); | 926 cls = Class::New<DartFunction>(); |
| 976 RegisterClass(cls, Symbols::Function(), core_lib); | 927 RegisterClass(cls, Symbols::Function(), core_lib); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1101 | 1052 |
| 1102 cls = Class::New<Array>(); | 1053 cls = Class::New<Array>(); |
| 1103 object_store->set_array_class(cls); | 1054 object_store->set_array_class(cls); |
| 1104 | 1055 |
| 1105 cls = Class::New<ImmutableArray>(); | 1056 cls = Class::New<ImmutableArray>(); |
| 1106 object_store->set_immutable_array_class(cls); | 1057 object_store->set_immutable_array_class(cls); |
| 1107 | 1058 |
| 1108 cls = Class::New<GrowableObjectArray>(); | 1059 cls = Class::New<GrowableObjectArray>(); |
| 1109 object_store->set_growable_object_array_class(cls); | 1060 object_store->set_growable_object_array_class(cls); |
| 1110 | 1061 |
| 1111 cls = Class::New<Float32x4>(); | 1062 #define REGISTER_SCALARLIST_CLASS(name, object_store_name) \ |
| 1112 object_store->set_float32x4_class(cls); | 1063 cls = Class::New<name>(); \ |
| 1064 object_store->set_##object_store_name##_class(cls); \ |
| 1113 | 1065 |
| 1114 cls = Class::New<Uint32x4>(); | 1066 REGISTER_SCALARLIST_CLASS(Float32x4, float32x4); |
| 1115 object_store->set_uint32x4_class(cls); | 1067 REGISTER_SCALARLIST_CLASS(Uint32x4, uint32x4); |
| 1068 REGISTER_SCALARLIST_CLASS(Int8Array, int8_array); |
| 1069 REGISTER_SCALARLIST_CLASS(Uint8Array, uint8_array); |
| 1070 REGISTER_SCALARLIST_CLASS(Uint8ClampedArray, uint8_clamped_array); |
| 1071 REGISTER_SCALARLIST_CLASS(Int16Array, int16_array); |
| 1072 REGISTER_SCALARLIST_CLASS(Uint16Array, uint16_array); |
| 1073 REGISTER_SCALARLIST_CLASS(Int32Array, int32_array); |
| 1074 REGISTER_SCALARLIST_CLASS(Uint32Array, uint32_array); |
| 1075 REGISTER_SCALARLIST_CLASS(Int64Array, int64_array); |
| 1076 REGISTER_SCALARLIST_CLASS(Uint64Array, uint64_array); |
| 1077 REGISTER_SCALARLIST_CLASS(Float32x4Array, float32x4_array); |
| 1078 REGISTER_SCALARLIST_CLASS(Float32Array, float32_array); |
| 1079 REGISTER_SCALARLIST_CLASS(Float64Array, float64_array); |
| 1080 REGISTER_SCALARLIST_CLASS(ExternalInt8Array, external_int8_array); |
| 1081 REGISTER_SCALARLIST_CLASS(ExternalUint8Array, external_uint8_array); |
| 1082 REGISTER_SCALARLIST_CLASS(ExternalUint8ClampedArray, |
| 1083 external_uint8_clamped_array); |
| 1084 REGISTER_SCALARLIST_CLASS(ExternalInt16Array, external_int16_array); |
| 1085 REGISTER_SCALARLIST_CLASS(ExternalUint16Array, external_uint16_array); |
| 1086 REGISTER_SCALARLIST_CLASS(ExternalInt32Array, external_int32_array); |
| 1087 REGISTER_SCALARLIST_CLASS(ExternalUint32Array, external_uint32_array); |
| 1088 REGISTER_SCALARLIST_CLASS(ExternalInt64Array, external_int64_array); |
| 1089 REGISTER_SCALARLIST_CLASS(ExternalUint64Array, external_uint64_array); |
| 1090 REGISTER_SCALARLIST_CLASS(ExternalFloat32x4Array, external_float32x4_array); |
| 1091 REGISTER_SCALARLIST_CLASS(ExternalFloat32Array, external_float32_array); |
| 1092 REGISTER_SCALARLIST_CLASS(ExternalFloat64Array, external_float64_array); |
| 1093 #undef REGISTER_SCALARLIST_CLASS |
| 1116 | 1094 |
| 1117 cls = Class::New<Int8Array>(); | 1095 #define REGISTER_TYPED_DATA_CLASS(clazz) \ |
| 1118 object_store->set_int8_array_class(cls); | 1096 cls = Class::NewTypedDataClass(kTypedData##clazz##Cid); |
| 1119 | 1097 CLASS_LIST_TYPED_DATA(REGISTER_TYPED_DATA_CLASS); |
| 1120 cls = Class::New<Uint8Array>(); | 1098 #undef REGISTER_TYPED_DATA_CLASS |
| 1121 object_store->set_uint8_array_class(cls); | 1099 #define REGISTER_EXT_TYPED_DATA_CLASS(clazz) \ |
| 1122 | 1100 cls = Class::NewExternalTypedDataClass(kExternalTypedData##clazz##Cid); |
| 1123 cls = Class::New<Uint8ClampedArray>(); | 1101 CLASS_LIST_TYPED_DATA(REGISTER_EXT_TYPED_DATA_CLASS); |
| 1124 object_store->set_uint8_clamped_array_class(cls); | 1102 #undef REGISTER_EXT_TYPED_DATA_CLASS |
| 1125 | |
| 1126 cls = Class::New<Int16Array>(); | |
| 1127 object_store->set_int16_array_class(cls); | |
| 1128 | |
| 1129 cls = Class::New<Uint16Array>(); | |
| 1130 object_store->set_uint16_array_class(cls); | |
| 1131 | |
| 1132 cls = Class::New<Int32Array>(); | |
| 1133 object_store->set_int32_array_class(cls); | |
| 1134 | |
| 1135 cls = Class::New<Uint32Array>(); | |
| 1136 object_store->set_uint32_array_class(cls); | |
| 1137 | |
| 1138 cls = Class::New<Int64Array>(); | |
| 1139 object_store->set_int64_array_class(cls); | |
| 1140 | |
| 1141 cls = Class::New<Uint64Array>(); | |
| 1142 object_store->set_uint64_array_class(cls); | |
| 1143 | |
| 1144 cls = Class::New<Float32x4Array>(); | |
| 1145 object_store->set_float32x4_array_class(cls); | |
| 1146 | |
| 1147 cls = Class::New<Float32Array>(); | |
| 1148 object_store->set_float32_array_class(cls); | |
| 1149 | |
| 1150 cls = Class::New<Float64Array>(); | |
| 1151 object_store->set_float64_array_class(cls); | |
| 1152 | |
| 1153 cls = Class::New<ExternalInt8Array>(); | |
| 1154 object_store->set_external_int8_array_class(cls); | |
| 1155 | |
| 1156 cls = Class::New<ExternalUint8Array>(); | |
| 1157 object_store->set_external_uint8_array_class(cls); | |
| 1158 | |
| 1159 cls = Class::New<ExternalUint8ClampedArray>(); | |
| 1160 object_store->set_external_uint8_clamped_array_class(cls); | |
| 1161 | |
| 1162 cls = Class::New<ExternalInt16Array>(); | |
| 1163 object_store->set_external_int16_array_class(cls); | |
| 1164 | |
| 1165 cls = Class::New<ExternalUint16Array>(); | |
| 1166 object_store->set_external_uint16_array_class(cls); | |
| 1167 | |
| 1168 cls = Class::New<ExternalInt32Array>(); | |
| 1169 object_store->set_external_int32_array_class(cls); | |
| 1170 | |
| 1171 cls = Class::New<ExternalUint32Array>(); | |
| 1172 object_store->set_external_uint32_array_class(cls); | |
| 1173 | |
| 1174 cls = Class::New<ExternalInt64Array>(); | |
| 1175 object_store->set_external_int64_array_class(cls); | |
| 1176 | |
| 1177 cls = Class::New<ExternalUint64Array>(); | |
| 1178 object_store->set_external_uint64_array_class(cls); | |
| 1179 | |
| 1180 cls = Class::New<ExternalFloat32x4Array>(); | |
| 1181 object_store->set_external_float32x4_array_class(cls); | |
| 1182 | |
| 1183 cls = Class::New<ExternalFloat32Array>(); | |
| 1184 object_store->set_external_float32_array_class(cls); | |
| 1185 | |
| 1186 cls = Class::New<ExternalFloat64Array>(); | |
| 1187 object_store->set_external_float64_array_class(cls); | |
| 1188 | 1103 |
| 1189 cls = Class::New<Integer>(); | 1104 cls = Class::New<Integer>(); |
| 1190 object_store->set_integer_implementation_class(cls); | 1105 object_store->set_integer_implementation_class(cls); |
| 1191 | 1106 |
| 1192 cls = Class::New<Smi>(); | 1107 cls = Class::New<Smi>(); |
| 1193 object_store->set_smi_class(cls); | 1108 object_store->set_smi_class(cls); |
| 1194 | 1109 |
| 1195 cls = Class::New<Mint>(); | 1110 cls = Class::New<Mint>(); |
| 1196 object_store->set_mint_class(cls); | 1111 object_store->set_mint_class(cls); |
| 1197 | 1112 |
| (...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2004 instance_size = ExternalTwoByteString::InstanceSize(); | 1919 instance_size = ExternalTwoByteString::InstanceSize(); |
| 2005 } | 1920 } |
| 2006 Class& result = Class::Handle(New<String>(class_id)); | 1921 Class& result = Class::Handle(New<String>(class_id)); |
| 2007 result.set_instance_size(instance_size); | 1922 result.set_instance_size(instance_size); |
| 2008 result.set_next_field_offset(instance_size); | 1923 result.set_next_field_offset(instance_size); |
| 2009 result.set_is_prefinalized(); | 1924 result.set_is_prefinalized(); |
| 2010 return result.raw(); | 1925 return result.raw(); |
| 2011 } | 1926 } |
| 2012 | 1927 |
| 2013 | 1928 |
| 1929 RawClass* Class::NewTypedDataClass(intptr_t class_id) { |
| 1930 ASSERT(RawObject::IsTypedDataClassId(class_id)); |
| 1931 intptr_t instance_size = TypedData::InstanceSize(); |
| 1932 Class& result = Class::Handle(New<TypedData>(class_id)); |
| 1933 result.set_instance_size(instance_size); |
| 1934 result.set_next_field_offset(instance_size); |
| 1935 result.set_is_prefinalized(); |
| 1936 return result.raw(); |
| 1937 } |
| 1938 |
| 1939 |
| 1940 RawClass* Class::NewExternalTypedDataClass(intptr_t class_id) { |
| 1941 ASSERT(RawObject::IsExternalTypedDataClassId(class_id)); |
| 1942 intptr_t instance_size = ExternalTypedData::InstanceSize(); |
| 1943 Class& result = Class::Handle(New<ExternalTypedData>(class_id)); |
| 1944 result.set_instance_size(instance_size); |
| 1945 result.set_next_field_offset(instance_size); |
| 1946 result.set_is_prefinalized(); |
| 1947 return result.raw(); |
| 1948 } |
| 1949 |
| 1950 |
| 2014 void Class::set_name(const String& value) const { | 1951 void Class::set_name(const String& value) const { |
| 2015 ASSERT(value.IsSymbol()); | 1952 ASSERT(value.IsSymbol()); |
| 2016 StorePointer(&raw_ptr()->name_, value.raw()); | 1953 StorePointer(&raw_ptr()->name_, value.raw()); |
| 2017 } | 1954 } |
| 2018 | 1955 |
| 2019 | 1956 |
| 2020 void Class::set_script(const Script& value) const { | 1957 void Class::set_script(const Script& value) const { |
| 2021 StorePointer(&raw_ptr()->script_, value.raw()); | 1958 StorePointer(&raw_ptr()->script_, value.raw()); |
| 2022 } | 1959 } |
| 2023 | 1960 |
| (...skipping 10386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12410 uint32_t _z = z(); | 12347 uint32_t _z = z(); |
| 12411 uint32_t _w = w(); | 12348 uint32_t _w = w(); |
| 12412 // Calculate the size of the string. | 12349 // Calculate the size of the string. |
| 12413 intptr_t len = OS::SNPrint(NULL, 0, kFormat, _x, _y, _z, _w) + 1; | 12350 intptr_t len = OS::SNPrint(NULL, 0, kFormat, _x, _y, _z, _w) + 1; |
| 12414 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 12351 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 12415 OS::SNPrint(chars, len, kFormat, _x, _y, _z, _w); | 12352 OS::SNPrint(chars, len, kFormat, _x, _y, _z, _w); |
| 12416 return chars; | 12353 return chars; |
| 12417 } | 12354 } |
| 12418 | 12355 |
| 12419 | 12356 |
| 12357 const intptr_t TypedData::element_size[] = { |
| 12358 1, // kTypedDataInt8ArrayCid. |
| 12359 1, // kTypedDataUint8ArrayCid. |
| 12360 1, // kTypedDataUint8ClampedArrayCid. |
| 12361 2, // kTypedDataInt16ArrayCid. |
| 12362 2, // kTypedDataUint16ArrayCid. |
| 12363 4, // kTypedDataInt32ArrayCid. |
| 12364 4, // kTypedDataUint32ArrayCid. |
| 12365 8, // kTypedDataInt64ArrayCid. |
| 12366 8, // kTypedDataUint64ArrayCid. |
| 12367 4, // kTypedDataFloat32ArrayCid. |
| 12368 8, // kTypedDataFloat64ArrayCid. |
| 12369 }; |
| 12370 |
| 12371 |
| 12372 RawTypedData* TypedData::New(intptr_t class_id, |
| 12373 intptr_t len, |
| 12374 Heap::Space space) { |
| 12375 // TODO(asiva): Add a check for maximum elements. |
| 12376 TypedData& result = TypedData::Handle(); |
| 12377 { |
| 12378 // The len field has already been checked by the caller, we only assert |
| 12379 // here that it is within a valid range. |
| 12380 ASSERT((len >= 0) && |
| 12381 (len < (kSmiMax / TypedData::ElementSizeInBytes(class_id)))); |
| 12382 intptr_t lengthInBytes = len * ElementSizeInBytes(class_id); |
| 12383 RawObject* raw = Object::Allocate(class_id, |
| 12384 TypedData::InstanceSize(lengthInBytes), |
| 12385 space); |
| 12386 NoGCScope no_gc; |
| 12387 result ^= raw; |
| 12388 result.SetLength(len); |
| 12389 if (len > 0) { |
| 12390 memset(result.DataAddr(0), 0, lengthInBytes); |
| 12391 } |
| 12392 } |
| 12393 return result.raw(); |
| 12394 } |
| 12395 |
| 12396 |
| 12397 const char* TypedData::ToCString() const { |
| 12398 return "TypedData"; |
| 12399 } |
| 12400 |
| 12401 |
| 12402 FinalizablePersistentHandle* ExternalTypedData::AddFinalizer( |
| 12403 void* peer, Dart_WeakPersistentHandleFinalizer callback) const { |
| 12404 SetPeer(peer); |
| 12405 return dart::AddFinalizer(*this, peer, callback); |
| 12406 } |
| 12407 |
| 12408 |
| 12409 RawExternalTypedData* ExternalTypedData::New(intptr_t class_id, |
| 12410 uint8_t* data, |
| 12411 intptr_t len, |
| 12412 Heap::Space space) { |
| 12413 ExternalTypedData& result = ExternalTypedData::Handle(); |
| 12414 { |
| 12415 RawObject* raw = Object::Allocate(class_id, |
| 12416 ExternalTypedData::InstanceSize(), |
| 12417 space); |
| 12418 NoGCScope no_gc; |
| 12419 result ^= raw; |
| 12420 result.SetLength(len); |
| 12421 result.SetData(data); |
| 12422 } |
| 12423 return result.raw(); |
| 12424 } |
| 12425 |
| 12426 |
| 12427 const char* ExternalTypedData::ToCString() const { |
| 12428 return "ExternalTypedData"; |
| 12429 } |
| 12430 |
| 12431 |
| 12420 void ByteArray::Copy(void* dst, | 12432 void ByteArray::Copy(void* dst, |
| 12421 const ByteArray& src, | 12433 const ByteArray& src, |
| 12422 intptr_t src_offset, | 12434 intptr_t src_offset, |
| 12423 intptr_t length) { | 12435 intptr_t length) { |
| 12424 ASSERT(Utils::RangeCheck(src_offset, length, src.ByteLength())); | 12436 ASSERT(Utils::RangeCheck(src_offset, length, src.ByteLength())); |
| 12425 { | 12437 { |
| 12426 NoGCScope no_gc; | 12438 NoGCScope no_gc; |
| 12427 if (length > 0) { | 12439 if (length > 0) { |
| 12428 memmove(dst, src.ByteAddr(src_offset), length); | 12440 memmove(dst, src.ByteAddr(src_offset), length); |
| 12429 } | 12441 } |
| (...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13385 } | 13397 } |
| 13386 return result.raw(); | 13398 return result.raw(); |
| 13387 } | 13399 } |
| 13388 | 13400 |
| 13389 | 13401 |
| 13390 const char* WeakProperty::ToCString() const { | 13402 const char* WeakProperty::ToCString() const { |
| 13391 return "_WeakProperty"; | 13403 return "_WeakProperty"; |
| 13392 } | 13404 } |
| 13393 | 13405 |
| 13394 } // namespace dart | 13406 } // namespace dart |
| OLD | NEW |