OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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_TO_IL_H_ | 5 #ifndef RUNTIME_VM_KERNEL_TO_IL_H_ |
6 #define RUNTIME_VM_KERNEL_TO_IL_H_ | 6 #define RUNTIME_VM_KERNEL_TO_IL_H_ |
7 | 7 |
8 #if !defined(DART_PRECOMPILED_RUNTIME) | 8 #if !defined(DART_PRECOMPILED_RUNTIME) |
9 | 9 |
10 #include "vm/growable_array.h" | 10 #include "vm/growable_array.h" |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 dart::String& DartSymbol(const uint8_t* utf8_array, intptr_t len) const; | 340 dart::String& DartSymbol(const uint8_t* utf8_array, intptr_t len) const; |
341 | 341 |
342 const dart::String& DartClassName(NameIndex kernel_class); | 342 const dart::String& DartClassName(NameIndex kernel_class); |
343 | 343 |
344 const dart::String& DartConstructorName(NameIndex constructor); | 344 const dart::String& DartConstructorName(NameIndex constructor); |
345 | 345 |
346 const dart::String& DartProcedureName(NameIndex procedure); | 346 const dart::String& DartProcedureName(NameIndex procedure); |
347 | 347 |
348 const dart::String& DartSetterName(NameIndex setter); | 348 const dart::String& DartSetterName(NameIndex setter); |
349 const dart::String& DartSetterName(Name* setter_name); | 349 const dart::String& DartSetterName(Name* setter_name); |
| 350 const dart::String& DartSetterName(NameIndex parent, StringIndex setter); |
350 | 351 |
351 const dart::String& DartGetterName(NameIndex getter); | 352 const dart::String& DartGetterName(NameIndex getter); |
352 const dart::String& DartGetterName(Name* getter_name); | 353 const dart::String& DartGetterName(Name* getter_name); |
| 354 const dart::String& DartGetterName(NameIndex parent, StringIndex getter); |
353 | 355 |
354 const dart::String& DartFieldName(Name* kernel_name); | 356 const dart::String& DartFieldName(Name* kernel_name); |
355 | 357 |
356 const dart::String& DartInitializerName(Name* kernel_name); | 358 const dart::String& DartInitializerName(Name* kernel_name); |
357 | 359 |
358 const dart::String& DartMethodName(NameIndex method); | 360 const dart::String& DartMethodName(NameIndex method); |
359 const dart::String& DartMethodName(Name* method_name); | 361 const dart::String& DartMethodName(Name* method_name); |
| 362 const dart::String& DartMethodName(NameIndex parent, StringIndex method); |
360 | 363 |
361 const dart::String& DartFactoryName(NameIndex factory); | 364 const dart::String& DartFactoryName(NameIndex factory); |
362 | 365 |
363 const Array& ArgumentNames(List<NamedExpression>* named); | 366 const Array& ArgumentNames(List<NamedExpression>* named); |
364 | 367 |
365 // A subclass overrides these when reading in the Kernel program in order to | 368 // A subclass overrides these when reading in the Kernel program in order to |
366 // support recursive type expressions (e.g. for "implements X" ... | 369 // support recursive type expressions (e.g. for "implements X" ... |
367 // annotations). | 370 // annotations). |
368 virtual RawLibrary* LookupLibraryByKernelLibrary(NameIndex library); | 371 virtual RawLibrary* LookupLibraryByKernelLibrary(NameIndex library); |
369 virtual RawClass* LookupClassByKernelClass(NameIndex klass); | 372 virtual RawClass* LookupClassByKernelClass(NameIndex klass); |
(...skipping 12 matching lines...) Expand all Loading... |
382 | 385 |
383 private: | 386 private: |
384 // This will mangle [name_to_modify] if necessary and make the result a symbol | 387 // This will mangle [name_to_modify] if necessary and make the result a symbol |
385 // if asked. The result will be available in [name_to_modify] and it is also | 388 // if asked. The result will be available in [name_to_modify] and it is also |
386 // returned. If the name is private, the canonical name [parent] will be used | 389 // returned. If the name is private, the canonical name [parent] will be used |
387 // to get the import URI of the library where the name is visible. | 390 // to get the import URI of the library where the name is visible. |
388 dart::String& ManglePrivateName(NameIndex parent, | 391 dart::String& ManglePrivateName(NameIndex parent, |
389 dart::String* name_to_modify, | 392 dart::String* name_to_modify, |
390 bool symbolize = true); | 393 bool symbolize = true); |
391 | 394 |
392 const dart::String& DartSetterName(NameIndex parent, StringIndex setter); | |
393 const dart::String& DartGetterName(NameIndex parent, StringIndex getter); | |
394 const dart::String& DartMethodName(NameIndex parent, StringIndex method); | |
395 | 395 |
396 Thread* thread_; | 396 Thread* thread_; |
397 Zone* zone_; | 397 Zone* zone_; |
398 Isolate* isolate_; | 398 Isolate* isolate_; |
399 Heap::Space allocation_space_; | 399 Heap::Space allocation_space_; |
400 | 400 |
401 TypedData& string_offsets_; | 401 TypedData& string_offsets_; |
402 TypedData& string_data_; | 402 TypedData& string_data_; |
403 TypedData& canonical_names_; | 403 TypedData& canonical_names_; |
404 }; | 404 }; |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 FunctionNode* current_function_node_; | 763 FunctionNode* current_function_node_; |
764 LocalScope* current_function_scope_; | 764 LocalScope* current_function_scope_; |
765 LocalScope* scope_; | 765 LocalScope* scope_; |
766 DepthState depth_; | 766 DepthState depth_; |
767 | 767 |
768 intptr_t name_index_; | 768 intptr_t name_index_; |
769 | 769 |
770 bool needs_expr_temp_; | 770 bool needs_expr_temp_; |
771 }; | 771 }; |
772 | 772 |
| 773 struct YieldContinuation { |
| 774 Instruction* entry; |
| 775 intptr_t try_index; |
| 776 |
| 777 YieldContinuation(Instruction* entry, intptr_t try_index) |
| 778 : entry(entry), try_index(try_index) {} |
| 779 |
| 780 YieldContinuation() |
| 781 : entry(NULL), try_index(CatchClauseNode::kInvalidTryIndex) {} |
| 782 }; |
| 783 |
773 class FlowGraphBuilder : public ExpressionVisitor, public StatementVisitor { | 784 class FlowGraphBuilder : public ExpressionVisitor, public StatementVisitor { |
774 public: | 785 public: |
775 FlowGraphBuilder(TreeNode* node, | 786 FlowGraphBuilder(TreeNode* node, |
776 ParsedFunction* parsed_function, | 787 ParsedFunction* parsed_function, |
777 const ZoneGrowableArray<const ICData*>& ic_data_array, | 788 const ZoneGrowableArray<const ICData*>& ic_data_array, |
778 InlineExitCollector* exit_collector, | 789 InlineExitCollector* exit_collector, |
779 intptr_t osr_id, | 790 intptr_t osr_id, |
780 intptr_t first_block_id = 1); | 791 intptr_t first_block_id = 1); |
781 virtual ~FlowGraphBuilder(); | 792 virtual ~FlowGraphBuilder(); |
782 | 793 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
873 Fragment TranslateStatement(Statement* statement); | 884 Fragment TranslateStatement(Statement* statement); |
874 Fragment TranslateCondition(Expression* expression, bool* negate); | 885 Fragment TranslateCondition(Expression* expression, bool* negate); |
875 Fragment TranslateExpression(Expression* expression); | 886 Fragment TranslateExpression(Expression* expression); |
876 | 887 |
877 Fragment TranslateFinallyFinalizers(TryFinallyBlock* outer_finally, | 888 Fragment TranslateFinallyFinalizers(TryFinallyBlock* outer_finally, |
878 intptr_t target_context_depth); | 889 intptr_t target_context_depth); |
879 | 890 |
880 Fragment TranslateFunctionNode(FunctionNode* node, TreeNode* parent); | 891 Fragment TranslateFunctionNode(FunctionNode* node, TreeNode* parent); |
881 | 892 |
882 Fragment EnterScope(TreeNode* node, bool* new_context = NULL); | 893 Fragment EnterScope(TreeNode* node, bool* new_context = NULL); |
| 894 Fragment EnterScope(intptr_t kernel_offset, bool* new_context = NULL); |
883 Fragment ExitScope(TreeNode* node); | 895 Fragment ExitScope(TreeNode* node); |
| 896 Fragment ExitScope(intptr_t kernel_offset); |
884 | 897 |
885 Fragment LoadContextAt(int depth); | 898 Fragment LoadContextAt(int depth); |
886 Fragment AdjustContextTo(int depth); | 899 Fragment AdjustContextTo(int depth); |
887 | 900 |
888 Fragment PushContext(int size); | 901 Fragment PushContext(int size); |
889 Fragment PopContext(); | 902 Fragment PopContext(); |
890 | 903 |
891 Fragment LoadInstantiatorTypeArguments(); | 904 Fragment LoadInstantiatorTypeArguments(); |
892 Fragment LoadFunctionTypeArguments(); | 905 Fragment LoadFunctionTypeArguments(); |
893 Fragment InstantiateType(const AbstractType& type); | 906 Fragment InstantiateType(const AbstractType& type); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
976 Fragment StringInterpolateSingle(TokenPosition position); | 989 Fragment StringInterpolateSingle(TokenPosition position); |
977 Fragment ThrowTypeError(); | 990 Fragment ThrowTypeError(); |
978 Fragment ThrowNoSuchMethodError(); | 991 Fragment ThrowNoSuchMethodError(); |
979 Fragment BuildImplicitClosureCreation(const Function& target); | 992 Fragment BuildImplicitClosureCreation(const Function& target); |
980 Fragment GuardFieldLength(const dart::Field& field, intptr_t deopt_id); | 993 Fragment GuardFieldLength(const dart::Field& field, intptr_t deopt_id); |
981 Fragment GuardFieldClass(const dart::Field& field, intptr_t deopt_id); | 994 Fragment GuardFieldClass(const dart::Field& field, intptr_t deopt_id); |
982 | 995 |
983 Fragment EvaluateAssertion(); | 996 Fragment EvaluateAssertion(); |
984 Fragment CheckReturnTypeInCheckedMode(); | 997 Fragment CheckReturnTypeInCheckedMode(); |
985 Fragment CheckVariableTypeInCheckedMode(VariableDeclaration* variable); | 998 Fragment CheckVariableTypeInCheckedMode(VariableDeclaration* variable); |
| 999 Fragment CheckVariableTypeInCheckedMode(const AbstractType& dst_type, |
| 1000 const dart::String& name_symbol); |
986 Fragment CheckBooleanInCheckedMode(); | 1001 Fragment CheckBooleanInCheckedMode(); |
987 Fragment CheckAssignableInCheckedMode(const dart::AbstractType& dst_type, | 1002 Fragment CheckAssignableInCheckedMode(const dart::AbstractType& dst_type, |
988 const dart::String& dst_name); | 1003 const dart::String& dst_name); |
989 | 1004 |
990 Fragment AssertBool(); | 1005 Fragment AssertBool(); |
991 Fragment AssertAssignable(const dart::AbstractType& dst_type, | 1006 Fragment AssertAssignable(const dart::AbstractType& dst_type, |
992 const dart::String& dst_name); | 1007 const dart::String& dst_name); |
993 | 1008 |
994 template <class Invocation> | 1009 template <class Invocation> |
995 bool RecognizeComparisonWithNull(Token::Kind token_kind, Invocation* node); | 1010 bool RecognizeComparisonWithNull(Token::Kind token_kind, Invocation* node); |
996 | 1011 |
997 bool NeedsDebugStepCheck(const Function& function, TokenPosition position); | 1012 bool NeedsDebugStepCheck(const Function& function, TokenPosition position); |
998 bool NeedsDebugStepCheck(Value* value, TokenPosition position); | 1013 bool NeedsDebugStepCheck(Value* value, TokenPosition position); |
999 Fragment DebugStepCheck(TokenPosition position); | 1014 Fragment DebugStepCheck(TokenPosition position); |
1000 | 1015 |
1001 dart::RawFunction* LookupMethodByMember(NameIndex target, | 1016 dart::RawFunction* LookupMethodByMember(NameIndex target, |
1002 const dart::String& method_name); | 1017 const dart::String& method_name); |
1003 | 1018 |
1004 LocalVariable* MakeTemporary(); | 1019 LocalVariable* MakeTemporary(); |
1005 LocalVariable* MakeNonTemporary(const dart::String& symbol); | 1020 LocalVariable* MakeNonTemporary(const dart::String& symbol); |
1006 | 1021 |
1007 intptr_t CurrentTryIndex(); | 1022 intptr_t CurrentTryIndex(); |
1008 intptr_t AllocateTryIndex() { return next_used_try_index_++; } | 1023 intptr_t AllocateTryIndex() { return next_used_try_index_++; } |
1009 | 1024 |
1010 void AddVariable(VariableDeclaration* declaration, LocalVariable* variable); | 1025 void AddVariable(VariableDeclaration* declaration, LocalVariable* variable); |
1011 void AddParameter(VariableDeclaration* declaration, | 1026 void AddParameter(VariableDeclaration* declaration, |
1012 LocalVariable* variable, | 1027 LocalVariable* variable, |
1013 intptr_t pos); | 1028 intptr_t pos); |
1014 dart::LocalVariable* LookupVariable(VariableDeclaration* var); | 1029 dart::LocalVariable* LookupVariable(VariableDeclaration* var); |
| 1030 dart::LocalVariable* LookupVariable(intptr_t kernel_offset); |
1015 | 1031 |
1016 void SetTempIndex(Definition* definition); | 1032 void SetTempIndex(Definition* definition); |
1017 | 1033 |
1018 void Push(Definition* definition); | 1034 void Push(Definition* definition); |
1019 Value* Pop(); | 1035 Value* Pop(); |
1020 Fragment Drop(); | 1036 Fragment Drop(); |
1021 | 1037 |
1022 bool IsInlining() { return exit_collector_ != NULL; } | 1038 bool IsInlining() { return exit_collector_ != NULL; } |
1023 | 1039 |
1024 Token::Kind MethodKind(const dart::String& name); | 1040 Token::Kind MethodKind(const dart::String& name); |
(...skipping 24 matching lines...) Expand all Loading... |
1049 intptr_t catch_depth_; | 1065 intptr_t catch_depth_; |
1050 intptr_t for_in_depth_; | 1066 intptr_t for_in_depth_; |
1051 Fragment fragment_; | 1067 Fragment fragment_; |
1052 Value* stack_; | 1068 Value* stack_; |
1053 intptr_t pending_argument_count_; | 1069 intptr_t pending_argument_count_; |
1054 | 1070 |
1055 GraphEntryInstr* graph_entry_; | 1071 GraphEntryInstr* graph_entry_; |
1056 | 1072 |
1057 ScopeBuildingResult* scopes_; | 1073 ScopeBuildingResult* scopes_; |
1058 | 1074 |
1059 struct YieldContinuation { | |
1060 Instruction* entry; | |
1061 intptr_t try_index; | |
1062 | |
1063 YieldContinuation(Instruction* entry, intptr_t try_index) | |
1064 : entry(entry), try_index(try_index) {} | |
1065 | |
1066 YieldContinuation() | |
1067 : entry(NULL), try_index(CatchClauseNode::kInvalidTryIndex) {} | |
1068 }; | |
1069 | |
1070 GrowableArray<YieldContinuation> yield_continuations_; | 1075 GrowableArray<YieldContinuation> yield_continuations_; |
1071 | 1076 |
1072 LocalVariable* CurrentException() { | 1077 LocalVariable* CurrentException() { |
1073 return scopes_->exception_variables[catch_depth_ - 1]; | 1078 return scopes_->exception_variables[catch_depth_ - 1]; |
1074 } | 1079 } |
1075 LocalVariable* CurrentStackTrace() { | 1080 LocalVariable* CurrentStackTrace() { |
1076 return scopes_->stack_trace_variables[catch_depth_ - 1]; | 1081 return scopes_->stack_trace_variables[catch_depth_ - 1]; |
1077 } | 1082 } |
1078 LocalVariable* CurrentCatchContext() { | 1083 LocalVariable* CurrentCatchContext() { |
1079 return scopes_->catch_context_variables[try_depth_]; | 1084 return scopes_->catch_context_variables[try_depth_]; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1112 friend class ConstantEvaluator; | 1117 friend class ConstantEvaluator; |
1113 friend class DartTypeTranslator; | 1118 friend class DartTypeTranslator; |
1114 friend class StreamingFlowGraphBuilder; | 1119 friend class StreamingFlowGraphBuilder; |
1115 friend class ScopeBuilder; | 1120 friend class ScopeBuilder; |
1116 friend class SwitchBlock; | 1121 friend class SwitchBlock; |
1117 friend class TryCatchBlock; | 1122 friend class TryCatchBlock; |
1118 friend class TryFinallyBlock; | 1123 friend class TryFinallyBlock; |
1119 }; | 1124 }; |
1120 | 1125 |
1121 | 1126 |
| 1127 class SwitchBlock { |
| 1128 public: |
| 1129 SwitchBlock(FlowGraphBuilder* builder, intptr_t num_cases) |
| 1130 : builder_(builder), |
| 1131 outer_(builder->switch_block_), |
| 1132 outer_finally_(builder->try_finally_block_), |
| 1133 num_cases_(num_cases), |
| 1134 context_depth_(builder->context_depth_), |
| 1135 try_index_(builder->CurrentTryIndex()) { |
| 1136 builder_->switch_block_ = this; |
| 1137 if (outer_ != NULL) { |
| 1138 depth_ = outer_->depth_ + outer_->num_cases_; |
| 1139 } else { |
| 1140 depth_ = 0; |
| 1141 } |
| 1142 } |
| 1143 ~SwitchBlock() { builder_->switch_block_ = outer_; } |
| 1144 |
| 1145 bool HadJumper(intptr_t case_num) { |
| 1146 return destinations_.Lookup(case_num) != NULL; |
| 1147 } |
| 1148 |
| 1149 // Get destination via absolute target number (i.e. the correct destination |
| 1150 // is not not necessarily in this block. |
| 1151 JoinEntryInstr* Destination(intptr_t target_index, |
| 1152 TryFinallyBlock** outer_finally = NULL, |
| 1153 intptr_t* context_depth = NULL) { |
| 1154 // Find corresponding [SwitchStatement]. |
| 1155 SwitchBlock* block = this; |
| 1156 while (block->depth_ > target_index) { |
| 1157 block = block->outer_; |
| 1158 } |
| 1159 |
| 1160 // Set the outer finally block. |
| 1161 if (outer_finally != NULL) { |
| 1162 *outer_finally = block->outer_finally_; |
| 1163 *context_depth = block->context_depth_; |
| 1164 } |
| 1165 |
| 1166 // Ensure there's [JoinEntryInstr] for that [SwitchCase]. |
| 1167 return block->EnsureDestination(target_index - block->depth_); |
| 1168 } |
| 1169 |
| 1170 // Get destination via relative target number (i.e. relative to this block, |
| 1171 // 0 is first case in this block etc). |
| 1172 JoinEntryInstr* DestinationDirect(intptr_t case_num, |
| 1173 TryFinallyBlock** outer_finally = NULL, |
| 1174 intptr_t* context_depth = NULL) { |
| 1175 // Set the outer finally block. |
| 1176 if (outer_finally != NULL) { |
| 1177 *outer_finally = outer_finally_; |
| 1178 *context_depth = context_depth_; |
| 1179 } |
| 1180 |
| 1181 // Ensure there's [JoinEntryInstr] for that [SwitchCase]. |
| 1182 return EnsureDestination(case_num); |
| 1183 } |
| 1184 |
| 1185 private: |
| 1186 JoinEntryInstr* EnsureDestination(intptr_t case_num) { |
| 1187 JoinEntryInstr* cached_inst = destinations_.Lookup(case_num); |
| 1188 if (cached_inst == NULL) { |
| 1189 JoinEntryInstr* inst = builder_->BuildJoinEntry(try_index_); |
| 1190 destinations_.Insert(case_num, inst); |
| 1191 return inst; |
| 1192 } |
| 1193 return cached_inst; |
| 1194 } |
| 1195 |
| 1196 FlowGraphBuilder* builder_; |
| 1197 SwitchBlock* outer_; |
| 1198 |
| 1199 IntMap<JoinEntryInstr*> destinations_; |
| 1200 |
| 1201 TryFinallyBlock* outer_finally_; |
| 1202 intptr_t num_cases_; |
| 1203 intptr_t depth_; |
| 1204 intptr_t context_depth_; |
| 1205 intptr_t try_index_; |
| 1206 }; |
| 1207 |
| 1208 |
| 1209 class TryCatchBlock { |
| 1210 public: |
| 1211 explicit TryCatchBlock(FlowGraphBuilder* builder, |
| 1212 intptr_t try_handler_index = -1) |
| 1213 : builder_(builder), |
| 1214 outer_(builder->try_catch_block_), |
| 1215 try_index_(try_handler_index) { |
| 1216 if (try_index_ == -1) try_index_ = builder->AllocateTryIndex(); |
| 1217 builder->try_catch_block_ = this; |
| 1218 } |
| 1219 ~TryCatchBlock() { builder_->try_catch_block_ = outer_; } |
| 1220 |
| 1221 intptr_t try_index() { return try_index_; } |
| 1222 TryCatchBlock* outer() const { return outer_; } |
| 1223 |
| 1224 private: |
| 1225 FlowGraphBuilder* builder_; |
| 1226 TryCatchBlock* outer_; |
| 1227 intptr_t try_index_; |
| 1228 }; |
| 1229 |
| 1230 |
| 1231 class TryFinallyBlock { |
| 1232 public: |
| 1233 TryFinallyBlock(FlowGraphBuilder* builder, |
| 1234 Statement* finalizer, |
| 1235 intptr_t finalizer_kernel_offset) |
| 1236 : builder_(builder), |
| 1237 outer_(builder->try_finally_block_), |
| 1238 finalizer_(finalizer), |
| 1239 finalizer_kernel_offset_(finalizer_kernel_offset), |
| 1240 context_depth_(builder->context_depth_), |
| 1241 // Finalizers are executed outside of the try block hence |
| 1242 // try depth of finalizers are one less than current try |
| 1243 // depth. |
| 1244 try_depth_(builder->try_depth_ - 1), |
| 1245 try_index_(builder_->CurrentTryIndex()) { |
| 1246 builder_->try_finally_block_ = this; |
| 1247 } |
| 1248 ~TryFinallyBlock() { builder_->try_finally_block_ = outer_; } |
| 1249 |
| 1250 Statement* finalizer() const { return finalizer_; } |
| 1251 intptr_t finalizer_kernel_offset() const { return finalizer_kernel_offset_; } |
| 1252 intptr_t context_depth() const { return context_depth_; } |
| 1253 intptr_t try_depth() const { return try_depth_; } |
| 1254 intptr_t try_index() const { return try_index_; } |
| 1255 TryFinallyBlock* outer() const { return outer_; } |
| 1256 |
| 1257 private: |
| 1258 FlowGraphBuilder* const builder_; |
| 1259 TryFinallyBlock* const outer_; |
| 1260 Statement* const finalizer_; |
| 1261 intptr_t finalizer_kernel_offset_; |
| 1262 const intptr_t context_depth_; |
| 1263 const intptr_t try_depth_; |
| 1264 const intptr_t try_index_; |
| 1265 }; |
| 1266 |
| 1267 |
| 1268 class BreakableBlock { |
| 1269 public: |
| 1270 explicit BreakableBlock(FlowGraphBuilder* builder) |
| 1271 : builder_(builder), |
| 1272 outer_(builder->breakable_block_), |
| 1273 destination_(NULL), |
| 1274 outer_finally_(builder->try_finally_block_), |
| 1275 context_depth_(builder->context_depth_), |
| 1276 try_index_(builder->CurrentTryIndex()) { |
| 1277 if (builder_->breakable_block_ == NULL) { |
| 1278 index_ = 0; |
| 1279 } else { |
| 1280 index_ = builder_->breakable_block_->index_ + 1; |
| 1281 } |
| 1282 builder_->breakable_block_ = this; |
| 1283 } |
| 1284 ~BreakableBlock() { builder_->breakable_block_ = outer_; } |
| 1285 |
| 1286 bool HadJumper() { return destination_ != NULL; } |
| 1287 |
| 1288 JoinEntryInstr* destination() { return destination_; } |
| 1289 |
| 1290 JoinEntryInstr* BreakDestination(intptr_t label_index, |
| 1291 TryFinallyBlock** outer_finally, |
| 1292 intptr_t* context_depth) { |
| 1293 BreakableBlock* block = builder_->breakable_block_; |
| 1294 while (block->index_ != label_index) { |
| 1295 block = block->outer_; |
| 1296 } |
| 1297 ASSERT(block != NULL); |
| 1298 *outer_finally = block->outer_finally_; |
| 1299 *context_depth = block->context_depth_; |
| 1300 return block->EnsureDestination(); |
| 1301 } |
| 1302 |
| 1303 private: |
| 1304 JoinEntryInstr* EnsureDestination() { |
| 1305 if (destination_ == NULL) { |
| 1306 destination_ = builder_->BuildJoinEntry(try_index_); |
| 1307 } |
| 1308 return destination_; |
| 1309 } |
| 1310 |
| 1311 FlowGraphBuilder* builder_; |
| 1312 intptr_t index_; |
| 1313 BreakableBlock* outer_; |
| 1314 JoinEntryInstr* destination_; |
| 1315 TryFinallyBlock* outer_finally_; |
| 1316 intptr_t context_depth_; |
| 1317 intptr_t try_index_; |
| 1318 }; |
| 1319 |
1122 class CatchBlock { | 1320 class CatchBlock { |
1123 public: | 1321 public: |
1124 CatchBlock(FlowGraphBuilder* builder, | 1322 CatchBlock(FlowGraphBuilder* builder, |
1125 LocalVariable* exception_var, | 1323 LocalVariable* exception_var, |
1126 LocalVariable* stack_trace_var, | 1324 LocalVariable* stack_trace_var, |
1127 intptr_t catch_try_index) | 1325 intptr_t catch_try_index) |
1128 : builder_(builder), | 1326 : builder_(builder), |
1129 outer_(builder->catch_block_), | 1327 outer_(builder->catch_block_), |
1130 exception_var_(exception_var), | 1328 exception_var_(exception_var), |
1131 stack_trace_var_(stack_trace_var), | 1329 stack_trace_var_(stack_trace_var), |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1163 namespace kernel { | 1361 namespace kernel { |
1164 | 1362 |
1165 RawObject* EvaluateMetadata(const dart::Field& metadata_field); | 1363 RawObject* EvaluateMetadata(const dart::Field& metadata_field); |
1166 RawObject* BuildParameterDescriptor(const Function& function); | 1364 RawObject* BuildParameterDescriptor(const Function& function); |
1167 | 1365 |
1168 } // namespace kernel | 1366 } // namespace kernel |
1169 } // namespace dart | 1367 } // namespace dart |
1170 | 1368 |
1171 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 1369 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
1172 #endif // RUNTIME_VM_KERNEL_TO_IL_H_ | 1370 #endif // RUNTIME_VM_KERNEL_TO_IL_H_ |
OLD | NEW |