| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 V(BoundedType) \ | 53 V(BoundedType) \ |
| 54 V(MixinAppType) \ | 54 V(MixinAppType) \ |
| 55 V(Number) \ | 55 V(Number) \ |
| 56 V(Integer) \ | 56 V(Integer) \ |
| 57 V(Smi) \ | 57 V(Smi) \ |
| 58 V(Mint) \ | 58 V(Mint) \ |
| 59 V(Bigint) \ | 59 V(Bigint) \ |
| 60 V(Double) \ | 60 V(Double) \ |
| 61 V(Bool) \ | 61 V(Bool) \ |
| 62 V(GrowableObjectArray) \ | 62 V(GrowableObjectArray) \ |
| 63 V(Float32x4) \ |
| 64 V(Int32x4) \ |
| 65 V(Float64x2) \ |
| 63 V(TypedData) \ | 66 V(TypedData) \ |
| 64 V(ExternalTypedData) \ | 67 V(ExternalTypedData) \ |
| 68 V(Capability) \ |
| 69 V(ReceivePort) \ |
| 70 V(SendPort) \ |
| 65 V(Stacktrace) \ | 71 V(Stacktrace) \ |
| 66 V(JSRegExp) \ | 72 V(JSRegExp) \ |
| 67 V(WeakProperty) \ | 73 V(WeakProperty) \ |
| 68 V(MirrorReference) \ | 74 V(MirrorReference) \ |
| 69 V(Float32x4) \ | |
| 70 V(Int32x4) \ | |
| 71 V(Float64x2) \ | |
| 72 V(UserTag) \ | 75 V(UserTag) \ |
| 73 | 76 |
| 74 #define CLASS_LIST_ARRAYS(V) \ | 77 #define CLASS_LIST_ARRAYS(V) \ |
| 75 V(Array) \ | 78 V(Array) \ |
| 76 V(ImmutableArray) \ | 79 V(ImmutableArray) \ |
| 77 | 80 |
| 78 #define CLASS_LIST_STRINGS(V) \ | 81 #define CLASS_LIST_STRINGS(V) \ |
| 79 V(String) \ | 82 V(String) \ |
| 80 V(OneByteString) \ | 83 V(OneByteString) \ |
| 81 V(TwoByteString) \ | 84 V(TwoByteString) \ |
| (...skipping 1415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1497 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->length_); } | 1500 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->length_); } |
| 1498 RawSmi* length_; | 1501 RawSmi* length_; |
| 1499 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->length_); } | 1502 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->length_); } |
| 1500 | 1503 |
| 1501 uint8_t* data_; | 1504 uint8_t* data_; |
| 1502 | 1505 |
| 1503 friend class TokenStream; | 1506 friend class TokenStream; |
| 1504 friend class RawTokenStream; | 1507 friend class RawTokenStream; |
| 1505 }; | 1508 }; |
| 1506 | 1509 |
| 1510 // VM implementations of the basic types in the isolate. |
| 1511 class RawCapability : public RawInstance { |
| 1512 RAW_HEAP_OBJECT_IMPLEMENTATION(Capability); |
| 1513 uint64_t id_; |
| 1514 }; |
| 1515 |
| 1516 |
| 1517 class RawSendPort : public RawInstance { |
| 1518 RAW_HEAP_OBJECT_IMPLEMENTATION(SendPort); |
| 1519 Dart_Port id_; |
| 1520 |
| 1521 friend class ReceivePort; |
| 1522 }; |
| 1523 |
| 1524 |
| 1525 class RawReceivePort : public RawInstance { |
| 1526 RAW_HEAP_OBJECT_IMPLEMENTATION(ReceivePort); |
| 1527 |
| 1528 RawObject** from() { |
| 1529 return reinterpret_cast<RawObject**>(&ptr()->send_port_); |
| 1530 } |
| 1531 RawSendPort* send_port_; |
| 1532 RawInstance* handler_; |
| 1533 RawObject** to() { |
| 1534 return reinterpret_cast<RawObject**>(&ptr()->handler_); |
| 1535 } |
| 1536 }; |
| 1537 |
| 1507 | 1538 |
| 1508 // VM type for capturing stacktraces when exceptions are thrown, | 1539 // VM type for capturing stacktraces when exceptions are thrown, |
| 1509 // Currently we don't have any interface that this object is supposed | 1540 // Currently we don't have any interface that this object is supposed |
| 1510 // to implement so we just support the 'toString' method which | 1541 // to implement so we just support the 'toString' method which |
| 1511 // converts the stack trace into a string. | 1542 // converts the stack trace into a string. |
| 1512 class RawStacktrace : public RawInstance { | 1543 class RawStacktrace : public RawInstance { |
| 1513 RAW_HEAP_OBJECT_IMPLEMENTATION(Stacktrace); | 1544 RAW_HEAP_OBJECT_IMPLEMENTATION(Stacktrace); |
| 1514 | 1545 |
| 1515 RawObject** from() { | 1546 RawObject** from() { |
| 1516 return reinterpret_cast<RawObject**>(&ptr()->code_array_); | 1547 return reinterpret_cast<RawObject**>(&ptr()->code_array_); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1678 kTwoByteStringCid == kStringCid + 2 && | 1709 kTwoByteStringCid == kStringCid + 2 && |
| 1679 kExternalOneByteStringCid == kStringCid + 3 && | 1710 kExternalOneByteStringCid == kStringCid + 3 && |
| 1680 kExternalTwoByteStringCid == kStringCid + 4); | 1711 kExternalTwoByteStringCid == kStringCid + 4); |
| 1681 return (index == kExternalOneByteStringCid || | 1712 return (index == kExternalOneByteStringCid || |
| 1682 index == kExternalTwoByteStringCid); | 1713 index == kExternalTwoByteStringCid); |
| 1683 } | 1714 } |
| 1684 | 1715 |
| 1685 | 1716 |
| 1686 inline bool RawObject::IsBuiltinListClassId(intptr_t index) { | 1717 inline bool RawObject::IsBuiltinListClassId(intptr_t index) { |
| 1687 // Make sure this function is updated when new builtin List types are added. | 1718 // Make sure this function is updated when new builtin List types are added. |
| 1688 ASSERT(kImmutableArrayCid == kArrayCid + 1 && | 1719 ASSERT(kImmutableArrayCid == kArrayCid + 1); |
| 1689 kTypedDataCid == kGrowableObjectArrayCid + 1); | |
| 1690 return ((index >= kArrayCid && index <= kImmutableArrayCid) || | 1720 return ((index >= kArrayCid && index <= kImmutableArrayCid) || |
| 1691 (index >= kGrowableObjectArrayCid && index < kTypedDataCid) || | 1721 (index == kGrowableObjectArrayCid) || |
| 1692 IsTypedDataClassId(index) || | 1722 IsTypedDataClassId(index) || |
| 1693 IsTypedDataViewClassId(index) || | 1723 IsTypedDataViewClassId(index) || |
| 1694 IsExternalTypedDataClassId(index)); | 1724 IsExternalTypedDataClassId(index)); |
| 1695 } | 1725 } |
| 1696 | 1726 |
| 1697 | 1727 |
| 1698 inline bool RawObject::IsTypedDataClassId(intptr_t index) { | 1728 inline bool RawObject::IsTypedDataClassId(intptr_t index) { |
| 1699 // Make sure this is updated when new TypedData types are added. | 1729 // Make sure this is updated when new TypedData types are added. |
| 1700 ASSERT(kTypedDataUint8ArrayCid == kTypedDataInt8ArrayCid + 1 && | 1730 ASSERT(kTypedDataUint8ArrayCid == kTypedDataInt8ArrayCid + 1 && |
| 1701 kTypedDataUint8ClampedArrayCid == kTypedDataInt8ArrayCid + 2 && | 1731 kTypedDataUint8ClampedArrayCid == kTypedDataInt8ArrayCid + 2 && |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1805 // Make sure this is updated when new TypedData types are added. | 1835 // Make sure this is updated when new TypedData types are added. |
| 1806 ASSERT(kTypedDataInt8ArrayViewCid == kTypedDataInt8ArrayCid + 14); | 1836 ASSERT(kTypedDataInt8ArrayViewCid == kTypedDataInt8ArrayCid + 14); |
| 1807 ASSERT(kExternalTypedDataInt8ArrayCid == kTypedDataInt8ArrayViewCid + 15); | 1837 ASSERT(kExternalTypedDataInt8ArrayCid == kTypedDataInt8ArrayViewCid + 15); |
| 1808 ASSERT(kNullCid == kExternalTypedDataInt8ArrayCid + 14); | 1838 ASSERT(kNullCid == kExternalTypedDataInt8ArrayCid + 14); |
| 1809 return (kNullCid - kTypedDataInt8ArrayCid); | 1839 return (kNullCid - kTypedDataInt8ArrayCid); |
| 1810 } | 1840 } |
| 1811 | 1841 |
| 1812 } // namespace dart | 1842 } // namespace dart |
| 1813 | 1843 |
| 1814 #endif // VM_RAW_OBJECT_H_ | 1844 #endif // VM_RAW_OBJECT_H_ |
| OLD | NEW |