| 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 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 // Normal instructions can have 0 (inside a block) or 1 (last instruction in | 707 // Normal instructions can have 0 (inside a block) or 1 (last instruction in |
| 708 // a block) successors. Branch instruction with >1 successors override this | 708 // a block) successors. Branch instruction with >1 successors override this |
| 709 // function. | 709 // function. |
| 710 virtual intptr_t SuccessorCount() const; | 710 virtual intptr_t SuccessorCount() const; |
| 711 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const; | 711 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const; |
| 712 | 712 |
| 713 void Goto(JoinEntryInstr* entry); | 713 void Goto(JoinEntryInstr* entry); |
| 714 | 714 |
| 715 virtual const char* DebugName() const = 0; | 715 virtual const char* DebugName() const = 0; |
| 716 | 716 |
| 717 #if defined(DEBUG) |
| 718 // Checks that the field stored in an instruction has proper form: |
| 719 // - must be a zone-handle |
| 720 // - In background compilation, must be cloned. |
| 721 // Aborts if field is not OK. |
| 722 void CheckField(const Field& field) const; |
| 723 #else |
| 724 void CheckField(const Field& field) const {} |
| 725 #endif // DEBUG |
| 726 |
| 717 // Printing support. | 727 // Printing support. |
| 718 const char* ToCString() const; | 728 const char* ToCString() const; |
| 719 #ifndef PRODUCT | 729 #ifndef PRODUCT |
| 720 virtual void PrintTo(BufferFormatter* f) const; | 730 virtual void PrintTo(BufferFormatter* f) const; |
| 721 virtual void PrintOperandsTo(BufferFormatter* f) const; | 731 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 722 #endif | 732 #endif |
| 723 | 733 |
| 724 #define DECLARE_INSTRUCTION_TYPE_CHECK(Name, Type) \ | 734 #define DECLARE_INSTRUCTION_TYPE_CHECK(Name, Type) \ |
| 725 bool Is##Name() { return (As##Name() != NULL); } \ | 735 bool Is##Name() { return (As##Name() != NULL); } \ |
| 726 virtual Type* As##Name() { return NULL; } | 736 virtual Type* As##Name() { return NULL; } |
| (...skipping 2816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3543 StoreBarrierType emit_store_barrier, | 3553 StoreBarrierType emit_store_barrier, |
| 3544 TokenPosition token_pos) | 3554 TokenPosition token_pos) |
| 3545 : field_(field), | 3555 : field_(field), |
| 3546 offset_in_bytes_(field.Offset()), | 3556 offset_in_bytes_(field.Offset()), |
| 3547 emit_store_barrier_(emit_store_barrier), | 3557 emit_store_barrier_(emit_store_barrier), |
| 3548 token_pos_(token_pos), | 3558 token_pos_(token_pos), |
| 3549 is_potential_unboxed_initialization_(false), | 3559 is_potential_unboxed_initialization_(false), |
| 3550 is_object_reference_initialization_(false) { | 3560 is_object_reference_initialization_(false) { |
| 3551 SetInputAt(kInstancePos, instance); | 3561 SetInputAt(kInstancePos, instance); |
| 3552 SetInputAt(kValuePos, value); | 3562 SetInputAt(kValuePos, value); |
| 3563 CheckField(field); |
| 3553 } | 3564 } |
| 3554 | 3565 |
| 3555 StoreInstanceFieldInstr(intptr_t offset_in_bytes, | 3566 StoreInstanceFieldInstr(intptr_t offset_in_bytes, |
| 3556 Value* instance, | 3567 Value* instance, |
| 3557 Value* value, | 3568 Value* value, |
| 3558 StoreBarrierType emit_store_barrier, | 3569 StoreBarrierType emit_store_barrier, |
| 3559 TokenPosition token_pos) | 3570 TokenPosition token_pos) |
| 3560 : field_(Field::ZoneHandle()), | 3571 : field_(Field::ZoneHandle()), |
| 3561 offset_in_bytes_(offset_in_bytes), | 3572 offset_in_bytes_(offset_in_bytes), |
| 3562 emit_store_barrier_(emit_store_barrier), | 3573 emit_store_barrier_(emit_store_barrier), |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3644 | 3655 |
| 3645 | 3656 |
| 3646 class GuardFieldInstr : public TemplateInstruction<1, NoThrow, Pure> { | 3657 class GuardFieldInstr : public TemplateInstruction<1, NoThrow, Pure> { |
| 3647 public: | 3658 public: |
| 3648 GuardFieldInstr(Value* value, | 3659 GuardFieldInstr(Value* value, |
| 3649 const Field& field, | 3660 const Field& field, |
| 3650 intptr_t deopt_id) | 3661 intptr_t deopt_id) |
| 3651 : TemplateInstruction(deopt_id), | 3662 : TemplateInstruction(deopt_id), |
| 3652 field_(field) { | 3663 field_(field) { |
| 3653 SetInputAt(0, value); | 3664 SetInputAt(0, value); |
| 3665 CheckField(field); |
| 3654 } | 3666 } |
| 3655 | 3667 |
| 3656 Value* value() const { return inputs_[0]; } | 3668 Value* value() const { return inputs_[0]; } |
| 3657 | 3669 |
| 3658 const Field& field() const { return field_; } | 3670 const Field& field() const { return field_; } |
| 3659 | 3671 |
| 3660 virtual bool CanDeoptimize() const { return true; } | 3672 virtual bool CanDeoptimize() const { return true; } |
| 3661 virtual bool CanBecomeDeoptimizationTarget() const { | 3673 virtual bool CanBecomeDeoptimizationTarget() const { |
| 3662 // Ensure that we record kDeopt PC descriptor in unoptimized code. | 3674 // Ensure that we record kDeopt PC descriptor in unoptimized code. |
| 3663 return true; | 3675 return true; |
| 3664 } | 3676 } |
| 3665 | 3677 |
| 3666 PRINT_OPERANDS_TO_SUPPORT | 3678 PRINT_OPERANDS_TO_SUPPORT |
| 3667 | 3679 |
| 3668 private: | 3680 private: |
| 3669 const Field& field_; | 3681 const Field& field_; |
| 3670 | 3682 |
| 3671 DISALLOW_COPY_AND_ASSIGN(GuardFieldInstr); | 3683 DISALLOW_COPY_AND_ASSIGN(GuardFieldInstr); |
| 3672 }; | 3684 }; |
| 3673 | 3685 |
| 3674 | 3686 |
| 3675 class GuardFieldClassInstr : public GuardFieldInstr { | 3687 class GuardFieldClassInstr : public GuardFieldInstr { |
| 3676 public: | 3688 public: |
| 3677 GuardFieldClassInstr(Value* value, | 3689 GuardFieldClassInstr(Value* value, |
| 3678 const Field& field, | 3690 const Field& field, |
| 3679 intptr_t deopt_id) | 3691 intptr_t deopt_id) |
| 3680 : GuardFieldInstr(value, field, deopt_id) { } | 3692 : GuardFieldInstr(value, field, deopt_id) { |
| 3693 CheckField(field); |
| 3694 } |
| 3681 | 3695 |
| 3682 DECLARE_INSTRUCTION(GuardFieldClass) | 3696 DECLARE_INSTRUCTION(GuardFieldClass) |
| 3683 | 3697 |
| 3684 virtual Instruction* Canonicalize(FlowGraph* flow_graph); | 3698 virtual Instruction* Canonicalize(FlowGraph* flow_graph); |
| 3685 | 3699 |
| 3686 virtual bool AttributesEqual(Instruction* other) const; | 3700 virtual bool AttributesEqual(Instruction* other) const; |
| 3687 | 3701 |
| 3688 private: | 3702 private: |
| 3689 DISALLOW_COPY_AND_ASSIGN(GuardFieldClassInstr); | 3703 DISALLOW_COPY_AND_ASSIGN(GuardFieldClassInstr); |
| 3690 }; | 3704 }; |
| 3691 | 3705 |
| 3692 | 3706 |
| 3693 class GuardFieldLengthInstr : public GuardFieldInstr { | 3707 class GuardFieldLengthInstr : public GuardFieldInstr { |
| 3694 public: | 3708 public: |
| 3695 GuardFieldLengthInstr(Value* value, | 3709 GuardFieldLengthInstr(Value* value, |
| 3696 const Field& field, | 3710 const Field& field, |
| 3697 intptr_t deopt_id) | 3711 intptr_t deopt_id) |
| 3698 : GuardFieldInstr(value, field, deopt_id) { } | 3712 : GuardFieldInstr(value, field, deopt_id) { |
| 3713 CheckField(field); |
| 3714 } |
| 3699 | 3715 |
| 3700 DECLARE_INSTRUCTION(GuardFieldLength) | 3716 DECLARE_INSTRUCTION(GuardFieldLength) |
| 3701 | 3717 |
| 3702 virtual Instruction* Canonicalize(FlowGraph* flow_graph); | 3718 virtual Instruction* Canonicalize(FlowGraph* flow_graph); |
| 3703 | 3719 |
| 3704 virtual bool AttributesEqual(Instruction* other) const; | 3720 virtual bool AttributesEqual(Instruction* other) const; |
| 3705 | 3721 |
| 3706 private: | 3722 private: |
| 3707 DISALLOW_COPY_AND_ASSIGN(GuardFieldLengthInstr); | 3723 DISALLOW_COPY_AND_ASSIGN(GuardFieldLengthInstr); |
| 3708 }; | 3724 }; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3743 | 3759 |
| 3744 class StoreStaticFieldInstr : public TemplateDefinition<1, NoThrow> { | 3760 class StoreStaticFieldInstr : public TemplateDefinition<1, NoThrow> { |
| 3745 public: | 3761 public: |
| 3746 StoreStaticFieldInstr(const Field& field, | 3762 StoreStaticFieldInstr(const Field& field, |
| 3747 Value* value, | 3763 Value* value, |
| 3748 TokenPosition token_pos) | 3764 TokenPosition token_pos) |
| 3749 : field_(field), | 3765 : field_(field), |
| 3750 token_pos_(token_pos) { | 3766 token_pos_(token_pos) { |
| 3751 ASSERT(field.IsZoneHandle()); | 3767 ASSERT(field.IsZoneHandle()); |
| 3752 SetInputAt(kValuePos, value); | 3768 SetInputAt(kValuePos, value); |
| 3769 CheckField(field); |
| 3753 } | 3770 } |
| 3754 | 3771 |
| 3755 enum { | 3772 enum { |
| 3756 kValuePos = 0 | 3773 kValuePos = 0 |
| 3757 }; | 3774 }; |
| 3758 | 3775 |
| 3759 DECLARE_INSTRUCTION(StoreStaticField) | 3776 DECLARE_INSTRUCTION(StoreStaticField) |
| 3760 | 3777 |
| 3761 const Field& field() const { return field_; } | 3778 const Field& field() const { return field_; } |
| 3762 Value* value() const { return inputs_[kValuePos]; } | 3779 Value* value() const { return inputs_[kValuePos]; } |
| (...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4634 DISALLOW_COPY_AND_ASSIGN(AllocateContextInstr); | 4651 DISALLOW_COPY_AND_ASSIGN(AllocateContextInstr); |
| 4635 }; | 4652 }; |
| 4636 | 4653 |
| 4637 | 4654 |
| 4638 class InitStaticFieldInstr : public TemplateInstruction<1, Throws> { | 4655 class InitStaticFieldInstr : public TemplateInstruction<1, Throws> { |
| 4639 public: | 4656 public: |
| 4640 InitStaticFieldInstr(Value* input, const Field& field) | 4657 InitStaticFieldInstr(Value* input, const Field& field) |
| 4641 : TemplateInstruction(Thread::Current()->GetNextDeoptId()), | 4658 : TemplateInstruction(Thread::Current()->GetNextDeoptId()), |
| 4642 field_(field) { | 4659 field_(field) { |
| 4643 SetInputAt(0, input); | 4660 SetInputAt(0, input); |
| 4661 CheckField(field); |
| 4644 } | 4662 } |
| 4645 | 4663 |
| 4646 virtual TokenPosition token_pos() const { | 4664 virtual TokenPosition token_pos() const { |
| 4647 return field_.token_pos(); | 4665 return field_.token_pos(); |
| 4648 } | 4666 } |
| 4649 const Field& field() const { return field_; } | 4667 const Field& field() const { return field_; } |
| 4650 | 4668 |
| 4651 DECLARE_INSTRUCTION(InitStaticField) | 4669 DECLARE_INSTRUCTION(InitStaticField) |
| 4652 | 4670 |
| 4653 virtual bool CanDeoptimize() const { return true; } | 4671 virtual bool CanDeoptimize() const { return true; } |
| (...skipping 3555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8209 LocationSummary* Name::MakeLocationSummary(Zone* zone, bool opt) const { \ | 8227 LocationSummary* Name::MakeLocationSummary(Zone* zone, bool opt) const { \ |
| 8210 UNIMPLEMENTED(); \ | 8228 UNIMPLEMENTED(); \ |
| 8211 return NULL; \ | 8229 return NULL; \ |
| 8212 } \ | 8230 } \ |
| 8213 void Name::EmitNativeCode(FlowGraphCompiler* compiler) { UNIMPLEMENTED(); } | 8231 void Name::EmitNativeCode(FlowGraphCompiler* compiler) { UNIMPLEMENTED(); } |
| 8214 | 8232 |
| 8215 | 8233 |
| 8216 } // namespace dart | 8234 } // namespace dart |
| 8217 | 8235 |
| 8218 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 8236 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |