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 #define LITHIUM_ALL_INSTRUCTION_LIST(V) \ |
| 43 V(ControlInstruction) \ |
| 44 V(Call) \ |
| 45 LITHIUM_CONCRETE_INSTRUCTION_LIST(V) |
| 46 |
| 47 |
42 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \ | 48 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \ |
43 V(AccessArgumentsAt) \ | 49 V(AccessArgumentsAt) \ |
44 V(AddI) \ | 50 V(AddI) \ |
45 V(ApplyArguments) \ | 51 V(ApplyArguments) \ |
46 V(ArgumentsElements) \ | 52 V(ArgumentsElements) \ |
47 V(ArgumentsLength) \ | 53 V(ArgumentsLength) \ |
48 V(ArithmeticD) \ | 54 V(ArithmeticD) \ |
49 V(ArithmeticT) \ | 55 V(ArithmeticT) \ |
50 V(ArrayLiteral) \ | 56 V(ArrayLiteral) \ |
51 V(BitI) \ | 57 V(BitI) \ |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 V(Typeof) \ | 164 V(Typeof) \ |
159 V(TypeofIs) \ | 165 V(TypeofIs) \ |
160 V(TypeofIsAndBranch) \ | 166 V(TypeofIsAndBranch) \ |
161 V(IsConstructCall) \ | 167 V(IsConstructCall) \ |
162 V(IsConstructCallAndBranch) \ | 168 V(IsConstructCallAndBranch) \ |
163 V(UnaryMathOperation) \ | 169 V(UnaryMathOperation) \ |
164 V(UnknownOSRValue) \ | 170 V(UnknownOSRValue) \ |
165 V(ValueOf) | 171 V(ValueOf) |
166 | 172 |
167 | 173 |
168 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \ | 174 #define DECLARE_INSTRUCTION(type) \ |
169 virtual Opcode opcode() const { return LInstruction::k##type; } \ | 175 virtual bool Is##type() const { return true; } \ |
170 virtual void CompileToNative(LCodeGen* generator); \ | 176 static L##type* cast(LInstruction* instr) { \ |
171 virtual const char* Mnemonic() const { return mnemonic; } \ | 177 ASSERT(instr->Is##type()); \ |
172 static L##type* cast(LInstruction* instr) { \ | 178 return reinterpret_cast<L##type*>(instr); \ |
173 ASSERT(instr->Is##type()); \ | |
174 return reinterpret_cast<L##type*>(instr); \ | |
175 } | 179 } |
176 | 180 |
177 | 181 |
| 182 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \ |
| 183 virtual void CompileToNative(LCodeGen* generator); \ |
| 184 virtual const char* Mnemonic() const { return mnemonic; } \ |
| 185 DECLARE_INSTRUCTION(type) |
| 186 |
| 187 |
178 #define DECLARE_HYDROGEN_ACCESSOR(type) \ | 188 #define DECLARE_HYDROGEN_ACCESSOR(type) \ |
179 H##type* hydrogen() const { \ | 189 H##type* hydrogen() const { \ |
180 return H##type::cast(hydrogen_value()); \ | 190 return H##type::cast(hydrogen_value()); \ |
181 } | 191 } |
182 | 192 |
183 | 193 |
184 class LInstruction: public ZoneObject { | 194 class LInstruction: public ZoneObject { |
185 public: | 195 public: |
186 LInstruction() | 196 LInstruction() |
187 : environment_(NULL), | 197 : environment_(NULL), |
188 hydrogen_value_(NULL), | 198 hydrogen_value_(NULL), |
189 is_call_(false), | 199 is_call_(false), |
190 is_save_doubles_(false) { } | 200 is_save_doubles_(false) { } |
191 | 201 |
192 virtual ~LInstruction() { } | 202 virtual ~LInstruction() { } |
193 | 203 |
194 virtual void CompileToNative(LCodeGen* generator) = 0; | 204 virtual void CompileToNative(LCodeGen* generator) = 0; |
195 virtual const char* Mnemonic() const = 0; | 205 virtual const char* Mnemonic() const = 0; |
196 virtual void PrintTo(StringStream* stream); | 206 virtual void PrintTo(StringStream* stream); |
197 virtual void PrintDataTo(StringStream* stream) = 0; | 207 virtual void PrintDataTo(StringStream* stream) = 0; |
198 virtual void PrintOutputOperandTo(StringStream* stream) = 0; | 208 virtual void PrintOutputOperandTo(StringStream* stream) = 0; |
199 | 209 |
200 enum Opcode { | |
201 // Declare a unique enum value for each instruction. | |
202 #define DECLARE_OPCODE(type) k##type, | |
203 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE) | |
204 kNumberOfInstructions | |
205 #undef DECLARE_OPCODE | |
206 }; | |
207 | |
208 virtual Opcode opcode() const = 0; | |
209 | |
210 // Declare virtual type testers. | 210 // Declare virtual type testers. |
211 #define DECLARE_PREDICATE(type) \ | 211 #define DECLARE_DO(type) virtual bool Is##type() const { return false; } |
212 bool Is##type() const { return opcode() == k##type; } | 212 LITHIUM_ALL_INSTRUCTION_LIST(DECLARE_DO) |
213 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE) | 213 #undef DECLARE_DO |
214 #undef DECLARE_PREDICATE | |
215 | 214 |
216 virtual bool IsControl() const { return false; } | 215 virtual bool IsControl() const { return false; } |
217 virtual void SetBranchTargets(int true_block_id, int false_block_id) { } | 216 virtual void SetBranchTargets(int true_block_id, int false_block_id) { } |
218 | 217 |
219 void set_environment(LEnvironment* env) { environment_ = env; } | 218 void set_environment(LEnvironment* env) { environment_ = env; } |
220 LEnvironment* environment() const { return environment_; } | 219 LEnvironment* environment() const { return environment_; } |
221 bool HasEnvironment() const { return environment_ != NULL; } | 220 bool HasEnvironment() const { return environment_ != NULL; } |
222 | 221 |
223 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); } | 222 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); } |
224 LPointerMap* pointer_map() const { return pointer_map_.get(); } | 223 LPointerMap* pointer_map() const { return pointer_map_.get(); } |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 | 449 |
451 class LUnknownOSRValue: public LTemplateInstruction<1, 0, 0> { | 450 class LUnknownOSRValue: public LTemplateInstruction<1, 0, 0> { |
452 public: | 451 public: |
453 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value") | 452 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value") |
454 }; | 453 }; |
455 | 454 |
456 | 455 |
457 template<int I, int T> | 456 template<int I, int T> |
458 class LControlInstruction: public LTemplateInstruction<0, I, T> { | 457 class LControlInstruction: public LTemplateInstruction<0, I, T> { |
459 public: | 458 public: |
| 459 DECLARE_INSTRUCTION(ControlInstruction) |
460 virtual bool IsControl() const { return true; } | 460 virtual bool IsControl() const { return true; } |
461 | 461 |
462 int true_block_id() const { return true_block_id_; } | 462 int true_block_id() const { return true_block_id_; } |
463 int false_block_id() const { return false_block_id_; } | 463 int false_block_id() const { return false_block_id_; } |
464 void SetBranchTargets(int true_block_id, int false_block_id) { | 464 void SetBranchTargets(int true_block_id, int false_block_id) { |
465 true_block_id_ = true_block_id; | 465 true_block_id_ = true_block_id; |
466 false_block_id_ = false_block_id; | 466 false_block_id_ = false_block_id; |
467 } | 467 } |
468 | 468 |
469 private: | 469 private: |
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1085 class LArithmeticD: public LTemplateInstruction<1, 2, 0> { | 1085 class LArithmeticD: public LTemplateInstruction<1, 2, 0> { |
1086 public: | 1086 public: |
1087 LArithmeticD(Token::Value op, LOperand* left, LOperand* right) | 1087 LArithmeticD(Token::Value op, LOperand* left, LOperand* right) |
1088 : op_(op) { | 1088 : op_(op) { |
1089 inputs_[0] = left; | 1089 inputs_[0] = left; |
1090 inputs_[1] = right; | 1090 inputs_[1] = right; |
1091 } | 1091 } |
1092 | 1092 |
1093 Token::Value op() const { return op_; } | 1093 Token::Value op() const { return op_; } |
1094 | 1094 |
1095 virtual Opcode opcode() const { return LInstruction::kArithmeticD; } | |
1096 virtual void CompileToNative(LCodeGen* generator); | 1095 virtual void CompileToNative(LCodeGen* generator); |
1097 virtual const char* Mnemonic() const; | 1096 virtual const char* Mnemonic() const; |
1098 | 1097 |
1099 private: | 1098 private: |
1100 Token::Value op_; | 1099 Token::Value op_; |
1101 }; | 1100 }; |
1102 | 1101 |
1103 | 1102 |
1104 class LArithmeticT: public LTemplateInstruction<1, 2, 0> { | 1103 class LArithmeticT: public LTemplateInstruction<1, 2, 0> { |
1105 public: | 1104 public: |
1106 LArithmeticT(Token::Value op, LOperand* left, LOperand* right) | 1105 LArithmeticT(Token::Value op, LOperand* left, LOperand* right) |
1107 : op_(op) { | 1106 : op_(op) { |
1108 inputs_[0] = left; | 1107 inputs_[0] = left; |
1109 inputs_[1] = right; | 1108 inputs_[1] = right; |
1110 } | 1109 } |
1111 | 1110 |
1112 virtual Opcode opcode() const { return LInstruction::kArithmeticT; } | |
1113 virtual void CompileToNative(LCodeGen* generator); | 1111 virtual void CompileToNative(LCodeGen* generator); |
1114 virtual const char* Mnemonic() const; | 1112 virtual const char* Mnemonic() const; |
1115 | 1113 |
1116 Token::Value op() const { return op_; } | 1114 Token::Value op() const { return op_; } |
1117 | 1115 |
1118 private: | 1116 private: |
1119 Token::Value op_; | 1117 Token::Value op_; |
1120 }; | 1118 }; |
1121 | 1119 |
1122 | 1120 |
(...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2186 int argument_count_; | 2184 int argument_count_; |
2187 LAllocator* allocator_; | 2185 LAllocator* allocator_; |
2188 int position_; | 2186 int position_; |
2189 LInstruction* instruction_pending_deoptimization_environment_; | 2187 LInstruction* instruction_pending_deoptimization_environment_; |
2190 int pending_deoptimization_ast_id_; | 2188 int pending_deoptimization_ast_id_; |
2191 | 2189 |
2192 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder); | 2190 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder); |
2193 }; | 2191 }; |
2194 | 2192 |
2195 #undef DECLARE_HYDROGEN_ACCESSOR | 2193 #undef DECLARE_HYDROGEN_ACCESSOR |
| 2194 #undef DECLARE_INSTRUCTION |
2196 #undef DECLARE_CONCRETE_INSTRUCTION | 2195 #undef DECLARE_CONCRETE_INSTRUCTION |
2197 | 2196 |
2198 } } // namespace v8::int | 2197 } } // namespace v8::int |
2199 | 2198 |
2200 #endif // V8_X64_LITHIUM_X64_H_ | 2199 #endif // V8_X64_LITHIUM_X64_H_ |
OLD | NEW |