| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 private: | 44 private: |
| 45 static uword HashValue(intptr_t pos) { return pos % (Smi::kMaxValue - 13); } | 45 static uword HashValue(intptr_t pos) { return pos % (Smi::kMaxValue - 13); } |
| 46 | 46 |
| 47 static RawSmi* KeyAsSmi(const intptr_t key) { | 47 static RawSmi* KeyAsSmi(const intptr_t key) { |
| 48 ASSERT(key >= 0); | 48 ASSERT(key >= 0); |
| 49 return Smi::New(key); | 49 return Smi::New(key); |
| 50 } | 50 } |
| 51 }; | 51 }; |
| 52 typedef UnorderedHashMap<KernelConstMapKeyEqualsTraits> KernelConstantsMap; | 52 typedef UnorderedHashMap<KernelConstMapKeyEqualsTraits> KernelConstantsMap; |
| 53 | 53 |
| 54 | |
| 55 template <typename K, typename V> | 54 template <typename K, typename V> |
| 56 class Map : public DirectChainedHashMap<RawPointerKeyValueTrait<K, V> > { | 55 class Map : public DirectChainedHashMap<RawPointerKeyValueTrait<K, V> > { |
| 57 public: | 56 public: |
| 58 typedef typename RawPointerKeyValueTrait<K, V>::Key Key; | 57 typedef typename RawPointerKeyValueTrait<K, V>::Key Key; |
| 59 typedef typename RawPointerKeyValueTrait<K, V>::Value Value; | 58 typedef typename RawPointerKeyValueTrait<K, V>::Value Value; |
| 60 typedef typename RawPointerKeyValueTrait<K, V>::Pair Pair; | 59 typedef typename RawPointerKeyValueTrait<K, V>::Pair Pair; |
| 61 | 60 |
| 62 inline void Insert(const Key& key, const Value& value) { | 61 inline void Insert(const Key& key, const Value& value) { |
| 63 Pair pair(key, value); | 62 Pair pair(key, value); |
| 64 DirectChainedHashMap<RawPointerKeyValueTrait<K, V> >::Insert(pair); | 63 DirectChainedHashMap<RawPointerKeyValueTrait<K, V> >::Insert(pair); |
| 65 } | 64 } |
| 66 | 65 |
| 67 inline V Lookup(const Key& key) { | 66 inline V Lookup(const Key& key) { |
| 68 Pair* pair = | 67 Pair* pair = |
| 69 DirectChainedHashMap<RawPointerKeyValueTrait<K, V> >::Lookup(key); | 68 DirectChainedHashMap<RawPointerKeyValueTrait<K, V> >::Lookup(key); |
| 70 if (pair == NULL) { | 69 if (pair == NULL) { |
| 71 return V(); | 70 return V(); |
| 72 } else { | 71 } else { |
| 73 return pair->value; | 72 return pair->value; |
| 74 } | 73 } |
| 75 } | 74 } |
| 76 | 75 |
| 77 inline Pair* LookupPair(const Key& key) { | 76 inline Pair* LookupPair(const Key& key) { |
| 78 return DirectChainedHashMap<RawPointerKeyValueTrait<K, V> >::Lookup(key); | 77 return DirectChainedHashMap<RawPointerKeyValueTrait<K, V> >::Lookup(key); |
| 79 } | 78 } |
| 80 }; | 79 }; |
| 81 | 80 |
| 82 | |
| 83 template <typename V> | 81 template <typename V> |
| 84 class IntKeyRawPointerValueTrait { | 82 class IntKeyRawPointerValueTrait { |
| 85 public: | 83 public: |
| 86 typedef intptr_t Key; | 84 typedef intptr_t Key; |
| 87 typedef V Value; | 85 typedef V Value; |
| 88 | 86 |
| 89 struct Pair { | 87 struct Pair { |
| 90 Key key; | 88 Key key; |
| 91 Value value; | 89 Value value; |
| 92 Pair() : key(NULL), value() {} | 90 Pair() : key(NULL), value() {} |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 return pair->value; | 147 return pair->value; |
| 150 } | 148 } |
| 151 } | 149 } |
| 152 | 150 |
| 153 inline Pair* LookupPair(const Key& key) { | 151 inline Pair* LookupPair(const Key& key) { |
| 154 return MallocDirectChainedHashMap<RawPointerKeyValueTrait<K, V> >::Lookup( | 152 return MallocDirectChainedHashMap<RawPointerKeyValueTrait<K, V> >::Lookup( |
| 155 key); | 153 key); |
| 156 } | 154 } |
| 157 }; | 155 }; |
| 158 | 156 |
| 159 | |
| 160 class BreakableBlock; | 157 class BreakableBlock; |
| 161 class CatchBlock; | 158 class CatchBlock; |
| 162 class FlowGraphBuilder; | 159 class FlowGraphBuilder; |
| 163 class SwitchBlock; | 160 class SwitchBlock; |
| 164 class TryCatchBlock; | 161 class TryCatchBlock; |
| 165 class TryFinallyBlock; | 162 class TryFinallyBlock; |
| 166 | 163 |
| 167 class Fragment { | 164 class Fragment { |
| 168 public: | 165 public: |
| 169 Instruction* entry; | 166 Instruction* entry; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 184 Fragment& operator<<=(Instruction* next); | 181 Fragment& operator<<=(Instruction* next); |
| 185 | 182 |
| 186 Fragment closed(); | 183 Fragment closed(); |
| 187 }; | 184 }; |
| 188 | 185 |
| 189 Fragment operator+(const Fragment& first, const Fragment& second); | 186 Fragment operator+(const Fragment& first, const Fragment& second); |
| 190 Fragment operator<<(const Fragment& fragment, Instruction* next); | 187 Fragment operator<<(const Fragment& fragment, Instruction* next); |
| 191 | 188 |
| 192 typedef ZoneGrowableArray<PushArgumentInstr*>* ArgumentArray; | 189 typedef ZoneGrowableArray<PushArgumentInstr*>* ArgumentArray; |
| 193 | 190 |
| 194 | |
| 195 class ActiveClass { | 191 class ActiveClass { |
| 196 public: | 192 public: |
| 197 ActiveClass() | 193 ActiveClass() |
| 198 : kernel_class(NULL), | 194 : kernel_class(NULL), |
| 199 class_type_parameters(0), | 195 class_type_parameters(0), |
| 200 class_type_parameters_offset_start(-1), | 196 class_type_parameters_offset_start(-1), |
| 201 klass(NULL), | 197 klass(NULL), |
| 202 member_is_procedure(false), | 198 member_is_procedure(false), |
| 203 member_is_factory_procedure(false), | 199 member_is_factory_procedure(false), |
| 204 member_type_parameters(0), | 200 member_type_parameters(0), |
| 205 member_type_parameters_offset_start(-1) {} | 201 member_type_parameters_offset_start(-1) {} |
| 206 | 202 |
| 207 // The current enclosing kernel class (if available, otherwise NULL). | 203 // The current enclosing kernel class (if available, otherwise NULL). |
| 208 Class* kernel_class; | 204 Class* kernel_class; |
| 209 intptr_t class_type_parameters; | 205 intptr_t class_type_parameters; |
| 210 intptr_t class_type_parameters_offset_start; | 206 intptr_t class_type_parameters_offset_start; |
| 211 | 207 |
| 212 // The current enclosing class (or the library top-level class). When this is | 208 // The current enclosing class (or the library top-level class). When this is |
| 213 // a library's top-level class, the kernel_class will be NULL. | 209 // a library's top-level class, the kernel_class will be NULL. |
| 214 const dart::Class* klass; | 210 const dart::Class* klass; |
| 215 | 211 |
| 216 bool member_is_procedure; | 212 bool member_is_procedure; |
| 217 bool member_is_factory_procedure; | 213 bool member_is_factory_procedure; |
| 218 intptr_t member_type_parameters; | 214 intptr_t member_type_parameters; |
| 219 intptr_t member_type_parameters_offset_start; | 215 intptr_t member_type_parameters_offset_start; |
| 220 }; | 216 }; |
| 221 | 217 |
| 222 | |
| 223 class ActiveClassScope { | 218 class ActiveClassScope { |
| 224 public: | 219 public: |
| 225 ActiveClassScope(ActiveClass* active_class, | 220 ActiveClassScope(ActiveClass* active_class, |
| 226 intptr_t class_type_parameters, | 221 intptr_t class_type_parameters, |
| 227 intptr_t class_type_parameters_offset_start, | 222 intptr_t class_type_parameters_offset_start, |
| 228 const dart::Class* klass) | 223 const dart::Class* klass) |
| 229 : active_class_(active_class), saved_(*active_class) { | 224 : active_class_(active_class), saved_(*active_class) { |
| 230 active_class_->kernel_class = NULL; | 225 active_class_->kernel_class = NULL; |
| 231 active_class_->class_type_parameters = class_type_parameters; | 226 active_class_->class_type_parameters = class_type_parameters; |
| 232 active_class_->class_type_parameters_offset_start = | 227 active_class_->class_type_parameters_offset_start = |
| 233 class_type_parameters_offset_start; | 228 class_type_parameters_offset_start; |
| 234 active_class_->klass = klass; | 229 active_class_->klass = klass; |
| 235 } | 230 } |
| 236 | 231 |
| 237 ~ActiveClassScope() { *active_class_ = saved_; } | 232 ~ActiveClassScope() { *active_class_ = saved_; } |
| 238 | 233 |
| 239 private: | 234 private: |
| 240 ActiveClass* active_class_; | 235 ActiveClass* active_class_; |
| 241 ActiveClass saved_; | 236 ActiveClass saved_; |
| 242 }; | 237 }; |
| 243 | 238 |
| 244 | |
| 245 class ActiveMemberScope { | 239 class ActiveMemberScope { |
| 246 public: | 240 public: |
| 247 ActiveMemberScope(ActiveClass* active_class, | 241 ActiveMemberScope(ActiveClass* active_class, |
| 248 bool member_is_procedure, | 242 bool member_is_procedure, |
| 249 bool member_is_factory_procedure, | 243 bool member_is_factory_procedure, |
| 250 intptr_t member_type_parameters, | 244 intptr_t member_type_parameters, |
| 251 intptr_t member_type_parameters_offset_start) | 245 intptr_t member_type_parameters_offset_start) |
| 252 : active_class_(active_class), saved_(*active_class) { | 246 : active_class_(active_class), saved_(*active_class) { |
| 253 // The class and kernel_class is inherited. | 247 // The class and kernel_class is inherited. |
| 254 active_class_->member_is_procedure = member_is_procedure; | 248 active_class_->member_is_procedure = member_is_procedure; |
| 255 active_class_->member_is_factory_procedure = member_is_factory_procedure; | 249 active_class_->member_is_factory_procedure = member_is_factory_procedure; |
| 256 active_class_->member_type_parameters = member_type_parameters; | 250 active_class_->member_type_parameters = member_type_parameters; |
| 257 active_class_->member_type_parameters_offset_start = | 251 active_class_->member_type_parameters_offset_start = |
| 258 member_type_parameters_offset_start; | 252 member_type_parameters_offset_start; |
| 259 } | 253 } |
| 260 | 254 |
| 261 ~ActiveMemberScope() { *active_class_ = saved_; } | 255 ~ActiveMemberScope() { *active_class_ = saved_; } |
| 262 | 256 |
| 263 private: | 257 private: |
| 264 ActiveClass* active_class_; | 258 ActiveClass* active_class_; |
| 265 ActiveClass saved_; | 259 ActiveClass saved_; |
| 266 }; | 260 }; |
| 267 | 261 |
| 268 | |
| 269 class TranslationHelper { | 262 class TranslationHelper { |
| 270 public: | 263 public: |
| 271 explicit TranslationHelper(dart::Thread* thread); | 264 explicit TranslationHelper(dart::Thread* thread); |
| 272 virtual ~TranslationHelper() {} | 265 virtual ~TranslationHelper() {} |
| 273 | 266 |
| 274 Thread* thread() { return thread_; } | 267 Thread* thread() { return thread_; } |
| 275 | 268 |
| 276 Zone* zone() { return zone_; } | 269 Zone* zone() { return zone_; } |
| 277 | 270 |
| 278 Isolate* isolate() { return isolate_; } | 271 Isolate* isolate() { return isolate_; } |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 | 370 |
| 378 private: | 371 private: |
| 379 // This will mangle [name_to_modify] if necessary and make the result a symbol | 372 // 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 | 373 // 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 | 374 // 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. | 375 // to get the import URI of the library where the name is visible. |
| 383 dart::String& ManglePrivateName(NameIndex parent, | 376 dart::String& ManglePrivateName(NameIndex parent, |
| 384 dart::String* name_to_modify, | 377 dart::String* name_to_modify, |
| 385 bool symbolize = true); | 378 bool symbolize = true); |
| 386 | 379 |
| 387 | |
| 388 Thread* thread_; | 380 Thread* thread_; |
| 389 Zone* zone_; | 381 Zone* zone_; |
| 390 Isolate* isolate_; | 382 Isolate* isolate_; |
| 391 Heap::Space allocation_space_; | 383 Heap::Space allocation_space_; |
| 392 | 384 |
| 393 TypedData& string_offsets_; | 385 TypedData& string_offsets_; |
| 394 TypedData& string_data_; | 386 TypedData& string_data_; |
| 395 TypedData& canonical_names_; | 387 TypedData& canonical_names_; |
| 396 }; | 388 }; |
| 397 | 389 |
| 398 | |
| 399 struct FunctionScope { | 390 struct FunctionScope { |
| 400 intptr_t kernel_offset; | 391 intptr_t kernel_offset; |
| 401 LocalScope* scope; | 392 LocalScope* scope; |
| 402 }; | 393 }; |
| 403 | 394 |
| 404 | |
| 405 class ScopeBuildingResult : public ZoneAllocated { | 395 class ScopeBuildingResult : public ZoneAllocated { |
| 406 public: | 396 public: |
| 407 ScopeBuildingResult() | 397 ScopeBuildingResult() |
| 408 : this_variable(NULL), | 398 : this_variable(NULL), |
| 409 type_arguments_variable(NULL), | 399 type_arguments_variable(NULL), |
| 410 switch_variable(NULL), | 400 switch_variable(NULL), |
| 411 finally_return_variable(NULL), | 401 finally_return_variable(NULL), |
| 412 setter_value(NULL), | 402 setter_value(NULL), |
| 413 yield_jump_variable(NULL), | 403 yield_jump_variable(NULL), |
| 414 yield_context_variable(NULL) {} | 404 yield_context_variable(NULL) {} |
| (...skipping 30 matching lines...) Expand all Loading... |
| 445 // Variables used in exception handlers, one per exception handler nesting | 435 // Variables used in exception handlers, one per exception handler nesting |
| 446 // level. | 436 // level. |
| 447 GrowableArray<LocalVariable*> exception_variables; | 437 GrowableArray<LocalVariable*> exception_variables; |
| 448 GrowableArray<LocalVariable*> stack_trace_variables; | 438 GrowableArray<LocalVariable*> stack_trace_variables; |
| 449 GrowableArray<LocalVariable*> catch_context_variables; | 439 GrowableArray<LocalVariable*> catch_context_variables; |
| 450 | 440 |
| 451 // For-in iterators, one per for-in nesting level. | 441 // For-in iterators, one per for-in nesting level. |
| 452 GrowableArray<LocalVariable*> iterator_variables; | 442 GrowableArray<LocalVariable*> iterator_variables; |
| 453 }; | 443 }; |
| 454 | 444 |
| 455 | |
| 456 struct YieldContinuation { | 445 struct YieldContinuation { |
| 457 Instruction* entry; | 446 Instruction* entry; |
| 458 intptr_t try_index; | 447 intptr_t try_index; |
| 459 | 448 |
| 460 YieldContinuation(Instruction* entry, intptr_t try_index) | 449 YieldContinuation(Instruction* entry, intptr_t try_index) |
| 461 : entry(entry), try_index(try_index) {} | 450 : entry(entry), try_index(try_index) {} |
| 462 | 451 |
| 463 YieldContinuation() | 452 YieldContinuation() |
| 464 : entry(NULL), try_index(CatchClauseNode::kInvalidTryIndex) {} | 453 : entry(NULL), try_index(CatchClauseNode::kInvalidTryIndex) {} |
| 465 }; | 454 }; |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 LocalVariable* CurrentException() { | 675 LocalVariable* CurrentException() { |
| 687 return scopes_->exception_variables[catch_depth_ - 1]; | 676 return scopes_->exception_variables[catch_depth_ - 1]; |
| 688 } | 677 } |
| 689 LocalVariable* CurrentStackTrace() { | 678 LocalVariable* CurrentStackTrace() { |
| 690 return scopes_->stack_trace_variables[catch_depth_ - 1]; | 679 return scopes_->stack_trace_variables[catch_depth_ - 1]; |
| 691 } | 680 } |
| 692 LocalVariable* CurrentCatchContext() { | 681 LocalVariable* CurrentCatchContext() { |
| 693 return scopes_->catch_context_variables[try_depth_]; | 682 return scopes_->catch_context_variables[try_depth_]; |
| 694 } | 683 } |
| 695 | 684 |
| 696 | |
| 697 // A chained list of breakable blocks. Chaining and lookup is done by the | 685 // A chained list of breakable blocks. Chaining and lookup is done by the |
| 698 // [BreakableBlock] class. | 686 // [BreakableBlock] class. |
| 699 BreakableBlock* breakable_block_; | 687 BreakableBlock* breakable_block_; |
| 700 | 688 |
| 701 // A chained list of switch blocks. Chaining and lookup is done by the | 689 // A chained list of switch blocks. Chaining and lookup is done by the |
| 702 // [SwitchBlock] class. | 690 // [SwitchBlock] class. |
| 703 SwitchBlock* switch_block_; | 691 SwitchBlock* switch_block_; |
| 704 | 692 |
| 705 // A chained list of try-finally blocks. Chaining and lookup is done by the | 693 // A chained list of try-finally blocks. Chaining and lookup is done by the |
| 706 // [TryFinallyBlock] class. | 694 // [TryFinallyBlock] class. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 722 friend class BreakableBlock; | 710 friend class BreakableBlock; |
| 723 friend class CatchBlock; | 711 friend class CatchBlock; |
| 724 friend class ConstantEvaluator; | 712 friend class ConstantEvaluator; |
| 725 friend class StreamingFlowGraphBuilder; | 713 friend class StreamingFlowGraphBuilder; |
| 726 friend class ScopeBuilder; | 714 friend class ScopeBuilder; |
| 727 friend class SwitchBlock; | 715 friend class SwitchBlock; |
| 728 friend class TryCatchBlock; | 716 friend class TryCatchBlock; |
| 729 friend class TryFinallyBlock; | 717 friend class TryFinallyBlock; |
| 730 }; | 718 }; |
| 731 | 719 |
| 732 | |
| 733 class SwitchBlock { | 720 class SwitchBlock { |
| 734 public: | 721 public: |
| 735 SwitchBlock(FlowGraphBuilder* builder, intptr_t case_count) | 722 SwitchBlock(FlowGraphBuilder* builder, intptr_t case_count) |
| 736 : builder_(builder), | 723 : builder_(builder), |
| 737 outer_(builder->switch_block_), | 724 outer_(builder->switch_block_), |
| 738 outer_finally_(builder->try_finally_block_), | 725 outer_finally_(builder->try_finally_block_), |
| 739 case_count_(case_count), | 726 case_count_(case_count), |
| 740 context_depth_(builder->context_depth_), | 727 context_depth_(builder->context_depth_), |
| 741 try_index_(builder->CurrentTryIndex()) { | 728 try_index_(builder->CurrentTryIndex()) { |
| 742 builder_->switch_block_ = this; | 729 builder_->switch_block_ = this; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 | 791 |
| 805 IntMap<JoinEntryInstr*> destinations_; | 792 IntMap<JoinEntryInstr*> destinations_; |
| 806 | 793 |
| 807 TryFinallyBlock* outer_finally_; | 794 TryFinallyBlock* outer_finally_; |
| 808 intptr_t case_count_; | 795 intptr_t case_count_; |
| 809 intptr_t depth_; | 796 intptr_t depth_; |
| 810 intptr_t context_depth_; | 797 intptr_t context_depth_; |
| 811 intptr_t try_index_; | 798 intptr_t try_index_; |
| 812 }; | 799 }; |
| 813 | 800 |
| 814 | |
| 815 class TryCatchBlock { | 801 class TryCatchBlock { |
| 816 public: | 802 public: |
| 817 explicit TryCatchBlock(FlowGraphBuilder* builder, | 803 explicit TryCatchBlock(FlowGraphBuilder* builder, |
| 818 intptr_t try_handler_index = -1) | 804 intptr_t try_handler_index = -1) |
| 819 : builder_(builder), | 805 : builder_(builder), |
| 820 outer_(builder->try_catch_block_), | 806 outer_(builder->try_catch_block_), |
| 821 try_index_(try_handler_index) { | 807 try_index_(try_handler_index) { |
| 822 if (try_index_ == -1) try_index_ = builder->AllocateTryIndex(); | 808 if (try_index_ == -1) try_index_ = builder->AllocateTryIndex(); |
| 823 builder->try_catch_block_ = this; | 809 builder->try_catch_block_ = this; |
| 824 } | 810 } |
| 825 ~TryCatchBlock() { builder_->try_catch_block_ = outer_; } | 811 ~TryCatchBlock() { builder_->try_catch_block_ = outer_; } |
| 826 | 812 |
| 827 intptr_t try_index() { return try_index_; } | 813 intptr_t try_index() { return try_index_; } |
| 828 TryCatchBlock* outer() const { return outer_; } | 814 TryCatchBlock* outer() const { return outer_; } |
| 829 | 815 |
| 830 private: | 816 private: |
| 831 FlowGraphBuilder* builder_; | 817 FlowGraphBuilder* builder_; |
| 832 TryCatchBlock* outer_; | 818 TryCatchBlock* outer_; |
| 833 intptr_t try_index_; | 819 intptr_t try_index_; |
| 834 }; | 820 }; |
| 835 | 821 |
| 836 | |
| 837 class TryFinallyBlock { | 822 class TryFinallyBlock { |
| 838 public: | 823 public: |
| 839 TryFinallyBlock(FlowGraphBuilder* builder, | 824 TryFinallyBlock(FlowGraphBuilder* builder, intptr_t finalizer_kernel_offset) |
| 840 intptr_t finalizer_kernel_offset) | |
| 841 : builder_(builder), | 825 : builder_(builder), |
| 842 outer_(builder->try_finally_block_), | 826 outer_(builder->try_finally_block_), |
| 843 finalizer_kernel_offset_(finalizer_kernel_offset), | 827 finalizer_kernel_offset_(finalizer_kernel_offset), |
| 844 context_depth_(builder->context_depth_), | 828 context_depth_(builder->context_depth_), |
| 845 // Finalizers are executed outside of the try block hence | 829 // Finalizers are executed outside of the try block hence |
| 846 // try depth of finalizers are one less than current try | 830 // try depth of finalizers are one less than current try |
| 847 // depth. | 831 // depth. |
| 848 try_depth_(builder->try_depth_ - 1), | 832 try_depth_(builder->try_depth_ - 1), |
| 849 try_index_(builder_->CurrentTryIndex()) { | 833 try_index_(builder_->CurrentTryIndex()) { |
| 850 builder_->try_finally_block_ = this; | 834 builder_->try_finally_block_ = this; |
| 851 } | 835 } |
| 852 ~TryFinallyBlock() { builder_->try_finally_block_ = outer_; } | 836 ~TryFinallyBlock() { builder_->try_finally_block_ = outer_; } |
| 853 | 837 |
| 854 intptr_t finalizer_kernel_offset() const { return finalizer_kernel_offset_; } | 838 intptr_t finalizer_kernel_offset() const { return finalizer_kernel_offset_; } |
| 855 intptr_t context_depth() const { return context_depth_; } | 839 intptr_t context_depth() const { return context_depth_; } |
| 856 intptr_t try_depth() const { return try_depth_; } | 840 intptr_t try_depth() const { return try_depth_; } |
| 857 intptr_t try_index() const { return try_index_; } | 841 intptr_t try_index() const { return try_index_; } |
| 858 TryFinallyBlock* outer() const { return outer_; } | 842 TryFinallyBlock* outer() const { return outer_; } |
| 859 | 843 |
| 860 private: | 844 private: |
| 861 FlowGraphBuilder* const builder_; | 845 FlowGraphBuilder* const builder_; |
| 862 TryFinallyBlock* const outer_; | 846 TryFinallyBlock* const outer_; |
| 863 intptr_t finalizer_kernel_offset_; | 847 intptr_t finalizer_kernel_offset_; |
| 864 const intptr_t context_depth_; | 848 const intptr_t context_depth_; |
| 865 const intptr_t try_depth_; | 849 const intptr_t try_depth_; |
| 866 const intptr_t try_index_; | 850 const intptr_t try_index_; |
| 867 }; | 851 }; |
| 868 | 852 |
| 869 | |
| 870 class BreakableBlock { | 853 class BreakableBlock { |
| 871 public: | 854 public: |
| 872 explicit BreakableBlock(FlowGraphBuilder* builder) | 855 explicit BreakableBlock(FlowGraphBuilder* builder) |
| 873 : builder_(builder), | 856 : builder_(builder), |
| 874 outer_(builder->breakable_block_), | 857 outer_(builder->breakable_block_), |
| 875 destination_(NULL), | 858 destination_(NULL), |
| 876 outer_finally_(builder->try_finally_block_), | 859 outer_finally_(builder->try_finally_block_), |
| 877 context_depth_(builder->context_depth_), | 860 context_depth_(builder->context_depth_), |
| 878 try_index_(builder->CurrentTryIndex()) { | 861 try_index_(builder->CurrentTryIndex()) { |
| 879 if (builder_->breakable_block_ == NULL) { | 862 if (builder_->breakable_block_ == NULL) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 939 intptr_t catch_try_index() { return catch_try_index_; } | 922 intptr_t catch_try_index() { return catch_try_index_; } |
| 940 | 923 |
| 941 private: | 924 private: |
| 942 FlowGraphBuilder* builder_; | 925 FlowGraphBuilder* builder_; |
| 943 CatchBlock* outer_; | 926 CatchBlock* outer_; |
| 944 LocalVariable* exception_var_; | 927 LocalVariable* exception_var_; |
| 945 LocalVariable* stack_trace_var_; | 928 LocalVariable* stack_trace_var_; |
| 946 intptr_t catch_try_index_; | 929 intptr_t catch_try_index_; |
| 947 }; | 930 }; |
| 948 | 931 |
| 949 | |
| 950 RawObject* EvaluateMetadata(const dart::Field& metadata_field); | 932 RawObject* EvaluateMetadata(const dart::Field& metadata_field); |
| 951 RawObject* BuildParameterDescriptor(const Function& function); | 933 RawObject* BuildParameterDescriptor(const Function& function); |
| 952 void CollectTokenPositionsFor(const Script& script); | 934 void CollectTokenPositionsFor(const Script& script); |
| 953 String& GetSourceFor(const Script& script); | 935 String& GetSourceFor(const Script& script); |
| 954 Array& GetLineStartsFor(const Script& script); | 936 Array& GetLineStartsFor(const Script& script); |
| 955 | 937 |
| 956 | |
| 957 } // namespace kernel | 938 } // namespace kernel |
| 958 } // namespace dart | 939 } // namespace dart |
| 959 | 940 |
| 960 #else // !defined(DART_PRECOMPILED_RUNTIME) | 941 #else // !defined(DART_PRECOMPILED_RUNTIME) |
| 961 | 942 |
| 943 #include "vm/kernel.h" |
| 962 #include "vm/object.h" | 944 #include "vm/object.h" |
| 963 #include "vm/kernel.h" | |
| 964 | 945 |
| 965 namespace dart { | 946 namespace dart { |
| 966 namespace kernel { | 947 namespace kernel { |
| 967 | 948 |
| 968 RawObject* EvaluateMetadata(const dart::Field& metadata_field); | 949 RawObject* EvaluateMetadata(const dart::Field& metadata_field); |
| 969 RawObject* BuildParameterDescriptor(const Function& function); | 950 RawObject* BuildParameterDescriptor(const Function& function); |
| 970 | 951 |
| 971 } // namespace kernel | 952 } // namespace kernel |
| 972 } // namespace dart | 953 } // namespace dart |
| 973 | 954 |
| 974 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 955 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
| 975 #endif // RUNTIME_VM_KERNEL_TO_IL_H_ | 956 #endif // RUNTIME_VM_KERNEL_TO_IL_H_ |
| OLD | NEW |