| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 RUNTIME_VM_KERNEL_BINARY_FLOWGRAPH_H_ | 5 #ifndef RUNTIME_VM_KERNEL_BINARY_FLOWGRAPH_H_ |
| 6 #define RUNTIME_VM_KERNEL_BINARY_FLOWGRAPH_H_ | 6 #define RUNTIME_VM_KERNEL_BINARY_FLOWGRAPH_H_ |
| 7 | 7 |
| 8 #if !defined(DART_PRECOMPILED_RUNTIME) | 8 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 895 if (++next_read_ == field) return; | 895 if (++next_read_ == field) return; |
| 896 case kName: | 896 case kName: |
| 897 builder_->SkipName(); // read name. | 897 builder_->SkipName(); // read name. |
| 898 if (++next_read_ == field) return; | 898 if (++next_read_ == field) return; |
| 899 case kSourceUriIndex: | 899 case kSourceUriIndex: |
| 900 source_uri_index_ = builder_->ReadUInt(); // read source_uri_index. | 900 source_uri_index_ = builder_->ReadUInt(); // read source_uri_index. |
| 901 builder_->current_script_id_ = source_uri_index_; | 901 builder_->current_script_id_ = source_uri_index_; |
| 902 builder_->record_token_position(position_); | 902 builder_->record_token_position(position_); |
| 903 builder_->record_token_position(end_position_); | 903 builder_->record_token_position(end_position_); |
| 904 if (++next_read_ == field) return; | 904 if (++next_read_ == field) return; |
| 905 case kAnnotations: | 905 case kAnnotations: { |
| 906 builder_->SkipListOfExpressions(); // read annotations. | 906 annotation_count_ = builder_->ReadListLength(); // read list length. |
| 907 for (intptr_t i = 0; i < annotation_count_; ++i) { |
| 908 builder_->SkipExpression(); // read ith expression. |
| 909 } |
| 907 if (++next_read_ == field) return; | 910 if (++next_read_ == field) return; |
| 911 } |
| 908 case kType: | 912 case kType: |
| 909 builder_->SkipDartType(); // read type. | 913 builder_->SkipDartType(); // read type. |
| 910 if (++next_read_ == field) return; | 914 if (++next_read_ == field) return; |
| 911 case kInitializer: | 915 case kInitializer: |
| 912 if (builder_->ReadTag() == kSomething) | 916 if (builder_->ReadTag() == kSomething) |
| 913 builder_->SkipExpression(); // read initializer. | 917 builder_->SkipExpression(); // read initializer. |
| 914 if (++next_read_ == field) return; | 918 if (++next_read_ == field) return; |
| 915 case kEnd: | 919 case kEnd: |
| 916 return; | 920 return; |
| 917 } | 921 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 928 bool IsStatic() { | 932 bool IsStatic() { |
| 929 return (flags_ & Field::kFlagStatic) == Field::kFlagStatic; | 933 return (flags_ & Field::kFlagStatic) == Field::kFlagStatic; |
| 930 } | 934 } |
| 931 | 935 |
| 932 NameIndex canonical_name_; | 936 NameIndex canonical_name_; |
| 933 TokenPosition position_; | 937 TokenPosition position_; |
| 934 TokenPosition end_position_; | 938 TokenPosition end_position_; |
| 935 word flags_; | 939 word flags_; |
| 936 intptr_t parent_class_binary_offset_; | 940 intptr_t parent_class_binary_offset_; |
| 937 intptr_t source_uri_index_; | 941 intptr_t source_uri_index_; |
| 942 intptr_t annotation_count_; |
| 938 | 943 |
| 939 private: | 944 private: |
| 940 StreamingFlowGraphBuilder* builder_; | 945 StreamingFlowGraphBuilder* builder_; |
| 941 intptr_t next_read_; | 946 intptr_t next_read_; |
| 942 }; | 947 }; |
| 943 | 948 |
| 944 | 949 |
| 945 // Helper class that reads a kernel Procedure from binary. | 950 // Helper class that reads a kernel Procedure from binary. |
| 946 // | 951 // |
| 947 // Use ReadUntilExcluding to read up to but not including a field. | 952 // Use ReadUntilExcluding to read up to but not including a field. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1008 if (++next_read_ == field) return; | 1013 if (++next_read_ == field) return; |
| 1009 case kName: | 1014 case kName: |
| 1010 builder_->SkipName(); // read name. | 1015 builder_->SkipName(); // read name. |
| 1011 if (++next_read_ == field) return; | 1016 if (++next_read_ == field) return; |
| 1012 case kSourceUriIndex: | 1017 case kSourceUriIndex: |
| 1013 source_uri_index_ = builder_->ReadUInt(); // read source_uri_index. | 1018 source_uri_index_ = builder_->ReadUInt(); // read source_uri_index. |
| 1014 builder_->current_script_id_ = source_uri_index_; | 1019 builder_->current_script_id_ = source_uri_index_; |
| 1015 builder_->record_token_position(position_); | 1020 builder_->record_token_position(position_); |
| 1016 builder_->record_token_position(end_position_); | 1021 builder_->record_token_position(end_position_); |
| 1017 if (++next_read_ == field) return; | 1022 if (++next_read_ == field) return; |
| 1018 case kAnnotations: | 1023 case kAnnotations: { |
| 1019 builder_->SkipListOfExpressions(); // read annotations. | 1024 annotation_count_ = builder_->ReadListLength(); // read list length. |
| 1025 for (intptr_t i = 0; i < annotation_count_; ++i) { |
| 1026 builder_->SkipExpression(); // read ith expression. |
| 1027 } |
| 1020 if (++next_read_ == field) return; | 1028 if (++next_read_ == field) return; |
| 1029 } |
| 1021 case kFunction: | 1030 case kFunction: |
| 1022 if (builder_->ReadTag() == kSomething) | 1031 if (builder_->ReadTag() == kSomething) |
| 1023 builder_->SkipFunctionNode(); // read function node. | 1032 builder_->SkipFunctionNode(); // read function node. |
| 1024 if (++next_read_ == field) return; | 1033 if (++next_read_ == field) return; |
| 1025 case kEnd: | 1034 case kEnd: |
| 1026 return; | 1035 return; |
| 1027 } | 1036 } |
| 1028 } | 1037 } |
| 1029 | 1038 |
| 1030 void SetNext(Fields field) { next_read_ = field; } | 1039 void SetNext(Fields field) { next_read_ = field; } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1046 return (flags_ & Procedure::kFlagConst) == Procedure::kFlagConst; | 1055 return (flags_ & Procedure::kFlagConst) == Procedure::kFlagConst; |
| 1047 } | 1056 } |
| 1048 | 1057 |
| 1049 NameIndex canonical_name_; | 1058 NameIndex canonical_name_; |
| 1050 TokenPosition position_; | 1059 TokenPosition position_; |
| 1051 TokenPosition end_position_; | 1060 TokenPosition end_position_; |
| 1052 Procedure::ProcedureKind kind_; | 1061 Procedure::ProcedureKind kind_; |
| 1053 word flags_; | 1062 word flags_; |
| 1054 intptr_t parent_class_binary_offset_; | 1063 intptr_t parent_class_binary_offset_; |
| 1055 intptr_t source_uri_index_; | 1064 intptr_t source_uri_index_; |
| 1065 intptr_t annotation_count_; |
| 1056 | 1066 |
| 1057 private: | 1067 private: |
| 1058 StreamingFlowGraphBuilder* builder_; | 1068 StreamingFlowGraphBuilder* builder_; |
| 1059 intptr_t next_read_; | 1069 intptr_t next_read_; |
| 1060 }; | 1070 }; |
| 1061 | 1071 |
| 1062 // Helper class that reads a kernel Constructor from binary. | 1072 // Helper class that reads a kernel Constructor from binary. |
| 1063 // | 1073 // |
| 1064 // Use ReadUntilExcluding to read up to but not including a field. | 1074 // Use ReadUntilExcluding to read up to but not including a field. |
| 1065 // One can then for instance read the field from the call-site (and remember to | 1075 // One can then for instance read the field from the call-site (and remember to |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1114 case kFlags: | 1124 case kFlags: |
| 1115 flags_ = builder_->ReadFlags(); // read flags. | 1125 flags_ = builder_->ReadFlags(); // read flags. |
| 1116 if (++next_read_ == field) return; | 1126 if (++next_read_ == field) return; |
| 1117 case kParentClassBinaryOffset: | 1127 case kParentClassBinaryOffset: |
| 1118 parent_class_binary_offset_ = | 1128 parent_class_binary_offset_ = |
| 1119 builder_->ReadUInt(); // read parent class binary offset. | 1129 builder_->ReadUInt(); // read parent class binary offset. |
| 1120 if (++next_read_ == field) return; | 1130 if (++next_read_ == field) return; |
| 1121 case kName: | 1131 case kName: |
| 1122 builder_->SkipName(); // read name. | 1132 builder_->SkipName(); // read name. |
| 1123 if (++next_read_ == field) return; | 1133 if (++next_read_ == field) return; |
| 1124 case kAnnotations: | 1134 case kAnnotations: { |
| 1125 builder_->SkipListOfExpressions(); // read annotations. | 1135 annotation_count_ = builder_->ReadListLength(); // read list length. |
| 1136 for (intptr_t i = 0; i < annotation_count_; ++i) { |
| 1137 builder_->SkipExpression(); // read ith expression. |
| 1138 } |
| 1126 if (++next_read_ == field) return; | 1139 if (++next_read_ == field) return; |
| 1140 } |
| 1127 case kFunction: | 1141 case kFunction: |
| 1128 builder_->SkipFunctionNode(); // read function. | 1142 builder_->SkipFunctionNode(); // read function. |
| 1129 if (++next_read_ == field) return; | 1143 if (++next_read_ == field) return; |
| 1130 case kInitializers: { | 1144 case kInitializers: { |
| 1131 intptr_t list_length = | 1145 intptr_t list_length = |
| 1132 builder_->ReadListLength(); // read initializers list length. | 1146 builder_->ReadListLength(); // read initializers list length. |
| 1133 for (intptr_t i = 0; i < list_length; i++) { | 1147 for (intptr_t i = 0; i < list_length; i++) { |
| 1134 Tag tag = builder_->ReadTag(); | 1148 Tag tag = builder_->ReadTag(); |
| 1135 switch (tag) { | 1149 switch (tag) { |
| 1136 case kInvalidInitializer: | 1150 case kInvalidInitializer: |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1172 } | 1186 } |
| 1173 bool IsConst() { | 1187 bool IsConst() { |
| 1174 return (flags_ & Constructor::kFlagConst) == Constructor::kFlagConst; | 1188 return (flags_ & Constructor::kFlagConst) == Constructor::kFlagConst; |
| 1175 } | 1189 } |
| 1176 | 1190 |
| 1177 NameIndex canonical_name_; | 1191 NameIndex canonical_name_; |
| 1178 TokenPosition position_; | 1192 TokenPosition position_; |
| 1179 TokenPosition end_position_; | 1193 TokenPosition end_position_; |
| 1180 word flags_; | 1194 word flags_; |
| 1181 intptr_t parent_class_binary_offset_; | 1195 intptr_t parent_class_binary_offset_; |
| 1196 intptr_t annotation_count_; |
| 1182 | 1197 |
| 1183 private: | 1198 private: |
| 1184 StreamingFlowGraphBuilder* builder_; | 1199 StreamingFlowGraphBuilder* builder_; |
| 1185 intptr_t next_read_; | 1200 intptr_t next_read_; |
| 1186 }; | 1201 }; |
| 1187 | 1202 |
| 1188 // Helper class that reads a kernel Class from binary. | 1203 // Helper class that reads a kernel Class from binary. |
| 1189 // | 1204 // |
| 1190 // Use ReadUntilExcluding to read up to but not including a field. | 1205 // Use ReadUntilExcluding to read up to but not including a field. |
| 1191 // One can then for instance read the field from the call-site (and remember to | 1206 // One can then for instance read the field from the call-site (and remember to |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1242 is_abstract_ = builder_->ReadBool(); // read is_abstract. | 1257 is_abstract_ = builder_->ReadBool(); // read is_abstract. |
| 1243 if (++next_read_ == field) return; | 1258 if (++next_read_ == field) return; |
| 1244 case kNameIndex: | 1259 case kNameIndex: |
| 1245 name_index_ = builder_->ReadStringReference(); // read name index. | 1260 name_index_ = builder_->ReadStringReference(); // read name index. |
| 1246 if (++next_read_ == field) return; | 1261 if (++next_read_ == field) return; |
| 1247 case kSourceUriIndex: | 1262 case kSourceUriIndex: |
| 1248 source_uri_index_ = builder_->ReadUInt(); // read source_uri_index. | 1263 source_uri_index_ = builder_->ReadUInt(); // read source_uri_index. |
| 1249 builder_->current_script_id_ = source_uri_index_; | 1264 builder_->current_script_id_ = source_uri_index_; |
| 1250 builder_->record_token_position(position_); | 1265 builder_->record_token_position(position_); |
| 1251 if (++next_read_ == field) return; | 1266 if (++next_read_ == field) return; |
| 1252 case kAnnotations: | 1267 case kAnnotations: { |
| 1253 builder_->SkipListOfExpressions(); // read annotations. | 1268 annotation_count_ = builder_->ReadListLength(); // read list length. |
| 1269 for (intptr_t i = 0; i < annotation_count_; ++i) { |
| 1270 builder_->SkipExpression(); // read ith expression. |
| 1271 } |
| 1254 if (++next_read_ == field) return; | 1272 if (++next_read_ == field) return; |
| 1273 } |
| 1255 case kTypeParameters: | 1274 case kTypeParameters: |
| 1256 builder_->SkipTypeParametersList(); // read type parameters. | 1275 builder_->SkipTypeParametersList(); // read type parameters. |
| 1257 if (++next_read_ == field) return; | 1276 if (++next_read_ == field) return; |
| 1258 case kSuperClass: { | 1277 case kSuperClass: { |
| 1259 Tag type_tag = builder_->ReadTag(); // read super class type (part 1). | 1278 Tag type_tag = builder_->ReadTag(); // read super class type (part 1). |
| 1260 if (type_tag == kSomething) { | 1279 if (type_tag == kSomething) { |
| 1261 builder_->SkipDartType(); // read super class type (part 2). | 1280 builder_->SkipDartType(); // read super class type (part 2). |
| 1262 } | 1281 } |
| 1263 if (++next_read_ == field) return; | 1282 if (++next_read_ == field) return; |
| 1264 } | 1283 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1310 void SetJustRead(Fields field) { | 1329 void SetJustRead(Fields field) { |
| 1311 next_read_ = field; | 1330 next_read_ = field; |
| 1312 ++next_read_; | 1331 ++next_read_; |
| 1313 } | 1332 } |
| 1314 | 1333 |
| 1315 NameIndex canonical_name_; | 1334 NameIndex canonical_name_; |
| 1316 TokenPosition position_; | 1335 TokenPosition position_; |
| 1317 bool is_abstract_; | 1336 bool is_abstract_; |
| 1318 StringIndex name_index_; | 1337 StringIndex name_index_; |
| 1319 intptr_t source_uri_index_; | 1338 intptr_t source_uri_index_; |
| 1339 intptr_t annotation_count_; |
| 1320 | 1340 |
| 1321 private: | 1341 private: |
| 1322 StreamingFlowGraphBuilder* builder_; | 1342 StreamingFlowGraphBuilder* builder_; |
| 1323 intptr_t next_read_; | 1343 intptr_t next_read_; |
| 1324 }; | 1344 }; |
| 1325 | 1345 |
| 1326 // Helper class that reads a kernel Library from binary. | 1346 // Helper class that reads a kernel Library from binary. |
| 1327 // | 1347 // |
| 1328 // Use ReadUntilExcluding to read up to but not including a field. | 1348 // Use ReadUntilExcluding to read up to but not including a field. |
| 1329 // One can then for instance read the field from the call-site (and remember to | 1349 // One can then for instance read the field from the call-site (and remember to |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1458 private: | 1478 private: |
| 1459 Reader* reader_; | 1479 Reader* reader_; |
| 1460 intptr_t saved_offset_; | 1480 intptr_t saved_offset_; |
| 1461 }; | 1481 }; |
| 1462 | 1482 |
| 1463 } // namespace kernel | 1483 } // namespace kernel |
| 1464 } // namespace dart | 1484 } // namespace dart |
| 1465 | 1485 |
| 1466 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 1486 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
| 1467 #endif // RUNTIME_VM_KERNEL_BINARY_FLOWGRAPH_H_ | 1487 #endif // RUNTIME_VM_KERNEL_BINARY_FLOWGRAPH_H_ |
| OLD | NEW |