| 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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 | 246 |
| 247 Definition* definition() const { return definition_; } | 247 Definition* definition() const { return definition_; } |
| 248 void set_definition(Definition* definition) { definition_ = definition; } | 248 void set_definition(Definition* definition) { definition_ = definition; } |
| 249 | 249 |
| 250 Value* previous_use() const { return previous_use_; } | 250 Value* previous_use() const { return previous_use_; } |
| 251 void set_previous_use(Value* previous) { previous_use_ = previous; } | 251 void set_previous_use(Value* previous) { previous_use_ = previous; } |
| 252 | 252 |
| 253 Value* next_use() const { return next_use_; } | 253 Value* next_use() const { return next_use_; } |
| 254 void set_next_use(Value* next) { next_use_ = next; } | 254 void set_next_use(Value* next) { next_use_ = next; } |
| 255 | 255 |
| 256 bool IsSingleUse() const { |
| 257 return (next_use_ == NULL) && (previous_use_ == NULL); |
| 258 } |
| 259 |
| 256 Instruction* instruction() const { return instruction_; } | 260 Instruction* instruction() const { return instruction_; } |
| 257 void set_instruction(Instruction* instruction) { instruction_ = instruction; } | 261 void set_instruction(Instruction* instruction) { instruction_ = instruction; } |
| 258 | 262 |
| 259 intptr_t use_index() const { return use_index_; } | 263 intptr_t use_index() const { return use_index_; } |
| 260 void set_use_index(intptr_t index) { use_index_ = index; } | 264 void set_use_index(intptr_t index) { use_index_ = index; } |
| 261 | 265 |
| 262 static void AddToList(Value* value, Value** list); | 266 static void AddToList(Value* value, Value** list); |
| 263 void RemoveFromUseList(); | 267 void RemoveFromUseList(); |
| 264 | 268 |
| 265 Value* Copy() { return new Value(definition_); } | 269 Value* Copy() { return new Value(definition_); } |
| (...skipping 3413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3679 DISALLOW_COPY_AND_ASSIGN(BinaryDoubleOpInstr); | 3683 DISALLOW_COPY_AND_ASSIGN(BinaryDoubleOpInstr); |
| 3680 }; | 3684 }; |
| 3681 | 3685 |
| 3682 | 3686 |
| 3683 class BinaryMintOpInstr : public TemplateDefinition<2> { | 3687 class BinaryMintOpInstr : public TemplateDefinition<2> { |
| 3684 public: | 3688 public: |
| 3685 BinaryMintOpInstr(Token::Kind op_kind, | 3689 BinaryMintOpInstr(Token::Kind op_kind, |
| 3686 Value* left, | 3690 Value* left, |
| 3687 Value* right, | 3691 Value* right, |
| 3688 InstanceCallInstr* instance_call) | 3692 InstanceCallInstr* instance_call) |
| 3689 : op_kind_(op_kind) { | 3693 : op_kind_(op_kind), |
| 3694 instance_call_(instance_call) { |
| 3690 ASSERT(left != NULL); | 3695 ASSERT(left != NULL); |
| 3691 ASSERT(right != NULL); | 3696 ASSERT(right != NULL); |
| 3692 inputs_[0] = left; | 3697 inputs_[0] = left; |
| 3693 inputs_[1] = right; | 3698 inputs_[1] = right; |
| 3694 deopt_id_ = instance_call->deopt_id(); | 3699 deopt_id_ = instance_call->deopt_id(); |
| 3695 } | 3700 } |
| 3696 | 3701 |
| 3697 Value* left() const { return inputs_[0]; } | 3702 Value* left() const { return inputs_[0]; } |
| 3698 Value* right() const { return inputs_[1]; } | 3703 Value* right() const { return inputs_[1]; } |
| 3699 | 3704 |
| 3700 Token::Kind op_kind() const { return op_kind_; } | 3705 Token::Kind op_kind() const { return op_kind_; } |
| 3701 | 3706 |
| 3707 InstanceCallInstr* instance_call() const { return instance_call_; } |
| 3708 |
| 3702 virtual void PrintOperandsTo(BufferFormatter* f) const; | 3709 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 3703 | 3710 |
| 3704 virtual bool CanDeoptimize() const { | 3711 virtual bool CanDeoptimize() const { |
| 3705 return (op_kind() == Token::kADD) || (op_kind() == Token::kSUB); | 3712 return (op_kind() == Token::kADD) || (op_kind() == Token::kSUB); |
| 3706 } | 3713 } |
| 3707 | 3714 |
| 3708 virtual bool HasSideEffect() const { return false; } | 3715 virtual bool HasSideEffect() const { return false; } |
| 3709 | 3716 |
| 3710 virtual bool AffectedBySideEffect() const { return false; } | 3717 virtual bool AffectedBySideEffect() const { return false; } |
| 3711 | 3718 |
| 3712 virtual bool AttributesEqual(Instruction* other) const { | 3719 virtual bool AttributesEqual(Instruction* other) const { |
| 3720 ASSERT(other->IsBinaryMintOp()); |
| 3713 return op_kind() == other->AsBinaryMintOp()->op_kind(); | 3721 return op_kind() == other->AsBinaryMintOp()->op_kind(); |
| 3714 } | 3722 } |
| 3715 | 3723 |
| 3716 virtual CompileType* ComputeInitialType() const; | 3724 virtual CompileType* ComputeInitialType() const; |
| 3717 | 3725 |
| 3718 virtual Representation representation() const { | 3726 virtual Representation representation() const { |
| 3719 return kUnboxedMint; | 3727 return kUnboxedMint; |
| 3720 } | 3728 } |
| 3721 | 3729 |
| 3722 virtual Representation RequiredInputRepresentation(intptr_t idx) const { | 3730 virtual Representation RequiredInputRepresentation(intptr_t idx) const { |
| 3723 ASSERT((idx == 0) || (idx == 1)); | 3731 ASSERT((idx == 0) || (idx == 1)); |
| 3724 return kUnboxedMint; | 3732 return kUnboxedMint; |
| 3725 } | 3733 } |
| 3726 | 3734 |
| 3727 virtual intptr_t DeoptimizationTarget() const { | 3735 virtual intptr_t DeoptimizationTarget() const { |
| 3728 // Direct access since this instruction cannot deoptimize, and the deopt-id | 3736 // Direct access since this instruction cannot deoptimize, and the deopt-id |
| 3729 // was inherited from another instruction that could deoptimize. | 3737 // was inherited from another instruction that could deoptimize. |
| 3730 return deopt_id_; | 3738 return deopt_id_; |
| 3731 } | 3739 } |
| 3732 | 3740 |
| 3733 virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer); | 3741 virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer); |
| 3734 | 3742 |
| 3735 DECLARE_INSTRUCTION(BinaryMintOp) | 3743 DECLARE_INSTRUCTION(BinaryMintOp) |
| 3736 | 3744 |
| 3737 private: | 3745 private: |
| 3738 const Token::Kind op_kind_; | 3746 const Token::Kind op_kind_; |
| 3747 InstanceCallInstr* instance_call_; |
| 3739 | 3748 |
| 3740 DISALLOW_COPY_AND_ASSIGN(BinaryMintOpInstr); | 3749 DISALLOW_COPY_AND_ASSIGN(BinaryMintOpInstr); |
| 3741 }; | 3750 }; |
| 3742 | 3751 |
| 3743 | 3752 |
| 3744 class ShiftMintOpInstr : public TemplateDefinition<2> { | 3753 class ShiftMintOpInstr : public TemplateDefinition<2> { |
| 3745 public: | 3754 public: |
| 3746 ShiftMintOpInstr(Token::Kind op_kind, | 3755 ShiftMintOpInstr(Token::Kind op_kind, |
| 3747 Value* left, | 3756 Value* left, |
| 3748 Value* right, | 3757 Value* right, |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3854 | 3863 |
| 3855 | 3864 |
| 3856 class BinarySmiOpInstr : public TemplateDefinition<2> { | 3865 class BinarySmiOpInstr : public TemplateDefinition<2> { |
| 3857 public: | 3866 public: |
| 3858 BinarySmiOpInstr(Token::Kind op_kind, | 3867 BinarySmiOpInstr(Token::Kind op_kind, |
| 3859 InstanceCallInstr* instance_call, | 3868 InstanceCallInstr* instance_call, |
| 3860 Value* left, | 3869 Value* left, |
| 3861 Value* right) | 3870 Value* right) |
| 3862 : op_kind_(op_kind), | 3871 : op_kind_(op_kind), |
| 3863 instance_call_(instance_call), | 3872 instance_call_(instance_call), |
| 3864 overflow_(true) { | 3873 overflow_(true), |
| 3874 is_truncating_(false) { |
| 3865 ASSERT(left != NULL); | 3875 ASSERT(left != NULL); |
| 3866 ASSERT(right != NULL); | 3876 ASSERT(right != NULL); |
| 3867 inputs_[0] = left; | 3877 inputs_[0] = left; |
| 3868 inputs_[1] = right; | 3878 inputs_[1] = right; |
| 3869 deopt_id_ = instance_call->deopt_id(); | 3879 deopt_id_ = instance_call->deopt_id(); |
| 3870 } | 3880 } |
| 3871 | 3881 |
| 3872 Value* left() const { return inputs_[0]; } | 3882 Value* left() const { return inputs_[0]; } |
| 3873 Value* right() const { return inputs_[1]; } | 3883 Value* right() const { return inputs_[1]; } |
| 3874 | 3884 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 3888 | 3898 |
| 3889 virtual bool HasSideEffect() const { return false; } | 3899 virtual bool HasSideEffect() const { return false; } |
| 3890 | 3900 |
| 3891 virtual bool AffectedBySideEffect() const { return false; } | 3901 virtual bool AffectedBySideEffect() const { return false; } |
| 3892 virtual bool AttributesEqual(Instruction* other) const; | 3902 virtual bool AttributesEqual(Instruction* other) const; |
| 3893 | 3903 |
| 3894 void set_overflow(bool overflow) { | 3904 void set_overflow(bool overflow) { |
| 3895 overflow_ = overflow; | 3905 overflow_ = overflow; |
| 3896 } | 3906 } |
| 3897 | 3907 |
| 3908 void set_is_truncating(bool value) { |
| 3909 is_truncating_ = value; |
| 3910 } |
| 3911 bool is_truncating() const { return is_truncating_; } |
| 3912 |
| 3898 void PrintTo(BufferFormatter* f) const; | 3913 void PrintTo(BufferFormatter* f) const; |
| 3899 | 3914 |
| 3900 virtual void InferRange(); | 3915 virtual void InferRange(); |
| 3901 | 3916 |
| 3902 virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer); | 3917 virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer); |
| 3903 | 3918 |
| 3904 // Returns true if right is a non-zero Smi constant which absolute value is | 3919 // Returns true if right is a non-zero Smi constant which absolute value is |
| 3905 // a power of two. | 3920 // a power of two. |
| 3906 bool RightIsPowerOfTwoConstant() const; | 3921 bool RightIsPowerOfTwoConstant() const; |
| 3907 | 3922 |
| 3908 private: | 3923 private: |
| 3909 const Token::Kind op_kind_; | 3924 const Token::Kind op_kind_; |
| 3910 InstanceCallInstr* instance_call_; | 3925 InstanceCallInstr* instance_call_; |
| 3911 bool overflow_; | 3926 bool overflow_; |
| 3927 bool is_truncating_; |
| 3912 | 3928 |
| 3913 DISALLOW_COPY_AND_ASSIGN(BinarySmiOpInstr); | 3929 DISALLOW_COPY_AND_ASSIGN(BinarySmiOpInstr); |
| 3914 }; | 3930 }; |
| 3915 | 3931 |
| 3916 | 3932 |
| 3917 // Handles both Smi operations: BIT_OR and NEGATE. | 3933 // Handles both Smi operations: BIT_OR and NEGATE. |
| 3918 class UnarySmiOpInstr : public TemplateDefinition<1> { | 3934 class UnarySmiOpInstr : public TemplateDefinition<1> { |
| 3919 public: | 3935 public: |
| 3920 UnarySmiOpInstr(Token::Kind op_kind, | 3936 UnarySmiOpInstr(Token::Kind op_kind, |
| 3921 InstanceCallInstr* instance_call, | 3937 InstanceCallInstr* instance_call, |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4487 ForwardInstructionIterator* current_iterator_; | 4503 ForwardInstructionIterator* current_iterator_; |
| 4488 | 4504 |
| 4489 private: | 4505 private: |
| 4490 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 4506 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 4491 }; | 4507 }; |
| 4492 | 4508 |
| 4493 | 4509 |
| 4494 } // namespace dart | 4510 } // namespace dart |
| 4495 | 4511 |
| 4496 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 4512 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |