Chromium Code Reviews| 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 843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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()); | 857 ASSERT(!lib.IsNull()); |
| 858 ASSERT(lib.raw() == Library::ScalarlistLibrary()); | 858 ASSERT(lib.raw() == Library::ScalarlistLibrary()); |
| 859 #define REGISTER_SCALARLIST_CLASS(name, object_store_name) \ | 859 #define REGISTER_SCALARLIST_CLASS(name, object_store_name) \ |
| 860 cls = Class::New<name>(); \ | 860 cls = Class::New<name>(); \ |
| 861 object_store->set_##object_store_name##_class(cls); \ | 861 object_store->set_##object_store_name##_class(cls); \ |
| 862 RegisterPrivateClass(cls, Symbols::_##name(), lib); \ | 862 RegisterPrivateClass(cls, Symbols::_##name(), lib); \ |
| 863 | 863 |
| 864 REGISTER_SCALARLIST_CLASS(Float32x4, float32x4); | |
| 865 REGISTER_SCALARLIST_CLASS(Uint32x4, uint32x4); | |
| 866 REGISTER_SCALARLIST_CLASS(Int8Array, int8_array); | 864 REGISTER_SCALARLIST_CLASS(Int8Array, int8_array); |
| 867 REGISTER_SCALARLIST_CLASS(Uint8Array, uint8_array); | 865 REGISTER_SCALARLIST_CLASS(Uint8Array, uint8_array); |
| 868 REGISTER_SCALARLIST_CLASS(Uint8ClampedArray, uint8_clamped_array); | 866 REGISTER_SCALARLIST_CLASS(Uint8ClampedArray, uint8_clamped_array); |
| 869 REGISTER_SCALARLIST_CLASS(Int16Array, int16_array); | 867 REGISTER_SCALARLIST_CLASS(Int16Array, int16_array); |
| 870 REGISTER_SCALARLIST_CLASS(Uint16Array, uint16_array); | 868 REGISTER_SCALARLIST_CLASS(Uint16Array, uint16_array); |
| 871 REGISTER_SCALARLIST_CLASS(Int32Array, int32_array); | 869 REGISTER_SCALARLIST_CLASS(Int32Array, int32_array); |
| 872 REGISTER_SCALARLIST_CLASS(Uint32Array, uint32_array); | 870 REGISTER_SCALARLIST_CLASS(Uint32Array, uint32_array); |
| 873 REGISTER_SCALARLIST_CLASS(Int64Array, int64_array); | 871 REGISTER_SCALARLIST_CLASS(Int64Array, int64_array); |
| 874 REGISTER_SCALARLIST_CLASS(Uint64Array, uint64_array); | 872 REGISTER_SCALARLIST_CLASS(Uint64Array, uint64_array); |
| 875 REGISTER_SCALARLIST_CLASS(Float32x4Array, float32x4_array); | 873 REGISTER_SCALARLIST_CLASS(Float32x4Array, float32x4_array); |
| 876 REGISTER_SCALARLIST_CLASS(Float32Array, float32_array); | 874 REGISTER_SCALARLIST_CLASS(Float32Array, float32_array); |
| 877 REGISTER_SCALARLIST_CLASS(Float64Array, float64_array); | 875 REGISTER_SCALARLIST_CLASS(Float64Array, float64_array); |
| 878 REGISTER_SCALARLIST_CLASS(ExternalInt8Array, external_int8_array); | 876 REGISTER_SCALARLIST_CLASS(ExternalInt8Array, external_int8_array); |
| 879 REGISTER_SCALARLIST_CLASS(ExternalUint8Array, external_uint8_array); | 877 REGISTER_SCALARLIST_CLASS(ExternalUint8Array, external_uint8_array); |
| 880 REGISTER_SCALARLIST_CLASS(ExternalUint8ClampedArray, | 878 REGISTER_SCALARLIST_CLASS(ExternalUint8ClampedArray, |
| 881 external_uint8_clamped_array); | 879 external_uint8_clamped_array); |
| 882 REGISTER_SCALARLIST_CLASS(ExternalInt16Array, external_int16_array); | 880 REGISTER_SCALARLIST_CLASS(ExternalInt16Array, external_int16_array); |
| 883 REGISTER_SCALARLIST_CLASS(ExternalUint16Array, external_uint16_array); | 881 REGISTER_SCALARLIST_CLASS(ExternalUint16Array, external_uint16_array); |
| 884 REGISTER_SCALARLIST_CLASS(ExternalInt32Array, external_int32_array); | 882 REGISTER_SCALARLIST_CLASS(ExternalInt32Array, external_int32_array); |
| 885 REGISTER_SCALARLIST_CLASS(ExternalUint32Array, external_uint32_array); | 883 REGISTER_SCALARLIST_CLASS(ExternalUint32Array, external_uint32_array); |
| 886 REGISTER_SCALARLIST_CLASS(ExternalInt64Array, external_int64_array); | 884 REGISTER_SCALARLIST_CLASS(ExternalInt64Array, external_int64_array); |
| 887 REGISTER_SCALARLIST_CLASS(ExternalUint64Array, external_uint64_array); | 885 REGISTER_SCALARLIST_CLASS(ExternalUint64Array, external_uint64_array); |
| 888 REGISTER_SCALARLIST_CLASS(ExternalFloat32x4Array, external_float32x4_array); | 886 REGISTER_SCALARLIST_CLASS(ExternalFloat32x4Array, external_float32x4_array); |
| 889 REGISTER_SCALARLIST_CLASS(ExternalFloat32Array, external_float32_array); | 887 REGISTER_SCALARLIST_CLASS(ExternalFloat32Array, external_float32_array); |
| 890 REGISTER_SCALARLIST_CLASS(ExternalFloat64Array, external_float64_array); | 888 REGISTER_SCALARLIST_CLASS(ExternalFloat64Array, external_float64_array); |
| 891 #undef REGISTER_SCALARLIST_CLASS | 889 #undef REGISTER_SCALARLIST_CLASS |
| 890 // Add Float32x4 and Uint32x4 to dart:scalarlist and register them in | |
| 891 // object_store. | |
| 892 cls = Class::New<Float32x4>(); | |
| 893 object_store->set_float32x4_class(cls); | |
| 894 RegisterPrivateClass(cls, Symbols::_Float32x4(), lib); | |
| 895 cls = Class::New<Uint32x4>(); | |
| 896 object_store->set_uint32x4_class(cls); | |
| 897 RegisterPrivateClass(cls, Symbols::_Uint32x4(), lib); | |
|
siva
2013/03/12 11:44:22
Why are you adding these classes to the scalarlist
Cutch
2013/03/25 21:06:35
They were already available to scalarlist. What's
| |
| 898 | |
| 892 | 899 |
| 893 // Pre-register the typeddata library so the native class implementations | 900 // Pre-register the typeddata library so the native class implementations |
| 894 // can be hooked up before compiling it. | 901 // can be hooked up before compiling it. |
| 895 LOAD_LIBRARY(TypedData, typeddata); | 902 LOAD_LIBRARY(TypedData, typeddata); |
| 896 ASSERT(!lib.IsNull()); | 903 ASSERT(!lib.IsNull()); |
| 897 ASSERT(lib.raw() == Library::TypedDataLibrary()); | 904 ASSERT(lib.raw() == Library::TypedDataLibrary()); |
| 905 const intptr_t typeddata_class_array_length = | |
| 906 RawObject::NumberOfTypedDataClasses() + 2; // +2 for Float32x4 & Uint32x4 | |
| 898 Array& typeddata_classes = | 907 Array& typeddata_classes = |
| 899 Array::Handle(Array::New(RawObject::NumberOfTypedDataClasses())); | 908 Array::Handle(Array::New(typeddata_class_array_length)); |
| 900 int index = 0; | 909 int index = 0; |
| 901 #define REGISTER_TYPED_DATA_CLASS(clazz) \ | 910 #define REGISTER_TYPED_DATA_CLASS(clazz) \ |
| 902 cls = Class::NewTypedDataClass(kTypedData##clazz##Cid); \ | 911 cls = Class::NewTypedDataClass(kTypedData##clazz##Cid); \ |
| 903 index = kTypedData##clazz##Cid - kTypedDataInt8ArrayCid; \ | 912 index = kTypedData##clazz##Cid - kTypedDataInt8ArrayCid; \ |
| 904 typeddata_classes.SetAt(index, cls); \ | 913 typeddata_classes.SetAt(index, cls); \ |
| 905 RegisterPrivateClass(cls, Symbols::_##clazz(), lib); \ | 914 RegisterPrivateClass(cls, Symbols::_##clazz(), lib); \ |
| 906 | 915 |
| 907 CLASS_LIST_TYPED_DATA(REGISTER_TYPED_DATA_CLASS); | 916 CLASS_LIST_TYPED_DATA(REGISTER_TYPED_DATA_CLASS); |
| 908 #undef REGISTER_TYPED_DATA_CLASS | 917 #undef REGISTER_TYPED_DATA_CLASS |
| 909 #define REGISTER_EXT_TYPED_DATA_CLASS(clazz) \ | 918 #define REGISTER_EXT_TYPED_DATA_CLASS(clazz) \ |
| 910 cls = Class::NewExternalTypedDataClass(kExternalTypedData##clazz##Cid); \ | 919 cls = Class::NewExternalTypedDataClass(kExternalTypedData##clazz##Cid); \ |
| 911 index = kExternalTypedData##clazz##Cid - kTypedDataInt8ArrayCid; \ | 920 index = kExternalTypedData##clazz##Cid - kTypedDataInt8ArrayCid; \ |
| 912 typeddata_classes.SetAt(index, cls); \ | 921 typeddata_classes.SetAt(index, cls); \ |
| 913 RegisterPrivateClass(cls, Symbols::_External##clazz(), lib); \ | 922 RegisterPrivateClass(cls, Symbols::_External##clazz(), lib); \ |
| 914 | 923 |
| 915 CLASS_LIST_TYPED_DATA(REGISTER_EXT_TYPED_DATA_CLASS); | 924 CLASS_LIST_TYPED_DATA(REGISTER_EXT_TYPED_DATA_CLASS); |
| 916 #undef REGISTER_EXT_TYPED_DATA_CLASS | 925 #undef REGISTER_EXT_TYPED_DATA_CLASS |
| 926 // Add Float32x4 and Uint32x4 to dart:typeddata. | |
| 927 cls = object_store->float32x4_class(); | |
| 928 typeddata_classes.SetAt(typeddata_class_array_length-2, cls); | |
| 929 RegisterPrivateClass(cls, Symbols::_Float32x4(), lib); | |
| 930 cls = object_store->uint32x4_class(); | |
| 931 typeddata_classes.SetAt(typeddata_class_array_length-1, cls); | |
| 932 RegisterPrivateClass(cls, Symbols::_Uint32x4(), lib); | |
| 933 | |
| 917 object_store->set_typeddata_classes(typeddata_classes); | 934 object_store->set_typeddata_classes(typeddata_classes); |
| 918 | 935 |
| 919 // Set the super type of class Stacktrace to Object type so that the | 936 // Set the super type of class Stacktrace to Object type so that the |
| 920 // 'toString' method is implemented. | 937 // 'toString' method is implemented. |
| 921 cls = object_store->stacktrace_class(); | 938 cls = object_store->stacktrace_class(); |
| 922 cls.set_super_type(type); | 939 cls.set_super_type(type); |
| 923 | 940 |
| 924 // Note: The abstract class Function is represented by VM class | 941 // Note: The abstract class Function is represented by VM class |
| 925 // DartFunction, not VM class Function. | 942 // DartFunction, not VM class Function. |
| 926 cls = Class::New<DartFunction>(); | 943 cls = Class::New<DartFunction>(); |
| (...skipping 11421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 12348 uint32_t _w = w(); | 12365 uint32_t _w = w(); |
| 12349 // Calculate the size of the string. | 12366 // Calculate the size of the string. |
| 12350 intptr_t len = OS::SNPrint(NULL, 0, kFormat, _x, _y, _z, _w) + 1; | 12367 intptr_t len = OS::SNPrint(NULL, 0, kFormat, _x, _y, _z, _w) + 1; |
| 12351 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 12368 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 12352 OS::SNPrint(chars, len, kFormat, _x, _y, _z, _w); | 12369 OS::SNPrint(chars, len, kFormat, _x, _y, _z, _w); |
| 12353 return chars; | 12370 return chars; |
| 12354 } | 12371 } |
| 12355 | 12372 |
| 12356 | 12373 |
| 12357 const intptr_t TypedData::element_size[] = { | 12374 const intptr_t TypedData::element_size[] = { |
| 12358 1, // kTypedDataInt8ArrayCid. | 12375 1, // kTypedDataInt8ArrayCid. |
| 12359 1, // kTypedDataUint8ArrayCid. | 12376 1, // kTypedDataUint8ArrayCid. |
| 12360 1, // kTypedDataUint8ClampedArrayCid. | 12377 1, // kTypedDataUint8ClampedArrayCid. |
| 12361 2, // kTypedDataInt16ArrayCid. | 12378 2, // kTypedDataInt16ArrayCid. |
| 12362 2, // kTypedDataUint16ArrayCid. | 12379 2, // kTypedDataUint16ArrayCid. |
| 12363 4, // kTypedDataInt32ArrayCid. | 12380 4, // kTypedDataInt32ArrayCid. |
| 12364 4, // kTypedDataUint32ArrayCid. | 12381 4, // kTypedDataUint32ArrayCid. |
| 12365 8, // kTypedDataInt64ArrayCid. | 12382 8, // kTypedDataInt64ArrayCid. |
| 12366 8, // kTypedDataUint64ArrayCid. | 12383 8, // kTypedDataUint64ArrayCid. |
| 12367 4, // kTypedDataFloat32ArrayCid. | 12384 4, // kTypedDataFloat32ArrayCid. |
| 12368 8, // kTypedDataFloat64ArrayCid. | 12385 8, // kTypedDataFloat64ArrayCid. |
| 12386 16, // kTypedDataFloat32x4ArrayCid. | |
| 12369 }; | 12387 }; |
| 12370 | 12388 |
| 12371 | 12389 |
| 12372 RawTypedData* TypedData::New(intptr_t class_id, | 12390 RawTypedData* TypedData::New(intptr_t class_id, |
| 12373 intptr_t len, | 12391 intptr_t len, |
| 12374 Heap::Space space) { | 12392 Heap::Space space) { |
| 12375 // TODO(asiva): Add a check for maximum elements. | 12393 // TODO(asiva): Add a check for maximum elements. |
| 12376 TypedData& result = TypedData::Handle(); | 12394 TypedData& result = TypedData::Handle(); |
| 12377 { | 12395 { |
| 12378 // The len field has already been checked by the caller, we only assert | 12396 // The len field has already been checked by the caller, we only assert |
| (...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13397 } | 13415 } |
| 13398 return result.raw(); | 13416 return result.raw(); |
| 13399 } | 13417 } |
| 13400 | 13418 |
| 13401 | 13419 |
| 13402 const char* WeakProperty::ToCString() const { | 13420 const char* WeakProperty::ToCString() const { |
| 13403 return "_WeakProperty"; | 13421 return "_WeakProperty"; |
| 13404 } | 13422 } |
| 13405 | 13423 |
| 13406 } // namespace dart | 13424 } // namespace dart |
| OLD | NEW |