OLD | NEW |
---|---|
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 enum ComputationKind { | 234 enum ComputationKind { |
235 #define DECLARE_COMPUTATION_KIND(ShortName, ClassName) k##ShortName, | 235 #define DECLARE_COMPUTATION_KIND(ShortName, ClassName) k##ShortName, |
236 | 236 |
237 FOR_EACH_COMPUTATION(DECLARE_COMPUTATION_KIND) | 237 FOR_EACH_COMPUTATION(DECLARE_COMPUTATION_KIND) |
238 | 238 |
239 #undef DECLARE_COMPUTATION_KIND | 239 #undef DECLARE_COMPUTATION_KIND |
240 }; | 240 }; |
241 | 241 |
242 virtual ComputationKind computation_kind() const = 0; | 242 virtual ComputationKind computation_kind() const = 0; |
243 | 243 |
244 virtual Representation RequiredInputRepresentation(intptr_t i) const { | |
srdjan
2012/08/30 17:59:24
Add comment (or change parameter name) describing
Vyacheslav Egorov (Google)
2012/09/21 12:51:52
Done.
| |
245 return kTagged; | |
246 } | |
247 | |
244 virtual Representation representation() const { | 248 virtual Representation representation() const { |
245 return kTagged; | 249 return kTagged; |
246 } | 250 } |
247 | 251 |
252 // Returns deoptimization id that corresponds to the deoptimization target | |
253 // that input operands conversions inserted for this instruction can jump | |
254 // to. | |
srdjan
2012/08/30 17:59:24
Please add: can return kNoDeoptId.
Vyacheslav Egorov (Google)
2012/09/21 12:51:52
Done.
| |
255 virtual intptr_t DeoptimizationTarget() const { | |
256 UNREACHABLE(); | |
257 return Isolate::kNoDeoptId; | |
258 } | |
259 | |
248 // Declare predicate for each computation. | 260 // Declare predicate for each computation. |
249 #define DECLARE_PREDICATE(ShortName, ClassName) \ | 261 #define DECLARE_PREDICATE(ShortName, ClassName) \ |
250 inline bool Is##ShortName() const; \ | 262 inline bool Is##ShortName() const; \ |
251 inline const ClassName* As##ShortName() const; \ | 263 inline const ClassName* As##ShortName() const; \ |
252 inline ClassName* As##ShortName(); | 264 inline ClassName* As##ShortName(); |
253 FOR_EACH_COMPUTATION(DECLARE_PREDICATE) | 265 FOR_EACH_COMPUTATION(DECLARE_PREDICATE) |
254 #undef DECLARE_PREDICATE | 266 #undef DECLARE_PREDICATE |
255 | 267 |
268 protected: | |
269 intptr_t deopt_id_; | |
srdjan
2012/08/30 17:59:24
Optional: do you need to be able to set it in any
Vyacheslav Egorov (Google)
2012/09/21 12:51:52
Done.
| |
270 | |
256 private: | 271 private: |
257 friend class BranchInstr; | 272 friend class BranchInstr; |
258 | 273 |
259 intptr_t deopt_id_; | |
260 const ICData* ic_data_; | 274 const ICData* ic_data_; |
261 LocationSummary* locs_; | 275 LocationSummary* locs_; |
262 | 276 |
263 DISALLOW_COPY_AND_ASSIGN(Computation); | 277 DISALLOW_COPY_AND_ASSIGN(Computation); |
264 }; | 278 }; |
265 | 279 |
266 | 280 |
267 // An embedded container with N elements of type T. Used (with partial | 281 // An embedded container with N elements of type T. Used (with partial |
268 // specialization for N=0) because embedded arrays cannot have size 0. | 282 // specialization for N=0) because embedded arrays cannot have size 0. |
269 template<typename T, intptr_t N> | 283 template<typename T, intptr_t N> |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
739 DECLARE_COMPUTATION(EqualityCompare) | 753 DECLARE_COMPUTATION(EqualityCompare) |
740 | 754 |
741 intptr_t token_pos() const { return token_pos_; } | 755 intptr_t token_pos() const { return token_pos_; } |
742 | 756 |
743 // Receiver class id is computed from collected ICData. | 757 // Receiver class id is computed from collected ICData. |
744 void set_receiver_class_id(intptr_t value) { receiver_class_id_ = value; } | 758 void set_receiver_class_id(intptr_t value) { receiver_class_id_ = value; } |
745 intptr_t receiver_class_id() const { return receiver_class_id_; } | 759 intptr_t receiver_class_id() const { return receiver_class_id_; } |
746 | 760 |
747 virtual void PrintOperandsTo(BufferFormatter* f) const; | 761 virtual void PrintOperandsTo(BufferFormatter* f) const; |
748 | 762 |
749 virtual bool CanDeoptimize() const { return true; } | 763 virtual bool CanDeoptimize() const { |
764 return (receiver_class_id() != kDoubleCid); | |
765 } | |
766 | |
750 virtual intptr_t ResultCid() const; | 767 virtual intptr_t ResultCid() const; |
751 | 768 |
752 virtual void EmitBranchCode(FlowGraphCompiler* compiler, | 769 virtual void EmitBranchCode(FlowGraphCompiler* compiler, |
753 BranchInstr* branch); | 770 BranchInstr* branch); |
754 | 771 |
772 virtual intptr_t DeoptimizationTarget() const { | |
773 return deopt_id_; | |
774 } | |
775 | |
776 virtual Representation RequiredInputRepresentation(intptr_t i) const { | |
srdjan
2012/08/30 17:59:24
Asssert i is 0 or 1.
Vyacheslav Egorov (Google)
2012/09/21 12:51:52
Done.
| |
777 return (receiver_class_id() == kDoubleCid) ? kUnboxedDouble : kTagged; | |
778 } | |
779 | |
755 private: | 780 private: |
756 const intptr_t token_pos_; | 781 const intptr_t token_pos_; |
757 intptr_t receiver_class_id_; // Set by optimizer. | 782 intptr_t receiver_class_id_; // Set by optimizer. |
758 | 783 |
759 DISALLOW_COPY_AND_ASSIGN(EqualityCompareComp); | 784 DISALLOW_COPY_AND_ASSIGN(EqualityCompareComp); |
760 }; | 785 }; |
761 | 786 |
762 | 787 |
763 class RelationalOpComp : public ComparisonComp { | 788 class RelationalOpComp : public ComparisonComp { |
764 public: | 789 public: |
(...skipping 14 matching lines...) Expand all Loading... | |
779 // TODO(srdjan): instead of class-id pass an enum that can differentiate | 804 // TODO(srdjan): instead of class-id pass an enum that can differentiate |
780 // between boxed and unboxed doubles and integers. | 805 // between boxed and unboxed doubles and integers. |
781 void set_operands_class_id(intptr_t value) { | 806 void set_operands_class_id(intptr_t value) { |
782 operands_class_id_ = value; | 807 operands_class_id_ = value; |
783 } | 808 } |
784 | 809 |
785 intptr_t operands_class_id() const { return operands_class_id_; } | 810 intptr_t operands_class_id() const { return operands_class_id_; } |
786 | 811 |
787 virtual void PrintOperandsTo(BufferFormatter* f) const; | 812 virtual void PrintOperandsTo(BufferFormatter* f) const; |
788 | 813 |
789 virtual bool CanDeoptimize() const { return true; } | 814 virtual bool CanDeoptimize() const { |
815 return operands_class_id() != kDoubleCid; | |
816 } | |
817 | |
790 virtual intptr_t ResultCid() const; | 818 virtual intptr_t ResultCid() const; |
791 | 819 |
792 virtual void EmitBranchCode(FlowGraphCompiler* compiler, | 820 virtual void EmitBranchCode(FlowGraphCompiler* compiler, |
793 BranchInstr* branch); | 821 BranchInstr* branch); |
794 | 822 |
823 | |
824 virtual intptr_t DeoptimizationTarget() const { | |
825 return deopt_id_; | |
826 } | |
827 | |
828 virtual Representation RequiredInputRepresentation(intptr_t i) const { | |
srdjan
2012/08/30 17:59:24
ASSERT(i is 0, 1) ?
Vyacheslav Egorov (Google)
2012/09/21 12:51:52
Done.
| |
829 return (operands_class_id() == kDoubleCid) ? kUnboxedDouble : kTagged; | |
830 } | |
831 | |
795 private: | 832 private: |
796 const intptr_t token_pos_; | 833 const intptr_t token_pos_; |
797 intptr_t operands_class_id_; // class id of both operands. | 834 intptr_t operands_class_id_; // class id of both operands. |
798 | 835 |
799 DISALLOW_COPY_AND_ASSIGN(RelationalOpComp); | 836 DISALLOW_COPY_AND_ASSIGN(RelationalOpComp); |
800 }; | 837 }; |
801 | 838 |
802 | 839 |
803 class StaticCallComp : public TemplateComputation<0> { | 840 class StaticCallComp : public TemplateComputation<0> { |
804 public: | 841 public: |
(...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1591 private: | 1628 private: |
1592 InstanceCallComp* instance_call_; | 1629 InstanceCallComp* instance_call_; |
1593 | 1630 |
1594 DISALLOW_COPY_AND_ASSIGN(CheckEitherNonSmiComp); | 1631 DISALLOW_COPY_AND_ASSIGN(CheckEitherNonSmiComp); |
1595 }; | 1632 }; |
1596 | 1633 |
1597 | 1634 |
1598 class BoxDoubleComp : public TemplateComputation<1> { | 1635 class BoxDoubleComp : public TemplateComputation<1> { |
1599 public: | 1636 public: |
1600 BoxDoubleComp(Value* value, InstanceCallComp* instance_call) | 1637 BoxDoubleComp(Value* value, InstanceCallComp* instance_call) |
1601 : instance_call_(instance_call) { | 1638 : token_pos_((instance_call != NULL) ? instance_call->token_pos() : 0) { |
1602 ASSERT(value != NULL); | 1639 ASSERT(value != NULL); |
1603 inputs_[0] = value; | 1640 inputs_[0] = value; |
1604 } | 1641 } |
1605 | 1642 |
1606 Value* value() const { return inputs_[0]; } | 1643 Value* value() const { return inputs_[0]; } |
1607 InstanceCallComp* instance_call() const { return instance_call_; } | 1644 |
1645 intptr_t token_pos() const { return token_pos_; } | |
1608 | 1646 |
1609 virtual bool CanDeoptimize() const { return false; } | 1647 virtual bool CanDeoptimize() const { return false; } |
1648 virtual bool HasSideEffect() const { return false; } | |
1649 virtual bool AttributesEqual(Computation* other) const { return true; } | |
srdjan
2012/08/30 17:59:24
Always true, regardless of the value? Please add c
Vyacheslav Egorov (Google)
2012/09/21 12:51:52
I am not sure what to add.
AttributesEqual check
| |
1610 | 1650 |
1611 virtual intptr_t ResultCid() const; | 1651 virtual intptr_t ResultCid() const; |
1612 | 1652 |
1653 virtual Representation RequiredInputRepresentation(intptr_t idx) const { | |
1654 ASSERT(idx == 0); | |
1655 return kUnboxedDouble; | |
1656 } | |
1657 | |
1613 DECLARE_COMPUTATION(BoxDouble) | 1658 DECLARE_COMPUTATION(BoxDouble) |
1614 | 1659 |
1615 private: | 1660 private: |
1616 InstanceCallComp* instance_call_; | 1661 const intptr_t token_pos_; |
1617 | 1662 |
1618 DISALLOW_COPY_AND_ASSIGN(BoxDoubleComp); | 1663 DISALLOW_COPY_AND_ASSIGN(BoxDoubleComp); |
1619 }; | 1664 }; |
1620 | 1665 |
1621 | 1666 |
1622 class UnboxDoubleComp : public TemplateComputation<1> { | 1667 class UnboxDoubleComp : public TemplateComputation<1> { |
1623 public: | 1668 public: |
1624 UnboxDoubleComp(Value* value, InstanceCallComp* instance_call) | 1669 UnboxDoubleComp(Value* value, intptr_t deopt_id) |
1625 : instance_call_(instance_call) { | 1670 : deopt_id_(deopt_id) { |
1626 ASSERT(value != NULL); | 1671 ASSERT(value != NULL); |
1627 inputs_[0] = value; | 1672 inputs_[0] = value; |
1628 } | 1673 } |
1629 | 1674 |
1630 Value* value() const { return inputs_[0]; } | 1675 Value* value() const { return inputs_[0]; } |
1631 InstanceCallComp* instance_call() const { return instance_call_; } | |
1632 | 1676 |
1633 virtual bool CanDeoptimize() const { | 1677 virtual bool CanDeoptimize() const { |
1634 return value()->ResultCid() != kDoubleCid; | 1678 return value()->ResultCid() != kDoubleCid; |
1635 } | 1679 } |
1636 // The output is not an instance. | 1680 |
1637 virtual intptr_t ResultCid() const { return kDynamicCid; } | 1681 // The output is not an instance but when it is boxed it becomes double. |
1682 virtual intptr_t ResultCid() const { return kDoubleCid; } | |
1638 | 1683 |
1639 virtual Representation representation() const { | 1684 virtual Representation representation() const { |
1640 return kUnboxedDouble; | 1685 return kUnboxedDouble; |
1641 } | 1686 } |
1642 | 1687 |
1688 virtual bool HasSideEffect() const { return false; } | |
1689 virtual bool AttributesEqual(Computation* other) const { return true; } | |
1690 | |
1643 DECLARE_COMPUTATION(UnboxDouble) | 1691 DECLARE_COMPUTATION(UnboxDouble) |
1644 | 1692 |
1645 private: | 1693 private: |
1646 InstanceCallComp* instance_call_; | 1694 const intptr_t deopt_id_; |
1647 | 1695 |
1648 DISALLOW_COPY_AND_ASSIGN(UnboxDoubleComp); | 1696 DISALLOW_COPY_AND_ASSIGN(UnboxDoubleComp); |
1649 }; | 1697 }; |
1650 | 1698 |
1651 | 1699 |
1652 class UnboxedDoubleBinaryOpComp : public TemplateComputation<2> { | 1700 class UnboxedDoubleBinaryOpComp : public TemplateComputation<2> { |
1653 public: | 1701 public: |
1654 UnboxedDoubleBinaryOpComp(Token::Kind op_kind, | 1702 UnboxedDoubleBinaryOpComp(Token::Kind op_kind, |
1655 Value* left, | 1703 Value* left, |
1656 Value* right) | 1704 Value* right, |
1657 : op_kind_(op_kind) { | 1705 InstanceCallComp* call) |
1706 : op_kind_(op_kind), deopt_id_(call->deopt_id()) { | |
1658 ASSERT(left != NULL); | 1707 ASSERT(left != NULL); |
1659 ASSERT(right != NULL); | 1708 ASSERT(right != NULL); |
1660 inputs_[0] = left; | 1709 inputs_[0] = left; |
1661 inputs_[1] = right; | 1710 inputs_[1] = right; |
1662 } | 1711 } |
1663 | 1712 |
1664 Value* left() const { return inputs_[0]; } | 1713 Value* left() const { return inputs_[0]; } |
1665 Value* right() const { return inputs_[1]; } | 1714 Value* right() const { return inputs_[1]; } |
1666 | 1715 |
1667 Token::Kind op_kind() const { return op_kind_; } | 1716 Token::Kind op_kind() const { return op_kind_; } |
1668 | 1717 |
1669 virtual void PrintOperandsTo(BufferFormatter* f) const; | 1718 virtual void PrintOperandsTo(BufferFormatter* f) const; |
1670 | 1719 |
1671 virtual bool CanDeoptimize() const { return false; } | 1720 virtual bool CanDeoptimize() const { return false; } |
1672 // The output is not an instance. | 1721 virtual bool HasSideEffect() const { return false; } |
1673 virtual intptr_t ResultCid() const { return kDynamicCid; } | 1722 |
1723 virtual bool AttributesEqual(Computation* other) const { | |
1724 return op_kind() == other->AsUnboxedDoubleBinaryOp()->op_kind(); | |
1725 } | |
1726 | |
1727 // The output is not an instance but when it is boxed it becomes double. | |
1728 virtual intptr_t ResultCid() const { return kDoubleCid; } | |
1674 | 1729 |
1675 virtual Representation representation() const { | 1730 virtual Representation representation() const { |
1676 return kUnboxedDouble; | 1731 return kUnboxedDouble; |
1677 } | 1732 } |
1678 | 1733 |
1734 virtual Representation RequiredInputRepresentation(intptr_t idx) const { | |
1735 ASSERT((idx == 0) || (idx == 1)); | |
1736 return kUnboxedDouble; | |
1737 } | |
1738 | |
1739 virtual intptr_t DeoptimizationTarget() const { | |
1740 return deopt_id_; | |
1741 } | |
1742 | |
1679 DECLARE_COMPUTATION(UnboxedDoubleBinaryOp) | 1743 DECLARE_COMPUTATION(UnboxedDoubleBinaryOp) |
1680 | 1744 |
1681 private: | 1745 private: |
1682 const Token::Kind op_kind_; | 1746 const Token::Kind op_kind_; |
1747 const intptr_t deopt_id_; | |
1683 | 1748 |
1684 DISALLOW_COPY_AND_ASSIGN(UnboxedDoubleBinaryOpComp); | 1749 DISALLOW_COPY_AND_ASSIGN(UnboxedDoubleBinaryOpComp); |
1685 }; | 1750 }; |
1686 | 1751 |
1687 | 1752 |
1688 class BinarySmiOpComp : public TemplateComputation<2> { | 1753 class BinarySmiOpComp : public TemplateComputation<2> { |
1689 public: | 1754 public: |
1690 BinarySmiOpComp(Token::Kind op_kind, | 1755 BinarySmiOpComp(Token::Kind op_kind, |
1691 InstanceCallComp* instance_call, | 1756 InstanceCallComp* instance_call, |
1692 Value* left, | 1757 Value* left, |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2176 } | 2241 } |
2177 | 2242 |
2178 Environment* env() const { return env_; } | 2243 Environment* env() const { return env_; } |
2179 void set_env(Environment* env) { env_ = env; } | 2244 void set_env(Environment* env) { env_ = env; } |
2180 | 2245 |
2181 intptr_t lifetime_position() const { return lifetime_position_; } | 2246 intptr_t lifetime_position() const { return lifetime_position_; } |
2182 void set_lifetime_position(intptr_t pos) { | 2247 void set_lifetime_position(intptr_t pos) { |
2183 lifetime_position_ = pos; | 2248 lifetime_position_ = pos; |
2184 } | 2249 } |
2185 | 2250 |
2251 virtual Representation RequiredInputRepresentation(intptr_t i) const { | |
srdjan
2012/08/30 17:59:24
Again, please document i.
Vyacheslav Egorov (Google)
2012/09/21 12:51:52
Done.
| |
2252 return kTagged; | |
2253 } | |
2254 | |
2186 virtual Representation representation() const { | 2255 virtual Representation representation() const { |
2187 return kTagged; | 2256 return kTagged; |
2188 } | 2257 } |
2189 | 2258 |
2259 bool WasEliminated() const { | |
2260 return next() == NULL; | |
2261 } | |
2262 | |
2263 // Returns deoptimization id that corresponds to the deoptimization target | |
2264 // that input operands conversions inserted for this instruction can jump | |
2265 // to. | |
2266 virtual intptr_t DeoptimizationTarget() const { | |
2267 UNREACHABLE(); | |
2268 return Isolate::kNoDeoptId; | |
2269 } | |
2270 | |
2190 private: | 2271 private: |
2191 friend class BindInstr; // Needed for BindInstr::InsertBefore. | 2272 friend class BindInstr; // Needed for BindInstr::InsertBefore. |
2192 | 2273 |
2193 intptr_t lifetime_position_; // Position used by register allocator. | 2274 intptr_t lifetime_position_; // Position used by register allocator. |
2194 Instruction* previous_; | 2275 Instruction* previous_; |
2195 Instruction* next_; | 2276 Instruction* next_; |
2196 Environment* env_; | 2277 Environment* env_; |
2197 DISALLOW_COPY_AND_ASSIGN(Instruction); | 2278 DISALLOW_COPY_AND_ASSIGN(Instruction); |
2198 }; | 2279 }; |
2199 | 2280 |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2745 } | 2826 } |
2746 | 2827 |
2747 virtual void EmitNativeCode(FlowGraphCompiler* compiler); | 2828 virtual void EmitNativeCode(FlowGraphCompiler* compiler); |
2748 | 2829 |
2749 // Insert this instruction before 'next'. | 2830 // Insert this instruction before 'next'. |
2750 void InsertBefore(Instruction* next); | 2831 void InsertBefore(Instruction* next); |
2751 | 2832 |
2752 // Insert this instruction after 'prev'. | 2833 // Insert this instruction after 'prev'. |
2753 void InsertAfter(Instruction* prev); | 2834 void InsertAfter(Instruction* prev); |
2754 | 2835 |
2836 virtual Representation RequiredInputRepresentation(intptr_t i) const { | |
2837 return computation()->RequiredInputRepresentation(i); | |
2838 } | |
2839 | |
2755 virtual Representation representation() const { | 2840 virtual Representation representation() const { |
2756 return computation()->representation(); | 2841 return computation()->representation(); |
2757 } | 2842 } |
2758 | 2843 |
2844 virtual intptr_t DeoptimizationTarget() const { | |
2845 return computation()->DeoptimizationTarget(); | |
2846 } | |
2847 | |
2759 private: | 2848 private: |
2760 Computation* computation_; | 2849 Computation* computation_; |
2761 const bool is_used_; | 2850 const bool is_used_; |
2762 | 2851 |
2763 DISALLOW_COPY_AND_ASSIGN(BindInstr); | 2852 DISALLOW_COPY_AND_ASSIGN(BindInstr); |
2764 }; | 2853 }; |
2765 | 2854 |
2766 | 2855 |
2767 class PhiInstr : public Definition { | 2856 class PhiInstr : public Definition { |
2768 public: | 2857 public: |
2769 explicit PhiInstr(intptr_t num_inputs) | 2858 explicit PhiInstr(JoinEntryInstr* block, intptr_t num_inputs) |
2770 : inputs_(num_inputs), is_alive_(false) { | 2859 : block_(block), |
2860 inputs_(num_inputs), | |
2861 is_alive_(false), | |
2862 representation_(kTagged) { | |
2771 for (intptr_t i = 0; i < num_inputs; ++i) { | 2863 for (intptr_t i = 0; i < num_inputs; ++i) { |
2772 inputs_.Add(NULL); | 2864 inputs_.Add(NULL); |
2773 } | 2865 } |
2774 } | 2866 } |
2775 | 2867 |
2868 JoinEntryInstr* block() const { return block_; } | |
2869 | |
2776 virtual RawAbstractType* CompileType() const; | 2870 virtual RawAbstractType* CompileType() const; |
2777 virtual intptr_t GetPropagatedCid() { return propagated_cid(); } | 2871 virtual intptr_t GetPropagatedCid() { return propagated_cid(); } |
2778 | 2872 |
2779 virtual intptr_t ArgumentCount() const { return 0; } | 2873 virtual intptr_t ArgumentCount() const { return 0; } |
2780 | 2874 |
2781 intptr_t InputCount() const { return inputs_.length(); } | 2875 intptr_t InputCount() const { return inputs_.length(); } |
2782 | 2876 |
2783 Value* InputAt(intptr_t i) const { return inputs_[i]; } | 2877 Value* InputAt(intptr_t i) const { return inputs_[i]; } |
2784 | 2878 |
2785 void SetInputAt(intptr_t i, Value* value) { inputs_[i] = value; } | 2879 void SetInputAt(intptr_t i, Value* value) { inputs_[i] = value; } |
2786 | 2880 |
2787 virtual bool CanDeoptimize() const { return false; } | 2881 virtual bool CanDeoptimize() const { return false; } |
2788 | 2882 |
2789 // TODO(regis): This helper will be removed once we support type sets. | 2883 // TODO(regis): This helper will be removed once we support type sets. |
2790 RawAbstractType* LeastSpecificInputType() const; | 2884 RawAbstractType* LeastSpecificInputType() const; |
2791 | 2885 |
2792 // Phi is alive if it reaches a non-environment use. | 2886 // Phi is alive if it reaches a non-environment use. |
2793 bool is_alive() const { return is_alive_; } | 2887 bool is_alive() const { return is_alive_; } |
2794 void mark_alive() { is_alive_ = true; } | 2888 void mark_alive() { is_alive_ = true; } |
2795 | 2889 |
2890 virtual Representation RequiredInputRepresentation(intptr_t i) const { | |
2891 return representation_; | |
2892 } | |
2893 | |
2894 virtual Representation representation() const { | |
2895 return representation_; | |
2896 } | |
2897 | |
2898 virtual void set_representation(Representation r) { | |
2899 representation_ = r; | |
2900 } | |
2901 | |
2796 DECLARE_INSTRUCTION(Phi) | 2902 DECLARE_INSTRUCTION(Phi) |
2797 | 2903 |
2798 private: | 2904 private: |
2905 JoinEntryInstr* block_; | |
2799 GrowableArray<Value*> inputs_; | 2906 GrowableArray<Value*> inputs_; |
2800 bool is_alive_; | 2907 bool is_alive_; |
2908 Representation representation_; | |
2801 | 2909 |
2802 DISALLOW_COPY_AND_ASSIGN(PhiInstr); | 2910 DISALLOW_COPY_AND_ASSIGN(PhiInstr); |
2803 }; | 2911 }; |
2804 | 2912 |
2805 | 2913 |
2806 class ParameterInstr : public Definition { | 2914 class ParameterInstr : public Definition { |
2807 public: | 2915 public: |
2808 explicit ParameterInstr(intptr_t index) : index_(index) { } | 2916 explicit ParameterInstr(intptr_t index) : index_(index) { } |
2809 | 2917 |
2810 DECLARE_INSTRUCTION(Parameter) | 2918 DECLARE_INSTRUCTION(Parameter) |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2865 } | 2973 } |
2866 return locs_; | 2974 return locs_; |
2867 } | 2975 } |
2868 | 2976 |
2869 LocationSummary* MakeLocationSummary() const; | 2977 LocationSummary* MakeLocationSummary() const; |
2870 | 2978 |
2871 virtual void EmitNativeCode(FlowGraphCompiler* compiler); | 2979 virtual void EmitNativeCode(FlowGraphCompiler* compiler); |
2872 | 2980 |
2873 virtual bool CanDeoptimize() const { return false; } | 2981 virtual bool CanDeoptimize() const { return false; } |
2874 | 2982 |
2875 bool WasEliminated() const { | |
2876 return next() == NULL; | |
2877 } | |
2878 | |
2879 private: | 2983 private: |
2880 Value* value_; | 2984 Value* value_; |
2881 LocationSummary* locs_; | 2985 LocationSummary* locs_; |
2882 | 2986 |
2883 DISALLOW_COPY_AND_ASSIGN(PushArgumentInstr); | 2987 DISALLOW_COPY_AND_ASSIGN(PushArgumentInstr); |
2884 }; | 2988 }; |
2885 | 2989 |
2886 | 2990 |
2887 class ReturnInstr : public TemplateInstruction<1> { | 2991 class ReturnInstr : public TemplateInstruction<1> { |
2888 public: | 2992 public: |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3078 virtual LocationSummary* locs() { | 3182 virtual LocationSummary* locs() { |
3079 if (computation_->locs_ == NULL) { | 3183 if (computation_->locs_ == NULL) { |
3080 LocationSummary* summary = computation_->MakeLocationSummary(); | 3184 LocationSummary* summary = computation_->MakeLocationSummary(); |
3081 // Branches don't produce a result. | 3185 // Branches don't produce a result. |
3082 summary->set_out(Location::NoLocation()); | 3186 summary->set_out(Location::NoLocation()); |
3083 computation_->locs_ = summary; | 3187 computation_->locs_ = summary; |
3084 } | 3188 } |
3085 return computation_->locs_; | 3189 return computation_->locs_; |
3086 } | 3190 } |
3087 | 3191 |
3192 virtual intptr_t DeoptimizationTarget() const { | |
3193 return computation_->DeoptimizationTarget(); | |
3194 } | |
3195 | |
3196 virtual Representation RequiredInputRepresentation(intptr_t i) const { | |
3197 return computation()->RequiredInputRepresentation(i); | |
3198 } | |
3199 | |
3088 private: | 3200 private: |
3089 ComparisonComp* computation_; | 3201 ComparisonComp* computation_; |
3090 LocationSummary* locs_; | 3202 LocationSummary* locs_; |
3091 | 3203 |
3092 DISALLOW_COPY_AND_ASSIGN(BranchInstr); | 3204 DISALLOW_COPY_AND_ASSIGN(BranchInstr); |
3093 }; | 3205 }; |
3094 | 3206 |
3095 | 3207 |
3096 #undef DECLARE_INSTRUCTION | 3208 #undef DECLARE_INSTRUCTION |
3097 | 3209 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3182 ForwardInstructionIterator* current_iterator_; | 3294 ForwardInstructionIterator* current_iterator_; |
3183 | 3295 |
3184 private: | 3296 private: |
3185 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 3297 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
3186 }; | 3298 }; |
3187 | 3299 |
3188 | 3300 |
3189 } // namespace dart | 3301 } // namespace dart |
3190 | 3302 |
3191 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 3303 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
OLD | NEW |