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

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

Issue 392043003: The dart version of typeddata library has changed to be compatible with the dart2js implementation (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 5 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/parser.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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 kTypedData##clazz##ViewCid, 143 kTypedData##clazz##ViewCid,
144 CLASS_LIST_TYPED_DATA(DEFINE_OBJECT_KIND) 144 CLASS_LIST_TYPED_DATA(DEFINE_OBJECT_KIND)
145 kByteDataViewCid, 145 kByteDataViewCid,
146 #undef DEFINE_OBJECT_KIND 146 #undef DEFINE_OBJECT_KIND
147 147
148 #define DEFINE_OBJECT_KIND(clazz) \ 148 #define DEFINE_OBJECT_KIND(clazz) \
149 kExternalTypedData##clazz##Cid, 149 kExternalTypedData##clazz##Cid,
150 CLASS_LIST_TYPED_DATA(DEFINE_OBJECT_KIND) 150 CLASS_LIST_TYPED_DATA(DEFINE_OBJECT_KIND)
151 #undef DEFINE_OBJECT_KIND 151 #undef DEFINE_OBJECT_KIND
152 152
153 kByteBufferCid,
154
153 // The following entries do not describe a predefined class, but instead 155 // The following entries do not describe a predefined class, but instead
154 // are class indexes for pre-allocated instance (Null, dynamic and Void). 156 // are class indexes for pre-allocated instance (Null, dynamic and Void).
155 kNullCid, 157 kNullCid,
156 kDynamicCid, 158 kDynamicCid,
157 kVoidCid, 159 kVoidCid,
158 160
159 // The following entry does not describe a real class, but instead it is an 161 // The following entry does not describe a real class, but instead it is an
160 // id which is used to identify free list elements in the heap. 162 // id which is used to identify free list elements in the heap.
161 kFreeListElement, 163 kFreeListElement,
162 164
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 static bool IsStringClassId(intptr_t index); 412 static bool IsStringClassId(intptr_t index);
411 static bool IsOneByteStringClassId(intptr_t index); 413 static bool IsOneByteStringClassId(intptr_t index);
412 static bool IsTwoByteStringClassId(intptr_t index); 414 static bool IsTwoByteStringClassId(intptr_t index);
413 static bool IsExternalStringClassId(intptr_t index); 415 static bool IsExternalStringClassId(intptr_t index);
414 static bool IsBuiltinListClassId(intptr_t index); 416 static bool IsBuiltinListClassId(intptr_t index);
415 static bool IsTypedDataClassId(intptr_t index); 417 static bool IsTypedDataClassId(intptr_t index);
416 static bool IsTypedDataViewClassId(intptr_t index); 418 static bool IsTypedDataViewClassId(intptr_t index);
417 static bool IsExternalTypedDataClassId(intptr_t index); 419 static bool IsExternalTypedDataClassId(intptr_t index);
418 static bool IsInternalVMdefinedClassId(intptr_t index); 420 static bool IsInternalVMdefinedClassId(intptr_t index);
419 static bool IsVariableSizeClassId(intptr_t index); 421 static bool IsVariableSizeClassId(intptr_t index);
422 static bool IsImplicitFieldClassId(intptr_t index);
420 423
421 static intptr_t NumberOfTypedDataClasses(); 424 static intptr_t NumberOfTypedDataClasses();
422 425
423 private: 426 private:
424 uword tags_; // Various object tags (bits). 427 uword tags_; // Various object tags (bits).
425 428
426 class WatchedBit : public BitField<bool, kWatchedBit, 1> {}; 429 class WatchedBit : public BitField<bool, kWatchedBit, 1> {};
427 430
428 class MarkBit : public BitField<bool, kMarkBit, 1> {}; 431 class MarkBit : public BitField<bool, kMarkBit, 1> {};
429 432
(...skipping 14 matching lines...) Expand all
444 447
445 intptr_t SizeFromClass() const; 448 intptr_t SizeFromClass() const;
446 449
447 intptr_t GetClassId() const { 450 intptr_t GetClassId() const {
448 uword tags = ptr()->tags_; 451 uword tags = ptr()->tags_;
449 return ClassIdTag::decode(tags); 452 return ClassIdTag::decode(tags);
450 } 453 }
451 454
452 friend class Api; 455 friend class Api;
453 friend class Array; 456 friend class Array;
457 friend class ByteBuffer;
454 friend class Code; 458 friend class Code;
455 friend class FreeListElement; 459 friend class FreeListElement;
456 friend class GCMarker; 460 friend class GCMarker;
457 friend class ExternalTypedData; 461 friend class ExternalTypedData;
458 friend class ForwardList; 462 friend class ForwardList;
459 friend class Heap; 463 friend class Heap;
460 friend class HeapMapAsJSONVisitor; 464 friend class HeapMapAsJSONVisitor;
461 friend class ClassStatsVisitor; 465 friend class ClassStatsVisitor;
462 friend class MarkingVisitor; 466 friend class MarkingVisitor;
463 friend class Object; 467 friend class Object;
(...skipping 1362 matching lines...) Expand 10 before | Expand all | Expand 10 after
1826 } 1830 }
1827 1831
1828 1832
1829 inline bool RawObject::IsBuiltinListClassId(intptr_t index) { 1833 inline bool RawObject::IsBuiltinListClassId(intptr_t index) {
1830 // Make sure this function is updated when new builtin List types are added. 1834 // Make sure this function is updated when new builtin List types are added.
1831 COMPILE_ASSERT(kImmutableArrayCid == kArrayCid + 1); 1835 COMPILE_ASSERT(kImmutableArrayCid == kArrayCid + 1);
1832 return ((index >= kArrayCid && index <= kImmutableArrayCid) || 1836 return ((index >= kArrayCid && index <= kImmutableArrayCid) ||
1833 (index == kGrowableObjectArrayCid) || 1837 (index == kGrowableObjectArrayCid) ||
1834 IsTypedDataClassId(index) || 1838 IsTypedDataClassId(index) ||
1835 IsTypedDataViewClassId(index) || 1839 IsTypedDataViewClassId(index) ||
1836 IsExternalTypedDataClassId(index)); 1840 IsExternalTypedDataClassId(index) ||
1841 (index == kByteBufferCid));
1837 } 1842 }
1838 1843
1839 1844
1840 inline bool RawObject::IsTypedDataClassId(intptr_t index) { 1845 inline bool RawObject::IsTypedDataClassId(intptr_t index) {
1841 // Make sure this is updated when new TypedData types are added. 1846 // Make sure this is updated when new TypedData types are added.
1842 COMPILE_ASSERT(kTypedDataUint8ArrayCid == kTypedDataInt8ArrayCid + 1 && 1847 COMPILE_ASSERT(kTypedDataUint8ArrayCid == kTypedDataInt8ArrayCid + 1 &&
1843 kTypedDataUint8ClampedArrayCid == kTypedDataInt8ArrayCid + 2 && 1848 kTypedDataUint8ClampedArrayCid == kTypedDataInt8ArrayCid + 2 &&
1844 kTypedDataInt16ArrayCid == kTypedDataInt8ArrayCid + 3 && 1849 kTypedDataInt16ArrayCid == kTypedDataInt8ArrayCid + 3 &&
1845 kTypedDataUint16ArrayCid == kTypedDataInt8ArrayCid + 4 && 1850 kTypedDataUint16ArrayCid == kTypedDataInt8ArrayCid + 4 &&
1846 kTypedDataInt32ArrayCid == kTypedDataInt8ArrayCid + 5 && 1851 kTypedDataInt32ArrayCid == kTypedDataInt8ArrayCid + 5 &&
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1903 (kExternalTypedDataFloat32ArrayCid == 1908 (kExternalTypedDataFloat32ArrayCid ==
1904 kExternalTypedDataInt8ArrayCid + 9) && 1909 kExternalTypedDataInt8ArrayCid + 9) &&
1905 (kExternalTypedDataFloat64ArrayCid == 1910 (kExternalTypedDataFloat64ArrayCid ==
1906 kExternalTypedDataInt8ArrayCid + 10) && 1911 kExternalTypedDataInt8ArrayCid + 10) &&
1907 (kExternalTypedDataFloat32x4ArrayCid == 1912 (kExternalTypedDataFloat32x4ArrayCid ==
1908 kExternalTypedDataInt8ArrayCid + 11) && 1913 kExternalTypedDataInt8ArrayCid + 11) &&
1909 (kExternalTypedDataInt32x4ArrayCid == 1914 (kExternalTypedDataInt32x4ArrayCid ==
1910 kExternalTypedDataInt8ArrayCid + 12) && 1915 kExternalTypedDataInt8ArrayCid + 12) &&
1911 (kExternalTypedDataFloat64x2ArrayCid == 1916 (kExternalTypedDataFloat64x2ArrayCid ==
1912 kExternalTypedDataInt8ArrayCid + 13) && 1917 kExternalTypedDataInt8ArrayCid + 13) &&
1913 (kNullCid == kExternalTypedDataInt8ArrayCid + 14)); 1918 (kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14));
1914 return (index >= kExternalTypedDataInt8ArrayCid && 1919 return (index >= kExternalTypedDataInt8ArrayCid &&
1915 index <= kExternalTypedDataFloat64x2ArrayCid); 1920 index <= kExternalTypedDataFloat64x2ArrayCid);
1916 } 1921 }
1917 1922
1918 1923
1919 inline bool RawObject::IsInternalVMdefinedClassId(intptr_t index) { 1924 inline bool RawObject::IsInternalVMdefinedClassId(intptr_t index) {
1920 return ((index < kNumPredefinedCids) && 1925 return ((index < kNumPredefinedCids) &&
1921 !RawObject::IsTypedDataViewClassId(index)); 1926 !RawObject::IsImplicitFieldClassId(index));
1922 } 1927 }
1923 1928
1924 1929
1925
1926 inline bool RawObject::IsVariableSizeClassId(intptr_t index) { 1930 inline bool RawObject::IsVariableSizeClassId(intptr_t index) {
1927 return (index == kArrayCid) || 1931 return (index == kArrayCid) ||
1928 (index == kImmutableArrayCid) || 1932 (index == kImmutableArrayCid) ||
1929 RawObject::IsOneByteStringClassId(index) || 1933 RawObject::IsOneByteStringClassId(index) ||
1930 RawObject::IsTwoByteStringClassId(index) || 1934 RawObject::IsTwoByteStringClassId(index) ||
1931 RawObject::IsTypedDataClassId(index) || 1935 RawObject::IsTypedDataClassId(index) ||
1932 (index == kContextCid) || 1936 (index == kContextCid) ||
1933 (index == kTypeArgumentsCid) || 1937 (index == kTypeArgumentsCid) ||
1934 (index == kInstructionsCid) || 1938 (index == kInstructionsCid) ||
1935 (index == kPcDescriptorsCid) || 1939 (index == kPcDescriptorsCid) ||
1936 (index == kStackmapCid) || 1940 (index == kStackmapCid) ||
1937 (index == kLocalVarDescriptorsCid) || 1941 (index == kLocalVarDescriptorsCid) ||
1938 (index == kExceptionHandlersCid) || 1942 (index == kExceptionHandlersCid) ||
1939 (index == kDeoptInfoCid) || 1943 (index == kDeoptInfoCid) ||
1940 (index == kCodeCid) || 1944 (index == kCodeCid) ||
1941 (index == kContextScopeCid) || 1945 (index == kContextScopeCid) ||
1942 (index == kInstanceCid) || 1946 (index == kInstanceCid) ||
1943 (index == kBigintCid) || 1947 (index == kBigintCid) ||
1944 (index == kJSRegExpCid); 1948 (index == kJSRegExpCid);
1945 } 1949 }
1946 1950
1947 1951
1952 // This is a set of classes that are not Dart classes whose representation
1953 // is defined by the VM but are used in the VM code by computing the
1954 // implicit field offsets of the various fields in the dart object.
1955 inline bool RawObject::IsImplicitFieldClassId(intptr_t index) {
1956 return (IsTypedDataViewClassId(index) || index == kByteBufferCid);
1957 }
1958
1959
1948 inline intptr_t RawObject::NumberOfTypedDataClasses() { 1960 inline intptr_t RawObject::NumberOfTypedDataClasses() {
1949 // Make sure this is updated when new TypedData types are added. 1961 // Make sure this is updated when new TypedData types are added.
1950 COMPILE_ASSERT(kTypedDataInt8ArrayViewCid == kTypedDataInt8ArrayCid + 14); 1962 COMPILE_ASSERT(kTypedDataInt8ArrayViewCid == kTypedDataInt8ArrayCid + 14);
1951 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == 1963 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid ==
1952 kTypedDataInt8ArrayViewCid + 15); 1964 kTypedDataInt8ArrayViewCid + 15);
1953 COMPILE_ASSERT(kNullCid == kExternalTypedDataInt8ArrayCid + 14); 1965 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14);
1966 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1);
1954 return (kNullCid - kTypedDataInt8ArrayCid); 1967 return (kNullCid - kTypedDataInt8ArrayCid);
1955 } 1968 }
1956 1969
1957 } // namespace dart 1970 } // namespace dart
1958 1971
1959 #endif // VM_RAW_OBJECT_H_ 1972 #endif // VM_RAW_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/parser.cc ('k') | runtime/vm/raw_object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698