OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 23 matching lines...) Expand all Loading... |
34 #include "safepoint-table.h" | 34 #include "safepoint-table.h" |
35 | 35 |
36 namespace v8 { | 36 namespace v8 { |
37 namespace internal { | 37 namespace internal { |
38 | 38 |
39 // Forward declarations. | 39 // Forward declarations. |
40 class LCodeGen; | 40 class LCodeGen; |
41 class LEnvironment; | 41 class LEnvironment; |
42 class Translation; | 42 class Translation; |
43 | 43 |
| 44 |
| 45 // Type hierarchy: |
| 46 // |
| 47 // LInstruction |
| 48 // LGap |
| 49 |
| 50 #define LITHIUM_ALL_INSTRUCTION_LIST(V) \ |
| 51 LITHIUM_CONCRETE_INSTRUCTION_LIST(V) |
| 52 |
| 53 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \ |
| 54 V(Gap) |
| 55 |
| 56 |
| 57 #define DECLARE_INSTRUCTION(type) \ |
| 58 virtual bool Is##type() const { return true; } \ |
| 59 static L##type* cast(LInstruction* instr) { \ |
| 60 ASSERT(instr->Is##type()); \ |
| 61 return reinterpret_cast<L##type*>(instr); \ |
| 62 } |
| 63 |
| 64 |
| 65 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \ |
| 66 virtual void CompileToNative(LCodeGen* generator); \ |
| 67 virtual const char* Mnemonic() const { return mnemonic; } \ |
| 68 DECLARE_INSTRUCTION(type) |
| 69 |
| 70 |
| 71 #define DECLARE_HYDROGEN_ACCESSOR(type) \ |
| 72 H##type* hydrogen() const { \ |
| 73 return H##type::cast(hydrogen_value()); \ |
| 74 } |
| 75 |
| 76 |
44 class LInstruction: public ZoneObject { | 77 class LInstruction: public ZoneObject { |
45 public: | 78 public: |
46 LInstruction() { } | 79 LInstruction() |
| 80 : hydrogen_value_(NULL) { } |
47 virtual ~LInstruction() { } | 81 virtual ~LInstruction() { } |
48 | 82 |
49 virtual void PrintTo(StringStream* stream) const { UNIMPLEMENTED(); } | |
50 virtual void PrintDataTo(StringStream* stream) const { } | |
51 | |
52 // Predicates should be generated by macro as in lithium-ia32.h. | 83 // Predicates should be generated by macro as in lithium-ia32.h. |
53 virtual bool IsLabel() const { | 84 virtual bool IsLabel() const { |
54 UNIMPLEMENTED(); | 85 UNIMPLEMENTED(); |
55 return false; | 86 return false; |
56 } | 87 } |
57 virtual bool IsOsrEntry() const { | 88 virtual bool IsOsrEntry() const { |
58 UNIMPLEMENTED(); | 89 UNIMPLEMENTED(); |
59 return false; | 90 return false; |
60 } | 91 } |
61 | 92 |
| 93 virtual void CompileToNative(LCodeGen* generator) = 0; |
| 94 virtual const char* Mnemonic() const = 0; |
| 95 virtual void PrintTo(StringStream* stream) const; |
| 96 virtual void PrintDataTo(StringStream* stream) const { } |
| 97 |
| 98 // Declare virtual type testers. |
| 99 #define DECLARE_DO(type) virtual bool Is##type() const { return false; } |
| 100 LITHIUM_ALL_INSTRUCTION_LIST(DECLARE_DO) |
| 101 #undef DECLARE_DO |
| 102 virtual bool IsControl() const { return false; } |
| 103 |
62 void set_environment(LEnvironment* env) { environment_.set(env); } | 104 void set_environment(LEnvironment* env) { environment_.set(env); } |
63 LEnvironment* environment() const { return environment_.get(); } | 105 LEnvironment* environment() const { return environment_.get(); } |
64 bool HasEnvironment() const { return environment_.is_set(); } | 106 bool HasEnvironment() const { return environment_.is_set(); } |
65 | 107 |
66 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); } | 108 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); } |
67 LPointerMap* pointer_map() const { return pointer_map_.get(); } | 109 LPointerMap* pointer_map() const { return pointer_map_.get(); } |
68 bool HasPointerMap() const { return pointer_map_.is_set(); } | 110 bool HasPointerMap() const { return pointer_map_.is_set(); } |
69 | 111 |
70 void set_result(LOperand* operand) { result_.set(operand); } | 112 void set_result(LOperand* operand) { result_.set(operand); } |
71 LOperand* result() const { return result_.get(); } | 113 LOperand* result() const { return result_.get(); } |
(...skipping 14 matching lines...) Expand all Loading... |
86 | 128 |
87 private: | 129 private: |
88 SetOncePointer<LEnvironment> environment_; | 130 SetOncePointer<LEnvironment> environment_; |
89 SetOncePointer<LPointerMap> pointer_map_; | 131 SetOncePointer<LPointerMap> pointer_map_; |
90 SetOncePointer<LOperand> result_; | 132 SetOncePointer<LOperand> result_; |
91 HValue* hydrogen_value_; | 133 HValue* hydrogen_value_; |
92 SetOncePointer<LEnvironment> deoptimization_environment_; | 134 SetOncePointer<LEnvironment> deoptimization_environment_; |
93 }; | 135 }; |
94 | 136 |
95 | 137 |
96 class LParallelMove : public ZoneObject { | |
97 public: | |
98 LParallelMove() : move_operands_(4) { } | |
99 | |
100 void AddMove(LOperand* from, LOperand* to) { | |
101 UNIMPLEMENTED(); | |
102 } | |
103 | |
104 const ZoneList<LMoveOperands>* move_operands() const { | |
105 UNIMPLEMENTED(); | |
106 return NULL; | |
107 } | |
108 | |
109 private: | |
110 ZoneList<LMoveOperands> move_operands_; | |
111 }; | |
112 | |
113 | |
114 class LGap: public LInstruction { | 138 class LGap: public LInstruction { |
115 public: | 139 public: |
116 explicit LGap(HBasicBlock* block) { } | 140 explicit LGap(HBasicBlock* block) |
| 141 : block_(block) { |
| 142 parallel_moves_[BEFORE] = NULL; |
| 143 parallel_moves_[START] = NULL; |
| 144 parallel_moves_[END] = NULL; |
| 145 parallel_moves_[AFTER] = NULL; |
| 146 } |
117 | 147 |
118 HBasicBlock* block() const { | 148 DECLARE_CONCRETE_INSTRUCTION(Gap, "gap") |
119 UNIMPLEMENTED(); | 149 virtual void PrintDataTo(StringStream* stream) const; |
120 return NULL; | 150 |
121 } | 151 bool IsRedundant() const; |
| 152 |
| 153 HBasicBlock* block() const { return block_; } |
122 | 154 |
123 enum InnerPosition { | 155 enum InnerPosition { |
124 BEFORE, | 156 BEFORE, |
125 START, | 157 START, |
126 END, | 158 END, |
127 AFTER, | 159 AFTER, |
128 FIRST_INNER_POSITION = BEFORE, | 160 FIRST_INNER_POSITION = BEFORE, |
129 LAST_INNER_POSITION = AFTER | 161 LAST_INNER_POSITION = AFTER |
130 }; | 162 }; |
131 | 163 |
132 LParallelMove* GetOrCreateParallelMove(InnerPosition pos) { | 164 LParallelMove* GetOrCreateParallelMove(InnerPosition pos) { |
133 UNIMPLEMENTED(); | 165 if (parallel_moves_[pos] == NULL) parallel_moves_[pos] = new LParallelMove; |
134 return NULL; | 166 return parallel_moves_[pos]; |
135 } | 167 } |
136 | 168 |
137 LParallelMove* GetParallelMove(InnerPosition pos) { | 169 LParallelMove* GetParallelMove(InnerPosition pos) { |
138 UNIMPLEMENTED(); | 170 return parallel_moves_[pos]; |
139 return NULL; | |
140 } | 171 } |
141 | 172 |
142 private: | 173 private: |
143 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1]; | 174 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1]; |
144 HBasicBlock* block_; | 175 HBasicBlock* block_; |
145 }; | 176 }; |
146 | 177 |
147 | 178 |
148 class LLabel: public LGap { | 179 class LLabel: public LGap { |
149 public: | 180 public: |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 LInstruction* instructions_pending_deoptimization_environment_; | 418 LInstruction* instructions_pending_deoptimization_environment_; |
388 int pending_deoptimization_ast_id_; | 419 int pending_deoptimization_ast_id_; |
389 | 420 |
390 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder); | 421 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder); |
391 }; | 422 }; |
392 | 423 |
393 | 424 |
394 } } // namespace v8::internal | 425 } } // namespace v8::internal |
395 | 426 |
396 #endif // V8_X64_LITHIUM_X64_H_ | 427 #endif // V8_X64_LITHIUM_X64_H_ |
OLD | NEW |