Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: runtime/vm/intermediate_language.h

Issue 10875030: Add support for XMM registers in SSA code generation pipeline. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 M(CatchEntry, CatchEntryComp) \ 96 M(CatchEntry, CatchEntryComp) \
97 M(BinarySmiOp, BinarySmiOpComp) \ 97 M(BinarySmiOp, BinarySmiOpComp) \
98 M(BinaryMintOp, BinaryMintOpComp) \ 98 M(BinaryMintOp, BinaryMintOpComp) \
99 M(BinaryDoubleOp, BinaryDoubleOpComp) \ 99 M(BinaryDoubleOp, BinaryDoubleOpComp) \
100 M(UnarySmiOp, UnarySmiOpComp) \ 100 M(UnarySmiOp, UnarySmiOpComp) \
101 M(NumberNegate, NumberNegateComp) \ 101 M(NumberNegate, NumberNegateComp) \
102 M(CheckStackOverflow, CheckStackOverflowComp) \ 102 M(CheckStackOverflow, CheckStackOverflowComp) \
103 M(DoubleToDouble, DoubleToDoubleComp) \ 103 M(DoubleToDouble, DoubleToDoubleComp) \
104 M(SmiToDouble, SmiToDoubleComp) \ 104 M(SmiToDouble, SmiToDoubleComp) \
105 M(CheckClass, CheckClassComp) \ 105 M(CheckClass, CheckClassComp) \
106 M(Materialize, MaterializeComp) 106 M(Materialize, MaterializeComp) \
107 M(CheckEitherNonSmi, CheckEitherNonSmiComp) \
108 M(UnboxedDoubleBinaryOp, UnboxedDoubleBinaryOpComp) \
109 M(UnboxDouble, UnboxDoubleComp) \
110 M(BoxDouble, BoxDoubleComp)
107 111
108 112
109 #define FORWARD_DECLARATION(ShortName, ClassName) class ClassName; 113 #define FORWARD_DECLARATION(ShortName, ClassName) class ClassName;
110 FOR_EACH_COMPUTATION(FORWARD_DECLARATION) 114 FOR_EACH_COMPUTATION(FORWARD_DECLARATION)
111 FOR_EACH_VALUE(FORWARD_DECLARATION) 115 FOR_EACH_VALUE(FORWARD_DECLARATION)
112 #undef FORWARD_DECLARATION 116 #undef FORWARD_DECLARATION
113 117
114 // Forward declarations. 118 // Forward declarations.
115 class BindInstr; 119 class BindInstr;
116 class BranchInstr; 120 class BranchInstr;
117 class BufferFormatter; 121 class BufferFormatter;
118 class ComparisonComp; 122 class ComparisonComp;
119 class Definition; 123 class Definition;
120 class Instruction; 124 class Instruction;
121 class PushArgumentInstr; 125 class PushArgumentInstr;
122 class Value; 126 class Value;
123 127
128
129 enum Representation {
130 kTagged, kUnboxedDouble
131 };
132
133
124 class Computation : public ZoneAllocated { 134 class Computation : public ZoneAllocated {
125 public: 135 public:
126 Computation() : deopt_id_(Isolate::kNoDeoptId), ic_data_(NULL), locs_(NULL) { 136 Computation() : deopt_id_(Isolate::kNoDeoptId), ic_data_(NULL), locs_(NULL) {
127 Isolate* isolate = Isolate::Current(); 137 Isolate* isolate = Isolate::Current();
128 deopt_id_ = isolate->GetNextDeoptId(); 138 deopt_id_ = isolate->GetNextDeoptId();
129 ic_data_ = isolate->GetICDataForDeoptId(deopt_id_); 139 ic_data_ = isolate->GetICDataForDeoptId(deopt_id_);
130 } 140 }
131 141
132 // Unique id used for deoptimization. 142 // Unique id used for deoptimization.
133 intptr_t deopt_id() const { return deopt_id_; } 143 intptr_t deopt_id() const { return deopt_id_; }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 enum ComputationKind { 228 enum ComputationKind {
219 #define DECLARE_COMPUTATION_KIND(ShortName, ClassName) k##ShortName, 229 #define DECLARE_COMPUTATION_KIND(ShortName, ClassName) k##ShortName,
220 230
221 FOR_EACH_COMPUTATION(DECLARE_COMPUTATION_KIND) 231 FOR_EACH_COMPUTATION(DECLARE_COMPUTATION_KIND)
222 232
223 #undef DECLARE_COMPUTATION_KIND 233 #undef DECLARE_COMPUTATION_KIND
224 }; 234 };
225 235
226 virtual ComputationKind computation_kind() const = 0; 236 virtual ComputationKind computation_kind() const = 0;
227 237
238 virtual Representation representation() const {
239 return kTagged;
240 }
241
228 // Declare predicate for each computation. 242 // Declare predicate for each computation.
229 #define DECLARE_PREDICATE(ShortName, ClassName) \ 243 #define DECLARE_PREDICATE(ShortName, ClassName) \
230 inline bool Is##ShortName() const; \ 244 inline bool Is##ShortName() const; \
231 inline const ClassName* As##ShortName() const; \ 245 inline const ClassName* As##ShortName() const; \
232 inline ClassName* As##ShortName(); 246 inline ClassName* As##ShortName();
233 FOR_EACH_COMPUTATION(DECLARE_PREDICATE) 247 FOR_EACH_COMPUTATION(DECLARE_PREDICATE)
234 #undef DECLARE_PREDICATE 248 #undef DECLARE_PREDICATE
235 249
236 private: 250 private:
237 intptr_t deopt_id_; 251 intptr_t deopt_id_;
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 434
421 UseVal* next_use() const { return next_use_; } 435 UseVal* next_use() const { return next_use_; }
422 UseVal* previous_use() const { return previous_use_; } 436 UseVal* previous_use() const { return previous_use_; }
423 virtual void RemoveFromUseList(); 437 virtual void RemoveFromUseList();
424 virtual void RemoveInputUses() { RemoveFromUseList(); } 438 virtual void RemoveInputUses() { RemoveFromUseList(); }
425 439
426 virtual intptr_t ResultCid() const; 440 virtual intptr_t ResultCid() const;
427 441
428 private: 442 private:
429 void AddToUseList(); 443 void AddToUseList();
444
430 Definition* definition_; 445 Definition* definition_;
431 UseVal* next_use_; 446 UseVal* next_use_;
432 UseVal* previous_use_; 447 UseVal* previous_use_;
433 448
434 friend class Definition; 449 friend class Definition;
435 450
436 DISALLOW_COPY_AND_ASSIGN(UseVal); 451 DISALLOW_COPY_AND_ASSIGN(UseVal);
437 }; 452 };
438 453
439 454
(...skipping 1203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1643 virtual bool CanDeoptimize() const { return false; } 1658 virtual bool CanDeoptimize() const { return false; }
1644 1659
1645 private: 1660 private:
1646 const LocalVariable& exception_var_; 1661 const LocalVariable& exception_var_;
1647 const LocalVariable& stacktrace_var_; 1662 const LocalVariable& stacktrace_var_;
1648 1663
1649 DISALLOW_COPY_AND_ASSIGN(CatchEntryComp); 1664 DISALLOW_COPY_AND_ASSIGN(CatchEntryComp);
1650 }; 1665 };
1651 1666
1652 1667
1668 class CheckEitherNonSmiComp : public TemplateComputation<2> {
1669 public:
1670 CheckEitherNonSmiComp(Value* left, Value* right, InstanceCallComp* original)
1671 : original_(original) {
1672 ASSERT(left != NULL);
1673 ASSERT(right != NULL);
1674 inputs_[0] = left;
1675 inputs_[1] = right;
1676 }
1677
1678 DECLARE_COMPUTATION(CheckEitherNonSmi)
1679
1680 virtual bool CanDeoptimize() const { return true; }
1681
1682 virtual bool HasSideEffect() const { return false; }
1683
1684 Value* left() const { return inputs_[0]; }
1685
1686 Value* right() const { return inputs_[0]; }
1687
1688 intptr_t deopt_id() const { return original_->deopt_id(); }
Florian Schneider 2012/08/24 11:09:28 Either add accessors to the other deoptimizing ins
Vyacheslav Egorov (Google) 2012/08/24 13:23:01 Done.
Vyacheslav Egorov (Google) 2012/08/24 13:23:01 Done.
1689 intptr_t try_index() const { return original_->try_index(); }
1690
1691 private:
1692 InstanceCallComp* original_;
Florian Schneider 2012/08/24 11:09:28 Maybe rename to instance_call_ for consistency?
Vyacheslav Egorov (Google) 2012/08/24 13:23:01 Done.
1693
1694 DISALLOW_COPY_AND_ASSIGN(CheckEitherNonSmiComp);
1695 };
1696
1697
1698 class BoxDoubleComp : public TemplateComputation<1> {
1699 public:
1700 BoxDoubleComp(Value* value, InstanceCallComp* instance_call)
1701 : instance_call_(instance_call) {
1702 ASSERT(value != NULL);
1703 inputs_[0] = value;
1704 }
1705
1706 Value* value() const { return inputs_[0]; }
1707 InstanceCallComp* instance_call() const { return instance_call_; }
1708
1709 virtual bool CanDeoptimize() const { return false; }
1710
1711 virtual intptr_t ResultCid() const;
1712
1713 DECLARE_COMPUTATION(BoxDouble)
1714
1715 private:
1716 InstanceCallComp* instance_call_;
1717
1718 DISALLOW_COPY_AND_ASSIGN(BoxDoubleComp);
1719 };
1720
1721
1722 class UnboxDoubleComp : public TemplateComputation<1> {
1723 public:
1724 UnboxDoubleComp(Value* value, InstanceCallComp* instance_call)
1725 : instance_call_(instance_call) {
1726 ASSERT(value != NULL);
1727 inputs_[0] = value;
1728 }
1729
1730 Value* value() const { return inputs_[0]; }
1731 InstanceCallComp* instance_call() const { return instance_call_; }
1732
1733 virtual bool CanDeoptimize() const { return true; }
Florian Schneider 2012/08/24 11:09:28 More precisely: return (value()->ResultCid() != k
Vyacheslav Egorov (Google) 2012/08/24 13:23:01 Done.
1734
1735 virtual Representation representation() const {
1736 return kUnboxedDouble;
1737 }
1738
1739 DECLARE_COMPUTATION(UnboxDouble)
1740
1741 private:
1742 InstanceCallComp* instance_call_;
1743
1744 DISALLOW_COPY_AND_ASSIGN(UnboxDoubleComp);
1745 };
1746
1747
1748 class UnboxedDoubleBinaryOpComp : public TemplateComputation<2> {
1749 public:
1750 UnboxedDoubleBinaryOpComp(Token::Kind op_kind,
1751 InstanceCallComp* instance_call,
1752 Value* left,
1753 Value* right)
1754 : op_kind_(op_kind),
1755 instance_call_(instance_call) {
1756 ASSERT(left != NULL);
1757 ASSERT(right != NULL);
1758 inputs_[0] = left;
1759 inputs_[1] = right;
1760 }
1761
1762 Value* left() const { return inputs_[0]; }
1763 Value* right() const { return inputs_[1]; }
1764
1765 Token::Kind op_kind() const { return op_kind_; }
1766
1767 InstanceCallComp* instance_call() const { return instance_call_; }
1768
1769 virtual void PrintOperandsTo(BufferFormatter* f) const;
1770
1771 virtual bool CanDeoptimize() const { return false; }
1772
1773 virtual Representation representation() const {
1774 return kUnboxedDouble;
1775 }
1776
1777 DECLARE_COMPUTATION(UnboxedDoubleBinaryOp)
1778
1779 private:
1780 const Token::Kind op_kind_;
1781 InstanceCallComp* instance_call_;
Florian Schneider 2012/08/24 11:09:28 No need for instance_call_ here. This instruction
Vyacheslav Egorov (Google) 2012/08/24 13:23:01 Done.
1782
1783 DISALLOW_COPY_AND_ASSIGN(UnboxedDoubleBinaryOpComp);
1784 };
1785
1786
1653 class BinarySmiOpComp : public TemplateComputation<2> { 1787 class BinarySmiOpComp : public TemplateComputation<2> {
1654 public: 1788 public:
1655 BinarySmiOpComp(Token::Kind op_kind, 1789 BinarySmiOpComp(Token::Kind op_kind,
1656 InstanceCallComp* instance_call, 1790 InstanceCallComp* instance_call,
1657 Value* left, 1791 Value* left,
1658 Value* right) 1792 Value* right)
1659 : op_kind_(op_kind), 1793 : op_kind_(op_kind),
1660 instance_call_(instance_call) { 1794 instance_call_(instance_call) {
1661 ASSERT(left != NULL); 1795 ASSERT(left != NULL);
1662 ASSERT(right != NULL); 1796 ASSERT(right != NULL);
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
2086 } 2220 }
2087 2221
2088 Environment* env() const { return env_; } 2222 Environment* env() const { return env_; }
2089 void set_env(Environment* env) { env_ = env; } 2223 void set_env(Environment* env) { env_ = env; }
2090 2224
2091 intptr_t lifetime_position() const { return lifetime_position_; } 2225 intptr_t lifetime_position() const { return lifetime_position_; }
2092 void set_lifetime_position(intptr_t pos) { 2226 void set_lifetime_position(intptr_t pos) {
2093 lifetime_position_ = pos; 2227 lifetime_position_ = pos;
2094 } 2228 }
2095 2229
2230 virtual Representation representation() const {
2231 return kTagged;
2232 }
2233
2096 private: 2234 private:
2097 friend class BindInstr; // Needed for BindInstr::InsertBefore. 2235 friend class BindInstr; // Needed for BindInstr::InsertBefore.
2098 2236
2099 intptr_t lifetime_position_; // Position used by register allocator. 2237 intptr_t lifetime_position_; // Position used by register allocator.
2100 Instruction* previous_; 2238 Instruction* previous_;
2101 Instruction* next_; 2239 Instruction* next_;
2102 Environment* env_; 2240 Environment* env_;
2103 DISALLOW_COPY_AND_ASSIGN(Instruction); 2241 DISALLOW_COPY_AND_ASSIGN(Instruction);
2104 }; 2242 };
2105 2243
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
2654 return computation()->locs(); 2792 return computation()->locs();
2655 } 2793 }
2656 2794
2657 virtual void EmitNativeCode(FlowGraphCompiler* compiler); 2795 virtual void EmitNativeCode(FlowGraphCompiler* compiler);
2658 2796
2659 virtual void RemoveInputUses() { computation()->RemoveInputUses(); } 2797 virtual void RemoveInputUses() { computation()->RemoveInputUses(); }
2660 2798
2661 // Insert this instruction before 'next'. 2799 // Insert this instruction before 'next'.
2662 void InsertBefore(BindInstr* next); 2800 void InsertBefore(BindInstr* next);
2663 2801
2802 virtual Representation representation() const {
2803 return computation()->representation();
2804 }
2805
2664 private: 2806 private:
2665 Computation* computation_; 2807 Computation* computation_;
2666 const bool is_used_; 2808 const bool is_used_;
2667 2809
2668 DISALLOW_COPY_AND_ASSIGN(BindInstr); 2810 DISALLOW_COPY_AND_ASSIGN(BindInstr);
2669 }; 2811 };
2670 2812
2671 2813
2672 class PhiInstr : public Definition { 2814 class PhiInstr : public Definition {
2673 public: 2815 public:
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
3058 ASSERT((ix >= 0) && (ix < values_.length())); 3200 ASSERT((ix >= 0) && (ix < values_.length()));
3059 return &locations_[ix]; 3201 return &locations_[ix];
3060 } 3202 }
3061 3203
3062 intptr_t fixed_parameter_count() const { 3204 intptr_t fixed_parameter_count() const {
3063 return fixed_parameter_count_; 3205 return fixed_parameter_count_;
3064 } 3206 }
3065 3207
3066 void PrintTo(BufferFormatter* f) const; 3208 void PrintTo(BufferFormatter* f) const;
3067 3209
3210 Environment* Clone() const {
3211 return new Environment(values_, fixed_parameter_count_);
3212 }
3213
3068 private: 3214 private:
3215 Environment(const GrowableArray<Value*>& values,
3216 intptr_t fixed_parameter_count);
3217
3069 GrowableArray<Value*> values_; 3218 GrowableArray<Value*> values_;
3070 Location* locations_; 3219 Location* locations_;
3071 const intptr_t fixed_parameter_count_; 3220 const intptr_t fixed_parameter_count_;
3072 3221
3073 DISALLOW_COPY_AND_ASSIGN(Environment); 3222 DISALLOW_COPY_AND_ASSIGN(Environment);
3074 }; 3223 };
3075 3224
3076 3225
3077 // Visitor base class to visit each instruction and computation in a flow 3226 // Visitor base class to visit each instruction and computation in a flow
3078 // graph as defined by a reversed list of basic blocks. 3227 // graph as defined by a reversed list of basic blocks.
(...skipping 30 matching lines...) Expand all
3109 ForwardInstructionIterator* current_iterator_; 3258 ForwardInstructionIterator* current_iterator_;
3110 3259
3111 private: 3260 private:
3112 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 3261 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
3113 }; 3262 };
3114 3263
3115 3264
3116 } // namespace dart 3265 } // namespace dart
3117 3266
3118 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 3267 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698