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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 void* operator new(size_t size); \ | 173 void* operator new(size_t size); \ |
174 object(const object& value); \ | 174 object(const object& value); \ |
175 void operator=(Raw##super* value); \ | 175 void operator=(Raw##super* value); \ |
176 void operator=(const object& value); \ | 176 void operator=(const object& value); \ |
177 void operator=(const super& value); \ | 177 void operator=(const super& value); \ |
178 | 178 |
179 #define SNAPSHOT_READER_SUPPORT(object) \ | 179 #define SNAPSHOT_READER_SUPPORT(object) \ |
180 static Raw##object* ReadFrom(SnapshotReader* reader, \ | 180 static Raw##object* ReadFrom(SnapshotReader* reader, \ |
181 intptr_t object_id, \ | 181 intptr_t object_id, \ |
182 intptr_t tags, \ | 182 intptr_t tags, \ |
183 Snapshot::Kind); \ | 183 Snapshot::Kind, \ |
| 184 bool as_reference); \ |
184 friend class SnapshotReader; \ | 185 friend class SnapshotReader; \ |
185 | 186 |
186 #define OBJECT_IMPLEMENTATION(object, super) \ | 187 #define OBJECT_IMPLEMENTATION(object, super) \ |
187 public: /* NOLINT */ \ | 188 public: /* NOLINT */ \ |
188 void operator=(Raw##object* value) { \ | 189 void operator=(Raw##object* value) { \ |
189 initializeHandle(this, value); \ | 190 initializeHandle(this, value); \ |
190 } \ | 191 } \ |
191 void operator^=(RawObject* value) { \ | 192 void operator^=(RawObject* value) { \ |
192 initializeHandle(this, value); \ | 193 initializeHandle(this, value); \ |
193 ASSERT(IsNull() || Is##object()); \ | 194 ASSERT(IsNull() || Is##object()); \ |
(...skipping 6190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6384 | 6385 |
6385 static uint8_t* CharAddr(const String& str, intptr_t index) { | 6386 static uint8_t* CharAddr(const String& str, intptr_t index) { |
6386 ASSERT((index >= 0) && (index < str.Length())); | 6387 ASSERT((index >= 0) && (index < str.Length())); |
6387 ASSERT(str.IsOneByteString()); | 6388 ASSERT(str.IsOneByteString()); |
6388 return &str.UnsafeMutableNonPointer(raw_ptr(str)->data())[index]; | 6389 return &str.UnsafeMutableNonPointer(raw_ptr(str)->data())[index]; |
6389 } | 6390 } |
6390 | 6391 |
6391 static RawOneByteString* ReadFrom(SnapshotReader* reader, | 6392 static RawOneByteString* ReadFrom(SnapshotReader* reader, |
6392 intptr_t object_id, | 6393 intptr_t object_id, |
6393 intptr_t tags, | 6394 intptr_t tags, |
6394 Snapshot::Kind kind); | 6395 Snapshot::Kind kind, |
| 6396 bool as_reference); |
6395 | 6397 |
6396 friend class Class; | 6398 friend class Class; |
6397 friend class String; | 6399 friend class String; |
6398 friend class Symbols; | 6400 friend class Symbols; |
6399 friend class ExternalOneByteString; | 6401 friend class ExternalOneByteString; |
6400 friend class SnapshotReader; | 6402 friend class SnapshotReader; |
6401 friend class StringHasher; | 6403 friend class StringHasher; |
6402 }; | 6404 }; |
6403 | 6405 |
6404 | 6406 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6499 | 6501 |
6500 static uint16_t* CharAddr(const String& str, intptr_t index) { | 6502 static uint16_t* CharAddr(const String& str, intptr_t index) { |
6501 ASSERT((index >= 0) && (index < str.Length())); | 6503 ASSERT((index >= 0) && (index < str.Length())); |
6502 ASSERT(str.IsTwoByteString()); | 6504 ASSERT(str.IsTwoByteString()); |
6503 return &str.UnsafeMutableNonPointer(raw_ptr(str)->data())[index]; | 6505 return &str.UnsafeMutableNonPointer(raw_ptr(str)->data())[index]; |
6504 } | 6506 } |
6505 | 6507 |
6506 static RawTwoByteString* ReadFrom(SnapshotReader* reader, | 6508 static RawTwoByteString* ReadFrom(SnapshotReader* reader, |
6507 intptr_t object_id, | 6509 intptr_t object_id, |
6508 intptr_t tags, | 6510 intptr_t tags, |
6509 Snapshot::Kind kind); | 6511 Snapshot::Kind kind, |
| 6512 bool as_reference); |
6510 | 6513 |
6511 friend class Class; | 6514 friend class Class; |
6512 friend class String; | 6515 friend class String; |
6513 friend class SnapshotReader; | 6516 friend class SnapshotReader; |
6514 friend class Symbols; | 6517 friend class Symbols; |
6515 }; | 6518 }; |
6516 | 6519 |
6517 | 6520 |
6518 class ExternalOneByteString : public AllStatic { | 6521 class ExternalOneByteString : public AllStatic { |
6519 public: | 6522 public: |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6577 str.StoreNonPointer(&raw_ptr(str)->external_data_, data); | 6580 str.StoreNonPointer(&raw_ptr(str)->external_data_, data); |
6578 } | 6581 } |
6579 | 6582 |
6580 static void Finalize(void* isolate_callback_data, | 6583 static void Finalize(void* isolate_callback_data, |
6581 Dart_WeakPersistentHandle handle, | 6584 Dart_WeakPersistentHandle handle, |
6582 void* peer); | 6585 void* peer); |
6583 | 6586 |
6584 static RawExternalOneByteString* ReadFrom(SnapshotReader* reader, | 6587 static RawExternalOneByteString* ReadFrom(SnapshotReader* reader, |
6585 intptr_t object_id, | 6588 intptr_t object_id, |
6586 intptr_t tags, | 6589 intptr_t tags, |
6587 Snapshot::Kind kind); | 6590 Snapshot::Kind kind, |
| 6591 bool as_reference); |
6588 | 6592 |
6589 static intptr_t NextFieldOffset() { | 6593 static intptr_t NextFieldOffset() { |
6590 // Indicates this class cannot be extended by dart code. | 6594 // Indicates this class cannot be extended by dart code. |
6591 return -kWordSize; | 6595 return -kWordSize; |
6592 } | 6596 } |
6593 | 6597 |
6594 friend class Class; | 6598 friend class Class; |
6595 friend class String; | 6599 friend class String; |
6596 friend class SnapshotReader; | 6600 friend class SnapshotReader; |
6597 friend class Symbols; | 6601 friend class Symbols; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6656 str.StoreNonPointer(&raw_ptr(str)->external_data_, data); | 6660 str.StoreNonPointer(&raw_ptr(str)->external_data_, data); |
6657 } | 6661 } |
6658 | 6662 |
6659 static void Finalize(void* isolate_callback_data, | 6663 static void Finalize(void* isolate_callback_data, |
6660 Dart_WeakPersistentHandle handle, | 6664 Dart_WeakPersistentHandle handle, |
6661 void* peer); | 6665 void* peer); |
6662 | 6666 |
6663 static RawExternalTwoByteString* ReadFrom(SnapshotReader* reader, | 6667 static RawExternalTwoByteString* ReadFrom(SnapshotReader* reader, |
6664 intptr_t object_id, | 6668 intptr_t object_id, |
6665 intptr_t tags, | 6669 intptr_t tags, |
6666 Snapshot::Kind kind); | 6670 Snapshot::Kind kind, |
| 6671 bool as_reference); |
6667 | 6672 |
6668 static intptr_t NextFieldOffset() { | 6673 static intptr_t NextFieldOffset() { |
6669 // Indicates this class cannot be extended by dart code. | 6674 // Indicates this class cannot be extended by dart code. |
6670 return -kWordSize; | 6675 return -kWordSize; |
6671 } | 6676 } |
6672 | 6677 |
6673 friend class Class; | 6678 friend class Class; |
6674 friend class String; | 6679 friend class String; |
6675 friend class SnapshotReader; | 6680 friend class SnapshotReader; |
6676 friend class Symbols; | 6681 friend class Symbols; |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6828 }; | 6833 }; |
6829 | 6834 |
6830 | 6835 |
6831 class ImmutableArray : public AllStatic { | 6836 class ImmutableArray : public AllStatic { |
6832 public: | 6837 public: |
6833 static RawImmutableArray* New(intptr_t len, Heap::Space space = Heap::kNew); | 6838 static RawImmutableArray* New(intptr_t len, Heap::Space space = Heap::kNew); |
6834 | 6839 |
6835 static RawImmutableArray* ReadFrom(SnapshotReader* reader, | 6840 static RawImmutableArray* ReadFrom(SnapshotReader* reader, |
6836 intptr_t object_id, | 6841 intptr_t object_id, |
6837 intptr_t tags, | 6842 intptr_t tags, |
6838 Snapshot::Kind kind); | 6843 Snapshot::Kind kind, |
| 6844 bool as_reference); |
6839 | 6845 |
6840 static const ClassId kClassId = kImmutableArrayCid; | 6846 static const ClassId kClassId = kImmutableArrayCid; |
6841 | 6847 |
6842 static intptr_t InstanceSize() { | 6848 static intptr_t InstanceSize() { |
6843 return Array::InstanceSize(); | 6849 return Array::InstanceSize(); |
6844 } | 6850 } |
6845 | 6851 |
6846 static intptr_t InstanceSize(intptr_t len) { | 6852 static intptr_t InstanceSize(intptr_t len) { |
6847 return Array::InstanceSize(len); | 6853 return Array::InstanceSize(len); |
6848 } | 6854 } |
(...skipping 1302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8151 | 8157 |
8152 | 8158 |
8153 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 8159 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
8154 intptr_t index) { | 8160 intptr_t index) { |
8155 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 8161 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
8156 } | 8162 } |
8157 | 8163 |
8158 } // namespace dart | 8164 } // namespace dart |
8159 | 8165 |
8160 #endif // VM_OBJECT_H_ | 8166 #endif // VM_OBJECT_H_ |
OLD | NEW |