| 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 3407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3418 DISALLOW_COPY_AND_ASSIGN(InstanceOfInstr); | 3418 DISALLOW_COPY_AND_ASSIGN(InstanceOfInstr); |
| 3419 }; | 3419 }; |
| 3420 | 3420 |
| 3421 | 3421 |
| 3422 class AllocateObjectInstr : public TemplateDefinition<0> { | 3422 class AllocateObjectInstr : public TemplateDefinition<0> { |
| 3423 public: | 3423 public: |
| 3424 AllocateObjectInstr(ConstructorCallNode* node, | 3424 AllocateObjectInstr(ConstructorCallNode* node, |
| 3425 ZoneGrowableArray<PushArgumentInstr*>* arguments) | 3425 ZoneGrowableArray<PushArgumentInstr*>* arguments) |
| 3426 : ast_node_(*node), | 3426 : ast_node_(*node), |
| 3427 arguments_(arguments), | 3427 arguments_(arguments), |
| 3428 cid_(Class::Handle(node->constructor().Owner()).id()) { | 3428 cid_(Class::Handle(node->constructor().Owner()).id()), |
| 3429 identity_(kUnknown) { |
| 3429 // Either no arguments or one type-argument and one instantiator. | 3430 // Either no arguments or one type-argument and one instantiator. |
| 3430 ASSERT(arguments->is_empty() || (arguments->length() == 2)); | 3431 ASSERT(arguments->is_empty() || (arguments->length() == 2)); |
| 3431 } | 3432 } |
| 3432 | 3433 |
| 3433 DECLARE_INSTRUCTION(AllocateObject) | 3434 DECLARE_INSTRUCTION(AllocateObject) |
| 3434 virtual CompileType ComputeType() const; | 3435 virtual CompileType ComputeType() const; |
| 3435 | 3436 |
| 3436 virtual intptr_t ArgumentCount() const { return arguments_->length(); } | 3437 virtual intptr_t ArgumentCount() const { return arguments_->length(); } |
| 3437 virtual PushArgumentInstr* PushArgumentAt(intptr_t index) const { | 3438 virtual PushArgumentInstr* PushArgumentAt(intptr_t index) const { |
| 3438 return (*arguments_)[index]; | 3439 return (*arguments_)[index]; |
| 3439 } | 3440 } |
| 3440 | 3441 |
| 3441 const Function& constructor() const { return ast_node_.constructor(); } | 3442 const Function& constructor() const { return ast_node_.constructor(); } |
| 3442 intptr_t token_pos() const { return ast_node_.token_pos(); } | 3443 intptr_t token_pos() const { return ast_node_.token_pos(); } |
| 3443 | 3444 |
| 3444 virtual void PrintOperandsTo(BufferFormatter* f) const; | 3445 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 3445 | 3446 |
| 3446 virtual bool CanDeoptimize() const { return false; } | 3447 virtual bool CanDeoptimize() const { return false; } |
| 3447 | 3448 |
| 3448 virtual EffectSet Effects() const { return EffectSet::None(); } | 3449 virtual EffectSet Effects() const { return EffectSet::None(); } |
| 3449 | 3450 |
| 3451 // If the result of the allocation is not stored into any field, passed |
| 3452 // as an argument or used in a phi then it can't alias with any other |
| 3453 // SSA value. |
| 3454 enum Identity { |
| 3455 kUnknown, |
| 3456 kAliased, |
| 3457 kNotAliased |
| 3458 }; |
| 3459 |
| 3460 Identity identity() const { return identity_; } |
| 3461 void set_identity(Identity identity) { identity_ = identity; } |
| 3462 |
| 3450 private: | 3463 private: |
| 3451 const ConstructorCallNode& ast_node_; | 3464 const ConstructorCallNode& ast_node_; |
| 3452 ZoneGrowableArray<PushArgumentInstr*>* const arguments_; | 3465 ZoneGrowableArray<PushArgumentInstr*>* const arguments_; |
| 3453 const intptr_t cid_; | 3466 const intptr_t cid_; |
| 3467 Identity identity_; |
| 3454 | 3468 |
| 3455 DISALLOW_COPY_AND_ASSIGN(AllocateObjectInstr); | 3469 DISALLOW_COPY_AND_ASSIGN(AllocateObjectInstr); |
| 3456 }; | 3470 }; |
| 3457 | 3471 |
| 3458 | 3472 |
| 3459 class AllocateObjectWithBoundsCheckInstr : public TemplateDefinition<2> { | 3473 class AllocateObjectWithBoundsCheckInstr : public TemplateDefinition<2> { |
| 3460 public: | 3474 public: |
| 3461 AllocateObjectWithBoundsCheckInstr(ConstructorCallNode* node, | 3475 AllocateObjectWithBoundsCheckInstr(ConstructorCallNode* node, |
| 3462 Value* type_arguments, | 3476 Value* type_arguments, |
| 3463 Value* instantiator) | 3477 Value* instantiator) |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3585 | 3599 |
| 3586 private: | 3600 private: |
| 3587 intptr_t offset_; | 3601 intptr_t offset_; |
| 3588 | 3602 |
| 3589 DISALLOW_COPY_AND_ASSIGN(LoadUntaggedInstr); | 3603 DISALLOW_COPY_AND_ASSIGN(LoadUntaggedInstr); |
| 3590 }; | 3604 }; |
| 3591 | 3605 |
| 3592 | 3606 |
| 3593 class LoadFieldInstr : public TemplateDefinition<1> { | 3607 class LoadFieldInstr : public TemplateDefinition<1> { |
| 3594 public: | 3608 public: |
| 3595 LoadFieldInstr(Value* value, | 3609 LoadFieldInstr(Value* instance, |
| 3596 intptr_t offset_in_bytes, | 3610 intptr_t offset_in_bytes, |
| 3597 const AbstractType& type, | 3611 const AbstractType& type, |
| 3598 bool immutable = false) | 3612 bool immutable = false) |
| 3599 : offset_in_bytes_(offset_in_bytes), | 3613 : offset_in_bytes_(offset_in_bytes), |
| 3600 type_(type), | 3614 type_(type), |
| 3601 result_cid_(kDynamicCid), | 3615 result_cid_(kDynamicCid), |
| 3602 immutable_(immutable), | 3616 immutable_(immutable), |
| 3603 recognized_kind_(MethodRecognizer::kUnknown), | 3617 recognized_kind_(MethodRecognizer::kUnknown), |
| 3604 field_name_(NULL), | 3618 field_name_(NULL), |
| 3605 field_(NULL) { | 3619 field_(NULL) { |
| 3606 ASSERT(type.IsZoneHandle()); // May be null if field is not an instance. | 3620 ASSERT(type.IsZoneHandle()); // May be null if field is not an instance. |
| 3607 SetInputAt(0, value); | 3621 SetInputAt(0, instance); |
| 3608 } | 3622 } |
| 3609 | 3623 |
| 3610 Value* value() const { return inputs_[0]; } | 3624 Value* instance() const { return inputs_[0]; } |
| 3611 intptr_t offset_in_bytes() const { return offset_in_bytes_; } | 3625 intptr_t offset_in_bytes() const { return offset_in_bytes_; } |
| 3612 const AbstractType& type() const { return type_; } | 3626 const AbstractType& type() const { return type_; } |
| 3613 void set_result_cid(intptr_t value) { result_cid_ = value; } | 3627 void set_result_cid(intptr_t value) { result_cid_ = value; } |
| 3614 intptr_t result_cid() const { return result_cid_; } | 3628 intptr_t result_cid() const { return result_cid_; } |
| 3615 | 3629 |
| 3616 void set_field_name(const char* name) { field_name_ = name; } | 3630 void set_field_name(const char* name) { field_name_ = name; } |
| 3617 const char* field_name() const { return field_name_; } | 3631 const char* field_name() const { return field_name_; } |
| 3618 | 3632 |
| 3619 Field* field() const { return field_; } | 3633 const Field* field() const { return field_; } |
| 3620 void set_field(Field* field) { field_ = field; } | 3634 void set_field(const Field* field) { field_ = field; } |
| 3621 | 3635 |
| 3622 void set_recognized_kind(MethodRecognizer::Kind kind) { | 3636 void set_recognized_kind(MethodRecognizer::Kind kind) { |
| 3623 recognized_kind_ = kind; | 3637 recognized_kind_ = kind; |
| 3624 } | 3638 } |
| 3625 | 3639 |
| 3626 MethodRecognizer::Kind recognized_kind() const { | 3640 MethodRecognizer::Kind recognized_kind() const { |
| 3627 return recognized_kind_; | 3641 return recognized_kind_; |
| 3628 } | 3642 } |
| 3629 | 3643 |
| 3630 DECLARE_INSTRUCTION(LoadField) | 3644 DECLARE_INSTRUCTION(LoadField) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 3651 | 3665 |
| 3652 private: | 3666 private: |
| 3653 const intptr_t offset_in_bytes_; | 3667 const intptr_t offset_in_bytes_; |
| 3654 const AbstractType& type_; | 3668 const AbstractType& type_; |
| 3655 intptr_t result_cid_; | 3669 intptr_t result_cid_; |
| 3656 const bool immutable_; | 3670 const bool immutable_; |
| 3657 | 3671 |
| 3658 MethodRecognizer::Kind recognized_kind_; | 3672 MethodRecognizer::Kind recognized_kind_; |
| 3659 | 3673 |
| 3660 const char* field_name_; | 3674 const char* field_name_; |
| 3661 Field* field_; | 3675 const Field* field_; |
| 3662 | 3676 |
| 3663 DISALLOW_COPY_AND_ASSIGN(LoadFieldInstr); | 3677 DISALLOW_COPY_AND_ASSIGN(LoadFieldInstr); |
| 3664 }; | 3678 }; |
| 3665 | 3679 |
| 3666 | 3680 |
| 3667 class StoreVMFieldInstr : public TemplateDefinition<2> { | 3681 class StoreVMFieldInstr : public TemplateDefinition<2> { |
| 3668 public: | 3682 public: |
| 3669 StoreVMFieldInstr(Value* dest, | 3683 StoreVMFieldInstr(Value* dest, |
| 3670 intptr_t offset_in_bytes, | 3684 intptr_t offset_in_bytes, |
| 3671 Value* value, | 3685 Value* value, |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3949 virtual Representation RequiredInputRepresentation(intptr_t idx) const { | 3963 virtual Representation RequiredInputRepresentation(intptr_t idx) const { |
| 3950 ASSERT(idx == 0); | 3964 ASSERT(idx == 0); |
| 3951 return kUnboxedDouble; | 3965 return kUnboxedDouble; |
| 3952 } | 3966 } |
| 3953 | 3967 |
| 3954 virtual bool AllowsCSE() const { return true; } | 3968 virtual bool AllowsCSE() const { return true; } |
| 3955 virtual EffectSet Effects() const { return EffectSet::None(); } | 3969 virtual EffectSet Effects() const { return EffectSet::None(); } |
| 3956 virtual EffectSet Dependencies() const { return EffectSet::None(); } | 3970 virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| 3957 virtual bool AttributesEqual(Instruction* other) const { return true; } | 3971 virtual bool AttributesEqual(Instruction* other) const { return true; } |
| 3958 | 3972 |
| 3973 Definition* Canonicalize(FlowGraphOptimizer* optimizer); |
| 3974 |
| 3959 private: | 3975 private: |
| 3960 DISALLOW_COPY_AND_ASSIGN(BoxDoubleInstr); | 3976 DISALLOW_COPY_AND_ASSIGN(BoxDoubleInstr); |
| 3961 }; | 3977 }; |
| 3962 | 3978 |
| 3963 | 3979 |
| 3964 class BoxFloat32x4Instr : public TemplateDefinition<1> { | 3980 class BoxFloat32x4Instr : public TemplateDefinition<1> { |
| 3965 public: | 3981 public: |
| 3966 explicit BoxFloat32x4Instr(Value* value) { | 3982 explicit BoxFloat32x4Instr(Value* value) { |
| 3967 SetInputAt(0, value); | 3983 SetInputAt(0, value); |
| 3968 } | 3984 } |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4064 } | 4080 } |
| 4065 | 4081 |
| 4066 DECLARE_INSTRUCTION(UnboxDouble) | 4082 DECLARE_INSTRUCTION(UnboxDouble) |
| 4067 virtual CompileType ComputeType() const; | 4083 virtual CompileType ComputeType() const; |
| 4068 | 4084 |
| 4069 virtual bool AllowsCSE() const { return true; } | 4085 virtual bool AllowsCSE() const { return true; } |
| 4070 virtual EffectSet Effects() const { return EffectSet::None(); } | 4086 virtual EffectSet Effects() const { return EffectSet::None(); } |
| 4071 virtual EffectSet Dependencies() const { return EffectSet::None(); } | 4087 virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| 4072 virtual bool AttributesEqual(Instruction* other) const { return true; } | 4088 virtual bool AttributesEqual(Instruction* other) const { return true; } |
| 4073 | 4089 |
| 4090 Definition* Canonicalize(FlowGraphOptimizer* optimizer); |
| 4091 |
| 4074 private: | 4092 private: |
| 4075 DISALLOW_COPY_AND_ASSIGN(UnboxDoubleInstr); | 4093 DISALLOW_COPY_AND_ASSIGN(UnboxDoubleInstr); |
| 4076 }; | 4094 }; |
| 4077 | 4095 |
| 4078 | 4096 |
| 4079 class UnboxFloat32x4Instr : public TemplateDefinition<1> { | 4097 class UnboxFloat32x4Instr : public TemplateDefinition<1> { |
| 4080 public: | 4098 public: |
| 4081 UnboxFloat32x4Instr(Value* value, intptr_t deopt_id) { | 4099 UnboxFloat32x4Instr(Value* value, intptr_t deopt_id) { |
| 4082 SetInputAt(0, value); | 4100 SetInputAt(0, value); |
| 4083 deopt_id_ = deopt_id; | 4101 deopt_id_ = deopt_id; |
| (...skipping 1620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5704 ForwardInstructionIterator* current_iterator_; | 5722 ForwardInstructionIterator* current_iterator_; |
| 5705 | 5723 |
| 5706 private: | 5724 private: |
| 5707 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 5725 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 5708 }; | 5726 }; |
| 5709 | 5727 |
| 5710 | 5728 |
| 5711 } // namespace dart | 5729 } // namespace dart |
| 5712 | 5730 |
| 5713 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 5731 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |