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