| 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 3176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3187 : num_temps_(num_temps) { | 3187 : num_temps_(num_temps) { |
| 3188 SetInputAt(0, value); | 3188 SetInputAt(0, value); |
| 3189 } | 3189 } |
| 3190 | 3190 |
| 3191 DECLARE_INSTRUCTION(DropTemps) | 3191 DECLARE_INSTRUCTION(DropTemps) |
| 3192 | 3192 |
| 3193 Value* value() const { return inputs_[0]; } | 3193 Value* value() const { return inputs_[0]; } |
| 3194 | 3194 |
| 3195 intptr_t num_temps() const { return num_temps_; } | 3195 intptr_t num_temps() const { return num_temps_; } |
| 3196 | 3196 |
| 3197 virtual CompileType ComputeType() const; | 3197 virtual CompileType* ComputeInitialType() const; |
| 3198 | 3198 |
| 3199 virtual bool CanDeoptimize() const { return false; } | 3199 virtual bool CanDeoptimize() const { return false; } |
| 3200 | 3200 |
| 3201 virtual EffectSet Effects() const { | 3201 virtual EffectSet Effects() const { |
| 3202 UNREACHABLE(); // Eliminated by SSA construction. | 3202 UNREACHABLE(); // Eliminated by SSA construction. |
| 3203 return EffectSet::None(); | 3203 return EffectSet::None(); |
| 3204 } | 3204 } |
| 3205 | 3205 |
| 3206 virtual bool MayThrow() const { | 3206 virtual bool MayThrow() const { |
| 3207 UNREACHABLE(); | 3207 UNREACHABLE(); |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3671 Value* type_arguments_; | 3671 Value* type_arguments_; |
| 3672 const AbstractType& type_; | 3672 const AbstractType& type_; |
| 3673 const bool negate_result_; | 3673 const bool negate_result_; |
| 3674 | 3674 |
| 3675 DISALLOW_COPY_AND_ASSIGN(InstanceOfInstr); | 3675 DISALLOW_COPY_AND_ASSIGN(InstanceOfInstr); |
| 3676 }; | 3676 }; |
| 3677 | 3677 |
| 3678 | 3678 |
| 3679 class AllocateObjectInstr : public TemplateDefinition<0> { | 3679 class AllocateObjectInstr : public TemplateDefinition<0> { |
| 3680 public: | 3680 public: |
| 3681 AllocateObjectInstr(ConstructorCallNode* node, | 3681 AllocateObjectInstr(intptr_t token_pos, |
| 3682 const Class& cls, |
| 3682 ZoneGrowableArray<PushArgumentInstr*>* arguments) | 3683 ZoneGrowableArray<PushArgumentInstr*>* arguments) |
| 3683 : ast_node_(*node), | 3684 : token_pos_(token_pos), |
| 3685 cls_(cls), |
| 3684 arguments_(arguments), | 3686 arguments_(arguments), |
| 3685 cid_(Class::Handle(node->constructor().Owner()).id()), | 3687 identity_(kUnknown), |
| 3686 identity_(kUnknown) { | 3688 closure_function_(Function::ZoneHandle()), |
| 3689 context_field_(Field::ZoneHandle()) { |
| 3687 // Either no arguments or one type-argument and one instantiator. | 3690 // Either no arguments or one type-argument and one instantiator. |
| 3688 ASSERT(arguments->is_empty() || (arguments->length() == 2)); | 3691 ASSERT(arguments->is_empty() || (arguments->length() == 2)); |
| 3689 } | 3692 } |
| 3690 | 3693 |
| 3691 DECLARE_INSTRUCTION(AllocateObject) | 3694 DECLARE_INSTRUCTION(AllocateObject) |
| 3692 virtual CompileType ComputeType() const; | 3695 virtual CompileType ComputeType() const; |
| 3693 | 3696 |
| 3694 virtual intptr_t ArgumentCount() const { return arguments_->length(); } | 3697 virtual intptr_t ArgumentCount() const { return arguments_->length(); } |
| 3695 virtual PushArgumentInstr* PushArgumentAt(intptr_t index) const { | 3698 virtual PushArgumentInstr* PushArgumentAt(intptr_t index) const { |
| 3696 return (*arguments_)[index]; | 3699 return (*arguments_)[index]; |
| 3697 } | 3700 } |
| 3698 | 3701 |
| 3699 const Function& constructor() const { return ast_node_.constructor(); } | 3702 const Class& cls() const { return cls_; } |
| 3700 intptr_t token_pos() const { return ast_node_.token_pos(); } | 3703 intptr_t token_pos() const { return token_pos_; } |
| 3704 |
| 3705 const Function& closure_function() const { return closure_function_; } |
| 3706 void set_closure_function(const Function& function) { |
| 3707 closure_function_ ^= function.raw(); |
| 3708 } |
| 3709 |
| 3710 const Field& context_field() const { return context_field_; } |
| 3711 void set_context_field(const Field& field) { |
| 3712 context_field_ ^= field.raw(); |
| 3713 } |
| 3701 | 3714 |
| 3702 virtual void PrintOperandsTo(BufferFormatter* f) const; | 3715 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 3703 | 3716 |
| 3704 virtual bool CanDeoptimize() const { return false; } | 3717 virtual bool CanDeoptimize() const { return false; } |
| 3705 | 3718 |
| 3706 virtual EffectSet Effects() const { return EffectSet::None(); } | 3719 virtual EffectSet Effects() const { return EffectSet::None(); } |
| 3707 | 3720 |
| 3708 virtual bool MayThrow() const { return false; } | 3721 virtual bool MayThrow() const { return false; } |
| 3709 | 3722 |
| 3710 // If the result of the allocation is not stored into any field, passed | 3723 // If the result of the allocation is not stored into any field, passed |
| 3711 // as an argument or used in a phi then it can't alias with any other | 3724 // as an argument or used in a phi then it can't alias with any other |
| 3712 // SSA value. | 3725 // SSA value. |
| 3713 enum Identity { | 3726 enum Identity { |
| 3714 kUnknown, | 3727 kUnknown, |
| 3715 kAliased, | 3728 kAliased, |
| 3716 kNotAliased | 3729 kNotAliased |
| 3717 }; | 3730 }; |
| 3718 | 3731 |
| 3719 Identity identity() const { return identity_; } | 3732 Identity identity() const { return identity_; } |
| 3720 void set_identity(Identity identity) { identity_ = identity; } | 3733 void set_identity(Identity identity) { identity_ = identity; } |
| 3721 | 3734 |
| 3722 private: | 3735 private: |
| 3723 const ConstructorCallNode& ast_node_; | 3736 const intptr_t token_pos_; |
| 3737 const Class& cls_; |
| 3724 ZoneGrowableArray<PushArgumentInstr*>* const arguments_; | 3738 ZoneGrowableArray<PushArgumentInstr*>* const arguments_; |
| 3725 const intptr_t cid_; | |
| 3726 Identity identity_; | 3739 Identity identity_; |
| 3740 Function& closure_function_; |
| 3741 Field& context_field_; |
| 3727 | 3742 |
| 3728 DISALLOW_COPY_AND_ASSIGN(AllocateObjectInstr); | 3743 DISALLOW_COPY_AND_ASSIGN(AllocateObjectInstr); |
| 3729 }; | 3744 }; |
| 3730 | 3745 |
| 3731 | 3746 |
| 3732 // This instruction captures the state of the object which had its allocation | 3747 // This instruction captures the state of the object which had its allocation |
| 3733 // removed during the AllocationSinking pass. | 3748 // removed during the AllocationSinking pass. |
| 3734 // It does not produce any real code only deoptimization information. | 3749 // It does not produce any real code only deoptimization information. |
| 3735 class MaterializeObjectInstr : public Definition { | 3750 class MaterializeObjectInstr : public Definition { |
| 3736 public: | 3751 public: |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3965 public: | 3980 public: |
| 3966 LoadFieldInstr(Value* instance, | 3981 LoadFieldInstr(Value* instance, |
| 3967 intptr_t offset_in_bytes, | 3982 intptr_t offset_in_bytes, |
| 3968 const AbstractType& type, | 3983 const AbstractType& type, |
| 3969 bool immutable = false) | 3984 bool immutable = false) |
| 3970 : offset_in_bytes_(offset_in_bytes), | 3985 : offset_in_bytes_(offset_in_bytes), |
| 3971 type_(type), | 3986 type_(type), |
| 3972 result_cid_(kDynamicCid), | 3987 result_cid_(kDynamicCid), |
| 3973 immutable_(immutable), | 3988 immutable_(immutable), |
| 3974 recognized_kind_(MethodRecognizer::kUnknown), | 3989 recognized_kind_(MethodRecognizer::kUnknown), |
| 3975 field_name_(NULL), | |
| 3976 field_(NULL) { | 3990 field_(NULL) { |
| 3977 ASSERT(type.IsZoneHandle()); // May be null if field is not an instance. | 3991 ASSERT(type.IsZoneHandle()); // May be null if field is not an instance. |
| 3978 SetInputAt(0, instance); | 3992 SetInputAt(0, instance); |
| 3979 } | 3993 } |
| 3980 | 3994 |
| 3981 Value* instance() const { return inputs_[0]; } | 3995 Value* instance() const { return inputs_[0]; } |
| 3982 intptr_t offset_in_bytes() const { return offset_in_bytes_; } | 3996 intptr_t offset_in_bytes() const { return offset_in_bytes_; } |
| 3983 const AbstractType& type() const { return type_; } | 3997 const AbstractType& type() const { return type_; } |
| 3984 void set_result_cid(intptr_t value) { result_cid_ = value; } | 3998 void set_result_cid(intptr_t value) { result_cid_ = value; } |
| 3985 intptr_t result_cid() const { return result_cid_; } | 3999 intptr_t result_cid() const { return result_cid_; } |
| 3986 | 4000 |
| 3987 void set_field_name(const char* name) { field_name_ = name; } | |
| 3988 const char* field_name() const { return field_name_; } | |
| 3989 | |
| 3990 const Field* field() const { return field_; } | 4001 const Field* field() const { return field_; } |
| 3991 void set_field(const Field* field) { field_ = field; } | 4002 void set_field(const Field* field) { field_ = field; } |
| 3992 | 4003 |
| 3993 void set_recognized_kind(MethodRecognizer::Kind kind) { | 4004 void set_recognized_kind(MethodRecognizer::Kind kind) { |
| 3994 recognized_kind_ = kind; | 4005 recognized_kind_ = kind; |
| 3995 } | 4006 } |
| 3996 | 4007 |
| 3997 MethodRecognizer::Kind recognized_kind() const { | 4008 MethodRecognizer::Kind recognized_kind() const { |
| 3998 return recognized_kind_; | 4009 return recognized_kind_; |
| 3999 } | 4010 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 4023 virtual bool MayThrow() const { return false; } | 4034 virtual bool MayThrow() const { return false; } |
| 4024 | 4035 |
| 4025 private: | 4036 private: |
| 4026 const intptr_t offset_in_bytes_; | 4037 const intptr_t offset_in_bytes_; |
| 4027 const AbstractType& type_; | 4038 const AbstractType& type_; |
| 4028 intptr_t result_cid_; | 4039 intptr_t result_cid_; |
| 4029 const bool immutable_; | 4040 const bool immutable_; |
| 4030 | 4041 |
| 4031 MethodRecognizer::Kind recognized_kind_; | 4042 MethodRecognizer::Kind recognized_kind_; |
| 4032 | 4043 |
| 4033 const char* field_name_; | |
| 4034 const Field* field_; | 4044 const Field* field_; |
| 4035 | 4045 |
| 4036 DISALLOW_COPY_AND_ASSIGN(LoadFieldInstr); | 4046 DISALLOW_COPY_AND_ASSIGN(LoadFieldInstr); |
| 4037 }; | 4047 }; |
| 4038 | 4048 |
| 4039 | 4049 |
| 4040 class StoreVMFieldInstr : public TemplateDefinition<2> { | 4050 class StoreVMFieldInstr : public TemplateDefinition<2> { |
| 4041 public: | 4051 public: |
| 4042 StoreVMFieldInstr(Value* dest, | 4052 StoreVMFieldInstr(Value* dest, |
| 4043 intptr_t offset_in_bytes, | 4053 intptr_t offset_in_bytes, |
| (...skipping 2572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6616 ForwardInstructionIterator* current_iterator_; | 6626 ForwardInstructionIterator* current_iterator_; |
| 6617 | 6627 |
| 6618 private: | 6628 private: |
| 6619 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 6629 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 6620 }; | 6630 }; |
| 6621 | 6631 |
| 6622 | 6632 |
| 6623 } // namespace dart | 6633 } // namespace dart |
| 6624 | 6634 |
| 6625 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 6635 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |