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 21 matching lines...) Expand all Loading... |
32 #include "lithium-allocator.h" | 32 #include "lithium-allocator.h" |
33 #include "lithium.h" | 33 #include "lithium.h" |
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 | 41 |
42 | |
43 #define LITHIUM_ALL_INSTRUCTION_LIST(V) \ | |
44 V(ControlInstruction) \ | |
45 V(Call) \ | |
46 LITHIUM_CONCRETE_INSTRUCTION_LIST(V) | |
47 | |
48 | |
49 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \ | 42 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \ |
50 V(AccessArgumentsAt) \ | 43 V(AccessArgumentsAt) \ |
51 V(AddI) \ | 44 V(AddI) \ |
52 V(ApplyArguments) \ | 45 V(ApplyArguments) \ |
53 V(ArgumentsElements) \ | 46 V(ArgumentsElements) \ |
54 V(ArgumentsLength) \ | 47 V(ArgumentsLength) \ |
55 V(ArithmeticD) \ | 48 V(ArithmeticD) \ |
56 V(ArithmeticT) \ | 49 V(ArithmeticT) \ |
57 V(ArrayLiteral) \ | 50 V(ArrayLiteral) \ |
58 V(BitI) \ | 51 V(BitI) \ |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 V(Throw) \ | 158 V(Throw) \ |
166 V(ToFastProperties) \ | 159 V(ToFastProperties) \ |
167 V(Typeof) \ | 160 V(Typeof) \ |
168 V(TypeofIs) \ | 161 V(TypeofIs) \ |
169 V(TypeofIsAndBranch) \ | 162 V(TypeofIsAndBranch) \ |
170 V(UnaryMathOperation) \ | 163 V(UnaryMathOperation) \ |
171 V(UnknownOSRValue) \ | 164 V(UnknownOSRValue) \ |
172 V(ValueOf) | 165 V(ValueOf) |
173 | 166 |
174 | 167 |
175 #define DECLARE_INSTRUCTION(type) \ | 168 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \ |
176 virtual bool Is##type() const { return true; } \ | 169 virtual Opcode opcode() const { return LInstruction::k##type; } \ |
177 static L##type* cast(LInstruction* instr) { \ | 170 virtual void CompileToNative(LCodeGen* generator); \ |
178 ASSERT(instr->Is##type()); \ | 171 virtual const char* Mnemonic() const { return mnemonic; } \ |
179 return reinterpret_cast<L##type*>(instr); \ | 172 static L##type* cast(LInstruction* instr) { \ |
| 173 ASSERT(instr->Is##type()); \ |
| 174 return reinterpret_cast<L##type*>(instr); \ |
180 } | 175 } |
181 | 176 |
182 | 177 |
183 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \ | |
184 virtual void CompileToNative(LCodeGen* generator); \ | |
185 virtual const char* Mnemonic() const { return mnemonic; } \ | |
186 DECLARE_INSTRUCTION(type) | |
187 | |
188 | |
189 #define DECLARE_HYDROGEN_ACCESSOR(type) \ | 178 #define DECLARE_HYDROGEN_ACCESSOR(type) \ |
190 H##type* hydrogen() const { \ | 179 H##type* hydrogen() const { \ |
191 return H##type::cast(hydrogen_value()); \ | 180 return H##type::cast(hydrogen_value()); \ |
192 } | 181 } |
193 | 182 |
194 | 183 |
195 class LInstruction: public ZoneObject { | 184 class LInstruction: public ZoneObject { |
196 public: | 185 public: |
197 LInstruction() | 186 LInstruction() |
198 : environment_(NULL), | 187 : environment_(NULL), |
199 hydrogen_value_(NULL), | 188 hydrogen_value_(NULL), |
200 is_call_(false), | 189 is_call_(false), |
201 is_save_doubles_(false) { } | 190 is_save_doubles_(false) { } |
202 virtual ~LInstruction() { } | 191 virtual ~LInstruction() { } |
203 | 192 |
204 virtual void CompileToNative(LCodeGen* generator) = 0; | 193 virtual void CompileToNative(LCodeGen* generator) = 0; |
205 virtual const char* Mnemonic() const = 0; | 194 virtual const char* Mnemonic() const = 0; |
206 virtual void PrintTo(StringStream* stream); | 195 virtual void PrintTo(StringStream* stream); |
207 virtual void PrintDataTo(StringStream* stream) = 0; | 196 virtual void PrintDataTo(StringStream* stream) = 0; |
208 virtual void PrintOutputOperandTo(StringStream* stream) = 0; | 197 virtual void PrintOutputOperandTo(StringStream* stream) = 0; |
209 | 198 |
| 199 enum Opcode { |
| 200 // Declare a unique enum value for each instruction. |
| 201 #define DECLARE_OPCODE(type) k##type, |
| 202 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE) |
| 203 kNumberOfInstructions |
| 204 #undef DECLARE_OPCODE |
| 205 }; |
| 206 |
| 207 virtual Opcode opcode() const = 0; |
| 208 |
210 // Declare virtual type testers. | 209 // Declare virtual type testers. |
211 #define DECLARE_DO(type) virtual bool Is##type() const { return false; } | 210 #define DECLARE_PREDICATE(type) \ |
212 LITHIUM_ALL_INSTRUCTION_LIST(DECLARE_DO) | 211 bool Is##type() const { return opcode() == k##type; } |
213 #undef DECLARE_DO | 212 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE) |
| 213 #undef DECLARE_PREDICATE |
214 | 214 |
215 virtual bool IsControl() const { return false; } | 215 virtual bool IsControl() const { return false; } |
216 virtual void SetBranchTargets(int true_block_id, int false_block_id) { } | 216 virtual void SetBranchTargets(int true_block_id, int false_block_id) { } |
217 | 217 |
218 void set_environment(LEnvironment* env) { environment_ = env; } | 218 void set_environment(LEnvironment* env) { environment_ = env; } |
219 LEnvironment* environment() const { return environment_; } | 219 LEnvironment* environment() const { return environment_; } |
220 bool HasEnvironment() const { return environment_ != NULL; } | 220 bool HasEnvironment() const { return environment_ != NULL; } |
221 | 221 |
222 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); } | 222 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); } |
223 LPointerMap* pointer_map() const { return pointer_map_.get(); } | 223 LPointerMap* pointer_map() const { return pointer_map_.get(); } |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 | 456 |
457 class LUnknownOSRValue: public LTemplateInstruction<1, 0, 0> { | 457 class LUnknownOSRValue: public LTemplateInstruction<1, 0, 0> { |
458 public: | 458 public: |
459 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value") | 459 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value") |
460 }; | 460 }; |
461 | 461 |
462 | 462 |
463 template<int I, int T> | 463 template<int I, int T> |
464 class LControlInstruction: public LTemplateInstruction<0, I, T> { | 464 class LControlInstruction: public LTemplateInstruction<0, I, T> { |
465 public: | 465 public: |
466 DECLARE_INSTRUCTION(ControlInstruction) | |
467 virtual bool IsControl() const { return true; } | 466 virtual bool IsControl() const { return true; } |
468 | 467 |
469 int true_block_id() const { return true_block_id_; } | 468 int true_block_id() const { return true_block_id_; } |
470 int false_block_id() const { return false_block_id_; } | 469 int false_block_id() const { return false_block_id_; } |
471 void SetBranchTargets(int true_block_id, int false_block_id) { | 470 void SetBranchTargets(int true_block_id, int false_block_id) { |
472 true_block_id_ = true_block_id; | 471 true_block_id_ = true_block_id; |
473 false_block_id_ = false_block_id; | 472 false_block_id_ = false_block_id; |
474 } | 473 } |
475 | 474 |
476 private: | 475 private: |
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1126 class LArithmeticD: public LTemplateInstruction<1, 2, 0> { | 1125 class LArithmeticD: public LTemplateInstruction<1, 2, 0> { |
1127 public: | 1126 public: |
1128 LArithmeticD(Token::Value op, LOperand* left, LOperand* right) | 1127 LArithmeticD(Token::Value op, LOperand* left, LOperand* right) |
1129 : op_(op) { | 1128 : op_(op) { |
1130 inputs_[0] = left; | 1129 inputs_[0] = left; |
1131 inputs_[1] = right; | 1130 inputs_[1] = right; |
1132 } | 1131 } |
1133 | 1132 |
1134 Token::Value op() const { return op_; } | 1133 Token::Value op() const { return op_; } |
1135 | 1134 |
| 1135 virtual Opcode opcode() const { return LInstruction::kArithmeticD; } |
1136 virtual void CompileToNative(LCodeGen* generator); | 1136 virtual void CompileToNative(LCodeGen* generator); |
1137 virtual const char* Mnemonic() const; | 1137 virtual const char* Mnemonic() const; |
1138 | 1138 |
1139 private: | 1139 private: |
1140 Token::Value op_; | 1140 Token::Value op_; |
1141 }; | 1141 }; |
1142 | 1142 |
1143 | 1143 |
1144 class LArithmeticT: public LTemplateInstruction<1, 2, 0> { | 1144 class LArithmeticT: public LTemplateInstruction<1, 2, 0> { |
1145 public: | 1145 public: |
1146 LArithmeticT(Token::Value op, LOperand* left, LOperand* right) | 1146 LArithmeticT(Token::Value op, LOperand* left, LOperand* right) |
1147 : op_(op) { | 1147 : op_(op) { |
1148 inputs_[0] = left; | 1148 inputs_[0] = left; |
1149 inputs_[1] = right; | 1149 inputs_[1] = right; |
1150 } | 1150 } |
1151 | 1151 |
| 1152 virtual Opcode opcode() const { return LInstruction::kArithmeticT; } |
1152 virtual void CompileToNative(LCodeGen* generator); | 1153 virtual void CompileToNative(LCodeGen* generator); |
1153 virtual const char* Mnemonic() const; | 1154 virtual const char* Mnemonic() const; |
1154 | 1155 |
1155 Token::Value op() const { return op_; } | 1156 Token::Value op() const { return op_; } |
1156 | 1157 |
1157 private: | 1158 private: |
1158 Token::Value op_; | 1159 Token::Value op_; |
1159 }; | 1160 }; |
1160 | 1161 |
1161 | 1162 |
(...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2261 int argument_count_; | 2262 int argument_count_; |
2262 LAllocator* allocator_; | 2263 LAllocator* allocator_; |
2263 int position_; | 2264 int position_; |
2264 LInstruction* instruction_pending_deoptimization_environment_; | 2265 LInstruction* instruction_pending_deoptimization_environment_; |
2265 int pending_deoptimization_ast_id_; | 2266 int pending_deoptimization_ast_id_; |
2266 | 2267 |
2267 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder); | 2268 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder); |
2268 }; | 2269 }; |
2269 | 2270 |
2270 #undef DECLARE_HYDROGEN_ACCESSOR | 2271 #undef DECLARE_HYDROGEN_ACCESSOR |
2271 #undef DECLARE_INSTRUCTION | |
2272 #undef DECLARE_CONCRETE_INSTRUCTION | 2272 #undef DECLARE_CONCRETE_INSTRUCTION |
2273 | 2273 |
2274 } } // namespace v8::internal | 2274 } } // namespace v8::internal |
2275 | 2275 |
2276 #endif // V8_IA32_LITHIUM_IA32_H_ | 2276 #endif // V8_IA32_LITHIUM_IA32_H_ |
OLD | NEW |