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