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 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 private: | 825 private: |
826 // So that the SkippedCodeFunctions::DetachCode can null out the code fields. | 826 // So that the SkippedCodeFunctions::DetachCode can null out the code fields. |
827 friend class SkippedCodeFunctions; | 827 friend class SkippedCodeFunctions; |
828 friend class Class; | 828 friend class Class; |
829 | 829 |
830 RAW_HEAP_OBJECT_IMPLEMENTATION(Function); | 830 RAW_HEAP_OBJECT_IMPLEMENTATION(Function); |
831 | 831 |
832 static bool ShouldVisitCode(RawCode* raw_code); | 832 static bool ShouldVisitCode(RawCode* raw_code); |
833 static bool CheckUsageCounter(RawFunction* raw_fun); | 833 static bool CheckUsageCounter(RawFunction* raw_fun); |
834 | 834 |
| 835 uword entry_point_; // Accessed from generated code. |
| 836 |
835 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->name_); } | 837 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->name_); } |
836 RawString* name_; | 838 RawString* name_; |
837 RawObject* owner_; // Class or patch class or mixin class | 839 RawObject* owner_; // Class or patch class or mixin class |
838 // where this function is defined. | 840 // where this function is defined. |
839 RawAbstractType* result_type_; | 841 RawAbstractType* result_type_; |
840 RawArray* parameter_types_; | 842 RawArray* parameter_types_; |
841 RawArray* parameter_names_; | 843 RawArray* parameter_names_; |
842 RawObject* data_; // Additional data specific to the function kind. | 844 RawObject* data_; // Additional data specific to the function kind. |
843 RawObject** to_snapshot() { | 845 RawObject** to_snapshot() { |
844 return reinterpret_cast<RawObject**>(&ptr()->data_); | 846 return reinterpret_cast<RawObject**>(&ptr()->data_); |
845 } | 847 } |
846 RawArray* ic_data_array_; // ICData of unoptimized code. | 848 RawArray* ic_data_array_; // ICData of unoptimized code. |
847 RawObject** to_no_code() { | 849 RawObject** to_no_code() { |
848 return reinterpret_cast<RawObject**>(&ptr()->ic_data_array_); | 850 return reinterpret_cast<RawObject**>(&ptr()->ic_data_array_); |
849 } | 851 } |
850 RawCode* code_; // Currently active code. | 852 RawCode* code_; // Currently active code. Accessed from generated code. |
851 RawCode* unoptimized_code_; // Unoptimized code, keep it after optimization. | 853 NOT_IN_PRECOMPILED(RawCode* unoptimized_code_); // Unoptimized code, keep it |
| 854 // after optimization. |
852 RawObject** to() { | 855 RawObject** to() { |
| 856 #if defined(DART_PRECOMPILED_RUNTIME) |
| 857 return reinterpret_cast<RawObject**>(&ptr()->code_); |
| 858 #else |
853 return reinterpret_cast<RawObject**>(&ptr()->unoptimized_code_); | 859 return reinterpret_cast<RawObject**>(&ptr()->unoptimized_code_); |
| 860 #endif |
854 } | 861 } |
855 uword entry_point_; | |
856 | 862 |
857 TokenPosition token_pos_; | 863 NOT_IN_PRECOMPILED(TokenPosition token_pos_); |
858 TokenPosition end_token_pos_; | 864 NOT_IN_PRECOMPILED(TokenPosition end_token_pos_); |
859 int32_t usage_counter_; // Incremented while function is running. | 865 NOT_IN_PRECOMPILED(int32_t usage_counter_); // Accessed from generated code |
| 866 // (JIT only). |
| 867 uint32_t kind_tag_; // See Function::KindTagBits. |
860 int16_t num_fixed_parameters_; | 868 int16_t num_fixed_parameters_; |
861 int16_t num_optional_parameters_; // > 0: positional; < 0: named. | 869 int16_t num_optional_parameters_; // > 0: positional; < 0: named. |
862 int8_t deoptimization_counter_; | 870 NOT_IN_PRECOMPILED(uint16_t optimized_instruction_count_); |
863 int8_t was_compiled_; | 871 NOT_IN_PRECOMPILED(uint16_t optimized_call_site_count_); |
864 uint32_t kind_tag_; // See Function::KindTagBits. | 872 NOT_IN_PRECOMPILED(int8_t deoptimization_counter_); |
865 uint16_t optimized_instruction_count_; | 873 NOT_IN_PRECOMPILED(int8_t was_compiled_); |
866 uint16_t optimized_call_site_count_; | |
867 }; | 874 }; |
868 | 875 |
869 | 876 |
870 class RawClosureData : public RawObject { | 877 class RawClosureData : public RawObject { |
871 private: | 878 private: |
872 RAW_HEAP_OBJECT_IMPLEMENTATION(ClosureData); | 879 RAW_HEAP_OBJECT_IMPLEMENTATION(ClosureData); |
873 | 880 |
874 RawObject** from() { | 881 RawObject** from() { |
875 return reinterpret_cast<RawObject**>(&ptr()->context_scope_); | 882 return reinterpret_cast<RawObject**>(&ptr()->context_scope_); |
876 } | 883 } |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1106 enum InlinedMetadataIndex { | 1113 enum InlinedMetadataIndex { |
1107 kInlinedIntervalsIndex = 0, | 1114 kInlinedIntervalsIndex = 0, |
1108 kInlinedIdToFunctionIndex = 1, | 1115 kInlinedIdToFunctionIndex = 1, |
1109 kInlinedCallerIdMapIndex = 2, | 1116 kInlinedCallerIdMapIndex = 2, |
1110 kInlinedIdToTokenPosIndex = 3, | 1117 kInlinedIdToTokenPosIndex = 3, |
1111 kInlinedMetadataSize = 4, | 1118 kInlinedMetadataSize = 4, |
1112 }; | 1119 }; |
1113 | 1120 |
1114 RAW_HEAP_OBJECT_IMPLEMENTATION(Code); | 1121 RAW_HEAP_OBJECT_IMPLEMENTATION(Code); |
1115 | 1122 |
1116 uword entry_point_; | 1123 uword entry_point_; // Accessed from generated code. |
1117 uword checked_entry_point_; | 1124 uword checked_entry_point_; // Accessed from generated code (AOT only). |
1118 | 1125 |
1119 RawObject** from() { | 1126 RawObject** from() { |
1120 return reinterpret_cast<RawObject**>(&ptr()->active_instructions_); | 1127 return reinterpret_cast<RawObject**>(&ptr()->object_pool_); |
1121 } | 1128 } |
1122 RawInstructions* active_instructions_; | 1129 RawObjectPool* object_pool_; // Accessed from generated code. |
1123 RawInstructions* instructions_; | 1130 RawInstructions* instructions_; // Accessed from generated code. |
1124 RawObjectPool* object_pool_; | |
1125 // If owner_ is Function::null() the owner is a regular stub. | 1131 // If owner_ is Function::null() the owner is a regular stub. |
1126 // If owner_ is a Class the owner is the allocation stub for that class. | 1132 // If owner_ is a Class the owner is the allocation stub for that class. |
1127 // Else, owner_ is a regular Dart Function. | 1133 // Else, owner_ is a regular Dart Function. |
1128 RawObject* owner_; // Function, Null, or a Class. | 1134 RawObject* owner_; // Function, Null, or a Class. |
1129 RawExceptionHandlers* exception_handlers_; | 1135 RawExceptionHandlers* exception_handlers_; |
1130 RawPcDescriptors* pc_descriptors_; | 1136 RawPcDescriptors* pc_descriptors_; |
1131 RawArray* stackmaps_; | 1137 RawArray* stackmaps_; |
1132 RawArray* deopt_info_array_; | 1138 NOT_IN_PRECOMPILED(RawInstructions* active_instructions_); |
1133 RawArray* static_calls_target_table_; // (code-offset, function, code). | 1139 NOT_IN_PRECOMPILED(RawArray* deopt_info_array_); |
1134 RawLocalVarDescriptors* var_descriptors_; | 1140 // (code-offset, function, code) triples. |
1135 RawArray* inlined_metadata_; | 1141 NOT_IN_PRECOMPILED(RawArray* static_calls_target_table_); |
1136 RawCodeSourceMap* code_source_map_; | 1142 NOT_IN_PRECOMPILED(RawLocalVarDescriptors* var_descriptors_); |
1137 RawArray* comments_; | 1143 NOT_IN_PRECOMPILED(RawArray* inlined_metadata_); |
| 1144 NOT_IN_PRECOMPILED(RawCodeSourceMap* code_source_map_); |
| 1145 NOT_IN_PRECOMPILED(RawArray* comments_); |
1138 // If return_address_metadata_ is a Smi, it is the offset to the prologue. | 1146 // If return_address_metadata_ is a Smi, it is the offset to the prologue. |
1139 // Else, return_address_metadata_ is null. | 1147 // Else, return_address_metadata_ is null. |
1140 RawObject* return_address_metadata_; | 1148 NOT_IN_PRECOMPILED(RawObject* return_address_metadata_); |
1141 RawObject** to() { | 1149 RawObject** to() { |
| 1150 #if defined(DART_PRECOMPILED_RUNTIME) |
| 1151 return reinterpret_cast<RawObject**>(&ptr()->stackmaps_); |
| 1152 #else |
1142 return reinterpret_cast<RawObject**>(&ptr()->return_address_metadata_); | 1153 return reinterpret_cast<RawObject**>(&ptr()->return_address_metadata_); |
| 1154 #endif |
1143 } | 1155 } |
1144 | 1156 |
1145 // Compilation timestamp. | 1157 // Compilation timestamp. |
1146 int64_t compile_timestamp_; | 1158 NOT_IN_PRECOMPILED(int64_t compile_timestamp_); |
1147 | 1159 |
1148 // state_bits_ is a bitfield with three fields: | 1160 // state_bits_ is a bitfield with three fields: |
1149 // The optimized bit, the alive bit, and a count of the number of pointer | 1161 // The optimized bit, the alive bit, and a count of the number of pointer |
1150 // offsets. | 1162 // offsets. |
1151 // Alive: If true, the embedded object pointers will be visited during GC. | 1163 // Alive: If true, the embedded object pointers will be visited during GC. |
1152 int32_t state_bits_; | 1164 int32_t state_bits_; |
1153 | 1165 |
1154 // PC offsets for code patching. | 1166 // PC offsets for code patching. |
1155 int32_t lazy_deopt_pc_offset_; | 1167 NOT_IN_PRECOMPILED(int32_t lazy_deopt_pc_offset_); |
1156 | 1168 |
1157 // Variable length data follows here. | 1169 // Variable length data follows here. |
1158 int32_t* data() { OPEN_ARRAY_START(int32_t, int32_t); } | 1170 int32_t* data() { OPEN_ARRAY_START(int32_t, int32_t); } |
1159 const int32_t* data() const { OPEN_ARRAY_START(int32_t, int32_t); } | 1171 const int32_t* data() const { OPEN_ARRAY_START(int32_t, int32_t); } |
1160 | 1172 |
1161 static bool ContainsPC(RawObject* raw_obj, uword pc); | 1173 static bool ContainsPC(RawObject* raw_obj, uword pc); |
1162 | 1174 |
1163 friend class Function; | 1175 friend class Function; |
1164 template<bool> friend class MarkingVisitorBase; | 1176 template<bool> friend class MarkingVisitorBase; |
1165 friend class SkippedCodeFunctions; | 1177 friend class SkippedCodeFunctions; |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1518 case Snapshot::kAppWithJIT: | 1530 case Snapshot::kAppWithJIT: |
1519 return to(); | 1531 return to(); |
1520 case Snapshot::kMessage: | 1532 case Snapshot::kMessage: |
1521 case Snapshot::kNone: | 1533 case Snapshot::kNone: |
1522 case Snapshot::kInvalid: | 1534 case Snapshot::kInvalid: |
1523 break; | 1535 break; |
1524 } | 1536 } |
1525 UNREACHABLE(); | 1537 UNREACHABLE(); |
1526 return NULL; | 1538 return NULL; |
1527 } | 1539 } |
1528 int32_t deopt_id_; // Deoptimization id corresponding to this IC. | 1540 NOT_IN_PRECOMPILED(int32_t deopt_id_); |
1529 uint32_t state_bits_; // Number of arguments tested in IC, deopt reasons. | 1541 uint32_t state_bits_; // Number of arguments tested in IC, deopt reasons. |
1530 #if defined(TAG_IC_DATA) | 1542 #if defined(TAG_IC_DATA) |
1531 intptr_t tag_; // Debugging, verifying that the icdata is assigned to the | 1543 intptr_t tag_; // Debugging, verifying that the icdata is assigned to the |
1532 // same instruction again. Store -1 or Instruction::Tag. | 1544 // same instruction again. Store -1 or Instruction::Tag. |
1533 #endif | 1545 #endif |
1534 }; | 1546 }; |
1535 | 1547 |
1536 | 1548 |
1537 class RawMegamorphicCache : public RawObject { | 1549 class RawMegamorphicCache : public RawObject { |
1538 RAW_HEAP_OBJECT_IMPLEMENTATION(MegamorphicCache); | 1550 RAW_HEAP_OBJECT_IMPLEMENTATION(MegamorphicCache); |
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2454 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == | 2466 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == |
2455 kTypedDataInt8ArrayViewCid + 15); | 2467 kTypedDataInt8ArrayViewCid + 15); |
2456 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); | 2468 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); |
2457 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); | 2469 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); |
2458 return (kNullCid - kTypedDataInt8ArrayCid); | 2470 return (kNullCid - kTypedDataInt8ArrayCid); |
2459 } | 2471 } |
2460 | 2472 |
2461 } // namespace dart | 2473 } // namespace dart |
2462 | 2474 |
2463 #endif // VM_RAW_OBJECT_H_ | 2475 #endif // VM_RAW_OBJECT_H_ |
OLD | NEW |