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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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) \ | 60 V(OneByteString) \ |
61 V(TwoByteString) \ | 61 V(TwoByteString) \ |
62 V(FourByteString) \ | |
63 V(ExternalOneByteString) \ | 62 V(ExternalOneByteString) \ |
64 V(ExternalTwoByteString) \ | 63 V(ExternalTwoByteString) \ |
65 V(ExternalFourByteString) \ | |
66 V(Bool) \ | 64 V(Bool) \ |
67 V(Array) \ | 65 V(Array) \ |
68 V(ImmutableArray) \ | 66 V(ImmutableArray) \ |
69 V(GrowableObjectArray) \ | 67 V(GrowableObjectArray) \ |
70 V(ByteArray) \ | 68 V(ByteArray) \ |
71 V(Int8Array) \ | 69 V(Int8Array) \ |
72 V(Uint8Array) \ | 70 V(Uint8Array) \ |
73 V(Int16Array) \ | 71 V(Int16Array) \ |
74 V(Uint16Array) \ | 72 V(Uint16Array) \ |
75 V(Int32Array) \ | 73 V(Int32Array) \ |
(...skipping 1041 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1117 class RawTwoByteString : public RawString { | 1115 class RawTwoByteString : public RawString { |
1118 RAW_HEAP_OBJECT_IMPLEMENTATION(TwoByteString); | 1116 RAW_HEAP_OBJECT_IMPLEMENTATION(TwoByteString); |
1119 | 1117 |
1120 // Variable length data follows here. | 1118 // Variable length data follows here. |
1121 uint16_t data_[0]; | 1119 uint16_t data_[0]; |
1122 | 1120 |
1123 friend class SnapshotReader; | 1121 friend class SnapshotReader; |
1124 }; | 1122 }; |
1125 | 1123 |
1126 | 1124 |
1127 class RawFourByteString : public RawString { | |
1128 RAW_HEAP_OBJECT_IMPLEMENTATION(FourByteString); | |
1129 | |
1130 // Variable length data follows here. | |
1131 uint32_t data_[0]; | |
1132 | |
1133 friend class SnapshotReader; | |
1134 }; | |
1135 | |
1136 | |
1137 template<typename T> | 1125 template<typename T> |
1138 class ExternalStringData { | 1126 class ExternalStringData { |
1139 public: | 1127 public: |
1140 ExternalStringData(const T* data, void* peer, Dart_PeerFinalizer callback) : | 1128 ExternalStringData(const T* data, void* peer, Dart_PeerFinalizer callback) : |
1141 data_(data), peer_(peer), callback_(callback) { | 1129 data_(data), peer_(peer), callback_(callback) { |
1142 } | 1130 } |
1143 ~ExternalStringData() { | 1131 ~ExternalStringData() { |
1144 if (callback_ != NULL) (*callback_)(peer_); | 1132 if (callback_ != NULL) (*callback_)(peer_); |
1145 } | 1133 } |
1146 | 1134 |
(...skipping 20 matching lines...) Expand all Loading... | |
1167 | 1155 |
1168 | 1156 |
1169 class RawExternalTwoByteString : public RawString { | 1157 class RawExternalTwoByteString : public RawString { |
1170 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalTwoByteString); | 1158 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalTwoByteString); |
1171 | 1159 |
1172 ExternalStringData<uint16_t>* external_data_; | 1160 ExternalStringData<uint16_t>* external_data_; |
1173 friend class Api; | 1161 friend class Api; |
1174 }; | 1162 }; |
1175 | 1163 |
1176 | 1164 |
1177 class RawExternalFourByteString : public RawString { | |
1178 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalFourByteString); | |
1179 | |
1180 ExternalStringData<uint32_t>* external_data_; | |
1181 friend class Api; | |
1182 }; | |
1183 | |
1184 | |
1185 class RawBool : public RawInstance { | 1165 class RawBool : public RawInstance { |
1186 RAW_HEAP_OBJECT_IMPLEMENTATION(Bool); | 1166 RAW_HEAP_OBJECT_IMPLEMENTATION(Bool); |
1187 | 1167 |
1188 bool value_; | 1168 bool value_; |
1189 }; | 1169 }; |
1190 | 1170 |
1191 | 1171 |
1192 class RawArray : public RawInstance { | 1172 class RawArray : public RawInstance { |
1193 RAW_HEAP_OBJECT_IMPLEMENTATION(Array); | 1173 RAW_HEAP_OBJECT_IMPLEMENTATION(Array); |
1194 | 1174 |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1519 kMintCid == kIntegerCid + 2 && | 1499 kMintCid == kIntegerCid + 2 && |
1520 kBigintCid == kIntegerCid + 3 && | 1500 kBigintCid == kIntegerCid + 3 && |
1521 kDoubleCid == kIntegerCid + 4); | 1501 kDoubleCid == kIntegerCid + 4); |
1522 return (index >= kIntegerCid && index < kDoubleCid); | 1502 return (index >= kIntegerCid && index < kDoubleCid); |
1523 } | 1503 } |
1524 | 1504 |
1525 inline bool RawObject::IsStringClassId(intptr_t index) { | 1505 inline bool RawObject::IsStringClassId(intptr_t index) { |
1526 // Make sure this function is updated when new StringCid types are added. | 1506 // Make sure this function is updated when new StringCid types are added. |
1527 ASSERT(kOneByteStringCid == kStringCid + 1 && | 1507 ASSERT(kOneByteStringCid == kStringCid + 1 && |
1528 kTwoByteStringCid == kStringCid + 2 && | 1508 kTwoByteStringCid == kStringCid + 2 && |
1529 kFourByteStringCid == kStringCid + 3 && | 1509 kExternalOneByteStringCid == kStringCid + 3 && |
1530 kExternalOneByteStringCid == kStringCid + 4 && | 1510 kExternalTwoByteStringCid == kStringCid + 4 && |
1531 kExternalTwoByteStringCid == kStringCid + 5 && | 1511 kBoolCid == kStringCid + 5); |
1532 kExternalFourByteStringCid == kStringCid + 6 && | |
1533 kBoolCid == kStringCid + 7); | |
1534 return (index >= kStringCid && index < kBoolCid); | 1512 return (index >= kStringCid && index < kBoolCid); |
1535 } | 1513 } |
1536 | 1514 |
cshapiro
2012/10/24 23:52:29
If you are now in the business of adding missing w
siva
2012/10/26 21:38:29
I am not in that business (doesn't pay much), but
| |
1537 inline bool RawObject::IsOneByteStringClassId(intptr_t index) { | 1515 inline bool RawObject::IsOneByteStringClassId(intptr_t index) { |
1538 // Make sure this function is updated when new StringCid types are added. | 1516 // Make sure this function is updated when new StringCid types are added. |
1539 ASSERT(kOneByteStringCid == kStringCid + 1 && | 1517 ASSERT(kOneByteStringCid == kStringCid + 1 && |
1540 kTwoByteStringCid == kStringCid + 2 && | 1518 kTwoByteStringCid == kStringCid + 2 && |
1541 kFourByteStringCid == kStringCid + 3 && | 1519 kExternalOneByteStringCid == kStringCid + 3 && |
1542 kExternalOneByteStringCid == kStringCid + 4 && | 1520 kExternalTwoByteStringCid == kStringCid + 4 && |
1543 kExternalTwoByteStringCid == kStringCid + 5 && | 1521 kBoolCid == kStringCid + 5); |
1544 kExternalFourByteStringCid == kStringCid + 6 && | |
1545 kBoolCid == kStringCid + 7); | |
1546 return (index == kOneByteStringCid || index == kExternalOneByteStringCid); | 1522 return (index == kOneByteStringCid || index == kExternalOneByteStringCid); |
1547 } | 1523 } |
1548 | 1524 |
cshapiro
2012/10/24 23:52:29
Ditto.
siva
2012/10/26 21:38:29
Done.
| |
1549 inline bool RawObject::IsTwoByteStringClassId(intptr_t index) { | 1525 inline bool RawObject::IsTwoByteStringClassId(intptr_t index) { |
1550 // Make sure this function is updated when new StringCid types are added. | 1526 // Make sure this function is updated when new StringCid types are added. |
1551 ASSERT(kOneByteStringCid == kStringCid + 1 && | 1527 ASSERT(kOneByteStringCid == kStringCid + 1 && |
1552 kTwoByteStringCid == kStringCid + 2 && | 1528 kTwoByteStringCid == kStringCid + 2 && |
1553 kFourByteStringCid == kStringCid + 3 && | 1529 kExternalOneByteStringCid == kStringCid + 3 && |
1554 kExternalOneByteStringCid == kStringCid + 4 && | 1530 kExternalTwoByteStringCid == kStringCid + 4 && |
1555 kExternalTwoByteStringCid == kStringCid + 5 && | 1531 kBoolCid == kStringCid + 5); |
1556 kExternalFourByteStringCid == kStringCid + 6 && | |
1557 kBoolCid == kStringCid + 7); | |
1558 return (index == kOneByteStringCid || | 1532 return (index == kOneByteStringCid || |
1559 index == kTwoByteStringCid || | 1533 index == kTwoByteStringCid || |
1560 index == kExternalOneByteStringCid || | 1534 index == kExternalOneByteStringCid || |
1561 index == kExternalTwoByteStringCid); | 1535 index == kExternalTwoByteStringCid); |
1562 } | 1536 } |
1563 | 1537 |
1538 | |
1564 inline bool RawObject::IsExternalStringClassId(intptr_t index) { | 1539 inline bool RawObject::IsExternalStringClassId(intptr_t index) { |
1565 // 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. |
1566 ASSERT(kOneByteStringCid == kStringCid + 1 && | 1541 ASSERT(kOneByteStringCid == kStringCid + 1 && |
1567 kTwoByteStringCid == kStringCid + 2 && | 1542 kTwoByteStringCid == kStringCid + 2 && |
1568 kFourByteStringCid == kStringCid + 3 && | 1543 kExternalOneByteStringCid == kStringCid + 3 && |
1569 kExternalOneByteStringCid == kStringCid + 4 && | 1544 kExternalTwoByteStringCid == kStringCid + 4 && |
1570 kExternalTwoByteStringCid == kStringCid + 5 && | 1545 kBoolCid == kStringCid + 5); |
1571 kExternalFourByteStringCid == kStringCid + 6 && | |
1572 kBoolCid == kStringCid + 7); | |
1573 return (index == kExternalOneByteStringCid || | 1546 return (index == kExternalOneByteStringCid || |
1574 index == kExternalTwoByteStringCid || | 1547 index == kExternalTwoByteStringCid); |
1575 index == kExternalFourByteStringCid); | |
1576 } | 1548 } |
1577 | 1549 |
1550 | |
1578 inline bool RawObject::IsBuiltinListClassId(intptr_t index) { | 1551 inline bool RawObject::IsBuiltinListClassId(intptr_t index) { |
1579 // Make sure this function is updated when new builtin List types are added. | 1552 // Make sure this function is updated when new builtin List types are added. |
1580 ASSERT(kImmutableArrayCid == kArrayCid + 1 && | 1553 ASSERT(kImmutableArrayCid == kArrayCid + 1 && |
1581 kGrowableObjectArrayCid == kArrayCid + 2 && | 1554 kGrowableObjectArrayCid == kArrayCid + 2 && |
1582 kByteArrayCid == kArrayCid + 3); | 1555 kByteArrayCid == kArrayCid + 3); |
1583 return (index >= kArrayCid && index < kByteArrayCid) || | 1556 return (index >= kArrayCid && index < kByteArrayCid) || |
1584 IsByteArrayClassId(index); | 1557 IsByteArrayClassId(index); |
1585 } | 1558 } |
1586 | 1559 |
1587 inline bool RawObject::IsByteArrayClassId(intptr_t index) { | 1560 inline bool RawObject::IsByteArrayClassId(intptr_t index) { |
(...skipping 18 matching lines...) Expand all Loading... | |
1606 kExternalUint64ArrayCid == kByteArrayCid + 18 && | 1579 kExternalUint64ArrayCid == kByteArrayCid + 18 && |
1607 kExternalFloat32ArrayCid == kByteArrayCid + 19 && | 1580 kExternalFloat32ArrayCid == kByteArrayCid + 19 && |
1608 kExternalFloat64ArrayCid == kByteArrayCid + 20 && | 1581 kExternalFloat64ArrayCid == kByteArrayCid + 20 && |
1609 kStacktraceCid == kByteArrayCid + 21); | 1582 kStacktraceCid == kByteArrayCid + 21); |
1610 return (index >= kByteArrayCid && index <= kExternalFloat64ArrayCid); | 1583 return (index >= kByteArrayCid && index <= kExternalFloat64ArrayCid); |
1611 } | 1584 } |
1612 | 1585 |
1613 } // namespace dart | 1586 } // namespace dart |
1614 | 1587 |
1615 #endif // VM_RAW_OBJECT_H_ | 1588 #endif // VM_RAW_OBJECT_H_ |
OLD | NEW |