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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 ASSERT(result == SizeFromClass()); | 244 ASSERT(result == SizeFromClass()); |
245 return result; | 245 return result; |
246 } | 246 } |
247 result = SizeFromClass(); | 247 result = SizeFromClass(); |
248 ASSERT((result > SizeTag::kMaxSizeTag) || FreeBit::decode(tags)); | 248 ASSERT((result > SizeTag::kMaxSizeTag) || FreeBit::decode(tags)); |
249 return result; | 249 return result; |
250 } | 250 } |
251 | 251 |
252 void Validate() const; | 252 void Validate() const; |
253 intptr_t VisitPointers(ObjectPointerVisitor* visitor); | 253 intptr_t VisitPointers(ObjectPointerVisitor* visitor); |
| 254 bool FindObject(FindObjectVisitor* visitor); |
254 | 255 |
255 static RawObject* FromAddr(uword addr) { | 256 static RawObject* FromAddr(uword addr) { |
256 // We expect the untagged address here. | 257 // We expect the untagged address here. |
257 ASSERT((addr & kSmiTagMask) != kHeapObjectTag); | 258 ASSERT((addr & kSmiTagMask) != kHeapObjectTag); |
258 return reinterpret_cast<RawObject*>(addr + kHeapObjectTag); | 259 return reinterpret_cast<RawObject*>(addr + kHeapObjectTag); |
259 } | 260 } |
260 | 261 |
261 static uword ToAddr(RawObject* raw_obj) { | 262 static uword ToAddr(RawObject* raw_obj) { |
262 return reinterpret_cast<uword>(raw_obj->ptr()); | 263 return reinterpret_cast<uword>(raw_obj->ptr()); |
263 } | 264 } |
264 | 265 |
265 static bool IsCreatedFromSnapshot(intptr_t value) { | 266 static bool IsCreatedFromSnapshot(intptr_t value) { |
266 return CreatedFromSnapshotTag::decode(value); | 267 return CreatedFromSnapshotTag::decode(value); |
267 } | 268 } |
268 | 269 |
269 static bool IsCanonical(intptr_t value) { | 270 static bool IsCanonical(intptr_t value) { |
270 return CanonicalObjectTag::decode(value); | 271 return CanonicalObjectTag::decode(value); |
271 } | 272 } |
272 | 273 |
| 274 static bool IsRawInstruction(RawObject* raw_obj); |
| 275 |
273 protected: | 276 protected: |
274 RawClass* class_; | 277 RawClass* class_; |
275 uword tags_; // Various object tags (bits). | 278 uword tags_; // Various object tags (bits). |
276 | 279 |
277 private: | 280 private: |
278 class FreeBit : public BitField<bool, kFreeBit, 1> {}; | 281 class FreeBit : public BitField<bool, kFreeBit, 1> {}; |
279 | 282 |
280 class MarkBit : public BitField<bool, kMarkBit, 1> {}; | 283 class MarkBit : public BitField<bool, kMarkBit, 1> {}; |
281 | 284 |
282 class CanonicalObjectTag : public BitField<bool, kCanonicalBit, 1> {}; | 285 class CanonicalObjectTag : public BitField<bool, kCanonicalBit, 1> {}; |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 RawObject** to() { | 661 RawObject** to() { |
659 return reinterpret_cast<RawObject**>(&ptr()->var_descriptors_); | 662 return reinterpret_cast<RawObject**>(&ptr()->var_descriptors_); |
660 } | 663 } |
661 | 664 |
662 intptr_t pointer_offsets_length_; | 665 intptr_t pointer_offsets_length_; |
663 // This cannot be boolean because of alignment issues on x64 architectures. | 666 // This cannot be boolean because of alignment issues on x64 architectures. |
664 intptr_t is_optimized_; | 667 intptr_t is_optimized_; |
665 | 668 |
666 // Variable length data follows here. | 669 // Variable length data follows here. |
667 int32_t data_[0]; | 670 int32_t data_[0]; |
| 671 |
| 672 // Private helper function used while visiting stack frames during |
| 673 // GC. The code which iterates over dart frames during GC is not |
| 674 // allowed to create handles. |
| 675 RawStackmap* GetStackmap(uword pc) const; |
| 676 |
| 677 friend class DartFrame; |
| 678 friend class StubFrame; |
668 }; | 679 }; |
669 | 680 |
670 | 681 |
671 class RawInstructions : public RawObject { | 682 class RawInstructions : public RawObject { |
672 RAW_HEAP_OBJECT_IMPLEMENTATION(Instructions); | 683 RAW_HEAP_OBJECT_IMPLEMENTATION(Instructions); |
673 | 684 |
674 RawCode* code_; | 685 RawCode* code_; |
675 intptr_t size_; | 686 intptr_t size_; |
676 | 687 |
677 // Variable length data follows here. | 688 // Variable length data follows here. |
678 uint8_t data_[0]; | 689 uint8_t data_[0]; |
679 | 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 |
680 friend class RawCode; | 696 friend class RawCode; |
| 697 friend class StackFrame; |
681 }; | 698 }; |
682 | 699 |
683 | 700 |
684 class RawPcDescriptors : public RawObject { | 701 class RawPcDescriptors : public RawObject { |
685 RAW_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors); | 702 RAW_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors); |
686 | 703 |
687 RawSmi* length_; // Number of descriptors. | 704 RawSmi* length_; // Number of descriptors. |
688 | 705 |
689 // Variable length data follows here. | 706 // Variable length data follows here. |
690 intptr_t data_[0]; | 707 intptr_t data_[0]; |
(...skipping 13 matching lines...) Expand all Loading... |
704 | 721 |
705 RawObject** from() { | 722 RawObject** from() { |
706 return reinterpret_cast<RawObject**>(&ptr()->code_); | 723 return reinterpret_cast<RawObject**>(&ptr()->code_); |
707 } | 724 } |
708 RawCode* code_; // Code object corresponding to the frame described. | 725 RawCode* code_; // Code object corresponding to the frame described. |
709 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. |
710 RawObject** to() { | 727 RawObject** to() { |
711 return reinterpret_cast<RawObject**>(&ptr()->bitmap_size_in_bytes_); | 728 return reinterpret_cast<RawObject**>(&ptr()->bitmap_size_in_bytes_); |
712 } | 729 } |
713 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. |
714 | 733 |
715 // Variable length data follows here (bitmap of the stack layout). | 734 // Variable length data follows here (bitmap of the stack layout). |
716 uint8_t data_[0]; | 735 uint8_t data_[0]; |
| 736 |
| 737 // Private helper functions used while visiting stack frames during |
| 738 // GC. The code which iterates over dart frames during GC is not |
| 739 // allowed to create handles. |
| 740 bool IsObject(intptr_t bit_offset) const; |
| 741 uword PC() const { return ptr()->pc_; } |
| 742 intptr_t MinimumBitOffset() const { return ptr()->min_set_bit_offset_; } |
| 743 intptr_t MaximumBitOffset() const { return ptr()->max_set_bit_offset_; } |
| 744 |
| 745 friend class RawCode; |
| 746 friend class DartFrame; |
717 }; | 747 }; |
718 | 748 |
719 | 749 |
720 class RawLocalVarDescriptors : public RawObject { | 750 class RawLocalVarDescriptors : public RawObject { |
721 RAW_HEAP_OBJECT_IMPLEMENTATION(LocalVarDescriptors); | 751 RAW_HEAP_OBJECT_IMPLEMENTATION(LocalVarDescriptors); |
722 | 752 |
723 struct VarInfo { | 753 struct VarInfo { |
724 intptr_t index; // Slot index on stack or in context. | 754 intptr_t index; // Slot index on stack or in context. |
725 intptr_t scope_id; // Scope to which the variable belongs. | 755 intptr_t scope_id; // Scope to which the variable belongs. |
726 intptr_t begin_pos; // Token position of scope start. | 756 intptr_t begin_pos; // Token position of scope start. |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1024 RawSmi* length_; | 1054 RawSmi* length_; |
1025 // Variable length data follows here. | 1055 // Variable length data follows here. |
1026 RawObject** data() { | 1056 RawObject** data() { |
1027 uword address_of_length = reinterpret_cast<uword>(&length_); | 1057 uword address_of_length = reinterpret_cast<uword>(&length_); |
1028 return reinterpret_cast<RawObject**>(address_of_length + kWordSize); | 1058 return reinterpret_cast<RawObject**>(address_of_length + kWordSize); |
1029 } | 1059 } |
1030 RawObject** to(intptr_t length) { | 1060 RawObject** to(intptr_t length) { |
1031 return reinterpret_cast<RawObject**>(&ptr()->data()[length - 1]); | 1061 return reinterpret_cast<RawObject**>(&ptr()->data()[length - 1]); |
1032 } | 1062 } |
1033 | 1063 |
| 1064 // Private helper functions used while visiting stack frames during |
| 1065 // GC. The code which iterates over dart frames during GC is not |
| 1066 // allowed to create handles. |
| 1067 intptr_t Length() const; |
| 1068 RawObject* DataAt(intptr_t index) const { return ptr()->data()[index]; } |
| 1069 |
| 1070 friend class RawCode; |
1034 friend class RawImmutableArray; | 1071 friend class RawImmutableArray; |
1035 friend class SnapshotReader; | 1072 friend class SnapshotReader; |
1036 friend class GrowableObjectArray; | 1073 friend class GrowableObjectArray; |
1037 }; | 1074 }; |
1038 | 1075 |
1039 | 1076 |
1040 class RawImmutableArray : public RawArray { | 1077 class RawImmutableArray : public RawArray { |
1041 RAW_HEAP_OBJECT_IMPLEMENTATION(ImmutableArray); | 1078 RAW_HEAP_OBJECT_IMPLEMENTATION(ImmutableArray); |
1042 | 1079 |
1043 friend class SnapshotReader; | 1080 friend class SnapshotReader; |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1164 intptr_t type_; // Uninitialized, simple or complex. | 1201 intptr_t type_; // Uninitialized, simple or complex. |
1165 intptr_t flags_; // Represents global/local, case insensitive, multiline. | 1202 intptr_t flags_; // Represents global/local, case insensitive, multiline. |
1166 | 1203 |
1167 // Variable length data follows here. | 1204 // Variable length data follows here. |
1168 uint8_t data_[0]; | 1205 uint8_t data_[0]; |
1169 }; | 1206 }; |
1170 | 1207 |
1171 } // namespace dart | 1208 } // namespace dart |
1172 | 1209 |
1173 #endif // VM_RAW_OBJECT_H_ | 1210 #endif // VM_RAW_OBJECT_H_ |
OLD | NEW |