| 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 6398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6409 | 6409 |
| 6410 static const uint8_t* CharAddr(const String& str, intptr_t index) { | 6410 static const uint8_t* CharAddr(const String& str, intptr_t index) { |
| 6411 ASSERT((index >= 0) && (index < str.Length())); | 6411 ASSERT((index >= 0) && (index < str.Length())); |
| 6412 ASSERT(str.IsExternalOneByteString()); | 6412 ASSERT(str.IsExternalOneByteString()); |
| 6413 return &(raw_ptr(str)->external_data_->data()[index]); | 6413 return &(raw_ptr(str)->external_data_->data()[index]); |
| 6414 } | 6414 } |
| 6415 | 6415 |
| 6416 static void SetExternalData(const String& str, | 6416 static void SetExternalData(const String& str, |
| 6417 ExternalStringData<uint8_t>* data) { | 6417 ExternalStringData<uint8_t>* data) { |
| 6418 ASSERT(str.IsExternalOneByteString()); | 6418 ASSERT(str.IsExternalOneByteString()); |
| 6419 ASSERT(!Isolate::Current()->heap()->Contains( |
| 6420 reinterpret_cast<uword>(data->data()))); |
| 6419 str.StoreNonPointer(&raw_ptr(str)->external_data_, data); | 6421 str.StoreNonPointer(&raw_ptr(str)->external_data_, data); |
| 6420 } | 6422 } |
| 6421 | 6423 |
| 6422 static void Finalize(void* isolate_callback_data, | 6424 static void Finalize(void* isolate_callback_data, |
| 6423 Dart_WeakPersistentHandle handle, | 6425 Dart_WeakPersistentHandle handle, |
| 6424 void* peer); | 6426 void* peer); |
| 6425 | 6427 |
| 6426 static RawExternalOneByteString* ReadFrom(SnapshotReader* reader, | 6428 static RawExternalOneByteString* ReadFrom(SnapshotReader* reader, |
| 6427 intptr_t object_id, | 6429 intptr_t object_id, |
| 6428 intptr_t tags, | 6430 intptr_t tags, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6485 | 6487 |
| 6486 static const uint16_t* CharAddr(const String& str, intptr_t index) { | 6488 static const uint16_t* CharAddr(const String& str, intptr_t index) { |
| 6487 ASSERT((index >= 0) && (index < str.Length())); | 6489 ASSERT((index >= 0) && (index < str.Length())); |
| 6488 ASSERT(str.IsExternalTwoByteString()); | 6490 ASSERT(str.IsExternalTwoByteString()); |
| 6489 return &(raw_ptr(str)->external_data_->data()[index]); | 6491 return &(raw_ptr(str)->external_data_->data()[index]); |
| 6490 } | 6492 } |
| 6491 | 6493 |
| 6492 static void SetExternalData(const String& str, | 6494 static void SetExternalData(const String& str, |
| 6493 ExternalStringData<uint16_t>* data) { | 6495 ExternalStringData<uint16_t>* data) { |
| 6494 ASSERT(str.IsExternalTwoByteString()); | 6496 ASSERT(str.IsExternalTwoByteString()); |
| 6497 ASSERT(!Isolate::Current()->heap()->Contains( |
| 6498 reinterpret_cast<uword>(data->data()))); |
| 6495 str.StoreNonPointer(&raw_ptr(str)->external_data_, data); | 6499 str.StoreNonPointer(&raw_ptr(str)->external_data_, data); |
| 6496 } | 6500 } |
| 6497 | 6501 |
| 6498 static void Finalize(void* isolate_callback_data, | 6502 static void Finalize(void* isolate_callback_data, |
| 6499 Dart_WeakPersistentHandle handle, | 6503 Dart_WeakPersistentHandle handle, |
| 6500 void* peer); | 6504 void* peer); |
| 6501 | 6505 |
| 6502 static RawExternalTwoByteString* ReadFrom(SnapshotReader* reader, | 6506 static RawExternalTwoByteString* ReadFrom(SnapshotReader* reader, |
| 6503 intptr_t object_id, | 6507 intptr_t object_id, |
| 6504 intptr_t tags, | 6508 intptr_t tags, |
| (...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7166 intptr_t cid = obj.raw()->GetClassId(); | 7170 intptr_t cid = obj.raw()->GetClassId(); |
| 7167 return RawObject::IsExternalTypedDataClassId(cid); | 7171 return RawObject::IsExternalTypedDataClassId(cid); |
| 7168 } | 7172 } |
| 7169 | 7173 |
| 7170 protected: | 7174 protected: |
| 7171 void SetLength(intptr_t value) const { | 7175 void SetLength(intptr_t value) const { |
| 7172 StoreSmi(&raw_ptr()->length_, Smi::New(value)); | 7176 StoreSmi(&raw_ptr()->length_, Smi::New(value)); |
| 7173 } | 7177 } |
| 7174 | 7178 |
| 7175 void SetData(uint8_t* data) const { | 7179 void SetData(uint8_t* data) const { |
| 7180 ASSERT(!Isolate::Current()->heap()->Contains( |
| 7181 reinterpret_cast<uword>(data))); |
| 7176 StoreNonPointer(&raw_ptr()->data_, data); | 7182 StoreNonPointer(&raw_ptr()->data_, data); |
| 7177 } | 7183 } |
| 7178 | 7184 |
| 7179 private: | 7185 private: |
| 7180 FINAL_HEAP_OBJECT_IMPLEMENTATION(ExternalTypedData, Instance); | 7186 FINAL_HEAP_OBJECT_IMPLEMENTATION(ExternalTypedData, Instance); |
| 7181 friend class Class; | 7187 friend class Class; |
| 7182 }; | 7188 }; |
| 7183 | 7189 |
| 7184 | 7190 |
| 7185 class TypedDataView : public AllStatic { | 7191 class TypedDataView : public AllStatic { |
| (...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7961 | 7967 |
| 7962 | 7968 |
| 7963 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 7969 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
| 7964 intptr_t index) { | 7970 intptr_t index) { |
| 7965 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 7971 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
| 7966 } | 7972 } |
| 7967 | 7973 |
| 7968 } // namespace dart | 7974 } // namespace dart |
| 7969 | 7975 |
| 7970 #endif // VM_OBJECT_H_ | 7976 #endif // VM_OBJECT_H_ |
| OLD | NEW |