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/atomic.h" | 9 #include "vm/atomic.h" |
10 #include "vm/globals.h" | 10 #include "vm/globals.h" |
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 friend class ExternalTypedData; | 568 friend class ExternalTypedData; |
569 friend class ForwardList; | 569 friend class ForwardList; |
570 friend class GrowableObjectArray; // StorePointer | 570 friend class GrowableObjectArray; // StorePointer |
571 friend class Heap; | 571 friend class Heap; |
572 friend class HeapMapAsJSONVisitor; | 572 friend class HeapMapAsJSONVisitor; |
573 friend class ClassStatsVisitor; | 573 friend class ClassStatsVisitor; |
574 friend class MarkingVisitor; | 574 friend class MarkingVisitor; |
575 friend class Mint; | 575 friend class Mint; |
576 friend class Object; | 576 friend class Object; |
577 friend class OneByteString; // StoreSmi | 577 friend class OneByteString; // StoreSmi |
578 friend class RawCode; | |
579 friend class RawExternalTypedData; | 578 friend class RawExternalTypedData; |
580 friend class RawInstructions; | 579 friend class RawInstructions; |
581 friend class RawInstance; | 580 friend class RawInstance; |
582 friend class RawTypedData; | 581 friend class RawTypedData; |
583 friend class Scavenger; | 582 friend class Scavenger; |
584 friend class ScavengerVisitor; | 583 friend class ScavengerVisitor; |
585 friend class SizeExcludingClassVisitor; // GetClassId | 584 friend class SizeExcludingClassVisitor; // GetClassId |
586 friend class RetainingPathVisitor; // GetClassId | 585 friend class RetainingPathVisitor; // GetClassId |
587 friend class SkippedCodeFunctions; // StorePointer | 586 friend class SkippedCodeFunctions; // StorePointer |
588 friend class InstructionsReader; // tags_ check | 587 friend class InstructionsReader; // tags_ check |
589 friend class SnapshotReader; | 588 friend class SnapshotReader; |
590 friend class SnapshotWriter; | 589 friend class SnapshotWriter; |
591 friend class String; | 590 friend class String; |
592 friend class TypedData; | 591 friend class TypedData; |
593 friend class TypedDataView; | 592 friend class TypedDataView; |
594 friend class WeakProperty; // StorePointer | 593 friend class WeakProperty; // StorePointer |
595 friend class Instance; // StorePointer | 594 friend class Instance; // StorePointer |
596 friend class StackFrame; // GetCodeObject assertion. | |
597 | 595 |
598 DISALLOW_ALLOCATION(); | 596 DISALLOW_ALLOCATION(); |
599 DISALLOW_IMPLICIT_CONSTRUCTORS(RawObject); | 597 DISALLOW_IMPLICIT_CONSTRUCTORS(RawObject); |
600 }; | 598 }; |
601 | 599 |
602 | 600 |
603 class RawClass : public RawObject { | 601 class RawClass : public RawObject { |
604 public: | 602 public: |
605 enum ClassFinalizedState { | 603 enum ClassFinalizedState { |
606 kAllocated = 0, // Initial state. | 604 kAllocated = 0, // Initial state. |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 RawObject** to_snapshot() { | 763 RawObject** to_snapshot() { |
766 return reinterpret_cast<RawObject**>(&ptr()->data_); | 764 return reinterpret_cast<RawObject**>(&ptr()->data_); |
767 } | 765 } |
768 RawArray* ic_data_array_; // ICData of unoptimized code. | 766 RawArray* ic_data_array_; // ICData of unoptimized code. |
769 RawObject** to_optimized_snapshot() { | 767 RawObject** to_optimized_snapshot() { |
770 return reinterpret_cast<RawObject**>(&ptr()->ic_data_array_); | 768 return reinterpret_cast<RawObject**>(&ptr()->ic_data_array_); |
771 } | 769 } |
772 RawObject** to_no_code() { | 770 RawObject** to_no_code() { |
773 return reinterpret_cast<RawObject**>(&ptr()->ic_data_array_); | 771 return reinterpret_cast<RawObject**>(&ptr()->ic_data_array_); |
774 } | 772 } |
775 RawCode* code_; // Currently active code. | 773 RawInstructions* instructions_; // Instructions of currently active code. |
776 RawCode* unoptimized_code_; // Unoptimized code, keep it after optimization. | 774 RawCode* unoptimized_code_; // Unoptimized code, keep it after optimization. |
777 RawObject** to() { | 775 RawObject** to() { |
778 return reinterpret_cast<RawObject**>(&ptr()->unoptimized_code_); | 776 return reinterpret_cast<RawObject**>(&ptr()->unoptimized_code_); |
779 } | 777 } |
780 uword entry_point_; | 778 uword entry_point_; |
781 | 779 |
782 int32_t token_pos_; | 780 int32_t token_pos_; |
783 int32_t end_token_pos_; | 781 int32_t end_token_pos_; |
784 int32_t usage_counter_; // Incremented while function is running. | 782 int32_t usage_counter_; // Incremented while function is running. |
785 int16_t num_fixed_parameters_; | 783 int16_t num_fixed_parameters_; |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 class RawCode : public RawObject { | 993 class RawCode : public RawObject { |
996 enum InlinedMetadataIndex { | 994 enum InlinedMetadataIndex { |
997 kInlinedIntervalsIndex = 0, | 995 kInlinedIntervalsIndex = 0, |
998 kInlinedIdToFunctionIndex = 1, | 996 kInlinedIdToFunctionIndex = 1, |
999 kInlinedCallerIdMapIndex = 2, | 997 kInlinedCallerIdMapIndex = 2, |
1000 kInlinedMetadataSize = 3, | 998 kInlinedMetadataSize = 3, |
1001 }; | 999 }; |
1002 | 1000 |
1003 RAW_HEAP_OBJECT_IMPLEMENTATION(Code); | 1001 RAW_HEAP_OBJECT_IMPLEMENTATION(Code); |
1004 | 1002 |
1005 uword entry_point_; | |
1006 | |
1007 RawObject** from() { | 1003 RawObject** from() { |
1008 return reinterpret_cast<RawObject**>(&ptr()->active_instructions_); | 1004 return reinterpret_cast<RawObject**>(&ptr()->instructions_); |
1009 } | 1005 } |
1010 RawInstructions* active_instructions_; | |
1011 RawInstructions* instructions_; | 1006 RawInstructions* instructions_; |
1012 RawObjectPool* object_pool_; | |
1013 // If owner_ is Function::null() the owner is a regular stub. | 1007 // If owner_ is Function::null() the owner is a regular stub. |
1014 // If owner_ is a Class the owner is the allocation stub for that class. | 1008 // If owner_ is a Class the owner is the allocation stub for that class. |
1015 // Else, owner_ is a regular Dart Function. | 1009 // Else, owner_ is a regular Dart Function. |
1016 RawObject* owner_; // Function, Null, or a Class. | 1010 RawObject* owner_; // Function, Null, or a Class. |
1017 RawExceptionHandlers* exception_handlers_; | 1011 RawExceptionHandlers* exception_handlers_; |
1018 RawPcDescriptors* pc_descriptors_; | 1012 RawPcDescriptors* pc_descriptors_; |
1019 RawArray* deopt_info_array_; | 1013 RawArray* deopt_info_array_; |
1020 RawArray* static_calls_target_table_; // (code-offset, function, code). | 1014 RawArray* static_calls_target_table_; // (code-offset, function, code). |
1021 RawArray* stackmaps_; | 1015 RawArray* stackmaps_; |
1022 RawLocalVarDescriptors* var_descriptors_; | 1016 RawLocalVarDescriptors* var_descriptors_; |
1023 RawArray* inlined_metadata_; | 1017 RawArray* inlined_metadata_; |
1024 RawArray* comments_; | 1018 RawArray* comments_; |
1025 // If return_address_metadata_ is a Smi, it is the offset to the prologue. | 1019 // If return_address_metadata_ is a Smi, it is the offset to the prologue. |
1026 // Else, return_address_metadata_ is null. | 1020 // Else, return_address_metadata_ is null. |
1027 RawObject* return_address_metadata_; | 1021 RawObject* return_address_metadata_; |
1028 RawObject** to() { | 1022 RawObject** to() { |
1029 return reinterpret_cast<RawObject**>(&ptr()->return_address_metadata_); | 1023 return reinterpret_cast<RawObject**>(&ptr()->return_address_metadata_); |
1030 } | 1024 } |
| 1025 uword entry_point_; |
1031 | 1026 |
1032 // Compilation timestamp. | 1027 // Compilation timestamp. |
1033 int64_t compile_timestamp_; | 1028 int64_t compile_timestamp_; |
1034 | 1029 |
1035 // state_bits_ is a bitfield with three fields: | 1030 // state_bits_ is a bitfield with three fields: |
1036 // The optimized bit, the alive bit, and a count of the number of pointer | 1031 // The optimized bit, the alive bit, and a count of the number of pointer |
1037 // offsets. | 1032 // offsets. |
1038 // Alive: If true, the embedded object pointers will be visited during GC. | 1033 // Alive: If true, the embedded object pointers will be visited during GC. |
1039 int32_t state_bits_; | 1034 int32_t state_bits_; |
1040 | 1035 |
1041 // PC offsets for code patching. | 1036 // PC offsets for code patching. |
| 1037 int32_t entry_patch_pc_offset_; |
| 1038 int32_t patch_code_pc_offset_; |
1042 int32_t lazy_deopt_pc_offset_; | 1039 int32_t lazy_deopt_pc_offset_; |
1043 | 1040 |
1044 // Variable length data follows here. | 1041 // Variable length data follows here. |
1045 int32_t* data() { OPEN_ARRAY_START(int32_t, int32_t); } | 1042 int32_t* data() { OPEN_ARRAY_START(int32_t, int32_t); } |
1046 const int32_t* data() const { OPEN_ARRAY_START(int32_t, int32_t); } | 1043 const int32_t* data() const { OPEN_ARRAY_START(int32_t, int32_t); } |
1047 | 1044 |
1048 static bool ContainsPC(RawObject* raw_obj, uword pc); | |
1049 | |
1050 friend class Function; | 1045 friend class Function; |
1051 friend class MarkingVisitor; | 1046 friend class MarkingVisitor; |
1052 friend class SkippedCodeFunctions; | 1047 friend class SkippedCodeFunctions; |
1053 friend class StackFrame; | 1048 friend class StackFrame; |
1054 }; | 1049 }; |
1055 | 1050 |
1056 | 1051 |
1057 class RawObjectPool : public RawObject { | 1052 class RawObjectPool : public RawObject { |
1058 RAW_HEAP_OBJECT_IMPLEMENTATION(ObjectPool); | 1053 RAW_HEAP_OBJECT_IMPLEMENTATION(ObjectPool); |
1059 | 1054 |
(...skipping 12 matching lines...) Expand all Loading... |
1072 Entry* first_entry() { return &ptr()->data()[0]; } | 1067 Entry* first_entry() { return &ptr()->data()[0]; } |
1073 | 1068 |
1074 friend class Object; | 1069 friend class Object; |
1075 friend class SnapshotReader; | 1070 friend class SnapshotReader; |
1076 }; | 1071 }; |
1077 | 1072 |
1078 | 1073 |
1079 class RawInstructions : public RawObject { | 1074 class RawInstructions : public RawObject { |
1080 RAW_HEAP_OBJECT_IMPLEMENTATION(Instructions); | 1075 RAW_HEAP_OBJECT_IMPLEMENTATION(Instructions); |
1081 | 1076 |
| 1077 RawObject** from() { |
| 1078 return reinterpret_cast<RawObject**>(&ptr()->code_); |
| 1079 } |
| 1080 RawCode* code_; |
| 1081 RawObjectPool* object_pool_; |
| 1082 RawObject** to() { |
| 1083 return reinterpret_cast<RawObject**>(&ptr()->object_pool_); |
| 1084 } |
1082 int32_t size_; | 1085 int32_t size_; |
1083 | 1086 |
1084 // Variable length data follows here. | 1087 // Variable length data follows here. |
1085 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); } | 1088 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); } |
1086 | 1089 |
1087 // Private helper function used while visiting stack frames. The | 1090 // Private helper function used while visiting stack frames. The |
1088 // code which iterates over dart frames is also called during GC and | 1091 // code which iterates over dart frames is also called during GC and |
1089 // is not allowed to create handles. | 1092 // is not allowed to create handles. |
1090 static bool ContainsPC(RawInstructions* raw_instr, uword pc); | 1093 static bool ContainsPC(RawObject* raw_obj, uword pc); |
1091 | 1094 |
1092 friend class RawCode; | 1095 friend class RawCode; |
1093 friend class RawFunction; | 1096 friend class RawFunction; |
1094 friend class Code; | 1097 friend class Code; |
1095 friend class StackFrame; | 1098 friend class StackFrame; |
1096 friend class MarkingVisitor; | 1099 friend class MarkingVisitor; |
1097 friend class SkippedCodeFunctions; | 1100 friend class SkippedCodeFunctions; |
1098 friend class Function; | 1101 friend class Function; |
1099 friend class InstructionsReader; | 1102 friend class InstructionsReader; |
1100 }; | 1103 }; |
(...skipping 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2223 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == | 2226 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == |
2224 kTypedDataInt8ArrayViewCid + 15); | 2227 kTypedDataInt8ArrayViewCid + 15); |
2225 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); | 2228 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); |
2226 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); | 2229 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); |
2227 return (kNullCid - kTypedDataInt8ArrayCid); | 2230 return (kNullCid - kTypedDataInt8ArrayCid); |
2228 } | 2231 } |
2229 | 2232 |
2230 } // namespace dart | 2233 } // namespace dart |
2231 | 2234 |
2232 #endif // VM_RAW_OBJECT_H_ | 2235 #endif // VM_RAW_OBJECT_H_ |
OLD | NEW |