| 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 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 863 // Pre-register the scalarlist library so the native class implementations | 863 // Pre-register the scalarlist library so the native class implementations |
| 864 // can be hooked up before compiling it. | 864 // can be hooked up before compiling it. |
| 865 LOAD_LIBRARY(Scalarlist, scalarlist); | 865 LOAD_LIBRARY(Scalarlist, scalarlist); |
| 866 ASSERT(!lib.IsNull()); | 866 ASSERT(!lib.IsNull()); |
| 867 ASSERT(lib.raw() == Library::ScalarlistLibrary()); | 867 ASSERT(lib.raw() == Library::ScalarlistLibrary()); |
| 868 #define REGISTER_SCALARLIST_CLASS(name, object_store_name) \ | 868 #define REGISTER_SCALARLIST_CLASS(name, object_store_name) \ |
| 869 cls = Class::New<name>(); \ | 869 cls = Class::New<name>(); \ |
| 870 object_store->set_##object_store_name##_class(cls); \ | 870 object_store->set_##object_store_name##_class(cls); \ |
| 871 RegisterPrivateClass(cls, Symbols::_##name(), lib); \ | 871 RegisterPrivateClass(cls, Symbols::_##name(), lib); \ |
| 872 | 872 |
| 873 REGISTER_SCALARLIST_CLASS(Float32x4, float32x4); |
| 874 REGISTER_SCALARLIST_CLASS(Uint32x4, uint32x4); |
| 873 REGISTER_SCALARLIST_CLASS(Int8Array, int8_array); | 875 REGISTER_SCALARLIST_CLASS(Int8Array, int8_array); |
| 874 REGISTER_SCALARLIST_CLASS(Uint8Array, uint8_array); | 876 REGISTER_SCALARLIST_CLASS(Uint8Array, uint8_array); |
| 875 REGISTER_SCALARLIST_CLASS(Uint8ClampedArray, uint8_clamped_array); | 877 REGISTER_SCALARLIST_CLASS(Uint8ClampedArray, uint8_clamped_array); |
| 876 REGISTER_SCALARLIST_CLASS(Int16Array, int16_array); | 878 REGISTER_SCALARLIST_CLASS(Int16Array, int16_array); |
| 877 REGISTER_SCALARLIST_CLASS(Uint16Array, uint16_array); | 879 REGISTER_SCALARLIST_CLASS(Uint16Array, uint16_array); |
| 878 REGISTER_SCALARLIST_CLASS(Int32Array, int32_array); | 880 REGISTER_SCALARLIST_CLASS(Int32Array, int32_array); |
| 879 REGISTER_SCALARLIST_CLASS(Uint32Array, uint32_array); | 881 REGISTER_SCALARLIST_CLASS(Uint32Array, uint32_array); |
| 880 REGISTER_SCALARLIST_CLASS(Int64Array, int64_array); | 882 REGISTER_SCALARLIST_CLASS(Int64Array, int64_array); |
| 881 REGISTER_SCALARLIST_CLASS(Uint64Array, uint64_array); | 883 REGISTER_SCALARLIST_CLASS(Uint64Array, uint64_array); |
| 882 REGISTER_SCALARLIST_CLASS(Float32x4Array, float32x4_array); | 884 REGISTER_SCALARLIST_CLASS(Float32x4Array, float32x4_array); |
| 883 REGISTER_SCALARLIST_CLASS(Float32Array, float32_array); | 885 REGISTER_SCALARLIST_CLASS(Float32Array, float32_array); |
| 884 REGISTER_SCALARLIST_CLASS(Float64Array, float64_array); | 886 REGISTER_SCALARLIST_CLASS(Float64Array, float64_array); |
| 885 REGISTER_SCALARLIST_CLASS(ExternalInt8Array, external_int8_array); | 887 REGISTER_SCALARLIST_CLASS(ExternalInt8Array, external_int8_array); |
| 886 REGISTER_SCALARLIST_CLASS(ExternalUint8Array, external_uint8_array); | 888 REGISTER_SCALARLIST_CLASS(ExternalUint8Array, external_uint8_array); |
| 887 REGISTER_SCALARLIST_CLASS(ExternalUint8ClampedArray, | 889 REGISTER_SCALARLIST_CLASS(ExternalUint8ClampedArray, |
| 888 external_uint8_clamped_array); | 890 external_uint8_clamped_array); |
| 889 REGISTER_SCALARLIST_CLASS(ExternalInt16Array, external_int16_array); | 891 REGISTER_SCALARLIST_CLASS(ExternalInt16Array, external_int16_array); |
| 890 REGISTER_SCALARLIST_CLASS(ExternalUint16Array, external_uint16_array); | 892 REGISTER_SCALARLIST_CLASS(ExternalUint16Array, external_uint16_array); |
| 891 REGISTER_SCALARLIST_CLASS(ExternalInt32Array, external_int32_array); | 893 REGISTER_SCALARLIST_CLASS(ExternalInt32Array, external_int32_array); |
| 892 REGISTER_SCALARLIST_CLASS(ExternalUint32Array, external_uint32_array); | 894 REGISTER_SCALARLIST_CLASS(ExternalUint32Array, external_uint32_array); |
| 893 REGISTER_SCALARLIST_CLASS(ExternalInt64Array, external_int64_array); | 895 REGISTER_SCALARLIST_CLASS(ExternalInt64Array, external_int64_array); |
| 894 REGISTER_SCALARLIST_CLASS(ExternalUint64Array, external_uint64_array); | 896 REGISTER_SCALARLIST_CLASS(ExternalUint64Array, external_uint64_array); |
| 895 REGISTER_SCALARLIST_CLASS(ExternalFloat32x4Array, external_float32x4_array); | 897 REGISTER_SCALARLIST_CLASS(ExternalFloat32x4Array, external_float32x4_array); |
| 896 REGISTER_SCALARLIST_CLASS(ExternalFloat32Array, external_float32_array); | 898 REGISTER_SCALARLIST_CLASS(ExternalFloat32Array, external_float32_array); |
| 897 REGISTER_SCALARLIST_CLASS(ExternalFloat64Array, external_float64_array); | 899 REGISTER_SCALARLIST_CLASS(ExternalFloat64Array, external_float64_array); |
| 898 #undef REGISTER_SCALARLIST_CLASS | 900 #undef REGISTER_SCALARLIST_CLASS |
| 899 // Add Float32x4 and Uint32x4 to dart:scalarlist and register them in | |
| 900 // object_store. | |
| 901 cls = Class::New<Float32x4>(); | |
| 902 object_store->set_float32x4_class(cls); | |
| 903 RegisterPrivateClass(cls, Symbols::_Float32x4(), lib); | |
| 904 cls = Class::New<Uint32x4>(); | |
| 905 object_store->set_uint32x4_class(cls); | |
| 906 RegisterPrivateClass(cls, Symbols::_Uint32x4(), lib); | |
| 907 | |
| 908 | 901 |
| 909 // Pre-register the typeddata library so the native class implementations | 902 // Pre-register the typeddata library so the native class implementations |
| 910 // can be hooked up before compiling it. | 903 // can be hooked up before compiling it. |
| 911 LOAD_LIBRARY(TypedData, typeddata); | 904 LOAD_LIBRARY(TypedData, typeddata); |
| 912 ASSERT(!lib.IsNull()); | 905 ASSERT(!lib.IsNull()); |
| 913 ASSERT(lib.raw() == Library::TypedDataLibrary()); | 906 ASSERT(lib.raw() == Library::TypedDataLibrary()); |
| 914 const intptr_t typeddata_class_array_length = | |
| 915 RawObject::NumberOfTypedDataClasses() + 2; // +2 for Float32x4 & Uint32x4 | |
| 916 Array& typeddata_classes = | 907 Array& typeddata_classes = |
| 917 Array::Handle(Array::New(typeddata_class_array_length)); | 908 Array::Handle(Array::New(RawObject::NumberOfTypedDataClasses())); |
| 918 int index = 0; | 909 int index = 0; |
| 919 #define REGISTER_TYPED_DATA_CLASS(clazz) \ | 910 #define REGISTER_TYPED_DATA_CLASS(clazz) \ |
| 920 cls = Class::NewTypedDataClass(kTypedData##clazz##Cid); \ | 911 cls = Class::NewTypedDataClass(kTypedData##clazz##Cid); \ |
| 921 index = kTypedData##clazz##Cid - kTypedDataInt8ArrayCid; \ | 912 index = kTypedData##clazz##Cid - kTypedDataInt8ArrayCid; \ |
| 922 typeddata_classes.SetAt(index, cls); \ | 913 typeddata_classes.SetAt(index, cls); \ |
| 923 RegisterPrivateClass(cls, Symbols::_##clazz(), lib); \ | 914 RegisterPrivateClass(cls, Symbols::_##clazz(), lib); \ |
| 924 | 915 |
| 925 CLASS_LIST_TYPED_DATA(REGISTER_TYPED_DATA_CLASS); | 916 CLASS_LIST_TYPED_DATA(REGISTER_TYPED_DATA_CLASS); |
| 926 #undef REGISTER_TYPED_DATA_CLASS | 917 #undef REGISTER_TYPED_DATA_CLASS |
| 927 #define REGISTER_TYPED_DATA_VIEW_CLASS(clazz) \ | 918 #define REGISTER_TYPED_DATA_VIEW_CLASS(clazz) \ |
| (...skipping 11 matching lines...) Expand all Loading... |
| 939 pending_classes.Add(cls, Heap::kOld); | 930 pending_classes.Add(cls, Heap::kOld); |
| 940 #undef REGISTER_TYPED_DATA_VIEW_CLASS | 931 #undef REGISTER_TYPED_DATA_VIEW_CLASS |
| 941 #define REGISTER_EXT_TYPED_DATA_CLASS(clazz) \ | 932 #define REGISTER_EXT_TYPED_DATA_CLASS(clazz) \ |
| 942 cls = Class::NewExternalTypedDataClass(kExternalTypedData##clazz##Cid); \ | 933 cls = Class::NewExternalTypedDataClass(kExternalTypedData##clazz##Cid); \ |
| 943 index = kExternalTypedData##clazz##Cid - kTypedDataInt8ArrayCid; \ | 934 index = kExternalTypedData##clazz##Cid - kTypedDataInt8ArrayCid; \ |
| 944 typeddata_classes.SetAt(index, cls); \ | 935 typeddata_classes.SetAt(index, cls); \ |
| 945 RegisterPrivateClass(cls, Symbols::_External##clazz(), lib); \ | 936 RegisterPrivateClass(cls, Symbols::_External##clazz(), lib); \ |
| 946 | 937 |
| 947 CLASS_LIST_TYPED_DATA(REGISTER_EXT_TYPED_DATA_CLASS); | 938 CLASS_LIST_TYPED_DATA(REGISTER_EXT_TYPED_DATA_CLASS); |
| 948 #undef REGISTER_EXT_TYPED_DATA_CLASS | 939 #undef REGISTER_EXT_TYPED_DATA_CLASS |
| 949 // Add Float32x4 and Uint32x4 to dart:typeddata. | |
| 950 cls = object_store->float32x4_class(); | |
| 951 typeddata_classes.SetAt(typeddata_class_array_length-2, cls); | |
| 952 RegisterPrivateClass(cls, Symbols::_Float32x4(), lib); | |
| 953 cls = object_store->uint32x4_class(); | |
| 954 typeddata_classes.SetAt(typeddata_class_array_length-1, cls); | |
| 955 RegisterPrivateClass(cls, Symbols::_Uint32x4(), lib); | |
| 956 | |
| 957 object_store->set_typeddata_classes(typeddata_classes); | 940 object_store->set_typeddata_classes(typeddata_classes); |
| 958 | 941 |
| 959 // Set the super type of class Stacktrace to Object type so that the | 942 // Set the super type of class Stacktrace to Object type so that the |
| 960 // 'toString' method is implemented. | 943 // 'toString' method is implemented. |
| 961 cls = object_store->stacktrace_class(); | 944 cls = object_store->stacktrace_class(); |
| 962 cls.set_super_type(type); | 945 cls.set_super_type(type); |
| 963 | 946 |
| 964 // Note: The abstract class Function is represented by VM class | 947 // Note: The abstract class Function is represented by VM class |
| 965 // DartFunction, not VM class Function. | 948 // DartFunction, not VM class Function. |
| 966 cls = Class::New<DartFunction>(); | 949 cls = Class::New<DartFunction>(); |
| (...skipping 11634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12601 uint32_t _w = w(); | 12584 uint32_t _w = w(); |
| 12602 // Calculate the size of the string. | 12585 // Calculate the size of the string. |
| 12603 intptr_t len = OS::SNPrint(NULL, 0, kFormat, _x, _y, _z, _w) + 1; | 12586 intptr_t len = OS::SNPrint(NULL, 0, kFormat, _x, _y, _z, _w) + 1; |
| 12604 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 12587 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 12605 OS::SNPrint(chars, len, kFormat, _x, _y, _z, _w); | 12588 OS::SNPrint(chars, len, kFormat, _x, _y, _z, _w); |
| 12606 return chars; | 12589 return chars; |
| 12607 } | 12590 } |
| 12608 | 12591 |
| 12609 | 12592 |
| 12610 const intptr_t TypedData::element_size[] = { | 12593 const intptr_t TypedData::element_size[] = { |
| 12611 1, // kTypedDataInt8ArrayCid. | 12594 1, // kTypedDataInt8ArrayCid. |
| 12612 1, // kTypedDataUint8ArrayCid. | 12595 1, // kTypedDataUint8ArrayCid. |
| 12613 1, // kTypedDataUint8ClampedArrayCid. | 12596 1, // kTypedDataUint8ClampedArrayCid. |
| 12614 2, // kTypedDataInt16ArrayCid. | 12597 2, // kTypedDataInt16ArrayCid. |
| 12615 2, // kTypedDataUint16ArrayCid. | 12598 2, // kTypedDataUint16ArrayCid. |
| 12616 4, // kTypedDataInt32ArrayCid. | 12599 4, // kTypedDataInt32ArrayCid. |
| 12617 4, // kTypedDataUint32ArrayCid. | 12600 4, // kTypedDataUint32ArrayCid. |
| 12618 8, // kTypedDataInt64ArrayCid. | 12601 8, // kTypedDataInt64ArrayCid. |
| 12619 8, // kTypedDataUint64ArrayCid. | 12602 8, // kTypedDataUint64ArrayCid. |
| 12620 4, // kTypedDataFloat32ArrayCid. | 12603 4, // kTypedDataFloat32ArrayCid. |
| 12621 8, // kTypedDataFloat64ArrayCid. | 12604 8, // kTypedDataFloat64ArrayCid. |
| 12622 16, // kTypedDataFloat32x4ArrayCid. | |
| 12623 }; | 12605 }; |
| 12624 | 12606 |
| 12625 | 12607 |
| 12626 void TypedData::Copy(const TypedData& dst, | 12608 void TypedData::Copy(const TypedData& dst, |
| 12627 intptr_t dst_offset_in_bytes, | 12609 intptr_t dst_offset_in_bytes, |
| 12628 const TypedData& src, | 12610 const TypedData& src, |
| 12629 intptr_t src_offset_in_bytes, | 12611 intptr_t src_offset_in_bytes, |
| 12630 intptr_t length_in_bytes) { | 12612 intptr_t length_in_bytes) { |
| 12631 ASSERT(Utils::RangeCheck(src_offset_in_bytes, | 12613 ASSERT(Utils::RangeCheck(src_offset_in_bytes, |
| 12632 length_in_bytes, | 12614 length_in_bytes, |
| (...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13694 } | 13676 } |
| 13695 return result.raw(); | 13677 return result.raw(); |
| 13696 } | 13678 } |
| 13697 | 13679 |
| 13698 | 13680 |
| 13699 const char* WeakProperty::ToCString() const { | 13681 const char* WeakProperty::ToCString() const { |
| 13700 return "_WeakProperty"; | 13682 return "_WeakProperty"; |
| 13701 } | 13683 } |
| 13702 | 13684 |
| 13703 } // namespace dart | 13685 } // namespace dart |
| OLD | NEW |