| 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); | |
| 885 REGISTER_SCALARLIST_CLASS(Float32Array, float32_array); | 882 REGISTER_SCALARLIST_CLASS(Float32Array, float32_array); |
| 886 REGISTER_SCALARLIST_CLASS(Float64Array, float64_array); | 883 REGISTER_SCALARLIST_CLASS(Float64Array, float64_array); |
| 887 REGISTER_SCALARLIST_CLASS(ExternalInt8Array, external_int8_array); | 884 REGISTER_SCALARLIST_CLASS(ExternalInt8Array, external_int8_array); |
| 888 REGISTER_SCALARLIST_CLASS(ExternalUint8Array, external_uint8_array); | 885 REGISTER_SCALARLIST_CLASS(ExternalUint8Array, external_uint8_array); |
| 889 REGISTER_SCALARLIST_CLASS(ExternalUint8ClampedArray, | 886 REGISTER_SCALARLIST_CLASS(ExternalUint8ClampedArray, |
| 890 external_uint8_clamped_array); | 887 external_uint8_clamped_array); |
| 891 REGISTER_SCALARLIST_CLASS(ExternalInt16Array, external_int16_array); | 888 REGISTER_SCALARLIST_CLASS(ExternalInt16Array, external_int16_array); |
| 892 REGISTER_SCALARLIST_CLASS(ExternalUint16Array, external_uint16_array); | 889 REGISTER_SCALARLIST_CLASS(ExternalUint16Array, external_uint16_array); |
| 893 REGISTER_SCALARLIST_CLASS(ExternalInt32Array, external_int32_array); | 890 REGISTER_SCALARLIST_CLASS(ExternalInt32Array, external_int32_array); |
| 894 REGISTER_SCALARLIST_CLASS(ExternalUint32Array, external_uint32_array); | 891 REGISTER_SCALARLIST_CLASS(ExternalUint32Array, external_uint32_array); |
| 895 REGISTER_SCALARLIST_CLASS(ExternalInt64Array, external_int64_array); | 892 REGISTER_SCALARLIST_CLASS(ExternalInt64Array, external_int64_array); |
| 896 REGISTER_SCALARLIST_CLASS(ExternalUint64Array, external_uint64_array); | 893 REGISTER_SCALARLIST_CLASS(ExternalUint64Array, external_uint64_array); |
| 897 REGISTER_SCALARLIST_CLASS(ExternalFloat32x4Array, external_float32x4_array); | |
| 898 REGISTER_SCALARLIST_CLASS(ExternalFloat32Array, external_float32_array); | 894 REGISTER_SCALARLIST_CLASS(ExternalFloat32Array, external_float32_array); |
| 899 REGISTER_SCALARLIST_CLASS(ExternalFloat64Array, external_float64_array); | 895 REGISTER_SCALARLIST_CLASS(ExternalFloat64Array, external_float64_array); |
| 900 #undef REGISTER_SCALARLIST_CLASS | 896 #undef REGISTER_SCALARLIST_CLASS |
| 901 | 897 |
| 898 |
| 902 // Pre-register the typeddata library so the native class implementations | 899 // Pre-register the typeddata library so the native class implementations |
| 903 // can be hooked up before compiling it. | 900 // can be hooked up before compiling it. |
| 904 LOAD_LIBRARY(TypedData, typeddata); | 901 LOAD_LIBRARY(TypedData, typeddata); |
| 905 ASSERT(!lib.IsNull()); | 902 ASSERT(!lib.IsNull()); |
| 906 ASSERT(lib.raw() == Library::TypedDataLibrary()); | 903 ASSERT(lib.raw() == Library::TypedDataLibrary()); |
| 904 const intptr_t typeddata_class_array_length = |
| 905 RawObject::NumberOfTypedDataClasses() + 2; // +2 for Float32x4 & Uint32x4 |
| 907 Array& typeddata_classes = | 906 Array& typeddata_classes = |
| 908 Array::Handle(Array::New(RawObject::NumberOfTypedDataClasses())); | 907 Array::Handle(Array::New(typeddata_class_array_length)); |
| 909 int index = 0; | 908 int index = 0; |
| 910 #define REGISTER_TYPED_DATA_CLASS(clazz) \ | 909 #define REGISTER_TYPED_DATA_CLASS(clazz) \ |
| 911 cls = Class::NewTypedDataClass(kTypedData##clazz##Cid); \ | 910 cls = Class::NewTypedDataClass(kTypedData##clazz##Cid); \ |
| 912 index = kTypedData##clazz##Cid - kTypedDataInt8ArrayCid; \ | 911 index = kTypedData##clazz##Cid - kTypedDataInt8ArrayCid; \ |
| 913 typeddata_classes.SetAt(index, cls); \ | 912 typeddata_classes.SetAt(index, cls); \ |
| 914 RegisterPrivateClass(cls, Symbols::_##clazz(), lib); \ | 913 RegisterPrivateClass(cls, Symbols::_##clazz(), lib); \ |
| 915 | 914 |
| 916 CLASS_LIST_TYPED_DATA(REGISTER_TYPED_DATA_CLASS); | 915 CLASS_LIST_TYPED_DATA(REGISTER_TYPED_DATA_CLASS); |
| 917 #undef REGISTER_TYPED_DATA_CLASS | 916 #undef REGISTER_TYPED_DATA_CLASS |
| 918 #define REGISTER_TYPED_DATA_VIEW_CLASS(clazz) \ | 917 #define REGISTER_TYPED_DATA_VIEW_CLASS(clazz) \ |
| (...skipping 11 matching lines...) Expand all Loading... |
| 930 pending_classes.Add(cls, Heap::kOld); | 929 pending_classes.Add(cls, Heap::kOld); |
| 931 #undef REGISTER_TYPED_DATA_VIEW_CLASS | 930 #undef REGISTER_TYPED_DATA_VIEW_CLASS |
| 932 #define REGISTER_EXT_TYPED_DATA_CLASS(clazz) \ | 931 #define REGISTER_EXT_TYPED_DATA_CLASS(clazz) \ |
| 933 cls = Class::NewExternalTypedDataClass(kExternalTypedData##clazz##Cid); \ | 932 cls = Class::NewExternalTypedDataClass(kExternalTypedData##clazz##Cid); \ |
| 934 index = kExternalTypedData##clazz##Cid - kTypedDataInt8ArrayCid; \ | 933 index = kExternalTypedData##clazz##Cid - kTypedDataInt8ArrayCid; \ |
| 935 typeddata_classes.SetAt(index, cls); \ | 934 typeddata_classes.SetAt(index, cls); \ |
| 936 RegisterPrivateClass(cls, Symbols::_External##clazz(), lib); \ | 935 RegisterPrivateClass(cls, Symbols::_External##clazz(), lib); \ |
| 937 | 936 |
| 938 CLASS_LIST_TYPED_DATA(REGISTER_EXT_TYPED_DATA_CLASS); | 937 CLASS_LIST_TYPED_DATA(REGISTER_EXT_TYPED_DATA_CLASS); |
| 939 #undef REGISTER_EXT_TYPED_DATA_CLASS | 938 #undef REGISTER_EXT_TYPED_DATA_CLASS |
| 939 // Add Float32x4 and Uint32x4 to dart:typeddata and register them in the |
| 940 // object store. |
| 941 cls = Class::New<Float32x4>(); |
| 942 object_store->set_float32x4_class(cls); |
| 943 typeddata_classes.SetAt(typeddata_class_array_length-2, cls); |
| 944 RegisterPrivateClass(cls, Symbols::_Float32x4(), lib); |
| 945 cls = Class::New<Uint32x4>(); |
| 946 object_store->set_uint32x4_class(cls); |
| 947 typeddata_classes.SetAt(typeddata_class_array_length-1, cls); |
| 948 RegisterPrivateClass(cls, Symbols::_Uint32x4(), lib); |
| 949 |
| 940 object_store->set_typeddata_classes(typeddata_classes); | 950 object_store->set_typeddata_classes(typeddata_classes); |
| 941 | 951 |
| 942 // Set the super type of class Stacktrace to Object type so that the | 952 // Set the super type of class Stacktrace to Object type so that the |
| 943 // 'toString' method is implemented. | 953 // 'toString' method is implemented. |
| 944 cls = object_store->stacktrace_class(); | 954 cls = object_store->stacktrace_class(); |
| 945 cls.set_super_type(type); | 955 cls.set_super_type(type); |
| 946 | 956 |
| 947 // Note: The abstract class Function is represented by VM class | 957 // Note: The abstract class Function is represented by VM class |
| 948 // DartFunction, not VM class Function. | 958 // DartFunction, not VM class Function. |
| 949 cls = Class::New<DartFunction>(); | 959 cls = Class::New<DartFunction>(); |
| (...skipping 11637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12587 uint32_t _w = w(); | 12597 uint32_t _w = w(); |
| 12588 // Calculate the size of the string. | 12598 // Calculate the size of the string. |
| 12589 intptr_t len = OS::SNPrint(NULL, 0, kFormat, _x, _y, _z, _w) + 1; | 12599 intptr_t len = OS::SNPrint(NULL, 0, kFormat, _x, _y, _z, _w) + 1; |
| 12590 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 12600 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 12591 OS::SNPrint(chars, len, kFormat, _x, _y, _z, _w); | 12601 OS::SNPrint(chars, len, kFormat, _x, _y, _z, _w); |
| 12592 return chars; | 12602 return chars; |
| 12593 } | 12603 } |
| 12594 | 12604 |
| 12595 | 12605 |
| 12596 const intptr_t TypedData::element_size[] = { | 12606 const intptr_t TypedData::element_size[] = { |
| 12597 1, // kTypedDataInt8ArrayCid. | 12607 1, // kTypedDataInt8ArrayCid. |
| 12598 1, // kTypedDataUint8ArrayCid. | 12608 1, // kTypedDataUint8ArrayCid. |
| 12599 1, // kTypedDataUint8ClampedArrayCid. | 12609 1, // kTypedDataUint8ClampedArrayCid. |
| 12600 2, // kTypedDataInt16ArrayCid. | 12610 2, // kTypedDataInt16ArrayCid. |
| 12601 2, // kTypedDataUint16ArrayCid. | 12611 2, // kTypedDataUint16ArrayCid. |
| 12602 4, // kTypedDataInt32ArrayCid. | 12612 4, // kTypedDataInt32ArrayCid. |
| 12603 4, // kTypedDataUint32ArrayCid. | 12613 4, // kTypedDataUint32ArrayCid. |
| 12604 8, // kTypedDataInt64ArrayCid. | 12614 8, // kTypedDataInt64ArrayCid. |
| 12605 8, // kTypedDataUint64ArrayCid. | 12615 8, // kTypedDataUint64ArrayCid. |
| 12606 4, // kTypedDataFloat32ArrayCid. | 12616 4, // kTypedDataFloat32ArrayCid. |
| 12607 8, // kTypedDataFloat64ArrayCid. | 12617 8, // kTypedDataFloat64ArrayCid. |
| 12618 16, // kTypedDataFloat32x4ArrayCid. |
| 12608 }; | 12619 }; |
| 12609 | 12620 |
| 12610 | 12621 |
| 12611 void TypedData::Copy(const TypedData& dst, | 12622 void TypedData::Copy(const TypedData& dst, |
| 12612 intptr_t dst_offset_in_bytes, | 12623 intptr_t dst_offset_in_bytes, |
| 12613 const TypedData& src, | 12624 const TypedData& src, |
| 12614 intptr_t src_offset_in_bytes, | 12625 intptr_t src_offset_in_bytes, |
| 12615 intptr_t length_in_bytes) { | 12626 intptr_t length_in_bytes) { |
| 12616 ASSERT(Utils::RangeCheck(src_offset_in_bytes, | 12627 ASSERT(Utils::RangeCheck(src_offset_in_bytes, |
| 12617 length_in_bytes, | 12628 length_in_bytes, |
| (...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13679 } | 13690 } |
| 13680 return result.raw(); | 13691 return result.raw(); |
| 13681 } | 13692 } |
| 13682 | 13693 |
| 13683 | 13694 |
| 13684 const char* WeakProperty::ToCString() const { | 13695 const char* WeakProperty::ToCString() const { |
| 13685 return "_WeakProperty"; | 13696 return "_WeakProperty"; |
| 13686 } | 13697 } |
| 13687 | 13698 |
| 13688 } // namespace dart | 13699 } // namespace dart |
| OLD | NEW |