| 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_RAW_OBJECT_H_ | 5 #ifndef VM_RAW_OBJECT_H_ |
| 6 #define VM_RAW_OBJECT_H_ | 6 #define VM_RAW_OBJECT_H_ |
| 7 | 7 |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/globals.h" | 9 #include "vm/globals.h" |
| 10 #include "vm/token.h" | 10 #include "vm/token.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 | 120 |
| 121 #define VISITOR_SUPPORT(object) \ | 121 #define VISITOR_SUPPORT(object) \ |
| 122 static intptr_t Visit##object##Pointers(Raw##object* raw_obj, \ | 122 static intptr_t Visit##object##Pointers(Raw##object* raw_obj, \ |
| 123 ObjectPointerVisitor* visitor); | 123 ObjectPointerVisitor* visitor); |
| 124 | 124 |
| 125 #define RAW_OBJECT_IMPLEMENTATION(object) \ | 125 #define RAW_OBJECT_IMPLEMENTATION(object) \ |
| 126 private: /* NOLINT */ \ | 126 private: /* NOLINT */ \ |
| 127 VISITOR_SUPPORT(object) \ | 127 VISITOR_SUPPORT(object) \ |
| 128 friend class object; \ | 128 friend class object; \ |
| 129 friend class RawObject; \ | 129 friend class RawObject; \ |
| 130 friend class Heap; \ | |
| 131 DISALLOW_ALLOCATION(); \ | 130 DISALLOW_ALLOCATION(); \ |
| 132 DISALLOW_IMPLICIT_CONSTRUCTORS(Raw##object) | 131 DISALLOW_IMPLICIT_CONSTRUCTORS(Raw##object) |
| 133 | 132 |
| 134 #define RAW_HEAP_OBJECT_IMPLEMENTATION(object) \ | 133 #define RAW_HEAP_OBJECT_IMPLEMENTATION(object) \ |
| 135 private: \ | 134 private: \ |
| 136 RAW_OBJECT_IMPLEMENTATION(object); \ | 135 RAW_OBJECT_IMPLEMENTATION(object); \ |
| 137 Raw##object* ptr() const { \ | 136 Raw##object* ptr() const { \ |
| 138 ASSERT(IsHeapObject()); \ | 137 ASSERT(IsHeapObject()); \ |
| 139 return reinterpret_cast<Raw##object*>( \ | 138 return reinterpret_cast<Raw##object*>( \ |
| 140 reinterpret_cast<uword>(this) - kHeapObjectTag); \ | 139 reinterpret_cast<uword>(this) - kHeapObjectTag); \ |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 ASSERT(result == SizeFromClass()); | 244 ASSERT(result == SizeFromClass()); |
| 246 return result; | 245 return result; |
| 247 } | 246 } |
| 248 result = SizeFromClass(); | 247 result = SizeFromClass(); |
| 249 ASSERT((result > SizeTag::kMaxSizeTag) || FreeBit::decode(tags)); | 248 ASSERT((result > SizeTag::kMaxSizeTag) || FreeBit::decode(tags)); |
| 250 return result; | 249 return result; |
| 251 } | 250 } |
| 252 | 251 |
| 253 void Validate() const; | 252 void Validate() const; |
| 254 intptr_t VisitPointers(ObjectPointerVisitor* visitor); | 253 intptr_t VisitPointers(ObjectPointerVisitor* visitor); |
| 255 bool FindObject(FindObjectVisitor* visitor); | |
| 256 | 254 |
| 257 static RawObject* FromAddr(uword addr) { | 255 static RawObject* FromAddr(uword addr) { |
| 258 // We expect the untagged address here. | 256 // We expect the untagged address here. |
| 259 ASSERT((addr & kSmiTagMask) != kHeapObjectTag); | 257 ASSERT((addr & kSmiTagMask) != kHeapObjectTag); |
| 260 return reinterpret_cast<RawObject*>(addr + kHeapObjectTag); | 258 return reinterpret_cast<RawObject*>(addr + kHeapObjectTag); |
| 261 } | 259 } |
| 262 | 260 |
| 263 static uword ToAddr(RawObject* raw_obj) { | 261 static uword ToAddr(RawObject* raw_obj) { |
| 264 return reinterpret_cast<uword>(raw_obj->ptr()); | 262 return reinterpret_cast<uword>(raw_obj->ptr()); |
| 265 } | 263 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 286 class CreatedFromSnapshotTag : public BitField<bool, kFromSnapshotBit, 1> {}; | 284 class CreatedFromSnapshotTag : public BitField<bool, kFromSnapshotBit, 1> {}; |
| 287 | 285 |
| 288 RawObject* ptr() const { | 286 RawObject* ptr() const { |
| 289 ASSERT(IsHeapObject()); | 287 ASSERT(IsHeapObject()); |
| 290 return reinterpret_cast<RawObject*>( | 288 return reinterpret_cast<RawObject*>( |
| 291 reinterpret_cast<uword>(this) - kHeapObjectTag); | 289 reinterpret_cast<uword>(this) - kHeapObjectTag); |
| 292 } | 290 } |
| 293 | 291 |
| 294 intptr_t SizeFromClass() const; | 292 intptr_t SizeFromClass() const; |
| 295 | 293 |
| 296 friend class Heap; | |
| 297 friend class Object; | 294 friend class Object; |
| 298 friend class Array; | 295 friend class Array; |
| 299 friend class RawInstructions; | |
| 300 friend class SnapshotWriter; | 296 friend class SnapshotWriter; |
| 301 friend class SnapshotReader; | 297 friend class SnapshotReader; |
| 302 friend class MarkingVisitor; | 298 friend class MarkingVisitor; |
| 303 | 299 |
| 304 DISALLOW_ALLOCATION(); | 300 DISALLOW_ALLOCATION(); |
| 305 DISALLOW_IMPLICIT_CONSTRUCTORS(RawObject); | 301 DISALLOW_IMPLICIT_CONSTRUCTORS(RawObject); |
| 306 }; | 302 }; |
| 307 | 303 |
| 308 | 304 |
| 309 class RawClass : public RawObject { | 305 class RawClass : public RawObject { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 intptr_t type_arguments_instance_field_offset_; // May be kNoTypeArguments. | 340 intptr_t type_arguments_instance_field_offset_; // May be kNoTypeArguments. |
| 345 intptr_t next_field_offset_; // Offset of then next instance field. | 341 intptr_t next_field_offset_; // Offset of then next instance field. |
| 346 intptr_t num_native_fields_; // Number of native fields in class. | 342 intptr_t num_native_fields_; // Number of native fields in class. |
| 347 intptr_t token_index_; | 343 intptr_t token_index_; |
| 348 int8_t class_state_; // Of type ClassState. | 344 int8_t class_state_; // Of type ClassState. |
| 349 bool is_const_; | 345 bool is_const_; |
| 350 bool is_interface_; | 346 bool is_interface_; |
| 351 | 347 |
| 352 friend class Object; | 348 friend class Object; |
| 353 friend class RawInstance; | 349 friend class RawInstance; |
| 354 friend class RawInstructions; | |
| 355 friend RawClass* AllocateFakeClass(); | 350 friend RawClass* AllocateFakeClass(); |
| 356 friend class SnapshotReader; | 351 friend class SnapshotReader; |
| 357 }; | 352 }; |
| 358 | 353 |
| 359 | 354 |
| 360 class RawUnresolvedClass : public RawObject { | 355 class RawUnresolvedClass : public RawObject { |
| 361 RAW_HEAP_OBJECT_IMPLEMENTATION(UnresolvedClass); | 356 RAW_HEAP_OBJECT_IMPLEMENTATION(UnresolvedClass); |
| 362 | 357 |
| 363 RawObject** from() { | 358 RawObject** from() { |
| 364 return reinterpret_cast<RawObject**>(&ptr()->library_prefix_); | 359 return reinterpret_cast<RawObject**>(&ptr()->library_prefix_); |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 RawObject** to() { | 661 RawObject** to() { |
| 667 return reinterpret_cast<RawObject**>(&ptr()->var_descriptors_); | 662 return reinterpret_cast<RawObject**>(&ptr()->var_descriptors_); |
| 668 } | 663 } |
| 669 | 664 |
| 670 intptr_t pointer_offsets_length_; | 665 intptr_t pointer_offsets_length_; |
| 671 // This cannot be boolean because of alignment issues on x64 architectures. | 666 // This cannot be boolean because of alignment issues on x64 architectures. |
| 672 intptr_t is_optimized_; | 667 intptr_t is_optimized_; |
| 673 | 668 |
| 674 // Variable length data follows here. | 669 // Variable length data follows here. |
| 675 int32_t data_[0]; | 670 int32_t data_[0]; |
| 676 | |
| 677 friend class DartFrame; | |
| 678 friend class StubFrame; | |
| 679 }; | 671 }; |
| 680 | 672 |
| 681 | 673 |
| 682 class RawInstructions : public RawObject { | 674 class RawInstructions : public RawObject { |
| 683 RAW_HEAP_OBJECT_IMPLEMENTATION(Instructions); | 675 RAW_HEAP_OBJECT_IMPLEMENTATION(Instructions); |
| 684 | 676 |
| 685 RawCode* code_; | 677 RawCode* code_; |
| 686 intptr_t size_; | 678 intptr_t size_; |
| 687 | 679 |
| 688 // Variable length data follows here. | 680 // Variable length data follows here. |
| 689 uint8_t data_[0]; | 681 uint8_t data_[0]; |
| 690 | 682 |
| 691 // Private helper function used while visiting stack frames. The | |
| 692 // code which iterates over dart frames is also called during GC and | |
| 693 // is not allowed to create handles. | |
| 694 static bool ContainsPC(RawObject* raw_obj, uword pc); | |
| 695 | |
| 696 friend class RawCode; | 683 friend class RawCode; |
| 697 friend class StackFrame; | |
| 698 }; | 684 }; |
| 699 | 685 |
| 700 | 686 |
| 701 class RawPcDescriptors : public RawObject { | 687 class RawPcDescriptors : public RawObject { |
| 702 RAW_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors); | 688 RAW_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors); |
| 703 | 689 |
| 704 RawSmi* length_; // Number of descriptors. | 690 RawSmi* length_; // Number of descriptors. |
| 705 | 691 |
| 706 // Variable length data follows here. | 692 // Variable length data follows here. |
| 707 intptr_t data_[0]; | 693 intptr_t data_[0]; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 721 | 707 |
| 722 RawObject** from() { | 708 RawObject** from() { |
| 723 return reinterpret_cast<RawObject**>(&ptr()->code_); | 709 return reinterpret_cast<RawObject**>(&ptr()->code_); |
| 724 } | 710 } |
| 725 RawCode* code_; // Code object corresponding to the frame described. | 711 RawCode* code_; // Code object corresponding to the frame described. |
| 726 RawSmi* bitmap_size_in_bytes_; // Size of the bit map in bytes. | 712 RawSmi* bitmap_size_in_bytes_; // Size of the bit map in bytes. |
| 727 RawObject** to() { | 713 RawObject** to() { |
| 728 return reinterpret_cast<RawObject**>(&ptr()->bitmap_size_in_bytes_); | 714 return reinterpret_cast<RawObject**>(&ptr()->bitmap_size_in_bytes_); |
| 729 } | 715 } |
| 730 uword pc_; // PC corresponding to this stack map representation. | 716 uword pc_; // PC corresponding to this stack map representation. |
| 731 intptr_t min_set_bit_offset_; // Minimum bit offset which is set. | |
| 732 intptr_t max_set_bit_offset_; // Maximum bit offset which is set. | |
| 733 | 717 |
| 734 // Variable length data follows here (bitmap of the stack layout). | 718 // Variable length data follows here (bitmap of the stack layout). |
| 735 uint8_t data_[0]; | 719 uint8_t data_[0]; |
| 736 }; | 720 }; |
| 737 | 721 |
| 738 | 722 |
| 739 class RawLocalVarDescriptors : public RawObject { | 723 class RawLocalVarDescriptors : public RawObject { |
| 740 RAW_HEAP_OBJECT_IMPLEMENTATION(LocalVarDescriptors); | 724 RAW_HEAP_OBJECT_IMPLEMENTATION(LocalVarDescriptors); |
| 741 | 725 |
| 742 struct VarInfo { | 726 struct VarInfo { |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1043 RawSmi* length_; | 1027 RawSmi* length_; |
| 1044 // Variable length data follows here. | 1028 // Variable length data follows here. |
| 1045 RawObject** data() { | 1029 RawObject** data() { |
| 1046 uword address_of_length = reinterpret_cast<uword>(&length_); | 1030 uword address_of_length = reinterpret_cast<uword>(&length_); |
| 1047 return reinterpret_cast<RawObject**>(address_of_length + kWordSize); | 1031 return reinterpret_cast<RawObject**>(address_of_length + kWordSize); |
| 1048 } | 1032 } |
| 1049 RawObject** to(intptr_t length) { | 1033 RawObject** to(intptr_t length) { |
| 1050 return reinterpret_cast<RawObject**>(&ptr()->data()[length - 1]); | 1034 return reinterpret_cast<RawObject**>(&ptr()->data()[length - 1]); |
| 1051 } | 1035 } |
| 1052 | 1036 |
| 1053 friend class RawCode; | |
| 1054 friend class RawImmutableArray; | 1037 friend class RawImmutableArray; |
| 1055 friend class SnapshotReader; | 1038 friend class SnapshotReader; |
| 1056 friend class GrowableObjectArray; | 1039 friend class GrowableObjectArray; |
| 1057 }; | 1040 }; |
| 1058 | 1041 |
| 1059 | 1042 |
| 1060 class RawImmutableArray : public RawArray { | 1043 class RawImmutableArray : public RawArray { |
| 1061 RAW_HEAP_OBJECT_IMPLEMENTATION(ImmutableArray); | 1044 RAW_HEAP_OBJECT_IMPLEMENTATION(ImmutableArray); |
| 1062 | 1045 |
| 1063 friend class SnapshotReader; | 1046 friend class SnapshotReader; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1184 intptr_t type_; // Uninitialized, simple or complex. | 1167 intptr_t type_; // Uninitialized, simple or complex. |
| 1185 intptr_t flags_; // Represents global/local, case insensitive, multiline. | 1168 intptr_t flags_; // Represents global/local, case insensitive, multiline. |
| 1186 | 1169 |
| 1187 // Variable length data follows here. | 1170 // Variable length data follows here. |
| 1188 uint8_t data_[0]; | 1171 uint8_t data_[0]; |
| 1189 }; | 1172 }; |
| 1190 | 1173 |
| 1191 } // namespace dart | 1174 } // namespace dart |
| 1192 | 1175 |
| 1193 #endif // VM_RAW_OBJECT_H_ | 1176 #endif // VM_RAW_OBJECT_H_ |
| OLD | NEW |