Chromium Code Reviews| 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 234 | 234 |
| 235 Definition* definition() const { return definition_; } | 235 Definition* definition() const { return definition_; } |
| 236 void set_definition(Definition* definition) { definition_ = definition; } | 236 void set_definition(Definition* definition) { definition_ = definition; } |
| 237 | 237 |
| 238 Value* previous_use() const { return previous_use_; } | 238 Value* previous_use() const { return previous_use_; } |
| 239 void set_previous_use(Value* previous) { previous_use_ = previous; } | 239 void set_previous_use(Value* previous) { previous_use_ = previous; } |
| 240 | 240 |
| 241 Value* next_use() const { return next_use_; } | 241 Value* next_use() const { return next_use_; } |
| 242 void set_next_use(Value* next) { next_use_ = next; } | 242 void set_next_use(Value* next) { next_use_ = next; } |
| 243 | 243 |
| 244 bool IsSingleUse() const { | |
| 245 return (next_use_ == NULL) && (previous_use_ == NULL); | |
|
Florian Schneider
2013/02/21 10:30:47
We have env_use_list to keep track of environment
Kevin Millikin (Google)
2013/02/21 12:44:35
Drive by to the drive by. I think it's more natur
srdjan
2013/02/21 15:56:27
We remove environment use list lazily in register
| |
| 246 } | |
| 247 | |
| 244 Instruction* instruction() const { return instruction_; } | 248 Instruction* instruction() const { return instruction_; } |
| 245 void set_instruction(Instruction* instruction) { instruction_ = instruction; } | 249 void set_instruction(Instruction* instruction) { instruction_ = instruction; } |
| 246 | 250 |
| 247 intptr_t use_index() const { return use_index_; } | 251 intptr_t use_index() const { return use_index_; } |
| 248 void set_use_index(intptr_t index) { use_index_ = index; } | 252 void set_use_index(intptr_t index) { use_index_ = index; } |
| 249 | 253 |
| 250 static void AddToList(Value* value, Value** list); | 254 static void AddToList(Value* value, Value** list); |
| 251 void RemoveFromUseList(); | 255 void RemoveFromUseList(); |
| 252 | 256 |
| 253 Value* Copy() { return new Value(definition_); } | 257 Value* Copy() { return new Value(definition_); } |
| (...skipping 3412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3666 DISALLOW_COPY_AND_ASSIGN(BinaryDoubleOpInstr); | 3670 DISALLOW_COPY_AND_ASSIGN(BinaryDoubleOpInstr); |
| 3667 }; | 3671 }; |
| 3668 | 3672 |
| 3669 | 3673 |
| 3670 class BinaryMintOpInstr : public TemplateDefinition<2> { | 3674 class BinaryMintOpInstr : public TemplateDefinition<2> { |
| 3671 public: | 3675 public: |
| 3672 BinaryMintOpInstr(Token::Kind op_kind, | 3676 BinaryMintOpInstr(Token::Kind op_kind, |
| 3673 Value* left, | 3677 Value* left, |
| 3674 Value* right, | 3678 Value* right, |
| 3675 InstanceCallInstr* instance_call) | 3679 InstanceCallInstr* instance_call) |
| 3676 : op_kind_(op_kind) { | 3680 : op_kind_(op_kind), |
| 3681 instance_call_(instance_call) { | |
| 3677 ASSERT(left != NULL); | 3682 ASSERT(left != NULL); |
| 3678 ASSERT(right != NULL); | 3683 ASSERT(right != NULL); |
| 3679 inputs_[0] = left; | 3684 inputs_[0] = left; |
| 3680 inputs_[1] = right; | 3685 inputs_[1] = right; |
| 3681 deopt_id_ = instance_call->deopt_id(); | 3686 deopt_id_ = instance_call->deopt_id(); |
| 3682 } | 3687 } |
| 3683 | 3688 |
| 3684 Value* left() const { return inputs_[0]; } | 3689 Value* left() const { return inputs_[0]; } |
| 3685 Value* right() const { return inputs_[1]; } | 3690 Value* right() const { return inputs_[1]; } |
| 3686 | 3691 |
| 3687 Token::Kind op_kind() const { return op_kind_; } | 3692 Token::Kind op_kind() const { return op_kind_; } |
| 3688 | 3693 |
| 3694 InstanceCallInstr* instance_call() const { return instance_call_; } | |
| 3695 | |
| 3689 virtual void PrintOperandsTo(BufferFormatter* f) const; | 3696 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 3690 | 3697 |
| 3691 virtual bool CanDeoptimize() const { | 3698 virtual bool CanDeoptimize() const { |
| 3692 return (op_kind() == Token::kADD) || (op_kind() == Token::kSUB); | 3699 return (op_kind() == Token::kADD) || (op_kind() == Token::kSUB); |
| 3693 } | 3700 } |
| 3694 | 3701 |
| 3695 virtual bool HasSideEffect() const { return false; } | 3702 virtual bool HasSideEffect() const { return false; } |
| 3696 | 3703 |
| 3697 virtual bool AffectedBySideEffect() const { return false; } | 3704 virtual bool AffectedBySideEffect() const { return false; } |
| 3698 | 3705 |
| 3699 virtual bool AttributesEqual(Instruction* other) const { | 3706 virtual bool AttributesEqual(Instruction* other) const { |
| 3707 ASSERT(other->IsBinaryMintOp()); | |
| 3700 return op_kind() == other->AsBinaryMintOp()->op_kind(); | 3708 return op_kind() == other->AsBinaryMintOp()->op_kind(); |
| 3701 } | 3709 } |
| 3702 | 3710 |
| 3703 virtual CompileType* ComputeInitialType() const; | 3711 virtual CompileType* ComputeInitialType() const; |
| 3704 | 3712 |
| 3705 virtual Representation representation() const { | 3713 virtual Representation representation() const { |
| 3706 return kUnboxedMint; | 3714 return kUnboxedMint; |
| 3707 } | 3715 } |
| 3708 | 3716 |
| 3709 virtual Representation RequiredInputRepresentation(intptr_t idx) const { | 3717 virtual Representation RequiredInputRepresentation(intptr_t idx) const { |
| 3710 ASSERT((idx == 0) || (idx == 1)); | 3718 ASSERT((idx == 0) || (idx == 1)); |
| 3711 return kUnboxedMint; | 3719 return kUnboxedMint; |
| 3712 } | 3720 } |
| 3713 | 3721 |
| 3714 virtual intptr_t DeoptimizationTarget() const { | 3722 virtual intptr_t DeoptimizationTarget() const { |
| 3715 // Direct access since this instruction cannot deoptimize, and the deopt-id | 3723 // Direct access since this instruction cannot deoptimize, and the deopt-id |
| 3716 // was inherited from another instruction that could deoptimize. | 3724 // was inherited from another instruction that could deoptimize. |
| 3717 return deopt_id_; | 3725 return deopt_id_; |
| 3718 } | 3726 } |
| 3719 | 3727 |
| 3720 virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer); | 3728 virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer); |
| 3721 | 3729 |
| 3722 DECLARE_INSTRUCTION(BinaryMintOp) | 3730 DECLARE_INSTRUCTION(BinaryMintOp) |
| 3723 | 3731 |
| 3724 private: | 3732 private: |
| 3725 const Token::Kind op_kind_; | 3733 const Token::Kind op_kind_; |
| 3734 InstanceCallInstr* instance_call_; | |
| 3726 | 3735 |
| 3727 DISALLOW_COPY_AND_ASSIGN(BinaryMintOpInstr); | 3736 DISALLOW_COPY_AND_ASSIGN(BinaryMintOpInstr); |
| 3728 }; | 3737 }; |
| 3729 | 3738 |
| 3730 | 3739 |
| 3731 class ShiftMintOpInstr : public TemplateDefinition<2> { | 3740 class ShiftMintOpInstr : public TemplateDefinition<2> { |
| 3732 public: | 3741 public: |
| 3733 ShiftMintOpInstr(Token::Kind op_kind, | 3742 ShiftMintOpInstr(Token::Kind op_kind, |
| 3734 Value* left, | 3743 Value* left, |
| 3735 Value* right, | 3744 Value* right, |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3841 | 3850 |
| 3842 | 3851 |
| 3843 class BinarySmiOpInstr : public TemplateDefinition<2> { | 3852 class BinarySmiOpInstr : public TemplateDefinition<2> { |
| 3844 public: | 3853 public: |
| 3845 BinarySmiOpInstr(Token::Kind op_kind, | 3854 BinarySmiOpInstr(Token::Kind op_kind, |
| 3846 InstanceCallInstr* instance_call, | 3855 InstanceCallInstr* instance_call, |
| 3847 Value* left, | 3856 Value* left, |
| 3848 Value* right) | 3857 Value* right) |
| 3849 : op_kind_(op_kind), | 3858 : op_kind_(op_kind), |
| 3850 instance_call_(instance_call), | 3859 instance_call_(instance_call), |
| 3851 overflow_(true) { | 3860 overflow_(true), |
| 3861 is_truncating_(false) { | |
| 3852 ASSERT(left != NULL); | 3862 ASSERT(left != NULL); |
| 3853 ASSERT(right != NULL); | 3863 ASSERT(right != NULL); |
| 3854 inputs_[0] = left; | 3864 inputs_[0] = left; |
| 3855 inputs_[1] = right; | 3865 inputs_[1] = right; |
| 3856 deopt_id_ = instance_call->deopt_id(); | 3866 deopt_id_ = instance_call->deopt_id(); |
| 3857 } | 3867 } |
| 3858 | 3868 |
| 3859 Value* left() const { return inputs_[0]; } | 3869 Value* left() const { return inputs_[0]; } |
| 3860 Value* right() const { return inputs_[1]; } | 3870 Value* right() const { return inputs_[1]; } |
| 3861 | 3871 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 3875 | 3885 |
| 3876 virtual bool HasSideEffect() const { return false; } | 3886 virtual bool HasSideEffect() const { return false; } |
| 3877 | 3887 |
| 3878 virtual bool AffectedBySideEffect() const { return false; } | 3888 virtual bool AffectedBySideEffect() const { return false; } |
| 3879 virtual bool AttributesEqual(Instruction* other) const; | 3889 virtual bool AttributesEqual(Instruction* other) const; |
| 3880 | 3890 |
| 3881 void set_overflow(bool overflow) { | 3891 void set_overflow(bool overflow) { |
| 3882 overflow_ = overflow; | 3892 overflow_ = overflow; |
| 3883 } | 3893 } |
| 3884 | 3894 |
| 3895 void set_is_truncating(bool value) { | |
| 3896 is_truncating_ = value; | |
| 3897 } | |
| 3898 bool is_truncating() const { return is_truncating_; } | |
| 3899 | |
| 3885 void PrintTo(BufferFormatter* f) const; | 3900 void PrintTo(BufferFormatter* f) const; |
| 3886 | 3901 |
| 3887 virtual void InferRange(); | 3902 virtual void InferRange(); |
| 3888 | 3903 |
| 3889 virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer); | 3904 virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer); |
| 3890 | 3905 |
| 3891 // Returns true if right is a non-zero Smi constant which absolute value is | 3906 // Returns true if right is a non-zero Smi constant which absolute value is |
| 3892 // a power of two. | 3907 // a power of two. |
| 3893 bool RightIsPowerOfTwoConstant() const; | 3908 bool RightIsPowerOfTwoConstant() const; |
| 3894 | 3909 |
| 3895 private: | 3910 private: |
| 3896 const Token::Kind op_kind_; | 3911 const Token::Kind op_kind_; |
| 3897 InstanceCallInstr* instance_call_; | 3912 InstanceCallInstr* instance_call_; |
| 3898 bool overflow_; | 3913 bool overflow_; |
| 3914 bool is_truncating_; | |
| 3899 | 3915 |
| 3900 DISALLOW_COPY_AND_ASSIGN(BinarySmiOpInstr); | 3916 DISALLOW_COPY_AND_ASSIGN(BinarySmiOpInstr); |
| 3901 }; | 3917 }; |
| 3902 | 3918 |
| 3903 | 3919 |
| 3904 // Handles both Smi operations: BIT_OR and NEGATE. | 3920 // Handles both Smi operations: BIT_OR and NEGATE. |
| 3905 class UnarySmiOpInstr : public TemplateDefinition<1> { | 3921 class UnarySmiOpInstr : public TemplateDefinition<1> { |
| 3906 public: | 3922 public: |
| 3907 UnarySmiOpInstr(Token::Kind op_kind, | 3923 UnarySmiOpInstr(Token::Kind op_kind, |
| 3908 InstanceCallInstr* instance_call, | 3924 InstanceCallInstr* instance_call, |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4474 ForwardInstructionIterator* current_iterator_; | 4490 ForwardInstructionIterator* current_iterator_; |
| 4475 | 4491 |
| 4476 private: | 4492 private: |
| 4477 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 4493 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 4478 }; | 4494 }; |
| 4479 | 4495 |
| 4480 | 4496 |
| 4481 } // namespace dart | 4497 } // namespace dart |
| 4482 | 4498 |
| 4483 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 4499 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |