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_OBJECT_H_ | 5 #ifndef VM_OBJECT_H_ |
6 #define VM_OBJECT_H_ | 6 #define VM_OBJECT_H_ |
7 | 7 |
8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
10 #include "platform/utils.h" | 10 #include "platform/utils.h" |
(...skipping 3607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3618 static intptr_t InstanceSize(intptr_t len) { | 3618 static intptr_t InstanceSize(intptr_t len) { |
3619 // Ensure that variable length data is not adding to the object length. | 3619 // Ensure that variable length data is not adding to the object length. |
3620 ASSERT(sizeof(RawObjectPool) == (sizeof(RawObject) + (2 * kWordSize))); | 3620 ASSERT(sizeof(RawObjectPool) == (sizeof(RawObject) + (2 * kWordSize))); |
3621 ASSERT(0 <= len && len <= kMaxElements); | 3621 ASSERT(0 <= len && len <= kMaxElements); |
3622 return RoundedAllocationSize( | 3622 return RoundedAllocationSize( |
3623 sizeof(RawObjectPool) + (len * kBytesPerElement)); | 3623 sizeof(RawObjectPool) + (len * kBytesPerElement)); |
3624 } | 3624 } |
3625 | 3625 |
3626 static RawObjectPool* New(intptr_t len); | 3626 static RawObjectPool* New(intptr_t len); |
3627 | 3627 |
| 3628 // Returns the pool index from the offset relative to a tagged RawObjectPool*, |
| 3629 // adjusting for the tag-bit. |
3628 static intptr_t IndexFromOffset(intptr_t offset) { | 3630 static intptr_t IndexFromOffset(intptr_t offset) { |
3629 return (offset + kHeapObjectTag - data_offset()) / kBytesPerElement; | 3631 return (offset + kHeapObjectTag - data_offset()) / kBytesPerElement; |
3630 } | 3632 } |
3631 | 3633 |
| 3634 static intptr_t OffsetFromIndex(intptr_t index) { |
| 3635 return element_offset(index) - kHeapObjectTag; |
| 3636 } |
| 3637 |
3632 void DebugPrint() const; | 3638 void DebugPrint() const; |
3633 | 3639 |
3634 private: | 3640 private: |
3635 RawObjectPool::Entry const* EntryAddr(intptr_t index) const { | 3641 RawObjectPool::Entry const* EntryAddr(intptr_t index) const { |
3636 ASSERT((index >= 0) && (index < Length())); | 3642 ASSERT((index >= 0) && (index < Length())); |
3637 return &raw_ptr()->data()[index]; | 3643 return &raw_ptr()->data()[index]; |
3638 } | 3644 } |
3639 | 3645 |
3640 FINAL_HEAP_OBJECT_IMPLEMENTATION(ObjectPool, Object); | 3646 FINAL_HEAP_OBJECT_IMPLEMENTATION(ObjectPool, Object); |
3641 friend class Class; | 3647 friend class Class; |
(...skipping 4396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8038 | 8044 |
8039 | 8045 |
8040 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 8046 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
8041 intptr_t index) { | 8047 intptr_t index) { |
8042 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 8048 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
8043 } | 8049 } |
8044 | 8050 |
8045 } // namespace dart | 8051 } // namespace dart |
8046 | 8052 |
8047 #endif // VM_OBJECT_H_ | 8053 #endif // VM_OBJECT_H_ |
OLD | NEW |