| 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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 static intptr_t decode(uword tag) { | 278 static intptr_t decode(uword tag) { |
| 279 return TagValueToSize(SizeBits::decode(tag)); | 279 return TagValueToSize(SizeBits::decode(tag)); |
| 280 } | 280 } |
| 281 | 281 |
| 282 static uword update(intptr_t size, uword tag) { | 282 static uword update(intptr_t size, uword tag) { |
| 283 return SizeBits::update(SizeToTagValue(size), tag); | 283 return SizeBits::update(SizeToTagValue(size), tag); |
| 284 } | 284 } |
| 285 | 285 |
| 286 private: | 286 private: |
| 287 // The actual unscaled bit field used within the tag field. | 287 // The actual unscaled bit field used within the tag field. |
| 288 class SizeBits : public BitField<intptr_t, kSizeTagPos, kSizeTagSize> {}; | 288 class SizeBits : |
| 289 public BitField<uword, intptr_t, kSizeTagPos, kSizeTagSize> {}; |
| 289 | 290 |
| 290 static intptr_t SizeToTagValue(intptr_t size) { | 291 static intptr_t SizeToTagValue(intptr_t size) { |
| 291 ASSERT(Utils::IsAligned(size, kObjectAlignment)); | 292 ASSERT(Utils::IsAligned(size, kObjectAlignment)); |
| 292 return (size > kMaxSizeTag) ? 0 : (size >> kObjectAlignmentLog2); | 293 return (size > kMaxSizeTag) ? 0 : (size >> kObjectAlignmentLog2); |
| 293 } | 294 } |
| 294 static intptr_t TagValueToSize(intptr_t value) { | 295 static intptr_t TagValueToSize(intptr_t value) { |
| 295 return value << kObjectAlignmentLog2; | 296 return value << kObjectAlignmentLog2; |
| 296 } | 297 } |
| 297 }; | 298 }; |
| 298 | 299 |
| 299 class ClassIdTag : | 300 class ClassIdTag : |
| 300 public BitField<intptr_t, kClassIdTagPos, kClassIdTagSize> {}; // NOLINT | 301 public BitField<uword, intptr_t, kClassIdTagPos, kClassIdTagSize> {}; |
| 301 | 302 |
| 302 bool IsWellFormed() const { | 303 bool IsWellFormed() const { |
| 303 uword value = reinterpret_cast<uword>(this); | 304 uword value = reinterpret_cast<uword>(this); |
| 304 return (value & kSmiTagMask) == 0 || | 305 return (value & kSmiTagMask) == 0 || |
| 305 Utils::IsAligned(value - kHeapObjectTag, kWordSize); | 306 Utils::IsAligned(value - kHeapObjectTag, kWordSize); |
| 306 } | 307 } |
| 307 bool IsHeapObject() const { | 308 bool IsHeapObject() const { |
| 308 ASSERT(IsWellFormed()); | 309 ASSERT(IsWellFormed()); |
| 309 uword value = reinterpret_cast<uword>(this); | 310 uword value = reinterpret_cast<uword>(this); |
| 310 return (value & kSmiTagMask) == kHeapObjectTag; | 311 return (value & kSmiTagMask) == kHeapObjectTag; |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 static bool IsExternalTypedDataClassId(intptr_t index); | 491 static bool IsExternalTypedDataClassId(intptr_t index); |
| 491 static bool IsInternalVMdefinedClassId(intptr_t index); | 492 static bool IsInternalVMdefinedClassId(intptr_t index); |
| 492 static bool IsVariableSizeClassId(intptr_t index); | 493 static bool IsVariableSizeClassId(intptr_t index); |
| 493 static bool IsImplicitFieldClassId(intptr_t index); | 494 static bool IsImplicitFieldClassId(intptr_t index); |
| 494 | 495 |
| 495 static intptr_t NumberOfTypedDataClasses(); | 496 static intptr_t NumberOfTypedDataClasses(); |
| 496 | 497 |
| 497 private: | 498 private: |
| 498 uword tags_; // Various object tags (bits). | 499 uword tags_; // Various object tags (bits). |
| 499 | 500 |
| 500 class WatchedBit : public BitField<bool, kWatchedBit, 1> {}; | 501 class WatchedBit : public BitField<uword, bool, kWatchedBit, 1> {}; |
| 501 | 502 |
| 502 class MarkBit : public BitField<bool, kMarkBit, 1> {}; | 503 class MarkBit : public BitField<uword, bool, kMarkBit, 1> {}; |
| 503 | 504 |
| 504 class RememberedBit : public BitField<bool, kRememberedBit, 1> {}; | 505 class RememberedBit : public BitField<uword, bool, kRememberedBit, 1> {}; |
| 505 | 506 |
| 506 class CanonicalObjectTag : public BitField<bool, kCanonicalBit, 1> {}; | 507 class CanonicalObjectTag : public BitField<uword, bool, kCanonicalBit, 1> {}; |
| 507 | 508 |
| 508 class VMHeapObjectTag : public BitField<bool, kVMHeapObjectBit, 1> {}; | 509 class VMHeapObjectTag : public BitField<uword, bool, kVMHeapObjectBit, 1> {}; |
| 509 | 510 |
| 510 class ReservedBits : public | 511 class ReservedBits : public |
| 511 BitField<intptr_t, kReservedTagPos, kReservedTagSize> {}; // NOLINT | 512 BitField<uword, intptr_t, kReservedTagPos, kReservedTagSize> {}; |
| 512 | 513 |
| 513 // TODO(koda): After handling tags_, return const*, like Object::raw_ptr(). | 514 // TODO(koda): After handling tags_, return const*, like Object::raw_ptr(). |
| 514 RawObject* ptr() const { | 515 RawObject* ptr() const { |
| 515 ASSERT(IsHeapObject()); | 516 ASSERT(IsHeapObject()); |
| 516 return reinterpret_cast<RawObject*>( | 517 return reinterpret_cast<RawObject*>( |
| 517 reinterpret_cast<uword>(this) - kHeapObjectTag); | 518 reinterpret_cast<uword>(this) - kHeapObjectTag); |
| 518 } | 519 } |
| 519 | 520 |
| 520 intptr_t SizeFromClass() const; | 521 intptr_t SizeFromClass() const; |
| 521 | 522 |
| (...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1267 kKindSize = 8, | 1268 kKindSize = 8, |
| 1268 kIndexPos = kKindPos + kKindSize, | 1269 kIndexPos = kKindPos + kKindSize, |
| 1269 // Since there are 24 bits for the stack slot index, Functions can have | 1270 // Since there are 24 bits for the stack slot index, Functions can have |
| 1270 // only ~16.7 million stack slots. | 1271 // only ~16.7 million stack slots. |
| 1271 kPayloadSize = sizeof(int32_t) * kBitsPerByte, | 1272 kPayloadSize = sizeof(int32_t) * kBitsPerByte, |
| 1272 kIndexSize = kPayloadSize - kIndexPos, | 1273 kIndexSize = kPayloadSize - kIndexPos, |
| 1273 kIndexBias = 1 << (kIndexSize - 1), | 1274 kIndexBias = 1 << (kIndexSize - 1), |
| 1274 kMaxIndex = (1 << (kIndexSize - 1)) - 1, | 1275 kMaxIndex = (1 << (kIndexSize - 1)) - 1, |
| 1275 }; | 1276 }; |
| 1276 | 1277 |
| 1277 class IndexBits : public BitField<int32_t, kIndexPos, kIndexSize> {}; | 1278 class IndexBits : public BitField<int32_t, int32_t, kIndexPos, kIndexSize> {}; |
| 1278 class KindBits : public BitField<int8_t, kKindPos, kKindSize>{}; | 1279 class KindBits : public BitField<int32_t, int8_t, kKindPos, kKindSize>{}; |
| 1279 | 1280 |
| 1280 struct VarInfo { | 1281 struct VarInfo { |
| 1281 int32_t index_kind; // Bitfield for slot index on stack or in context, | 1282 int32_t index_kind; // Bitfield for slot index on stack or in context, |
| 1282 // and Entry kind of type VarInfoKind. | 1283 // and Entry kind of type VarInfoKind. |
| 1283 TokenPosition begin_pos; // Token position of scope start. | 1284 TokenPosition begin_pos; // Token position of scope start. |
| 1284 TokenPosition end_pos; // Token position of scope end. | 1285 TokenPosition end_pos; // Token position of scope end. |
| 1285 int16_t scope_id; // Scope to which the variable belongs. | 1286 int16_t scope_id; // Scope to which the variable belongs. |
| 1286 | 1287 |
| 1287 VarInfoKind kind() const { | 1288 VarInfoKind kind() const { |
| 1288 return static_cast<VarInfoKind>(KindBits::decode(index_kind)); | 1289 return static_cast<VarInfoKind>(KindBits::decode(index_kind)); |
| (...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2334 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == | 2335 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == |
| 2335 kTypedDataInt8ArrayViewCid + 15); | 2336 kTypedDataInt8ArrayViewCid + 15); |
| 2336 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); | 2337 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); |
| 2337 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); | 2338 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); |
| 2338 return (kNullCid - kTypedDataInt8ArrayCid); | 2339 return (kNullCid - kTypedDataInt8ArrayCid); |
| 2339 } | 2340 } |
| 2340 | 2341 |
| 2341 } // namespace dart | 2342 } // namespace dart |
| 2342 | 2343 |
| 2343 #endif // VM_RAW_OBJECT_H_ | 2344 #endif // VM_RAW_OBJECT_H_ |
| OLD | NEW |