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 5597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5608 intptr_t cid = raw()->GetClassId(); | 5608 intptr_t cid = raw()->GetClassId(); |
5609 return ElementType(cid); | 5609 return ElementType(cid); |
5610 } | 5610 } |
5611 | 5611 |
5612 intptr_t LengthInBytes() const { | 5612 intptr_t LengthInBytes() const { |
5613 intptr_t cid = raw()->GetClassId(); | 5613 intptr_t cid = raw()->GetClassId(); |
5614 return (ElementSizeInBytes(cid) * Length()); | 5614 return (ElementSizeInBytes(cid) * Length()); |
5615 } | 5615 } |
5616 | 5616 |
5617 void* DataAddr(intptr_t byte_offset) const { | 5617 void* DataAddr(intptr_t byte_offset) const { |
5618 ASSERT((byte_offset >= 0) && (byte_offset < LengthInBytes())); | 5618 ASSERT((byte_offset == 0) || |
| 5619 ((byte_offset > 0) && (byte_offset < LengthInBytes()))); |
5619 return reinterpret_cast<void*>(raw_ptr()->data_ + byte_offset); | 5620 return reinterpret_cast<void*>(raw_ptr()->data_ + byte_offset); |
5620 } | 5621 } |
5621 | 5622 |
5622 #define TYPED_GETTER_SETTER(name, type) \ | 5623 #define TYPED_GETTER_SETTER(name, type) \ |
5623 type Get##name(intptr_t byte_offset) const { \ | 5624 type Get##name(intptr_t byte_offset) const { \ |
5624 return *reinterpret_cast<type*>(DataAddr(byte_offset)); \ | 5625 return *reinterpret_cast<type*>(DataAddr(byte_offset)); \ |
5625 } \ | 5626 } \ |
5626 void Set##name(intptr_t byte_offset, type value) const { \ | 5627 void Set##name(intptr_t byte_offset, type value) const { \ |
5627 *reinterpret_cast<type*>(DataAddr(byte_offset)) = value; \ | 5628 *reinterpret_cast<type*>(DataAddr(byte_offset)) = value; \ |
5628 } | 5629 } |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5740 intptr_t LengthInBytes() const { | 5741 intptr_t LengthInBytes() const { |
5741 intptr_t cid = raw()->GetClassId(); | 5742 intptr_t cid = raw()->GetClassId(); |
5742 return (ElementSizeInBytes(cid) * Length()); | 5743 return (ElementSizeInBytes(cid) * Length()); |
5743 } | 5744 } |
5744 | 5745 |
5745 void* GetPeer() const { | 5746 void* GetPeer() const { |
5746 return raw_ptr()->peer_; | 5747 return raw_ptr()->peer_; |
5747 } | 5748 } |
5748 | 5749 |
5749 void* DataAddr(intptr_t byte_offset) const { | 5750 void* DataAddr(intptr_t byte_offset) const { |
5750 ASSERT((byte_offset >= 0) && (byte_offset < LengthInBytes())); | 5751 ASSERT((byte_offset == 0) || |
| 5752 ((byte_offset > 0) && (byte_offset < LengthInBytes()))); |
5751 return reinterpret_cast<void*>(raw_ptr()->data_ + byte_offset); | 5753 return reinterpret_cast<void*>(raw_ptr()->data_ + byte_offset); |
5752 } | 5754 } |
5753 | 5755 |
5754 #define TYPED_GETTER_SETTER(name, type) \ | 5756 #define TYPED_GETTER_SETTER(name, type) \ |
5755 type Get##name(intptr_t byte_offset) const { \ | 5757 type Get##name(intptr_t byte_offset) const { \ |
5756 return *reinterpret_cast<type*>(DataAddr(byte_offset)); \ | 5758 return *reinterpret_cast<type*>(DataAddr(byte_offset)); \ |
5757 } \ | 5759 } \ |
5758 void Set##name(intptr_t byte_offset, type value) const { \ | 5760 void Set##name(intptr_t byte_offset, type value) const { \ |
5759 *reinterpret_cast<type*>(DataAddr(byte_offset)) = value; \ | 5761 *reinterpret_cast<type*>(DataAddr(byte_offset)) = value; \ |
5760 } | 5762 } |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6280 | 6282 |
6281 | 6283 |
6282 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 6284 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
6283 intptr_t index) { | 6285 intptr_t index) { |
6284 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 6286 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
6285 } | 6287 } |
6286 | 6288 |
6287 } // namespace dart | 6289 } // namespace dart |
6288 | 6290 |
6289 #endif // VM_OBJECT_H_ | 6291 #endif // VM_OBJECT_H_ |
OLD | NEW |