| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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_INTERMEDIATE_LANGUAGE_H_ | 5 #ifndef VM_INTERMEDIATE_LANGUAGE_H_ |
| 6 #define VM_INTERMEDIATE_LANGUAGE_H_ | 6 #define VM_INTERMEDIATE_LANGUAGE_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/ast.h" | 9 #include "vm/ast.h" |
| 10 #include "vm/growable_array.h" | 10 #include "vm/growable_array.h" |
| (...skipping 1548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1559 class CatchBlockEntryInstr : public BlockEntryInstr { | 1559 class CatchBlockEntryInstr : public BlockEntryInstr { |
| 1560 public: | 1560 public: |
| 1561 CatchBlockEntryInstr(intptr_t block_id, | 1561 CatchBlockEntryInstr(intptr_t block_id, |
| 1562 intptr_t try_index, | 1562 intptr_t try_index, |
| 1563 GraphEntryInstr* graph_entry, | 1563 GraphEntryInstr* graph_entry, |
| 1564 const Array& handler_types, | 1564 const Array& handler_types, |
| 1565 intptr_t catch_try_index, | 1565 intptr_t catch_try_index, |
| 1566 const LocalVariable& exception_var, | 1566 const LocalVariable& exception_var, |
| 1567 const LocalVariable& stacktrace_var, | 1567 const LocalVariable& stacktrace_var, |
| 1568 bool needs_stacktrace, | 1568 bool needs_stacktrace, |
| 1569 intptr_t deopt_id) | 1569 intptr_t deopt_id, |
| 1570 bool should_restore_closure_context = false) |
| 1570 : BlockEntryInstr(block_id, try_index), | 1571 : BlockEntryInstr(block_id, try_index), |
| 1571 graph_entry_(graph_entry), | 1572 graph_entry_(graph_entry), |
| 1572 predecessor_(NULL), | 1573 predecessor_(NULL), |
| 1573 catch_handler_types_(Array::ZoneHandle(handler_types.raw())), | 1574 catch_handler_types_(Array::ZoneHandle(handler_types.raw())), |
| 1574 catch_try_index_(catch_try_index), | 1575 catch_try_index_(catch_try_index), |
| 1575 exception_var_(exception_var), | 1576 exception_var_(exception_var), |
| 1576 stacktrace_var_(stacktrace_var), | 1577 stacktrace_var_(stacktrace_var), |
| 1577 needs_stacktrace_(needs_stacktrace) { | 1578 needs_stacktrace_(needs_stacktrace), |
| 1579 should_restore_closure_context_(should_restore_closure_context) { |
| 1578 deopt_id_ = deopt_id; | 1580 deopt_id_ = deopt_id; |
| 1579 } | 1581 } |
| 1580 | 1582 |
| 1581 DECLARE_INSTRUCTION(CatchBlockEntry) | 1583 DECLARE_INSTRUCTION(CatchBlockEntry) |
| 1582 | 1584 |
| 1583 virtual intptr_t PredecessorCount() const { | 1585 virtual intptr_t PredecessorCount() const { |
| 1584 return (predecessor_ == NULL) ? 0 : 1; | 1586 return (predecessor_ == NULL) ? 0 : 1; |
| 1585 } | 1587 } |
| 1586 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const { | 1588 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const { |
| 1587 ASSERT((index == 0) && (predecessor_ != NULL)); | 1589 ASSERT((index == 0) && (predecessor_ != NULL)); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1608 | 1610 |
| 1609 private: | 1611 private: |
| 1610 friend class BlockEntryInstr; // Access to predecessor_ when inlining. | 1612 friend class BlockEntryInstr; // Access to predecessor_ when inlining. |
| 1611 | 1613 |
| 1612 virtual void ClearPredecessors() { predecessor_ = NULL; } | 1614 virtual void ClearPredecessors() { predecessor_ = NULL; } |
| 1613 virtual void AddPredecessor(BlockEntryInstr* predecessor) { | 1615 virtual void AddPredecessor(BlockEntryInstr* predecessor) { |
| 1614 ASSERT(predecessor_ == NULL); | 1616 ASSERT(predecessor_ == NULL); |
| 1615 predecessor_ = predecessor; | 1617 predecessor_ = predecessor; |
| 1616 } | 1618 } |
| 1617 | 1619 |
| 1620 bool should_restore_closure_context() const { |
| 1621 ASSERT(exception_var_.is_captured() == stacktrace_var_.is_captured()); |
| 1622 ASSERT(!exception_var_.is_captured() || should_restore_closure_context_); |
| 1623 return should_restore_closure_context_; |
| 1624 } |
| 1625 |
| 1618 GraphEntryInstr* graph_entry_; | 1626 GraphEntryInstr* graph_entry_; |
| 1619 BlockEntryInstr* predecessor_; | 1627 BlockEntryInstr* predecessor_; |
| 1620 const Array& catch_handler_types_; | 1628 const Array& catch_handler_types_; |
| 1621 const intptr_t catch_try_index_; | 1629 const intptr_t catch_try_index_; |
| 1622 GrowableArray<Definition*> initial_definitions_; | 1630 GrowableArray<Definition*> initial_definitions_; |
| 1623 const LocalVariable& exception_var_; | 1631 const LocalVariable& exception_var_; |
| 1624 const LocalVariable& stacktrace_var_; | 1632 const LocalVariable& stacktrace_var_; |
| 1625 const bool needs_stacktrace_; | 1633 const bool needs_stacktrace_; |
| 1634 const bool should_restore_closure_context_; |
| 1626 | 1635 |
| 1627 DISALLOW_COPY_AND_ASSIGN(CatchBlockEntryInstr); | 1636 DISALLOW_COPY_AND_ASSIGN(CatchBlockEntryInstr); |
| 1628 }; | 1637 }; |
| 1629 | 1638 |
| 1630 | 1639 |
| 1631 // If the result of the allocation is not stored into any field, passed | 1640 // If the result of the allocation is not stored into any field, passed |
| 1632 // as an argument or used in a phi then it can't alias with any other | 1641 // as an argument or used in a phi then it can't alias with any other |
| 1633 // SSA value. | 1642 // SSA value. |
| 1634 class AliasIdentity : public ValueObject { | 1643 class AliasIdentity : public ValueObject { |
| 1635 public: | 1644 public: |
| (...skipping 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2770 DISALLOW_COPY_AND_ASSIGN(CurrentContextInstr); | 2779 DISALLOW_COPY_AND_ASSIGN(CurrentContextInstr); |
| 2771 }; | 2780 }; |
| 2772 | 2781 |
| 2773 | 2782 |
| 2774 class ClosureCallInstr : public TemplateDefinition<1, Throws> { | 2783 class ClosureCallInstr : public TemplateDefinition<1, Throws> { |
| 2775 public: | 2784 public: |
| 2776 ClosureCallInstr(Value* function, | 2785 ClosureCallInstr(Value* function, |
| 2777 ClosureCallNode* node, | 2786 ClosureCallNode* node, |
| 2778 ZoneGrowableArray<PushArgumentInstr*>* arguments) | 2787 ZoneGrowableArray<PushArgumentInstr*>* arguments) |
| 2779 : TemplateDefinition(Thread::Current()->GetNextDeoptId()), | 2788 : TemplateDefinition(Thread::Current()->GetNextDeoptId()), |
| 2780 ast_node_(*node), | 2789 argument_names_(node->arguments()->names()), |
| 2790 token_pos_(node->token_pos()), |
| 2791 arguments_(arguments) { |
| 2792 SetInputAt(0, function); |
| 2793 } |
| 2794 |
| 2795 ClosureCallInstr(Value* function, |
| 2796 ZoneGrowableArray<PushArgumentInstr*>* arguments, |
| 2797 const Array& argument_names, |
| 2798 TokenPosition token_pos) |
| 2799 : TemplateDefinition(Thread::Current()->GetNextDeoptId()), |
| 2800 argument_names_(argument_names), |
| 2801 token_pos_(token_pos), |
| 2781 arguments_(arguments) { | 2802 arguments_(arguments) { |
| 2782 SetInputAt(0, function); | 2803 SetInputAt(0, function); |
| 2783 } | 2804 } |
| 2784 | 2805 |
| 2785 DECLARE_INSTRUCTION(ClosureCall) | 2806 DECLARE_INSTRUCTION(ClosureCall) |
| 2786 | 2807 |
| 2787 const Array& argument_names() const { return ast_node_.arguments()->names(); } | 2808 const Array& argument_names() const { return argument_names_; } |
| 2788 virtual TokenPosition token_pos() const { | 2809 virtual TokenPosition token_pos() const { return token_pos_; } |
| 2789 return ast_node_.token_pos(); | |
| 2790 } | |
| 2791 | 2810 |
| 2792 virtual intptr_t ArgumentCount() const { return arguments_->length(); } | 2811 virtual intptr_t ArgumentCount() const { return arguments_->length(); } |
| 2793 virtual PushArgumentInstr* PushArgumentAt(intptr_t index) const { | 2812 virtual PushArgumentInstr* PushArgumentAt(intptr_t index) const { |
| 2794 return (*arguments_)[index]; | 2813 return (*arguments_)[index]; |
| 2795 } | 2814 } |
| 2796 | 2815 |
| 2797 // TODO(kmillikin): implement exact call counts for closure calls. | 2816 // TODO(kmillikin): implement exact call counts for closure calls. |
| 2798 virtual intptr_t CallCount() const { return 1; } | 2817 virtual intptr_t CallCount() const { return 1; } |
| 2799 | 2818 |
| 2800 virtual bool CanDeoptimize() const { return true; } | 2819 virtual bool CanDeoptimize() const { return true; } |
| 2801 | 2820 |
| 2802 virtual EffectSet Effects() const { return EffectSet::All(); } | 2821 virtual EffectSet Effects() const { return EffectSet::All(); } |
| 2803 | 2822 |
| 2804 PRINT_OPERANDS_TO_SUPPORT | 2823 PRINT_OPERANDS_TO_SUPPORT |
| 2805 | 2824 |
| 2806 private: | 2825 private: |
| 2807 const ClosureCallNode& ast_node_; | 2826 const Array& argument_names_; |
| 2827 TokenPosition token_pos_; |
| 2808 ZoneGrowableArray<PushArgumentInstr*>* arguments_; | 2828 ZoneGrowableArray<PushArgumentInstr*>* arguments_; |
| 2809 | 2829 |
| 2810 DISALLOW_COPY_AND_ASSIGN(ClosureCallInstr); | 2830 DISALLOW_COPY_AND_ASSIGN(ClosureCallInstr); |
| 2811 }; | 2831 }; |
| 2812 | 2832 |
| 2813 | 2833 |
| 2814 class InstanceCallInstr : public TemplateDefinition<0, Throws> { | 2834 class InstanceCallInstr : public TemplateDefinition<0, Throws> { |
| 2815 public: | 2835 public: |
| 2816 InstanceCallInstr(TokenPosition token_pos, | 2836 InstanceCallInstr(TokenPosition token_pos, |
| 2817 const String& function_name, | 2837 const String& function_name, |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3257 ic_data_(NULL), | 3277 ic_data_(NULL), |
| 3258 token_pos_(token_pos), | 3278 token_pos_(token_pos), |
| 3259 function_(function), | 3279 function_(function), |
| 3260 argument_names_(argument_names), | 3280 argument_names_(argument_names), |
| 3261 arguments_(arguments), | 3281 arguments_(arguments), |
| 3262 result_cid_(kDynamicCid), | 3282 result_cid_(kDynamicCid), |
| 3263 is_known_list_constructor_(false), | 3283 is_known_list_constructor_(false), |
| 3264 identity_(AliasIdentity::Unknown()) { | 3284 identity_(AliasIdentity::Unknown()) { |
| 3265 ic_data_ = GetICData(ic_data_array); | 3285 ic_data_ = GetICData(ic_data_array); |
| 3266 ASSERT(function.IsZoneHandle()); | 3286 ASSERT(function.IsZoneHandle()); |
| 3287 ASSERT(!function.IsNull()); |
| 3267 ASSERT(argument_names.IsZoneHandle() || argument_names.InVMHeap()); | 3288 ASSERT(argument_names.IsZoneHandle() || argument_names.InVMHeap()); |
| 3268 } | 3289 } |
| 3269 | 3290 |
| 3270 StaticCallInstr(TokenPosition token_pos, | 3291 StaticCallInstr(TokenPosition token_pos, |
| 3271 const Function& function, | 3292 const Function& function, |
| 3272 const Array& argument_names, | 3293 const Array& argument_names, |
| 3273 ZoneGrowableArray<PushArgumentInstr*>* arguments, | 3294 ZoneGrowableArray<PushArgumentInstr*>* arguments, |
| 3274 intptr_t deopt_id) | 3295 intptr_t deopt_id) |
| 3275 : TemplateDefinition(deopt_id), | 3296 : TemplateDefinition(deopt_id), |
| 3276 ic_data_(NULL), | 3297 ic_data_(NULL), |
| 3277 token_pos_(token_pos), | 3298 token_pos_(token_pos), |
| 3278 function_(function), | 3299 function_(function), |
| 3279 argument_names_(argument_names), | 3300 argument_names_(argument_names), |
| 3280 arguments_(arguments), | 3301 arguments_(arguments), |
| 3281 result_cid_(kDynamicCid), | 3302 result_cid_(kDynamicCid), |
| 3282 is_known_list_constructor_(false), | 3303 is_known_list_constructor_(false), |
| 3283 identity_(AliasIdentity::Unknown()) { | 3304 identity_(AliasIdentity::Unknown()) { |
| 3284 ASSERT(function.IsZoneHandle()); | 3305 ASSERT(function.IsZoneHandle()); |
| 3306 ASSERT(!function.IsNull()); |
| 3285 ASSERT(argument_names.IsZoneHandle() || argument_names.InVMHeap()); | 3307 ASSERT(argument_names.IsZoneHandle() || argument_names.InVMHeap()); |
| 3286 } | 3308 } |
| 3287 | 3309 |
| 3288 // ICData for static calls carries call count. | 3310 // ICData for static calls carries call count. |
| 3289 const ICData* ic_data() const { return ic_data_; } | 3311 const ICData* ic_data() const { return ic_data_; } |
| 3290 bool HasICData() const { | 3312 bool HasICData() const { |
| 3291 return (ic_data() != NULL) && !ic_data()->IsNull(); | 3313 return (ic_data() != NULL) && !ic_data()->IsNull(); |
| 3292 } | 3314 } |
| 3293 | 3315 |
| 3294 DECLARE_INSTRUCTION(StaticCall) | 3316 DECLARE_INSTRUCTION(StaticCall) |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3476 bool is_last_; | 3498 bool is_last_; |
| 3477 const TokenPosition token_pos_; | 3499 const TokenPosition token_pos_; |
| 3478 | 3500 |
| 3479 DISALLOW_COPY_AND_ASSIGN(StoreLocalInstr); | 3501 DISALLOW_COPY_AND_ASSIGN(StoreLocalInstr); |
| 3480 }; | 3502 }; |
| 3481 | 3503 |
| 3482 | 3504 |
| 3483 class NativeCallInstr : public TemplateDefinition<0, Throws> { | 3505 class NativeCallInstr : public TemplateDefinition<0, Throws> { |
| 3484 public: | 3506 public: |
| 3485 explicit NativeCallInstr(NativeBodyNode* node) | 3507 explicit NativeCallInstr(NativeBodyNode* node) |
| 3486 : ast_node_(*node), | 3508 : native_name_(&node->native_c_function_name()), |
| 3509 function_(&node->function()), |
| 3487 native_c_function_(NULL), | 3510 native_c_function_(NULL), |
| 3488 is_bootstrap_native_(false) { } | 3511 is_bootstrap_native_(false), |
| 3512 link_lazily_(node->link_lazily()), |
| 3513 token_pos_(node->token_pos()) { } |
| 3514 |
| 3515 NativeCallInstr(const String* name, |
| 3516 const Function* function, |
| 3517 bool link_lazily, |
| 3518 TokenPosition position) |
| 3519 : native_name_(name), |
| 3520 function_(function), |
| 3521 native_c_function_(NULL), |
| 3522 is_bootstrap_native_(false), |
| 3523 link_lazily_(link_lazily), |
| 3524 token_pos_(position) { } |
| 3489 | 3525 |
| 3490 DECLARE_INSTRUCTION(NativeCall) | 3526 DECLARE_INSTRUCTION(NativeCall) |
| 3491 | 3527 |
| 3492 virtual TokenPosition token_pos() const { | 3528 const String& native_name() const { return *native_name_; } |
| 3493 return ast_node_.token_pos(); | 3529 const Function& function() const { return *function_; } |
| 3494 } | 3530 NativeFunction native_c_function() const { return native_c_function_; } |
| 3495 | 3531 bool is_bootstrap_native() const { return is_bootstrap_native_; } |
| 3496 const Function& function() const { return ast_node_.function(); } | 3532 bool link_lazily() const { return link_lazily_; } |
| 3497 | 3533 virtual TokenPosition token_pos() const { return token_pos_; } |
| 3498 const String& native_name() const { | |
| 3499 return ast_node_.native_c_function_name(); | |
| 3500 } | |
| 3501 | |
| 3502 NativeFunction native_c_function() const { | |
| 3503 return native_c_function_; | |
| 3504 } | |
| 3505 | |
| 3506 bool is_bootstrap_native() const { | |
| 3507 return is_bootstrap_native_; | |
| 3508 } | |
| 3509 | |
| 3510 bool link_lazily() const { | |
| 3511 return ast_node_.link_lazily(); | |
| 3512 } | |
| 3513 | 3534 |
| 3514 virtual bool CanDeoptimize() const { return false; } | 3535 virtual bool CanDeoptimize() const { return false; } |
| 3515 | 3536 |
| 3516 virtual EffectSet Effects() const { return EffectSet::All(); } | 3537 virtual EffectSet Effects() const { return EffectSet::All(); } |
| 3517 | 3538 |
| 3518 void SetupNative(); | 3539 void SetupNative(); |
| 3519 | 3540 |
| 3520 PRINT_OPERANDS_TO_SUPPORT | 3541 PRINT_OPERANDS_TO_SUPPORT |
| 3521 | 3542 |
| 3522 private: | 3543 private: |
| 3523 void set_native_c_function(NativeFunction value) { | 3544 void set_native_c_function(NativeFunction value) { |
| 3524 native_c_function_ = value; | 3545 native_c_function_ = value; |
| 3525 } | 3546 } |
| 3526 | 3547 |
| 3527 void set_is_bootstrap_native(bool value) { is_bootstrap_native_ = value; } | 3548 void set_is_bootstrap_native(bool value) { is_bootstrap_native_ = value; } |
| 3528 | 3549 |
| 3529 const NativeBodyNode& ast_node_; | 3550 const String* native_name_; |
| 3551 const Function* function_; |
| 3530 NativeFunction native_c_function_; | 3552 NativeFunction native_c_function_; |
| 3531 bool is_bootstrap_native_; | 3553 bool is_bootstrap_native_; |
| 3554 bool link_lazily_; |
| 3555 const TokenPosition token_pos_; |
| 3532 | 3556 |
| 3533 DISALLOW_COPY_AND_ASSIGN(NativeCallInstr); | 3557 DISALLOW_COPY_AND_ASSIGN(NativeCallInstr); |
| 3534 }; | 3558 }; |
| 3535 | 3559 |
| 3536 | 3560 |
| 3537 class DebugStepCheckInstr : public TemplateInstruction<0, NoThrow> { | 3561 class DebugStepCheckInstr : public TemplateInstruction<0, NoThrow> { |
| 3538 public: | 3562 public: |
| 3539 DebugStepCheckInstr(TokenPosition token_pos, | 3563 DebugStepCheckInstr(TokenPosition token_pos, |
| 3540 RawPcDescriptors::Kind stub_kind) | 3564 RawPcDescriptors::Kind stub_kind) |
| 3541 : token_pos_(token_pos), | 3565 : token_pos_(token_pos), |
| (...skipping 4758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8300 LocationSummary* Name::MakeLocationSummary(Zone* zone, bool opt) const { \ | 8324 LocationSummary* Name::MakeLocationSummary(Zone* zone, bool opt) const { \ |
| 8301 UNIMPLEMENTED(); \ | 8325 UNIMPLEMENTED(); \ |
| 8302 return NULL; \ | 8326 return NULL; \ |
| 8303 } \ | 8327 } \ |
| 8304 void Name::EmitNativeCode(FlowGraphCompiler* compiler) { UNIMPLEMENTED(); } | 8328 void Name::EmitNativeCode(FlowGraphCompiler* compiler) { UNIMPLEMENTED(); } |
| 8305 | 8329 |
| 8306 | 8330 |
| 8307 } // namespace dart | 8331 } // namespace dart |
| 8308 | 8332 |
| 8309 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 8333 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |