| 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 3651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3662 DISALLOW_COPY_AND_ASSIGN(BinaryDoubleOpInstr); | 3662 DISALLOW_COPY_AND_ASSIGN(BinaryDoubleOpInstr); |
| 3663 }; | 3663 }; |
| 3664 | 3664 |
| 3665 | 3665 |
| 3666 class BinaryMintOpInstr : public TemplateDefinition<2> { | 3666 class BinaryMintOpInstr : public TemplateDefinition<2> { |
| 3667 public: | 3667 public: |
| 3668 BinaryMintOpInstr(Token::Kind op_kind, | 3668 BinaryMintOpInstr(Token::Kind op_kind, |
| 3669 Value* left, | 3669 Value* left, |
| 3670 Value* right, | 3670 Value* right, |
| 3671 InstanceCallInstr* instance_call) | 3671 InstanceCallInstr* instance_call) |
| 3672 : op_kind_(op_kind) { | 3672 : op_kind_(op_kind), |
| 3673 instance_call_(instance_call) { |
| 3673 ASSERT(left != NULL); | 3674 ASSERT(left != NULL); |
| 3674 ASSERT(right != NULL); | 3675 ASSERT(right != NULL); |
| 3675 inputs_[0] = left; | 3676 inputs_[0] = left; |
| 3676 inputs_[1] = right; | 3677 inputs_[1] = right; |
| 3677 deopt_id_ = instance_call->deopt_id(); | 3678 deopt_id_ = instance_call->deopt_id(); |
| 3678 } | 3679 } |
| 3679 | 3680 |
| 3680 Value* left() const { return inputs_[0]; } | 3681 Value* left() const { return inputs_[0]; } |
| 3681 Value* right() const { return inputs_[1]; } | 3682 Value* right() const { return inputs_[1]; } |
| 3682 | 3683 |
| 3683 Token::Kind op_kind() const { return op_kind_; } | 3684 Token::Kind op_kind() const { return op_kind_; } |
| 3684 | 3685 |
| 3686 InstanceCallInstr* instance_call() const { return instance_call_; } |
| 3687 |
| 3685 virtual void PrintOperandsTo(BufferFormatter* f) const; | 3688 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 3686 | 3689 |
| 3687 virtual bool CanDeoptimize() const { | 3690 virtual bool CanDeoptimize() const { |
| 3688 return (op_kind() == Token::kADD) || (op_kind() == Token::kSUB); | 3691 return (op_kind() == Token::kADD) || (op_kind() == Token::kSUB); |
| 3689 } | 3692 } |
| 3690 | 3693 |
| 3691 virtual bool HasSideEffect() const { return false; } | 3694 virtual bool HasSideEffect() const { return false; } |
| 3692 | 3695 |
| 3693 virtual bool AffectedBySideEffect() const { return false; } | 3696 virtual bool AffectedBySideEffect() const { return false; } |
| 3694 | 3697 |
| 3695 virtual bool AttributesEqual(Instruction* other) const { | 3698 virtual bool AttributesEqual(Instruction* other) const { |
| 3699 ASSERT(other->IsBinaryMintOp()); |
| 3696 return op_kind() == other->AsBinaryMintOp()->op_kind(); | 3700 return op_kind() == other->AsBinaryMintOp()->op_kind(); |
| 3697 } | 3701 } |
| 3698 | 3702 |
| 3699 virtual CompileType* ComputeInitialType() const; | 3703 virtual CompileType* ComputeInitialType() const; |
| 3700 | 3704 |
| 3701 virtual Representation representation() const { | 3705 virtual Representation representation() const { |
| 3702 return kUnboxedMint; | 3706 return kUnboxedMint; |
| 3703 } | 3707 } |
| 3704 | 3708 |
| 3705 virtual Representation RequiredInputRepresentation(intptr_t idx) const { | 3709 virtual Representation RequiredInputRepresentation(intptr_t idx) const { |
| 3706 ASSERT((idx == 0) || (idx == 1)); | 3710 ASSERT((idx == 0) || (idx == 1)); |
| 3707 return kUnboxedMint; | 3711 return kUnboxedMint; |
| 3708 } | 3712 } |
| 3709 | 3713 |
| 3710 virtual intptr_t DeoptimizationTarget() const { | 3714 virtual intptr_t DeoptimizationTarget() const { |
| 3711 // Direct access since this instruction cannot deoptimize, and the deopt-id | 3715 // Direct access since this instruction cannot deoptimize, and the deopt-id |
| 3712 // was inherited from another instruction that could deoptimize. | 3716 // was inherited from another instruction that could deoptimize. |
| 3713 return deopt_id_; | 3717 return deopt_id_; |
| 3714 } | 3718 } |
| 3715 | 3719 |
| 3716 virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer); | 3720 virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer); |
| 3717 | 3721 |
| 3718 DECLARE_INSTRUCTION(BinaryMintOp) | 3722 DECLARE_INSTRUCTION(BinaryMintOp) |
| 3719 | 3723 |
| 3720 private: | 3724 private: |
| 3721 const Token::Kind op_kind_; | 3725 const Token::Kind op_kind_; |
| 3726 InstanceCallInstr* instance_call_; |
| 3722 | 3727 |
| 3723 DISALLOW_COPY_AND_ASSIGN(BinaryMintOpInstr); | 3728 DISALLOW_COPY_AND_ASSIGN(BinaryMintOpInstr); |
| 3724 }; | 3729 }; |
| 3725 | 3730 |
| 3726 | 3731 |
| 3727 class ShiftMintOpInstr : public TemplateDefinition<2> { | 3732 class ShiftMintOpInstr : public TemplateDefinition<2> { |
| 3728 public: | 3733 public: |
| 3729 ShiftMintOpInstr(Token::Kind op_kind, | 3734 ShiftMintOpInstr(Token::Kind op_kind, |
| 3730 Value* left, | 3735 Value* left, |
| 3731 Value* right, | 3736 Value* right, |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3837 | 3842 |
| 3838 | 3843 |
| 3839 class BinarySmiOpInstr : public TemplateDefinition<2> { | 3844 class BinarySmiOpInstr : public TemplateDefinition<2> { |
| 3840 public: | 3845 public: |
| 3841 BinarySmiOpInstr(Token::Kind op_kind, | 3846 BinarySmiOpInstr(Token::Kind op_kind, |
| 3842 InstanceCallInstr* instance_call, | 3847 InstanceCallInstr* instance_call, |
| 3843 Value* left, | 3848 Value* left, |
| 3844 Value* right) | 3849 Value* right) |
| 3845 : op_kind_(op_kind), | 3850 : op_kind_(op_kind), |
| 3846 instance_call_(instance_call), | 3851 instance_call_(instance_call), |
| 3847 overflow_(true) { | 3852 overflow_(true), |
| 3853 is_truncating_(false) { |
| 3848 ASSERT(left != NULL); | 3854 ASSERT(left != NULL); |
| 3849 ASSERT(right != NULL); | 3855 ASSERT(right != NULL); |
| 3850 inputs_[0] = left; | 3856 inputs_[0] = left; |
| 3851 inputs_[1] = right; | 3857 inputs_[1] = right; |
| 3852 deopt_id_ = instance_call->deopt_id(); | 3858 deopt_id_ = instance_call->deopt_id(); |
| 3853 } | 3859 } |
| 3854 | 3860 |
| 3855 Value* left() const { return inputs_[0]; } | 3861 Value* left() const { return inputs_[0]; } |
| 3856 Value* right() const { return inputs_[1]; } | 3862 Value* right() const { return inputs_[1]; } |
| 3857 | 3863 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 3871 | 3877 |
| 3872 virtual bool HasSideEffect() const { return false; } | 3878 virtual bool HasSideEffect() const { return false; } |
| 3873 | 3879 |
| 3874 virtual bool AffectedBySideEffect() const { return false; } | 3880 virtual bool AffectedBySideEffect() const { return false; } |
| 3875 virtual bool AttributesEqual(Instruction* other) const; | 3881 virtual bool AttributesEqual(Instruction* other) const; |
| 3876 | 3882 |
| 3877 void set_overflow(bool overflow) { | 3883 void set_overflow(bool overflow) { |
| 3878 overflow_ = overflow; | 3884 overflow_ = overflow; |
| 3879 } | 3885 } |
| 3880 | 3886 |
| 3887 void set_is_truncating(bool value) { |
| 3888 is_truncating_ = value; |
| 3889 } |
| 3890 bool is_truncating() const { return is_truncating_; } |
| 3891 |
| 3881 void PrintTo(BufferFormatter* f) const; | 3892 void PrintTo(BufferFormatter* f) const; |
| 3882 | 3893 |
| 3883 virtual void InferRange(); | 3894 virtual void InferRange(); |
| 3884 | 3895 |
| 3885 virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer); | 3896 virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer); |
| 3886 | 3897 |
| 3887 // Returns true if right is a non-zero Smi constant which absolute value is | 3898 // Returns true if right is a non-zero Smi constant which absolute value is |
| 3888 // a power of two. | 3899 // a power of two. |
| 3889 bool RightIsPowerOfTwoConstant() const; | 3900 bool RightIsPowerOfTwoConstant() const; |
| 3890 | 3901 |
| 3891 private: | 3902 private: |
| 3892 const Token::Kind op_kind_; | 3903 const Token::Kind op_kind_; |
| 3893 InstanceCallInstr* instance_call_; | 3904 InstanceCallInstr* instance_call_; |
| 3894 bool overflow_; | 3905 bool overflow_; |
| 3906 bool is_truncating_; |
| 3895 | 3907 |
| 3896 DISALLOW_COPY_AND_ASSIGN(BinarySmiOpInstr); | 3908 DISALLOW_COPY_AND_ASSIGN(BinarySmiOpInstr); |
| 3897 }; | 3909 }; |
| 3898 | 3910 |
| 3899 | 3911 |
| 3900 // Handles both Smi operations: BIT_OR and NEGATE. | 3912 // Handles both Smi operations: BIT_OR and NEGATE. |
| 3901 class UnarySmiOpInstr : public TemplateDefinition<1> { | 3913 class UnarySmiOpInstr : public TemplateDefinition<1> { |
| 3902 public: | 3914 public: |
| 3903 UnarySmiOpInstr(Token::Kind op_kind, | 3915 UnarySmiOpInstr(Token::Kind op_kind, |
| 3904 InstanceCallInstr* instance_call, | 3916 InstanceCallInstr* instance_call, |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4470 ForwardInstructionIterator* current_iterator_; | 4482 ForwardInstructionIterator* current_iterator_; |
| 4471 | 4483 |
| 4472 private: | 4484 private: |
| 4473 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 4485 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 4474 }; | 4486 }; |
| 4475 | 4487 |
| 4476 | 4488 |
| 4477 } // namespace dart | 4489 } // namespace dart |
| 4478 | 4490 |
| 4479 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 4491 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |