Chromium Code Reviews| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 50 V(AbstractType) \ | 50 V(AbstractType) \ |
| 51 V(Type) \ | 51 V(Type) \ |
| 52 V(TypeParameter) \ | 52 V(TypeParameter) \ |
| 53 V(Number) \ | 53 V(Number) \ |
| 54 V(Integer) \ | 54 V(Integer) \ |
| 55 V(Smi) \ | 55 V(Smi) \ |
| 56 V(Mint) \ | 56 V(Mint) \ |
| 57 V(Bigint) \ | 57 V(Bigint) \ |
| 58 V(Double) \ | 58 V(Double) \ |
| 59 V(String) \ | 59 V(String) \ |
| 60 V(OneByteString) \ | |
| 61 V(TwoByteString) \ | |
| 62 V(ExternalOneByteString) \ | |
| 63 V(ExternalTwoByteString) \ | |
| 64 V(Bool) \ | 60 V(Bool) \ |
| 65 V(Array) \ | 61 V(Array) \ |
| 66 V(ImmutableArray) \ | 62 V(ImmutableArray) \ |
| 67 V(GrowableObjectArray) \ | 63 V(GrowableObjectArray) \ |
| 68 V(ByteArray) \ | 64 V(ByteArray) \ |
| 69 V(Int8Array) \ | 65 V(Int8Array) \ |
| 70 V(Uint8Array) \ | 66 V(Uint8Array) \ |
| 71 V(Int16Array) \ | 67 V(Int16Array) \ |
| 72 V(Uint16Array) \ | 68 V(Uint16Array) \ |
| 73 V(Int32Array) \ | 69 V(Int32Array) \ |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 84 V(ExternalUint32Array) \ | 80 V(ExternalUint32Array) \ |
| 85 V(ExternalInt64Array) \ | 81 V(ExternalInt64Array) \ |
| 86 V(ExternalUint64Array) \ | 82 V(ExternalUint64Array) \ |
| 87 V(ExternalFloat32Array) \ | 83 V(ExternalFloat32Array) \ |
| 88 V(ExternalFloat64Array) \ | 84 V(ExternalFloat64Array) \ |
| 89 V(Stacktrace) \ | 85 V(Stacktrace) \ |
| 90 V(JSRegExp) \ | 86 V(JSRegExp) \ |
| 91 V(WeakProperty) \ | 87 V(WeakProperty) \ |
| 92 V(DartFunction) \ | 88 V(DartFunction) \ |
| 93 | 89 |
| 94 #define CLASS_LIST(V) \ | 90 #define CLASS_LIST(V) \ |
|
siva
2012/11/02 01:15:25
CLASS_LIST should include all classes right, now i
Tom Ball
2012/11/02 23:31:50
Fixed CLASS_LIST and CLASS_LIST_NO_OBJECT to inclu
| |
| 95 V(Object) \ | 91 V(Object) \ |
| 96 CLASS_LIST_NO_OBJECT(V) | 92 CLASS_LIST_NO_OBJECT(V) |
| 97 | 93 |
| 94 #define CLASS_LIST_STRING_SUBTYPES(V) \ | |
| 95 V(OneByteString) \ | |
| 96 V(TwoByteString) \ | |
| 97 V(ExternalOneByteString) \ | |
| 98 V(ExternalTwoByteString) | |
| 99 | |
| 98 | 100 |
| 99 // Forward declarations. | 101 // Forward declarations. |
| 100 class Isolate; | 102 class Isolate; |
| 101 #define DEFINE_FORWARD_DECLARATION(clazz) \ | 103 #define DEFINE_FORWARD_DECLARATION(clazz) \ |
| 102 class Raw##clazz; | 104 class Raw##clazz; |
| 103 CLASS_LIST(DEFINE_FORWARD_DECLARATION) | 105 CLASS_LIST(DEFINE_FORWARD_DECLARATION) |
| 104 #undef DEFINE_FORWARD_DECLARATION | 106 #undef DEFINE_FORWARD_DECLARATION |
| 105 | 107 |
| 106 | 108 |
| 107 enum ClassId { | 109 enum ClassId { |
| 108 // Illegal class id. | 110 // Illegal class id. |
| 109 kIllegalCid = 0, | 111 kIllegalCid = 0, |
| 110 | 112 |
| 111 // List of Ids for predefined classes. | 113 // List of Ids for predefined classes. |
| 112 #define DEFINE_OBJECT_KIND(clazz) \ | 114 #define DEFINE_OBJECT_KIND(clazz) \ |
| 113 k##clazz##Cid, | 115 k##clazz##Cid, |
| 114 CLASS_LIST(DEFINE_OBJECT_KIND) | 116 CLASS_LIST(DEFINE_OBJECT_KIND) |
| 115 #undef DEFINE_OBJECT_KIND | 117 #undef DEFINE_OBJECT_KIND |
| 116 | 118 |
| 119 // The following entries describe the types of string subtypes. | |
| 120 kOneByteStringCid, | |
| 121 kTwoByteStringCid, | |
| 122 kExternalOneByteStringCid, | |
| 123 kExternalTwoByteStringCid, | |
| 124 | |
| 117 // The following entries do not describe a predefined class, but instead | 125 // The following entries do not describe a predefined class, but instead |
| 118 // are class indexes for pre-allocated instance (Null, dynamic and Void). | 126 // are class indexes for pre-allocated instance (Null, dynamic and Void). |
| 119 kNullCid, | 127 kNullCid, |
| 120 kDynamicCid, | 128 kDynamicCid, |
| 121 kVoidCid, | 129 kVoidCid, |
| 122 | 130 |
| 123 // The following entry does not describe a real class, but instead it is an | 131 // The following entry does not describe a real class, but instead it is an |
| 124 // id which is used to identify free list elements in the heap. | 132 // id which is used to identify free list elements in the heap. |
| 125 kFreeListElement, | 133 kFreeListElement, |
| 126 | 134 |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 378 friend class Heap; | 386 friend class Heap; |
| 379 friend class HeapProfiler; | 387 friend class HeapProfiler; |
| 380 friend class HeapProfilerRootVisitor; | 388 friend class HeapProfilerRootVisitor; |
| 381 friend class MarkingVisitor; | 389 friend class MarkingVisitor; |
| 382 friend class Object; | 390 friend class Object; |
| 383 friend class RawInstructions; | 391 friend class RawInstructions; |
| 384 friend class RawInstance; | 392 friend class RawInstance; |
| 385 friend class Scavenger; | 393 friend class Scavenger; |
| 386 friend class SnapshotReader; | 394 friend class SnapshotReader; |
| 387 friend class SnapshotWriter; | 395 friend class SnapshotWriter; |
| 396 friend class String; | |
| 388 | 397 |
| 389 DISALLOW_ALLOCATION(); | 398 DISALLOW_ALLOCATION(); |
| 390 DISALLOW_IMPLICIT_CONSTRUCTORS(RawObject); | 399 DISALLOW_IMPLICIT_CONSTRUCTORS(RawObject); |
| 391 }; | 400 }; |
| 392 | 401 |
| 393 | 402 |
| 394 class RawClass : public RawObject { | 403 class RawClass : public RawObject { |
| 395 public: | 404 public: |
| 396 enum ClassState { | 405 enum ClassState { |
| 397 kAllocated, // Initial state. | 406 kAllocated, // Initial state. |
| (...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1504 ASSERT(kSmiCid == kIntegerCid + 1 && | 1513 ASSERT(kSmiCid == kIntegerCid + 1 && |
| 1505 kMintCid == kIntegerCid + 2 && | 1514 kMintCid == kIntegerCid + 2 && |
| 1506 kBigintCid == kIntegerCid + 3 && | 1515 kBigintCid == kIntegerCid + 3 && |
| 1507 kDoubleCid == kIntegerCid + 4); | 1516 kDoubleCid == kIntegerCid + 4); |
| 1508 return (index >= kIntegerCid && index < kDoubleCid); | 1517 return (index >= kIntegerCid && index < kDoubleCid); |
| 1509 } | 1518 } |
| 1510 | 1519 |
| 1511 | 1520 |
| 1512 inline bool RawObject::IsStringClassId(intptr_t index) { | 1521 inline bool RawObject::IsStringClassId(intptr_t index) { |
| 1513 // Make sure this function is updated when new StringCid types are added. | 1522 // Make sure this function is updated when new StringCid types are added. |
| 1514 ASSERT(kOneByteStringCid == kStringCid + 1 && | 1523 ASSERT(kTwoByteStringCid == kOneByteStringCid + 1 && |
| 1515 kTwoByteStringCid == kStringCid + 2 && | 1524 kExternalOneByteStringCid == kOneByteStringCid + 2 && |
| 1516 kExternalOneByteStringCid == kStringCid + 3 && | 1525 kExternalTwoByteStringCid == kOneByteStringCid + 3); |
| 1517 kExternalTwoByteStringCid == kStringCid + 4 && | 1526 return (index >= kOneByteStringCid && index <= kExternalTwoByteStringCid); |
| 1518 kBoolCid == kStringCid + 5); | |
| 1519 return (index >= kStringCid && index < kBoolCid); | |
| 1520 } | 1527 } |
| 1521 | 1528 |
| 1522 | 1529 |
| 1523 inline bool RawObject::IsOneByteStringClassId(intptr_t index) { | 1530 inline bool RawObject::IsOneByteStringClassId(intptr_t index) { |
| 1524 // Make sure this function is updated when new StringCid types are added. | 1531 // Make sure this function is updated when new StringCid types are added. |
| 1525 ASSERT(kOneByteStringCid == kStringCid + 1 && | 1532 ASSERT(kTwoByteStringCid == kOneByteStringCid + 1 && |
| 1526 kTwoByteStringCid == kStringCid + 2 && | 1533 kExternalOneByteStringCid == kOneByteStringCid + 2 && |
| 1527 kExternalOneByteStringCid == kStringCid + 3 && | 1534 kExternalTwoByteStringCid == kOneByteStringCid + 3); |
| 1528 kExternalTwoByteStringCid == kStringCid + 4 && | |
| 1529 kBoolCid == kStringCid + 5); | |
| 1530 return (index == kOneByteStringCid || index == kExternalOneByteStringCid); | 1535 return (index == kOneByteStringCid || index == kExternalOneByteStringCid); |
| 1531 } | 1536 } |
| 1532 | 1537 |
| 1533 | 1538 |
| 1534 inline bool RawObject::IsTwoByteStringClassId(intptr_t index) { | 1539 inline bool RawObject::IsTwoByteStringClassId(intptr_t index) { |
| 1535 // Make sure this function is updated when new StringCid types are added. | 1540 // Make sure this function is updated when new StringCid types are added. |
| 1536 ASSERT(kOneByteStringCid == kStringCid + 1 && | 1541 ASSERT(kTwoByteStringCid == kOneByteStringCid + 1 && |
| 1537 kTwoByteStringCid == kStringCid + 2 && | 1542 kExternalOneByteStringCid == kOneByteStringCid + 2 && |
| 1538 kExternalOneByteStringCid == kStringCid + 3 && | 1543 kExternalTwoByteStringCid == kOneByteStringCid + 3); |
| 1539 kExternalTwoByteStringCid == kStringCid + 4 && | |
| 1540 kBoolCid == kStringCid + 5); | |
| 1541 return (index == kOneByteStringCid || | 1544 return (index == kOneByteStringCid || |
| 1542 index == kTwoByteStringCid || | 1545 index == kTwoByteStringCid || |
| 1543 index == kExternalOneByteStringCid || | 1546 index == kExternalOneByteStringCid || |
| 1544 index == kExternalTwoByteStringCid); | 1547 index == kExternalTwoByteStringCid); |
| 1545 } | 1548 } |
| 1546 | 1549 |
| 1547 | 1550 |
| 1548 inline bool RawObject::IsExternalStringClassId(intptr_t index) { | 1551 inline bool RawObject::IsExternalStringClassId(intptr_t index) { |
| 1549 // Make sure this function is updated when new StringCid types are added. | 1552 // Make sure this function is updated when new StringCid types are added. |
| 1550 ASSERT(kOneByteStringCid == kStringCid + 1 && | 1553 ASSERT(kTwoByteStringCid == kOneByteStringCid + 1 && |
| 1551 kTwoByteStringCid == kStringCid + 2 && | 1554 kExternalOneByteStringCid == kOneByteStringCid + 2 && |
| 1552 kExternalOneByteStringCid == kStringCid + 3 && | 1555 kExternalTwoByteStringCid == kOneByteStringCid + 3); |
| 1553 kExternalTwoByteStringCid == kStringCid + 4 && | |
| 1554 kBoolCid == kStringCid + 5); | |
| 1555 return (index == kExternalOneByteStringCid || | 1556 return (index == kExternalOneByteStringCid || |
| 1556 index == kExternalTwoByteStringCid); | 1557 index == kExternalTwoByteStringCid); |
| 1557 } | 1558 } |
| 1558 | 1559 |
| 1559 | 1560 |
| 1560 inline bool RawObject::IsBuiltinListClassId(intptr_t index) { | 1561 inline bool RawObject::IsBuiltinListClassId(intptr_t index) { |
| 1561 // Make sure this function is updated when new builtin List types are added. | 1562 // Make sure this function is updated when new builtin List types are added. |
| 1562 ASSERT(kImmutableArrayCid == kArrayCid + 1 && | 1563 ASSERT(kImmutableArrayCid == kArrayCid + 1 && |
| 1563 kGrowableObjectArrayCid == kArrayCid + 2 && | 1564 kGrowableObjectArrayCid == kArrayCid + 2 && |
| 1564 kByteArrayCid == kArrayCid + 3); | 1565 kByteArrayCid == kArrayCid + 3); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1604 kExternalUint64ArrayCid == kExternalInt8ArrayCid + 7 && | 1605 kExternalUint64ArrayCid == kExternalInt8ArrayCid + 7 && |
| 1605 kExternalFloat32ArrayCid == kExternalInt8ArrayCid + 8 && | 1606 kExternalFloat32ArrayCid == kExternalInt8ArrayCid + 8 && |
| 1606 kExternalFloat64ArrayCid == kExternalInt8ArrayCid + 9 && | 1607 kExternalFloat64ArrayCid == kExternalInt8ArrayCid + 9 && |
| 1607 kStacktraceCid == kExternalInt8ArrayCid + 10); | 1608 kStacktraceCid == kExternalInt8ArrayCid + 10); |
| 1608 return (index >= kExternalInt8ArrayCid && index <= kExternalFloat64ArrayCid); | 1609 return (index >= kExternalInt8ArrayCid && index <= kExternalFloat64ArrayCid); |
| 1609 } | 1610 } |
| 1610 | 1611 |
| 1611 } // namespace dart | 1612 } // namespace dart |
| 1612 | 1613 |
| 1613 #endif // VM_RAW_OBJECT_H_ | 1614 #endif // VM_RAW_OBJECT_H_ |
| OLD | NEW |