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 virtual ~LInstruction() { } | 201 virtual ~LInstruction() { } |
192 | 202 |
193 virtual void CompileToNative(LCodeGen* generator) = 0; | 203 virtual void CompileToNative(LCodeGen* generator) = 0; |
194 virtual const char* Mnemonic() const = 0; | 204 virtual const char* Mnemonic() const = 0; |
195 virtual void PrintTo(StringStream* stream); | 205 virtual void PrintTo(StringStream* stream); |
196 virtual void PrintDataTo(StringStream* stream) = 0; | 206 virtual void PrintDataTo(StringStream* stream) = 0; |
197 virtual void PrintOutputOperandTo(StringStream* stream) = 0; | 207 virtual void PrintOutputOperandTo(StringStream* stream) = 0; |
198 | 208 |
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 | |
209 // Declare virtual type testers. | 209 // Declare virtual type testers. |
210 #define DECLARE_PREDICATE(type) \ | 210 #define DECLARE_DO(type) virtual bool Is##type() const { return false; } |
211 bool Is##type() const { return opcode() == k##type; } | 211 LITHIUM_ALL_INSTRUCTION_LIST(DECLARE_DO) |
212 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE) | 212 #undef DECLARE_DO |
213 #undef DECLARE_PREDICATE | |
214 | 213 |
215 virtual bool IsControl() const { return false; } | 214 virtual bool IsControl() const { return false; } |
216 virtual void SetBranchTargets(int true_block_id, int false_block_id) { } | 215 virtual void SetBranchTargets(int true_block_id, int false_block_id) { } |
217 | 216 |
218 void set_environment(LEnvironment* env) { environment_ = env; } | 217 void set_environment(LEnvironment* env) { environment_ = env; } |
219 LEnvironment* environment() const { return environment_; } | 218 LEnvironment* environment() const { return environment_; } |
220 bool HasEnvironment() const { return environment_ != NULL; } | 219 bool HasEnvironment() const { return environment_ != NULL; } |
221 | 220 |
222 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); } | 221 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); } |
223 LPointerMap* pointer_map() const { return pointer_map_.get(); } | 222 LPointerMap* pointer_map() const { return pointer_map_.get(); } |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 | 448 |
450 class LUnknownOSRValue: public LTemplateInstruction<1, 0, 0> { | 449 class LUnknownOSRValue: public LTemplateInstruction<1, 0, 0> { |
451 public: | 450 public: |
452 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value") | 451 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value") |
453 }; | 452 }; |
454 | 453 |
455 | 454 |
456 template<int I, int T> | 455 template<int I, int T> |
457 class LControlInstruction: public LTemplateInstruction<0, I, T> { | 456 class LControlInstruction: public LTemplateInstruction<0, I, T> { |
458 public: | 457 public: |
| 458 DECLARE_INSTRUCTION(ControlInstruction) |
459 virtual bool IsControl() const { return true; } | 459 virtual bool IsControl() const { return true; } |
460 | 460 |
461 int true_block_id() const { return true_block_id_; } | 461 int true_block_id() const { return true_block_id_; } |
462 int false_block_id() const { return false_block_id_; } | 462 int false_block_id() const { return false_block_id_; } |
463 void SetBranchTargets(int true_block_id, int false_block_id) { | 463 void SetBranchTargets(int true_block_id, int false_block_id) { |
464 true_block_id_ = true_block_id; | 464 true_block_id_ = true_block_id; |
465 false_block_id_ = false_block_id; | 465 false_block_id_ = false_block_id; |
466 } | 466 } |
467 | 467 |
468 private: | 468 private: |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1099 class LArithmeticD: public LTemplateInstruction<1, 2, 0> { | 1099 class LArithmeticD: public LTemplateInstruction<1, 2, 0> { |
1100 public: | 1100 public: |
1101 LArithmeticD(Token::Value op, LOperand* left, LOperand* right) | 1101 LArithmeticD(Token::Value op, LOperand* left, LOperand* right) |
1102 : op_(op) { | 1102 : op_(op) { |
1103 inputs_[0] = left; | 1103 inputs_[0] = left; |
1104 inputs_[1] = right; | 1104 inputs_[1] = right; |
1105 } | 1105 } |
1106 | 1106 |
1107 Token::Value op() const { return op_; } | 1107 Token::Value op() const { return op_; } |
1108 | 1108 |
1109 virtual Opcode opcode() const { return LInstruction::kArithmeticD; } | |
1110 virtual void CompileToNative(LCodeGen* generator); | 1109 virtual void CompileToNative(LCodeGen* generator); |
1111 virtual const char* Mnemonic() const; | 1110 virtual const char* Mnemonic() const; |
1112 | 1111 |
1113 private: | 1112 private: |
1114 Token::Value op_; | 1113 Token::Value op_; |
1115 }; | 1114 }; |
1116 | 1115 |
1117 | 1116 |
1118 class LArithmeticT: public LTemplateInstruction<1, 2, 0> { | 1117 class LArithmeticT: public LTemplateInstruction<1, 2, 0> { |
1119 public: | 1118 public: |
1120 LArithmeticT(Token::Value op, LOperand* left, LOperand* right) | 1119 LArithmeticT(Token::Value op, LOperand* left, LOperand* right) |
1121 : op_(op) { | 1120 : op_(op) { |
1122 inputs_[0] = left; | 1121 inputs_[0] = left; |
1123 inputs_[1] = right; | 1122 inputs_[1] = right; |
1124 } | 1123 } |
1125 | 1124 |
1126 virtual Opcode opcode() const { return LInstruction::kArithmeticT; } | |
1127 virtual void CompileToNative(LCodeGen* generator); | 1125 virtual void CompileToNative(LCodeGen* generator); |
1128 virtual const char* Mnemonic() const; | 1126 virtual const char* Mnemonic() const; |
1129 | 1127 |
1130 Token::Value op() const { return op_; } | 1128 Token::Value op() const { return op_; } |
1131 | 1129 |
1132 private: | 1130 private: |
1133 Token::Value op_; | 1131 Token::Value op_; |
1134 }; | 1132 }; |
1135 | 1133 |
1136 | 1134 |
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2204 int argument_count_; | 2202 int argument_count_; |
2205 LAllocator* allocator_; | 2203 LAllocator* allocator_; |
2206 int position_; | 2204 int position_; |
2207 LInstruction* instruction_pending_deoptimization_environment_; | 2205 LInstruction* instruction_pending_deoptimization_environment_; |
2208 int pending_deoptimization_ast_id_; | 2206 int pending_deoptimization_ast_id_; |
2209 | 2207 |
2210 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder); | 2208 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder); |
2211 }; | 2209 }; |
2212 | 2210 |
2213 #undef DECLARE_HYDROGEN_ACCESSOR | 2211 #undef DECLARE_HYDROGEN_ACCESSOR |
| 2212 #undef DECLARE_INSTRUCTION |
2214 #undef DECLARE_CONCRETE_INSTRUCTION | 2213 #undef DECLARE_CONCRETE_INSTRUCTION |
2215 | 2214 |
2216 } } // namespace v8::internal | 2215 } } // namespace v8::internal |
2217 | 2216 |
2218 #endif // V8_ARM_LITHIUM_ARM_H_ | 2217 #endif // V8_ARM_LITHIUM_ARM_H_ |
OLD | NEW |