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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 // be dereferenced (e.g. RawSmi). | 216 // be dereferenced (e.g. RawSmi). |
217 class RawObject { | 217 class RawObject { |
218 public: | 218 public: |
219 // The tags field which is a part of the object header uses the following | 219 // The tags field which is a part of the object header uses the following |
220 // bit fields for storing tags. | 220 // bit fields for storing tags. |
221 enum TagBits { | 221 enum TagBits { |
222 kWatchedBit = 0, | 222 kWatchedBit = 0, |
223 kMarkBit = 1, | 223 kMarkBit = 1, |
224 kCanonicalBit = 2, | 224 kCanonicalBit = 2, |
225 kFromSnapshotBit = 3, | 225 kFromSnapshotBit = 3, |
226 kReservedTagBit = 4, // kReservedBit{1K, 10K,100K,1M,10M} | 226 kRememberedBit = 4, |
227 kReservedTagSize = 4, | 227 kReservedTagBit = 5, // kReservedBit{10K,100K,1M,10M} |
| 228 kReservedTagSize = 3, |
228 kSizeTagBit = 8, | 229 kSizeTagBit = 8, |
229 kSizeTagSize = 8, | 230 kSizeTagSize = 8, |
230 kClassIdTagBit = kSizeTagBit + kSizeTagSize, | 231 kClassIdTagBit = kSizeTagBit + kSizeTagSize, |
231 kClassIdTagSize = 16 | 232 kClassIdTagSize = 16 |
232 }; | 233 }; |
233 | 234 |
234 // Encodes the object size in the tag in units of object alignment. | 235 // Encodes the object size in the tag in units of object alignment. |
235 class SizeTag { | 236 class SizeTag { |
236 public: | 237 public: |
237 static const intptr_t kMaxSizeTag = | 238 static const intptr_t kMaxSizeTag = |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 ptr()->tags_ = CanonicalObjectTag::update(true, tags); | 323 ptr()->tags_ = CanonicalObjectTag::update(true, tags); |
323 } | 324 } |
324 bool IsCreatedFromSnapshot() const { | 325 bool IsCreatedFromSnapshot() const { |
325 return CreatedFromSnapshotTag::decode(ptr()->tags_); | 326 return CreatedFromSnapshotTag::decode(ptr()->tags_); |
326 } | 327 } |
327 void SetCreatedFromSnapshot() { | 328 void SetCreatedFromSnapshot() { |
328 uword tags = ptr()->tags_; | 329 uword tags = ptr()->tags_; |
329 ptr()->tags_ = CreatedFromSnapshotTag::update(true, tags); | 330 ptr()->tags_ = CreatedFromSnapshotTag::update(true, tags); |
330 } | 331 } |
331 | 332 |
| 333 // Support for GC remembered bit. |
| 334 bool IsRemembered() const { |
| 335 return RememberedBit::decode(ptr()->tags_); |
| 336 } |
| 337 void SetRememberedBit() { |
| 338 ASSERT(!IsRemembered()); |
| 339 uword tags = ptr()->tags_; |
| 340 ptr()->tags_ = RememberedBit::update(true, tags); |
| 341 } |
| 342 void ClearRememberedBit() { |
| 343 uword tags = ptr()->tags_; |
| 344 ptr()->tags_ = RememberedBit::update(false, tags); |
| 345 } |
| 346 |
332 bool IsDartInstance() { | 347 bool IsDartInstance() { |
333 return (!IsHeapObject() || (GetClassId() >= kInstanceCid)); | 348 return (!IsHeapObject() || (GetClassId() >= kInstanceCid)); |
334 } | 349 } |
335 | 350 |
336 intptr_t Size() const { | 351 intptr_t Size() const { |
337 uword tags = ptr()->tags_; | 352 uword tags = ptr()->tags_; |
338 intptr_t result = SizeTag::decode(tags); | 353 intptr_t result = SizeTag::decode(tags); |
339 if (result != 0) { | 354 if (result != 0) { |
340 ASSERT(result == SizeFromClass()); | 355 ASSERT(result == SizeFromClass()); |
341 return result; | 356 return result; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 | 397 |
383 static intptr_t NumberOfTypedDataClasses(); | 398 static intptr_t NumberOfTypedDataClasses(); |
384 | 399 |
385 private: | 400 private: |
386 uword tags_; // Various object tags (bits). | 401 uword tags_; // Various object tags (bits). |
387 | 402 |
388 class WatchedBit : public BitField<bool, kWatchedBit, 1> {}; | 403 class WatchedBit : public BitField<bool, kWatchedBit, 1> {}; |
389 | 404 |
390 class MarkBit : public BitField<bool, kMarkBit, 1> {}; | 405 class MarkBit : public BitField<bool, kMarkBit, 1> {}; |
391 | 406 |
| 407 class RememberedBit : public BitField<bool, kRememberedBit, 1> {}; |
| 408 |
392 class CanonicalObjectTag : public BitField<bool, kCanonicalBit, 1> {}; | 409 class CanonicalObjectTag : public BitField<bool, kCanonicalBit, 1> {}; |
393 | 410 |
394 class CreatedFromSnapshotTag : public BitField<bool, kFromSnapshotBit, 1> {}; | 411 class CreatedFromSnapshotTag : public BitField<bool, kFromSnapshotBit, 1> {}; |
395 | 412 |
396 class ReservedBits : public BitField<intptr_t, | 413 class ReservedBits : public BitField<intptr_t, |
397 kReservedTagBit, | 414 kReservedTagBit, |
398 kReservedTagSize> {}; // NOLINT | 415 kReservedTagSize> {}; // NOLINT |
399 | 416 |
400 RawObject* ptr() const { | 417 RawObject* ptr() const { |
401 ASSERT(IsHeapObject()); | 418 ASSERT(IsHeapObject()); |
(...skipping 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1662 // Make sure this is updated when new TypedData types are added. | 1679 // Make sure this is updated when new TypedData types are added. |
1663 ASSERT(kTypedDataInt8ArrayViewCid == kTypedDataInt8ArrayCid + 12); | 1680 ASSERT(kTypedDataInt8ArrayViewCid == kTypedDataInt8ArrayCid + 12); |
1664 ASSERT(kExternalTypedDataInt8ArrayCid == kTypedDataInt8ArrayViewCid + 13); | 1681 ASSERT(kExternalTypedDataInt8ArrayCid == kTypedDataInt8ArrayViewCid + 13); |
1665 ASSERT(kNullCid == kExternalTypedDataInt8ArrayCid + 12); | 1682 ASSERT(kNullCid == kExternalTypedDataInt8ArrayCid + 12); |
1666 return (kNullCid - kTypedDataInt8ArrayCid); | 1683 return (kNullCid - kTypedDataInt8ArrayCid); |
1667 } | 1684 } |
1668 | 1685 |
1669 } // namespace dart | 1686 } // namespace dart |
1670 | 1687 |
1671 #endif // VM_RAW_OBJECT_H_ | 1688 #endif // VM_RAW_OBJECT_H_ |
OLD | NEW |