| 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 6069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6080 TypedDataElementType ElementType() const { | 6080 TypedDataElementType ElementType() const { |
| 6081 intptr_t cid = raw()->GetClassId(); | 6081 intptr_t cid = raw()->GetClassId(); |
| 6082 return ElementType(cid); | 6082 return ElementType(cid); |
| 6083 } | 6083 } |
| 6084 | 6084 |
| 6085 intptr_t LengthInBytes() const { | 6085 intptr_t LengthInBytes() const { |
| 6086 intptr_t cid = raw()->GetClassId(); | 6086 intptr_t cid = raw()->GetClassId(); |
| 6087 return (ElementSizeInBytes(cid) * Length()); | 6087 return (ElementSizeInBytes(cid) * Length()); |
| 6088 } | 6088 } |
| 6089 | 6089 |
| 6090 void* GetPeer() const { | |
| 6091 return raw_ptr()->peer_; | |
| 6092 } | |
| 6093 | |
| 6094 void* DataAddr(intptr_t byte_offset) const { | 6090 void* DataAddr(intptr_t byte_offset) const { |
| 6095 ASSERT((byte_offset == 0) || | 6091 ASSERT((byte_offset == 0) || |
| 6096 ((byte_offset > 0) && (byte_offset < LengthInBytes()))); | 6092 ((byte_offset > 0) && (byte_offset < LengthInBytes()))); |
| 6097 return reinterpret_cast<void*>(raw_ptr()->data_ + byte_offset); | 6093 return reinterpret_cast<void*>(raw_ptr()->data_ + byte_offset); |
| 6098 } | 6094 } |
| 6099 | 6095 |
| 6100 #define TYPED_GETTER_SETTER(name, type) \ | 6096 #define TYPED_GETTER_SETTER(name, type) \ |
| 6101 type Get##name(intptr_t byte_offset) const { \ | 6097 type Get##name(intptr_t byte_offset) const { \ |
| 6102 return *reinterpret_cast<type*>(DataAddr(byte_offset)); \ | 6098 return *reinterpret_cast<type*>(DataAddr(byte_offset)); \ |
| 6103 } \ | 6099 } \ |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6163 | 6159 |
| 6164 protected: | 6160 protected: |
| 6165 void SetLength(intptr_t value) const { | 6161 void SetLength(intptr_t value) const { |
| 6166 raw_ptr()->length_ = Smi::New(value); | 6162 raw_ptr()->length_ = Smi::New(value); |
| 6167 } | 6163 } |
| 6168 | 6164 |
| 6169 void SetData(uint8_t* data) const { | 6165 void SetData(uint8_t* data) const { |
| 6170 raw_ptr()->data_ = data; | 6166 raw_ptr()->data_ = data; |
| 6171 } | 6167 } |
| 6172 | 6168 |
| 6173 void SetPeer(void* peer) const { | |
| 6174 raw_ptr()->peer_ = peer; | |
| 6175 } | |
| 6176 | |
| 6177 private: | 6169 private: |
| 6178 FINAL_HEAP_OBJECT_IMPLEMENTATION(ExternalTypedData, Instance); | 6170 FINAL_HEAP_OBJECT_IMPLEMENTATION(ExternalTypedData, Instance); |
| 6179 friend class Class; | 6171 friend class Class; |
| 6180 }; | 6172 }; |
| 6181 | 6173 |
| 6182 | 6174 |
| 6183 class TypedDataView : public AllStatic { | 6175 class TypedDataView : public AllStatic { |
| 6184 public: | 6176 public: |
| 6185 static intptr_t ElementSizeInBytes(const Instance& view_obj) { | 6177 static intptr_t ElementSizeInBytes(const Instance& view_obj) { |
| 6186 ASSERT(!view_obj.IsNull()); | 6178 ASSERT(!view_obj.IsNull()); |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6631 | 6623 |
| 6632 | 6624 |
| 6633 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 6625 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
| 6634 intptr_t index) { | 6626 intptr_t index) { |
| 6635 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 6627 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
| 6636 } | 6628 } |
| 6637 | 6629 |
| 6638 } // namespace dart | 6630 } // namespace dart |
| 6639 | 6631 |
| 6640 #endif // VM_OBJECT_H_ | 6632 #endif // VM_OBJECT_H_ |
| OLD | NEW |