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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 } | 252 } |
253 | 253 |
254 static intptr_t decode(uword tag) { | 254 static intptr_t decode(uword tag) { |
255 return TagValueToSize(SizeBits::decode(tag)); | 255 return TagValueToSize(SizeBits::decode(tag)); |
256 } | 256 } |
257 | 257 |
258 static uword update(intptr_t size, uword tag) { | 258 static uword update(intptr_t size, uword tag) { |
259 return SizeBits::update(SizeToTagValue(size), tag); | 259 return SizeBits::update(SizeToTagValue(size), tag); |
260 } | 260 } |
261 | 261 |
262 private: | 262 private: |
263 // The actual unscaled bit field used within the tag field. | 263 // The actual unscaled bit field used within the tag field. |
264 class SizeBits : public BitField<intptr_t, kSizeTagPos, kSizeTagSize> {}; | 264 class SizeBits : public BitField<intptr_t, kSizeTagPos, kSizeTagSize> {}; |
265 | 265 |
266 static intptr_t SizeToTagValue(intptr_t size) { | 266 static intptr_t SizeToTagValue(intptr_t size) { |
267 ASSERT(Utils::IsAligned(size, kObjectAlignment)); | 267 ASSERT(Utils::IsAligned(size, kObjectAlignment)); |
268 return (size > kMaxSizeTag) ? 0 : (size >> kObjectAlignmentLog2); | 268 return (size > kMaxSizeTag) ? 0 : (size >> kObjectAlignmentLog2); |
269 } | 269 } |
270 static intptr_t TagValueToSize(intptr_t value) { | 270 static intptr_t TagValueToSize(intptr_t value) { |
271 return value << kObjectAlignmentLog2; | 271 return value << kObjectAlignmentLog2; |
272 } | 272 } |
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1252 class RawSmi : public RawInteger { | 1252 class RawSmi : public RawInteger { |
1253 RAW_OBJECT_IMPLEMENTATION(Smi); | 1253 RAW_OBJECT_IMPLEMENTATION(Smi); |
1254 }; | 1254 }; |
1255 | 1255 |
1256 | 1256 |
1257 class RawMint : public RawInteger { | 1257 class RawMint : public RawInteger { |
1258 RAW_HEAP_OBJECT_IMPLEMENTATION(Mint); | 1258 RAW_HEAP_OBJECT_IMPLEMENTATION(Mint); |
1259 | 1259 |
1260 int64_t value_; | 1260 int64_t value_; |
1261 | 1261 |
| 1262 friend class Api; |
1262 friend class SnapshotReader; | 1263 friend class SnapshotReader; |
1263 }; | 1264 }; |
1264 | 1265 |
1265 | 1266 |
1266 class RawBigint : public RawInteger { | 1267 class RawBigint : public RawInteger { |
1267 RAW_HEAP_OBJECT_IMPLEMENTATION(Bigint); | 1268 RAW_HEAP_OBJECT_IMPLEMENTATION(Bigint); |
1268 | 1269 |
1269 // Actual length in chunks at the time of allocation (later we may | 1270 // Actual length in chunks at the time of allocation (later we may |
1270 // clamp the operational length but we need to maintain a consistent | 1271 // clamp the operational length but we need to maintain a consistent |
1271 // object length so that the object can be traversed during GC). | 1272 // object length so that the object can be traversed during GC). |
(...skipping 10 matching lines...) Expand all Loading... |
1282 | 1283 |
1283 friend class SnapshotReader; | 1284 friend class SnapshotReader; |
1284 }; | 1285 }; |
1285 | 1286 |
1286 | 1287 |
1287 class RawDouble : public RawNumber { | 1288 class RawDouble : public RawNumber { |
1288 RAW_HEAP_OBJECT_IMPLEMENTATION(Double); | 1289 RAW_HEAP_OBJECT_IMPLEMENTATION(Double); |
1289 | 1290 |
1290 double value_; | 1291 double value_; |
1291 | 1292 |
| 1293 friend class Api; |
1292 friend class SnapshotReader; | 1294 friend class SnapshotReader; |
1293 }; | 1295 }; |
1294 | 1296 |
1295 | 1297 |
1296 class RawString : public RawInstance { | 1298 class RawString : public RawInstance { |
1297 RAW_HEAP_OBJECT_IMPLEMENTATION(String); | 1299 RAW_HEAP_OBJECT_IMPLEMENTATION(String); |
1298 | 1300 |
1299 protected: | 1301 protected: |
1300 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->length_); } | 1302 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->length_); } |
1301 RawSmi* length_; | 1303 RawSmi* length_; |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1835 // Make sure this is updated when new TypedData types are added. | 1837 // Make sure this is updated when new TypedData types are added. |
1836 ASSERT(kTypedDataInt8ArrayViewCid == kTypedDataInt8ArrayCid + 14); | 1838 ASSERT(kTypedDataInt8ArrayViewCid == kTypedDataInt8ArrayCid + 14); |
1837 ASSERT(kExternalTypedDataInt8ArrayCid == kTypedDataInt8ArrayViewCid + 15); | 1839 ASSERT(kExternalTypedDataInt8ArrayCid == kTypedDataInt8ArrayViewCid + 15); |
1838 ASSERT(kNullCid == kExternalTypedDataInt8ArrayCid + 14); | 1840 ASSERT(kNullCid == kExternalTypedDataInt8ArrayCid + 14); |
1839 return (kNullCid - kTypedDataInt8ArrayCid); | 1841 return (kNullCid - kTypedDataInt8ArrayCid); |
1840 } | 1842 } |
1841 | 1843 |
1842 } // namespace dart | 1844 } // namespace dart |
1843 | 1845 |
1844 #endif // VM_RAW_OBJECT_H_ | 1846 #endif // VM_RAW_OBJECT_H_ |
OLD | NEW |