Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: runtime/vm/raw_object.h

Issue 12937010: Handle TypedDataView objects in Dart_TypedDataAcquireData and (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/raw_object.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 kByteDataViewCid,
161 #undef DEFINE_OBJECT_KIND
162
163 #define DEFINE_OBJECT_KIND(clazz) \
158 kExternalTypedData##clazz##Cid, 164 kExternalTypedData##clazz##Cid,
159 CLASS_LIST_TYPED_DATA(DEFINE_OBJECT_KIND) 165 CLASS_LIST_TYPED_DATA(DEFINE_OBJECT_KIND)
160 #undef DEFINE_OBJECT_KIND 166 #undef DEFINE_OBJECT_KIND
161 167
162 // The following entries do not describe a predefined class, but instead 168 // The following entries do not describe a predefined class, but instead
163 // are class indexes for pre-allocated instance (Null, dynamic and Void). 169 // are class indexes for pre-allocated instance (Null, dynamic and Void).
164 kNullCid, 170 kNullCid,
165 kDynamicCid, 171 kDynamicCid,
166 kVoidCid, 172 kVoidCid,
167 173
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 static bool IsNumberClassId(intptr_t index); 391 static bool IsNumberClassId(intptr_t index);
386 static bool IsIntegerClassId(intptr_t index); 392 static bool IsIntegerClassId(intptr_t index);
387 static bool IsStringClassId(intptr_t index); 393 static bool IsStringClassId(intptr_t index);
388 static bool IsOneByteStringClassId(intptr_t index); 394 static bool IsOneByteStringClassId(intptr_t index);
389 static bool IsTwoByteStringClassId(intptr_t index); 395 static bool IsTwoByteStringClassId(intptr_t index);
390 static bool IsExternalStringClassId(intptr_t index); 396 static bool IsExternalStringClassId(intptr_t index);
391 static bool IsBuiltinListClassId(intptr_t index); 397 static bool IsBuiltinListClassId(intptr_t index);
392 static bool IsByteArrayClassId(intptr_t index); 398 static bool IsByteArrayClassId(intptr_t index);
393 static bool IsExternalByteArrayClassId(intptr_t index); 399 static bool IsExternalByteArrayClassId(intptr_t index);
394 static bool IsTypedDataClassId(intptr_t index); 400 static bool IsTypedDataClassId(intptr_t index);
401 static bool IsTypedDataViewClassId(intptr_t index);
395 static bool IsExternalTypedDataClassId(intptr_t index); 402 static bool IsExternalTypedDataClassId(intptr_t index);
396 403
397 static intptr_t NumberOfTypedDataClasses(); 404 static intptr_t NumberOfTypedDataClasses();
398 405
399 private: 406 private:
400 uword tags_; // Various object tags (bits). 407 uword tags_; // Various object tags (bits).
401 408
402 class FreeBit : public BitField<bool, kFreeBit, 1> {}; 409 class FreeBit : public BitField<bool, kFreeBit, 1> {};
403 410
404 class MarkBit : public BitField<bool, kMarkBit, 1> {}; 411 class MarkBit : public BitField<bool, kMarkBit, 1> {};
(...skipping 1462 matching lines...) Expand 10 before | Expand all | Expand 10 after
1867 ASSERT(kTypedDataUint8ArrayCid == kTypedDataInt8ArrayCid + 1 && 1874 ASSERT(kTypedDataUint8ArrayCid == kTypedDataInt8ArrayCid + 1 &&
1868 kTypedDataUint8ClampedArrayCid == kTypedDataInt8ArrayCid + 2 && 1875 kTypedDataUint8ClampedArrayCid == kTypedDataInt8ArrayCid + 2 &&
1869 kTypedDataInt16ArrayCid == kTypedDataInt8ArrayCid + 3 && 1876 kTypedDataInt16ArrayCid == kTypedDataInt8ArrayCid + 3 &&
1870 kTypedDataUint16ArrayCid == kTypedDataInt8ArrayCid + 4 && 1877 kTypedDataUint16ArrayCid == kTypedDataInt8ArrayCid + 4 &&
1871 kTypedDataInt32ArrayCid == kTypedDataInt8ArrayCid + 5 && 1878 kTypedDataInt32ArrayCid == kTypedDataInt8ArrayCid + 5 &&
1872 kTypedDataUint32ArrayCid == kTypedDataInt8ArrayCid + 6 && 1879 kTypedDataUint32ArrayCid == kTypedDataInt8ArrayCid + 6 &&
1873 kTypedDataInt64ArrayCid == kTypedDataInt8ArrayCid + 7 && 1880 kTypedDataInt64ArrayCid == kTypedDataInt8ArrayCid + 7 &&
1874 kTypedDataUint64ArrayCid == kTypedDataInt8ArrayCid + 8 && 1881 kTypedDataUint64ArrayCid == kTypedDataInt8ArrayCid + 8 &&
1875 kTypedDataFloat32ArrayCid == kTypedDataInt8ArrayCid + 9 && 1882 kTypedDataFloat32ArrayCid == kTypedDataInt8ArrayCid + 9 &&
1876 kTypedDataFloat64ArrayCid == kTypedDataInt8ArrayCid + 10 && 1883 kTypedDataFloat64ArrayCid == kTypedDataInt8ArrayCid + 10 &&
1877 kExternalTypedDataInt8ArrayCid == kTypedDataInt8ArrayCid + 11); 1884 kTypedDataInt8ArrayViewCid == kTypedDataInt8ArrayCid + 11);
1878 return (index >= kTypedDataInt8ArrayCid && 1885 return (index >= kTypedDataInt8ArrayCid &&
1879 index <= kTypedDataFloat64ArrayCid); 1886 index <= kTypedDataFloat64ArrayCid);
1880 } 1887 }
1881 1888
1882 1889
1890 inline bool RawObject::IsTypedDataViewClassId(intptr_t index) {
1891 // Make sure this is updated when new TypedData types are added.
1892 ASSERT(kTypedDataUint8ArrayViewCid == kTypedDataInt8ArrayViewCid + 1 &&
1893 kTypedDataUint8ClampedArrayViewCid == kTypedDataInt8ArrayViewCid + 2 &&
1894 kTypedDataInt16ArrayViewCid == kTypedDataInt8ArrayViewCid + 3 &&
1895 kTypedDataUint16ArrayViewCid == kTypedDataInt8ArrayViewCid + 4 &&
1896 kTypedDataInt32ArrayViewCid == kTypedDataInt8ArrayViewCid + 5 &&
1897 kTypedDataUint32ArrayViewCid == kTypedDataInt8ArrayViewCid + 6 &&
1898 kTypedDataInt64ArrayViewCid == kTypedDataInt8ArrayViewCid + 7 &&
1899 kTypedDataUint64ArrayViewCid == kTypedDataInt8ArrayViewCid + 8 &&
1900 kTypedDataFloat32ArrayViewCid == kTypedDataInt8ArrayViewCid + 9 &&
1901 kTypedDataFloat64ArrayViewCid == kTypedDataInt8ArrayViewCid + 10 &&
1902 kByteDataViewCid == kTypedDataInt8ArrayViewCid + 11 &&
1903 kExternalTypedDataInt8ArrayCid == kTypedDataInt8ArrayViewCid + 12);
1904 return (index >= kTypedDataInt8ArrayViewCid &&
1905 index <= kByteDataViewCid);
1906 }
1907
1908
1883 inline bool RawObject::IsExternalTypedDataClassId(intptr_t index) { 1909 inline bool RawObject::IsExternalTypedDataClassId(intptr_t index) {
1884 // Make sure this is updated when new ExternalTypedData types are added. 1910 // Make sure this is updated when new ExternalTypedData types are added.
1885 ASSERT((kExternalTypedDataUint8ArrayCid == 1911 ASSERT((kExternalTypedDataUint8ArrayCid ==
1886 kExternalTypedDataInt8ArrayCid + 1) && 1912 kExternalTypedDataInt8ArrayCid + 1) &&
1887 (kExternalTypedDataUint8ClampedArrayCid == 1913 (kExternalTypedDataUint8ClampedArrayCid ==
1888 kExternalTypedDataInt8ArrayCid + 2) && 1914 kExternalTypedDataInt8ArrayCid + 2) &&
1889 (kExternalTypedDataInt16ArrayCid == 1915 (kExternalTypedDataInt16ArrayCid ==
1890 kExternalTypedDataInt8ArrayCid + 3) && 1916 kExternalTypedDataInt8ArrayCid + 3) &&
1891 (kExternalTypedDataUint16ArrayCid == 1917 (kExternalTypedDataUint16ArrayCid ==
1892 kExternalTypedDataInt8ArrayCid + 4) && 1918 kExternalTypedDataInt8ArrayCid + 4) &&
(...skipping 10 matching lines...) Expand all
1903 (kExternalTypedDataFloat64ArrayCid == 1929 (kExternalTypedDataFloat64ArrayCid ==
1904 kExternalTypedDataInt8ArrayCid + 10) && 1930 kExternalTypedDataInt8ArrayCid + 10) &&
1905 (kNullCid == kExternalTypedDataInt8ArrayCid + 11)); 1931 (kNullCid == kExternalTypedDataInt8ArrayCid + 11));
1906 return (index >= kExternalTypedDataInt8ArrayCid && 1932 return (index >= kExternalTypedDataInt8ArrayCid &&
1907 index <= kExternalTypedDataFloat64ArrayCid); 1933 index <= kExternalTypedDataFloat64ArrayCid);
1908 } 1934 }
1909 1935
1910 1936
1911 inline intptr_t RawObject::NumberOfTypedDataClasses() { 1937 inline intptr_t RawObject::NumberOfTypedDataClasses() {
1912 // Make sure this is updated when new TypedData types are added. 1938 // Make sure this is updated when new TypedData types are added.
1913 ASSERT(kExternalTypedDataInt8ArrayCid == kTypedDataInt8ArrayCid + 11); 1939 ASSERT(kTypedDataInt8ArrayViewCid == kTypedDataInt8ArrayCid + 11);
1940 ASSERT(kExternalTypedDataInt8ArrayCid == kTypedDataInt8ArrayViewCid + 12);
1914 ASSERT(kNullCid == kExternalTypedDataInt8ArrayCid + 11); 1941 ASSERT(kNullCid == kExternalTypedDataInt8ArrayCid + 11);
1915 return (kNullCid - kTypedDataInt8ArrayCid); 1942 return (kNullCid - kTypedDataInt8ArrayCid);
1916 } 1943 }
1917 1944
1918 } // namespace dart 1945 } // namespace dart
1919 1946
1920 #endif // VM_RAW_OBJECT_H_ 1947 #endif // VM_RAW_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/raw_object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698