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