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 #ifndef VM_RAW_OBJECT_H_ | 5 #ifndef VM_RAW_OBJECT_H_ |
6 #define VM_RAW_OBJECT_H_ | 6 #define VM_RAW_OBJECT_H_ |
7 | 7 |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "vm/globals.h" | 9 #include "vm/globals.h" |
10 #include "vm/token.h" | 10 #include "vm/token.h" |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 k##clazz##Cid, | 148 k##clazz##Cid, |
149 CLASS_LIST(DEFINE_OBJECT_KIND) | 149 CLASS_LIST(DEFINE_OBJECT_KIND) |
150 #undef DEFINE_OBJECT_KIND | 150 #undef DEFINE_OBJECT_KIND |
151 | 151 |
152 #define DEFINE_OBJECT_KIND(clazz) \ | 152 #define DEFINE_OBJECT_KIND(clazz) \ |
153 kTypedData##clazz##Cid, | 153 kTypedData##clazz##Cid, |
154 CLASS_LIST_TYPED_DATA(DEFINE_OBJECT_KIND) | 154 CLASS_LIST_TYPED_DATA(DEFINE_OBJECT_KIND) |
155 #undef DEFINE_OBJECT_KIND | 155 #undef DEFINE_OBJECT_KIND |
156 | 156 |
157 #define DEFINE_OBJECT_KIND(clazz) \ | 157 #define DEFINE_OBJECT_KIND(clazz) \ |
| 158 kTypedData##clazz##ViewCid, |
| 159 CLASS_LIST_TYPED_DATA(DEFINE_OBJECT_KIND) |
| 160 #undef DEFINE_OBJECT_KIND |
| 161 |
| 162 #define DEFINE_OBJECT_KIND(clazz) \ |
158 kExternalTypedData##clazz##Cid, | 163 kExternalTypedData##clazz##Cid, |
159 CLASS_LIST_TYPED_DATA(DEFINE_OBJECT_KIND) | 164 CLASS_LIST_TYPED_DATA(DEFINE_OBJECT_KIND) |
160 #undef DEFINE_OBJECT_KIND | 165 #undef DEFINE_OBJECT_KIND |
161 | 166 |
162 // The following entries do not describe a predefined class, but instead | 167 // The following entries do not describe a predefined class, but instead |
163 // are class indexes for pre-allocated instance (Null, dynamic and Void). | 168 // are class indexes for pre-allocated instance (Null, dynamic and Void). |
164 kNullCid, | 169 kNullCid, |
165 kDynamicCid, | 170 kDynamicCid, |
166 kVoidCid, | 171 kVoidCid, |
167 | 172 |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 static bool IsNumberClassId(intptr_t index); | 390 static bool IsNumberClassId(intptr_t index); |
386 static bool IsIntegerClassId(intptr_t index); | 391 static bool IsIntegerClassId(intptr_t index); |
387 static bool IsStringClassId(intptr_t index); | 392 static bool IsStringClassId(intptr_t index); |
388 static bool IsOneByteStringClassId(intptr_t index); | 393 static bool IsOneByteStringClassId(intptr_t index); |
389 static bool IsTwoByteStringClassId(intptr_t index); | 394 static bool IsTwoByteStringClassId(intptr_t index); |
390 static bool IsExternalStringClassId(intptr_t index); | 395 static bool IsExternalStringClassId(intptr_t index); |
391 static bool IsBuiltinListClassId(intptr_t index); | 396 static bool IsBuiltinListClassId(intptr_t index); |
392 static bool IsByteArrayClassId(intptr_t index); | 397 static bool IsByteArrayClassId(intptr_t index); |
393 static bool IsExternalByteArrayClassId(intptr_t index); | 398 static bool IsExternalByteArrayClassId(intptr_t index); |
394 static bool IsTypedDataClassId(intptr_t index); | 399 static bool IsTypedDataClassId(intptr_t index); |
| 400 static bool IsTypedDataViewClassId(intptr_t index); |
395 static bool IsExternalTypedDataClassId(intptr_t index); | 401 static bool IsExternalTypedDataClassId(intptr_t index); |
396 | 402 |
397 static intptr_t NumberOfTypedDataClasses(); | 403 static intptr_t NumberOfTypedDataClasses(); |
398 | 404 |
399 private: | 405 private: |
400 uword tags_; // Various object tags (bits). | 406 uword tags_; // Various object tags (bits). |
401 | 407 |
402 class FreeBit : public BitField<bool, kFreeBit, 1> {}; | 408 class FreeBit : public BitField<bool, kFreeBit, 1> {}; |
403 | 409 |
404 class MarkBit : public BitField<bool, kMarkBit, 1> {}; | 410 class MarkBit : public BitField<bool, kMarkBit, 1> {}; |
(...skipping 1462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1867 ASSERT(kTypedDataUint8ArrayCid == kTypedDataInt8ArrayCid + 1 && | 1873 ASSERT(kTypedDataUint8ArrayCid == kTypedDataInt8ArrayCid + 1 && |
1868 kTypedDataUint8ClampedArrayCid == kTypedDataInt8ArrayCid + 2 && | 1874 kTypedDataUint8ClampedArrayCid == kTypedDataInt8ArrayCid + 2 && |
1869 kTypedDataInt16ArrayCid == kTypedDataInt8ArrayCid + 3 && | 1875 kTypedDataInt16ArrayCid == kTypedDataInt8ArrayCid + 3 && |
1870 kTypedDataUint16ArrayCid == kTypedDataInt8ArrayCid + 4 && | 1876 kTypedDataUint16ArrayCid == kTypedDataInt8ArrayCid + 4 && |
1871 kTypedDataInt32ArrayCid == kTypedDataInt8ArrayCid + 5 && | 1877 kTypedDataInt32ArrayCid == kTypedDataInt8ArrayCid + 5 && |
1872 kTypedDataUint32ArrayCid == kTypedDataInt8ArrayCid + 6 && | 1878 kTypedDataUint32ArrayCid == kTypedDataInt8ArrayCid + 6 && |
1873 kTypedDataInt64ArrayCid == kTypedDataInt8ArrayCid + 7 && | 1879 kTypedDataInt64ArrayCid == kTypedDataInt8ArrayCid + 7 && |
1874 kTypedDataUint64ArrayCid == kTypedDataInt8ArrayCid + 8 && | 1880 kTypedDataUint64ArrayCid == kTypedDataInt8ArrayCid + 8 && |
1875 kTypedDataFloat32ArrayCid == kTypedDataInt8ArrayCid + 9 && | 1881 kTypedDataFloat32ArrayCid == kTypedDataInt8ArrayCid + 9 && |
1876 kTypedDataFloat64ArrayCid == kTypedDataInt8ArrayCid + 10 && | 1882 kTypedDataFloat64ArrayCid == kTypedDataInt8ArrayCid + 10 && |
1877 kExternalTypedDataInt8ArrayCid == kTypedDataInt8ArrayCid + 11); | 1883 kTypedDataInt8ArrayViewCid == kTypedDataInt8ArrayCid + 11); |
1878 return (index >= kTypedDataInt8ArrayCid && | 1884 return (index >= kTypedDataInt8ArrayCid && |
1879 index <= kTypedDataFloat64ArrayCid); | 1885 index <= kTypedDataFloat64ArrayCid); |
1880 } | 1886 } |
1881 | 1887 |
1882 | 1888 |
| 1889 inline bool RawObject::IsTypedDataViewClassId(intptr_t index) { |
| 1890 // Make sure this is updated when new TypedData types are added. |
| 1891 ASSERT(kTypedDataUint8ArrayViewCid == kTypedDataInt8ArrayViewCid + 1 && |
| 1892 kTypedDataUint8ClampedArrayViewCid == kTypedDataInt8ArrayViewCid + 2 && |
| 1893 kTypedDataInt16ArrayViewCid == kTypedDataInt8ArrayViewCid + 3 && |
| 1894 kTypedDataUint16ArrayViewCid == kTypedDataInt8ArrayViewCid + 4 && |
| 1895 kTypedDataInt32ArrayViewCid == kTypedDataInt8ArrayViewCid + 5 && |
| 1896 kTypedDataUint32ArrayViewCid == kTypedDataInt8ArrayViewCid + 6 && |
| 1897 kTypedDataInt64ArrayViewCid == kTypedDataInt8ArrayViewCid + 7 && |
| 1898 kTypedDataUint64ArrayViewCid == kTypedDataInt8ArrayViewCid + 8 && |
| 1899 kTypedDataFloat32ArrayViewCid == kTypedDataInt8ArrayViewCid + 9 && |
| 1900 kTypedDataFloat64ArrayViewCid == kTypedDataInt8ArrayViewCid + 10 && |
| 1901 kExternalTypedDataInt8ArrayCid == kTypedDataInt8ArrayViewCid + 11); |
| 1902 return (index >= kTypedDataInt8ArrayViewCid && |
| 1903 index <= kTypedDataFloat64ArrayViewCid); |
| 1904 } |
| 1905 |
| 1906 |
1883 inline bool RawObject::IsExternalTypedDataClassId(intptr_t index) { | 1907 inline bool RawObject::IsExternalTypedDataClassId(intptr_t index) { |
1884 // Make sure this is updated when new ExternalTypedData types are added. | 1908 // Make sure this is updated when new ExternalTypedData types are added. |
1885 ASSERT((kExternalTypedDataUint8ArrayCid == | 1909 ASSERT((kExternalTypedDataUint8ArrayCid == |
1886 kExternalTypedDataInt8ArrayCid + 1) && | 1910 kExternalTypedDataInt8ArrayCid + 1) && |
1887 (kExternalTypedDataUint8ClampedArrayCid == | 1911 (kExternalTypedDataUint8ClampedArrayCid == |
1888 kExternalTypedDataInt8ArrayCid + 2) && | 1912 kExternalTypedDataInt8ArrayCid + 2) && |
1889 (kExternalTypedDataInt16ArrayCid == | 1913 (kExternalTypedDataInt16ArrayCid == |
1890 kExternalTypedDataInt8ArrayCid + 3) && | 1914 kExternalTypedDataInt8ArrayCid + 3) && |
1891 (kExternalTypedDataUint16ArrayCid == | 1915 (kExternalTypedDataUint16ArrayCid == |
1892 kExternalTypedDataInt8ArrayCid + 4) && | 1916 kExternalTypedDataInt8ArrayCid + 4) && |
(...skipping 10 matching lines...) Expand all Loading... |
1903 (kExternalTypedDataFloat64ArrayCid == | 1927 (kExternalTypedDataFloat64ArrayCid == |
1904 kExternalTypedDataInt8ArrayCid + 10) && | 1928 kExternalTypedDataInt8ArrayCid + 10) && |
1905 (kNullCid == kExternalTypedDataInt8ArrayCid + 11)); | 1929 (kNullCid == kExternalTypedDataInt8ArrayCid + 11)); |
1906 return (index >= kExternalTypedDataInt8ArrayCid && | 1930 return (index >= kExternalTypedDataInt8ArrayCid && |
1907 index <= kExternalTypedDataFloat64ArrayCid); | 1931 index <= kExternalTypedDataFloat64ArrayCid); |
1908 } | 1932 } |
1909 | 1933 |
1910 | 1934 |
1911 inline intptr_t RawObject::NumberOfTypedDataClasses() { | 1935 inline intptr_t RawObject::NumberOfTypedDataClasses() { |
1912 // Make sure this is updated when new TypedData types are added. | 1936 // Make sure this is updated when new TypedData types are added. |
1913 ASSERT(kExternalTypedDataInt8ArrayCid == kTypedDataInt8ArrayCid + 11); | 1937 ASSERT(kTypedDataInt8ArrayViewCid == kTypedDataInt8ArrayCid + 11); |
| 1938 ASSERT(kExternalTypedDataInt8ArrayCid == kTypedDataInt8ArrayViewCid + 11); |
1914 ASSERT(kNullCid == kExternalTypedDataInt8ArrayCid + 11); | 1939 ASSERT(kNullCid == kExternalTypedDataInt8ArrayCid + 11); |
1915 return (kNullCid - kTypedDataInt8ArrayCid); | 1940 return (kNullCid - kTypedDataInt8ArrayCid); |
1916 } | 1941 } |
1917 | 1942 |
1918 } // namespace dart | 1943 } // namespace dart |
1919 | 1944 |
1920 #endif // VM_RAW_OBJECT_H_ | 1945 #endif // VM_RAW_OBJECT_H_ |
OLD | NEW |