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/atomic.h" | 9 #include "vm/atomic.h" |
10 #include "vm/globals.h" | 10 #include "vm/globals.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 V(TypeRef) \ | 54 V(TypeRef) \ |
55 V(TypeParameter) \ | 55 V(TypeParameter) \ |
56 V(BoundedType) \ | 56 V(BoundedType) \ |
57 V(MixinAppType) \ | 57 V(MixinAppType) \ |
58 V(Closure) \ | 58 V(Closure) \ |
59 V(Number) \ | 59 V(Number) \ |
60 V(Integer) \ | 60 V(Integer) \ |
61 V(Smi) \ | 61 V(Smi) \ |
62 V(Mint) \ | 62 V(Mint) \ |
63 V(Bigint) \ | 63 V(Bigint) \ |
| 64 V(Fraction) \ |
64 V(Double) \ | 65 V(Double) \ |
65 V(Bool) \ | 66 V(Bool) \ |
66 V(GrowableObjectArray) \ | 67 V(GrowableObjectArray) \ |
67 V(Float32x4) \ | 68 V(Float32x4) \ |
68 V(Int32x4) \ | 69 V(Int32x4) \ |
69 V(Float64x2) \ | 70 V(Float64x2) \ |
70 V(TypedData) \ | 71 V(TypedData) \ |
71 V(ExternalTypedData) \ | 72 V(ExternalTypedData) \ |
72 V(Capability) \ | 73 V(Capability) \ |
73 V(ReceivePort) \ | 74 V(ReceivePort) \ |
(...skipping 1724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1798 RAW_HEAP_OBJECT_IMPLEMENTATION(Bigint); | 1799 RAW_HEAP_OBJECT_IMPLEMENTATION(Bigint); |
1799 | 1800 |
1800 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->neg_); } | 1801 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->neg_); } |
1801 RawBool* neg_; | 1802 RawBool* neg_; |
1802 RawSmi* used_; | 1803 RawSmi* used_; |
1803 RawTypedData* digits_; | 1804 RawTypedData* digits_; |
1804 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->digits_); } | 1805 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->digits_); } |
1805 }; | 1806 }; |
1806 | 1807 |
1807 | 1808 |
| 1809 class RawFraction : public RawNumber { |
| 1810 RAW_HEAP_OBJECT_IMPLEMENTATION(Fraction); |
| 1811 |
| 1812 RawObject** from() { |
| 1813 return reinterpret_cast<RawObject**>(&ptr()->numerator_); |
| 1814 } |
| 1815 RawInteger* numerator_; |
| 1816 RawInteger* denominator_; |
| 1817 RawObject** to() { |
| 1818 return reinterpret_cast<RawObject**>(&ptr()->denominator_); |
| 1819 } |
| 1820 }; |
| 1821 |
| 1822 |
1808 class RawDouble : public RawNumber { | 1823 class RawDouble : public RawNumber { |
1809 RAW_HEAP_OBJECT_IMPLEMENTATION(Double); | 1824 RAW_HEAP_OBJECT_IMPLEMENTATION(Double); |
1810 | 1825 |
1811 ALIGN8 double value_; | 1826 ALIGN8 double value_; |
1812 | 1827 |
1813 friend class Api; | 1828 friend class Api; |
1814 friend class SnapshotReader; | 1829 friend class SnapshotReader; |
1815 }; | 1830 }; |
1816 COMPILE_ASSERT(sizeof(RawDouble) == 16); | 1831 COMPILE_ASSERT(sizeof(RawDouble) == 16); |
1817 | 1832 |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2230 return (index >= kErrorCid && index < kInstanceCid); | 2245 return (index >= kErrorCid && index < kInstanceCid); |
2231 } | 2246 } |
2232 | 2247 |
2233 | 2248 |
2234 inline bool RawObject::IsNumberClassId(intptr_t index) { | 2249 inline bool RawObject::IsNumberClassId(intptr_t index) { |
2235 // Make sure this function is updated when new Number types are added. | 2250 // Make sure this function is updated when new Number types are added. |
2236 COMPILE_ASSERT(kIntegerCid == kNumberCid + 1 && | 2251 COMPILE_ASSERT(kIntegerCid == kNumberCid + 1 && |
2237 kSmiCid == kNumberCid + 2 && | 2252 kSmiCid == kNumberCid + 2 && |
2238 kMintCid == kNumberCid + 3 && | 2253 kMintCid == kNumberCid + 3 && |
2239 kBigintCid == kNumberCid + 4 && | 2254 kBigintCid == kNumberCid + 4 && |
2240 kDoubleCid == kNumberCid + 5); | 2255 kFractionCid == kNumberCid + 5 && |
| 2256 kDoubleCid == kNumberCid + 6); |
2241 return (index >= kNumberCid && index < kBoolCid); | 2257 return (index >= kNumberCid && index < kBoolCid); |
2242 } | 2258 } |
2243 | 2259 |
2244 | 2260 |
2245 inline bool RawObject::IsIntegerClassId(intptr_t index) { | 2261 inline bool RawObject::IsIntegerClassId(intptr_t index) { |
2246 // Make sure this function is updated when new Integer types are added. | 2262 // Make sure this function is updated when new Integer types are added. |
2247 COMPILE_ASSERT(kSmiCid == kIntegerCid + 1 && | 2263 COMPILE_ASSERT(kSmiCid == kIntegerCid + 1 && |
2248 kMintCid == kIntegerCid + 2 && | 2264 kMintCid == kIntegerCid + 2 && |
2249 kBigintCid == kIntegerCid + 3 && | 2265 kBigintCid == kIntegerCid + 3 && |
2250 kDoubleCid == kIntegerCid + 4); | 2266 kFractionCid == kIntegerCid + 4); |
2251 return (index >= kIntegerCid && index < kDoubleCid); | 2267 return (index >= kIntegerCid && index < kFractionCid); |
2252 } | 2268 } |
2253 | 2269 |
2254 | 2270 |
2255 inline bool RawObject::IsStringClassId(intptr_t index) { | 2271 inline bool RawObject::IsStringClassId(intptr_t index) { |
2256 // Make sure this function is updated when new StringCid types are added. | 2272 // Make sure this function is updated when new StringCid types are added. |
2257 COMPILE_ASSERT(kOneByteStringCid == kStringCid + 1 && | 2273 COMPILE_ASSERT(kOneByteStringCid == kStringCid + 1 && |
2258 kTwoByteStringCid == kStringCid + 2 && | 2274 kTwoByteStringCid == kStringCid + 2 && |
2259 kExternalOneByteStringCid == kStringCid + 3 && | 2275 kExternalOneByteStringCid == kStringCid + 3 && |
2260 kExternalTwoByteStringCid == kStringCid + 4); | 2276 kExternalTwoByteStringCid == kStringCid + 4); |
2261 return (index >= kStringCid && index <= kExternalTwoByteStringCid); | 2277 return (index >= kStringCid && index <= kExternalTwoByteStringCid); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2409 (index == kContextScopeCid) || | 2425 (index == kContextScopeCid) || |
2410 (index == kInstanceCid) || | 2426 (index == kInstanceCid) || |
2411 (index == kRegExpCid); | 2427 (index == kRegExpCid); |
2412 } | 2428 } |
2413 | 2429 |
2414 | 2430 |
2415 // This is a set of classes that are not Dart classes whose representation | 2431 // This is a set of classes that are not Dart classes whose representation |
2416 // is defined by the VM but are used in the VM code by computing the | 2432 // is defined by the VM but are used in the VM code by computing the |
2417 // implicit field offsets of the various fields in the dart object. | 2433 // implicit field offsets of the various fields in the dart object. |
2418 inline bool RawObject::IsImplicitFieldClassId(intptr_t index) { | 2434 inline bool RawObject::IsImplicitFieldClassId(intptr_t index) { |
2419 return (IsTypedDataViewClassId(index) || index == kByteBufferCid); | 2435 return (IsTypedDataViewClassId(index) || (index == kByteBufferCid)); |
2420 } | 2436 } |
2421 | 2437 |
2422 | 2438 |
2423 inline intptr_t RawObject::NumberOfTypedDataClasses() { | 2439 inline intptr_t RawObject::NumberOfTypedDataClasses() { |
2424 // Make sure this is updated when new TypedData types are added. | 2440 // Make sure this is updated when new TypedData types are added. |
2425 COMPILE_ASSERT(kTypedDataInt8ArrayViewCid == kTypedDataInt8ArrayCid + 14); | 2441 COMPILE_ASSERT(kTypedDataInt8ArrayViewCid == kTypedDataInt8ArrayCid + 14); |
2426 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == | 2442 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == |
2427 kTypedDataInt8ArrayViewCid + 15); | 2443 kTypedDataInt8ArrayViewCid + 15); |
2428 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); | 2444 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); |
2429 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); | 2445 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); |
2430 return (kNullCid - kTypedDataInt8ArrayCid); | 2446 return (kNullCid - kTypedDataInt8ArrayCid); |
2431 } | 2447 } |
2432 | 2448 |
2433 } // namespace dart | 2449 } // namespace dart |
2434 | 2450 |
2435 #endif // VM_RAW_OBJECT_H_ | 2451 #endif // VM_RAW_OBJECT_H_ |
OLD | NEW |