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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 #undef DEFINE_OBJECT_KIND | 174 #undef DEFINE_OBJECT_KIND |
175 | 175 |
176 kByteBufferCid, | 176 kByteBufferCid, |
177 | 177 |
178 // The following entries do not describe a predefined class, but instead | 178 // The following entries do not describe a predefined class, but instead |
179 // are class indexes for pre-allocated instance (Null, dynamic and Void). | 179 // are class indexes for pre-allocated instance (Null, dynamic and Void). |
180 kNullCid, | 180 kNullCid, |
181 kDynamicCid, | 181 kDynamicCid, |
182 kVoidCid, | 182 kVoidCid, |
183 | 183 |
184 // The following entry does not describe a real class, but instead it is an | 184 // The following entries describes classes for pseudo-objects in the heap |
185 // id which is used to identify free list elements in the heap. | 185 // that should never be reachable from live objects. Free list elements |
| 186 // maintain the free list for old space, and forwarding corpses are used to |
| 187 // implement one-way become. |
186 kFreeListElement, | 188 kFreeListElement, |
| 189 kForwardingCorpse, |
187 | 190 |
188 kNumPredefinedCids, | 191 kNumPredefinedCids, |
189 }; | 192 }; |
190 | 193 |
191 enum ObjectAlignment { | 194 enum ObjectAlignment { |
192 // Alignment offsets are used to determine object age. | 195 // Alignment offsets are used to determine object age. |
193 kNewObjectAlignmentOffset = kWordSize, | 196 kNewObjectAlignmentOffset = kWordSize, |
194 kOldObjectAlignmentOffset = 0, | 197 kOldObjectAlignmentOffset = 0, |
195 // Object sizes are aligned to kObjectAlignment. | 198 // Object sizes are aligned to kObjectAlignment. |
196 kObjectAlignment = 2 * kWordSize, | 199 kObjectAlignment = 2 * kWordSize, |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 | 438 |
436 bool IsStringInstance() const { | 439 bool IsStringInstance() const { |
437 return IsStringClassId(GetClassId()); | 440 return IsStringClassId(GetClassId()); |
438 } | 441 } |
439 bool IsDartInstance() const { | 442 bool IsDartInstance() const { |
440 return (!IsHeapObject() || (GetClassId() >= kInstanceCid)); | 443 return (!IsHeapObject() || (GetClassId() >= kInstanceCid)); |
441 } | 444 } |
442 bool IsFreeListElement() const { | 445 bool IsFreeListElement() const { |
443 return ((GetClassId() == kFreeListElement)); | 446 return ((GetClassId() == kFreeListElement)); |
444 } | 447 } |
| 448 bool IsForwardingCorpse() const { |
| 449 return ((GetClassId() == kForwardingCorpse)); |
| 450 } |
| 451 bool IsPseudoObject() const { |
| 452 return IsFreeListElement() || IsForwardingCorpse(); |
| 453 } |
445 | 454 |
446 intptr_t Size() const { | 455 intptr_t Size() const { |
447 uword tags = ptr()->tags_; | 456 uword tags = ptr()->tags_; |
448 intptr_t result = SizeTag::decode(tags); | 457 intptr_t result = SizeTag::decode(tags); |
449 if (result != 0) { | 458 if (result != 0) { |
450 ASSERT(result == SizeFromClass()); | 459 ASSERT(result == SizeFromClass()); |
451 return result; | 460 return result; |
452 } | 461 } |
453 result = SizeFromClass(); | 462 result = SizeFromClass(); |
454 ASSERT(result > SizeTag::kMaxSizeTag); | 463 ASSERT(result > SizeTag::kMaxSizeTag); |
(...skipping 1965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2420 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == | 2429 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == |
2421 kTypedDataInt8ArrayViewCid + 15); | 2430 kTypedDataInt8ArrayViewCid + 15); |
2422 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); | 2431 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); |
2423 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); | 2432 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); |
2424 return (kNullCid - kTypedDataInt8ArrayCid); | 2433 return (kNullCid - kTypedDataInt8ArrayCid); |
2425 } | 2434 } |
2426 | 2435 |
2427 } // namespace dart | 2436 } // namespace dart |
2428 | 2437 |
2429 #endif // VM_RAW_OBJECT_H_ | 2438 #endif // VM_RAW_OBJECT_H_ |
OLD | NEW |