OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 H##type* hydrogen() const { \ | 197 H##type* hydrogen() const { \ |
198 return H##type::cast(hydrogen_value()); \ | 198 return H##type::cast(hydrogen_value()); \ |
199 } | 199 } |
200 | 200 |
201 | 201 |
202 class LInstruction: public ZoneObject { | 202 class LInstruction: public ZoneObject { |
203 public: | 203 public: |
204 LInstruction() | 204 LInstruction() |
205 : environment_(NULL), | 205 : environment_(NULL), |
206 hydrogen_value_(NULL), | 206 hydrogen_value_(NULL), |
207 is_call_(false), | 207 is_call_(false) { } |
208 is_save_doubles_(false) { } | |
209 | 208 |
210 virtual ~LInstruction() { } | 209 virtual ~LInstruction() { } |
211 | 210 |
212 virtual void CompileToNative(LCodeGen* generator) = 0; | 211 virtual void CompileToNative(LCodeGen* generator) = 0; |
213 virtual const char* Mnemonic() const = 0; | 212 virtual const char* Mnemonic() const = 0; |
214 virtual void PrintTo(StringStream* stream); | 213 virtual void PrintTo(StringStream* stream); |
215 virtual void PrintDataTo(StringStream* stream) = 0; | 214 virtual void PrintDataTo(StringStream* stream) = 0; |
216 virtual void PrintOutputOperandTo(StringStream* stream) = 0; | 215 virtual void PrintOutputOperandTo(StringStream* stream) = 0; |
217 | 216 |
218 enum Opcode { | 217 enum Opcode { |
(...skipping 22 matching lines...) Expand all Loading... |
241 LEnvironment* environment() const { return environment_; } | 240 LEnvironment* environment() const { return environment_; } |
242 bool HasEnvironment() const { return environment_ != NULL; } | 241 bool HasEnvironment() const { return environment_ != NULL; } |
243 | 242 |
244 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); } | 243 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); } |
245 LPointerMap* pointer_map() const { return pointer_map_.get(); } | 244 LPointerMap* pointer_map() const { return pointer_map_.get(); } |
246 bool HasPointerMap() const { return pointer_map_.is_set(); } | 245 bool HasPointerMap() const { return pointer_map_.is_set(); } |
247 | 246 |
248 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; } | 247 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; } |
249 HValue* hydrogen_value() const { return hydrogen_value_; } | 248 HValue* hydrogen_value() const { return hydrogen_value_; } |
250 | 249 |
251 void set_deoptimization_environment(LEnvironment* env) { | 250 void MarkAsCall() { is_call_ = true; } |
252 deoptimization_environment_.set(env); | |
253 } | |
254 LEnvironment* deoptimization_environment() const { | |
255 return deoptimization_environment_.get(); | |
256 } | |
257 bool HasDeoptimizationEnvironment() const { | |
258 return deoptimization_environment_.is_set(); | |
259 } | |
260 | 251 |
261 void MarkAsCall() { is_call_ = true; } | 252 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { } |
262 void MarkAsSaveDoubles() { is_save_doubles_ = true; } | |
263 | 253 |
264 // Interface to the register allocator and iterators. | 254 // Interface to the register allocator and iterators. |
265 bool IsMarkedAsCall() const { return is_call_; } | 255 bool IsMarkedAsCall() const { return is_call_; } |
266 bool IsMarkedAsSaveDoubles() const { return is_save_doubles_; } | |
267 | 256 |
268 virtual bool HasResult() const = 0; | 257 virtual bool HasResult() const = 0; |
269 virtual LOperand* result() = 0; | 258 virtual LOperand* result() = 0; |
270 | 259 |
271 virtual int InputCount() = 0; | 260 virtual int InputCount() = 0; |
272 virtual LOperand* InputAt(int i) = 0; | 261 virtual LOperand* InputAt(int i) = 0; |
273 virtual int TempCount() = 0; | 262 virtual int TempCount() = 0; |
274 virtual LOperand* TempAt(int i) = 0; | 263 virtual LOperand* TempAt(int i) = 0; |
275 | 264 |
276 LOperand* FirstInput() { return InputAt(0); } | 265 LOperand* FirstInput() { return InputAt(0); } |
277 LOperand* Output() { return HasResult() ? result() : NULL; } | 266 LOperand* Output() { return HasResult() ? result() : NULL; } |
278 | 267 |
279 #ifdef DEBUG | 268 #ifdef DEBUG |
280 void VerifyCall(); | 269 void VerifyCall(); |
281 #endif | 270 #endif |
282 | 271 |
283 private: | 272 private: |
284 LEnvironment* environment_; | 273 LEnvironment* environment_; |
285 SetOncePointer<LPointerMap> pointer_map_; | 274 SetOncePointer<LPointerMap> pointer_map_; |
286 HValue* hydrogen_value_; | 275 HValue* hydrogen_value_; |
287 SetOncePointer<LEnvironment> deoptimization_environment_; | |
288 bool is_call_; | 276 bool is_call_; |
289 bool is_save_doubles_; | |
290 }; | 277 }; |
291 | 278 |
292 | 279 |
293 // R = number of result operands (0 or 1). | 280 // R = number of result operands (0 or 1). |
294 // I = number of input operands. | 281 // I = number of input operands. |
295 // T = number of temporary operands. | 282 // T = number of temporary operands. |
296 template<int R, int I, int T> | 283 template<int R, int I, int T> |
297 class LTemplateInstruction: public LInstruction { | 284 class LTemplateInstruction: public LInstruction { |
298 public: | 285 public: |
299 // Allow 0 or 1 output operands. | 286 // Allow 0 or 1 output operands. |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
824 LInstanceOfKnownGlobal(LOperand* value, LOperand* temp) { | 811 LInstanceOfKnownGlobal(LOperand* value, LOperand* temp) { |
825 inputs_[0] = value; | 812 inputs_[0] = value; |
826 temps_[0] = temp; | 813 temps_[0] = temp; |
827 } | 814 } |
828 | 815 |
829 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal, | 816 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal, |
830 "instance-of-known-global") | 817 "instance-of-known-global") |
831 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal) | 818 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal) |
832 | 819 |
833 Handle<JSFunction> function() const { return hydrogen()->function(); } | 820 Handle<JSFunction> function() const { return hydrogen()->function(); } |
| 821 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() { |
| 822 return lazy_deopt_env_; |
| 823 } |
| 824 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { |
| 825 lazy_deopt_env_ = env; |
| 826 } |
| 827 |
| 828 private: |
| 829 LEnvironment* lazy_deopt_env_; |
834 }; | 830 }; |
835 | 831 |
836 | 832 |
837 class LBoundsCheck: public LTemplateInstruction<0, 2, 0> { | 833 class LBoundsCheck: public LTemplateInstruction<0, 2, 0> { |
838 public: | 834 public: |
839 LBoundsCheck(LOperand* index, LOperand* length) { | 835 LBoundsCheck(LOperand* index, LOperand* length) { |
840 inputs_[0] = index; | 836 inputs_[0] = index; |
841 inputs_[1] = length; | 837 inputs_[1] = length; |
842 } | 838 } |
843 | 839 |
(...skipping 1499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2343 | 2339 |
2344 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY }; | 2340 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY }; |
2345 | 2341 |
2346 // Marks a call for the register allocator. Assigns a pointer map to | 2342 // Marks a call for the register allocator. Assigns a pointer map to |
2347 // support GC and lazy deoptimization. Assigns an environment to support | 2343 // support GC and lazy deoptimization. Assigns an environment to support |
2348 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY. | 2344 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY. |
2349 LInstruction* MarkAsCall( | 2345 LInstruction* MarkAsCall( |
2350 LInstruction* instr, | 2346 LInstruction* instr, |
2351 HInstruction* hinstr, | 2347 HInstruction* hinstr, |
2352 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY); | 2348 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY); |
2353 LInstruction* MarkAsSaveDoubles(LInstruction* instr); | |
2354 | |
2355 LInstruction* SetInstructionPendingDeoptimizationEnvironment( | |
2356 LInstruction* instr, int ast_id); | |
2357 void ClearInstructionPendingDeoptimizationEnvironment(); | |
2358 | 2349 |
2359 LEnvironment* CreateEnvironment(HEnvironment* hydrogen_env, | 2350 LEnvironment* CreateEnvironment(HEnvironment* hydrogen_env, |
2360 int* argument_index_accumulator); | 2351 int* argument_index_accumulator); |
2361 | 2352 |
2362 void VisitInstruction(HInstruction* current); | 2353 void VisitInstruction(HInstruction* current); |
2363 | 2354 |
2364 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block); | 2355 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block); |
2365 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr); | 2356 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr); |
2366 LInstruction* DoArithmeticD(Token::Value op, | 2357 LInstruction* DoArithmeticD(Token::Value op, |
2367 HArithmeticBinaryOperation* instr); | 2358 HArithmeticBinaryOperation* instr); |
(...skipping 16 matching lines...) Expand all Loading... |
2384 | 2375 |
2385 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder); | 2376 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder); |
2386 }; | 2377 }; |
2387 | 2378 |
2388 #undef DECLARE_HYDROGEN_ACCESSOR | 2379 #undef DECLARE_HYDROGEN_ACCESSOR |
2389 #undef DECLARE_CONCRETE_INSTRUCTION | 2380 #undef DECLARE_CONCRETE_INSTRUCTION |
2390 | 2381 |
2391 } } // namespace v8::int | 2382 } } // namespace v8::int |
2392 | 2383 |
2393 #endif // V8_X64_LITHIUM_X64_H_ | 2384 #endif // V8_X64_LITHIUM_X64_H_ |
OLD | NEW |