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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 | 284 |
285 #define DECLARE_HYDROGEN_ACCESSOR(type) \ | 285 #define DECLARE_HYDROGEN_ACCESSOR(type) \ |
286 H##type* hydrogen() const { \ | 286 H##type* hydrogen() const { \ |
287 return H##type::cast(hydrogen_value()); \ | 287 return H##type::cast(hydrogen_value()); \ |
288 } | 288 } |
289 | 289 |
290 | 290 |
291 class LInstruction: public ZoneObject { | 291 class LInstruction: public ZoneObject { |
292 public: | 292 public: |
293 LInstruction() | 293 LInstruction() |
294 : hydrogen_value_(NULL) { } | 294 : environment_(NULL), |
| 295 hydrogen_value_(NULL), |
| 296 is_call_(false), |
| 297 is_save_doubles_(false) { } |
295 virtual ~LInstruction() { } | 298 virtual ~LInstruction() { } |
296 | 299 |
297 virtual void CompileToNative(LCodeGen* generator) = 0; | 300 virtual void CompileToNative(LCodeGen* generator) = 0; |
298 virtual const char* Mnemonic() const = 0; | 301 virtual const char* Mnemonic() const = 0; |
299 virtual void PrintTo(StringStream* stream); | 302 virtual void PrintTo(StringStream* stream); |
300 virtual void PrintDataTo(StringStream* stream) = 0; | 303 virtual void PrintDataTo(StringStream* stream) = 0; |
301 virtual void PrintOutputOperandTo(StringStream* stream) = 0; | 304 virtual void PrintOutputOperandTo(StringStream* stream) = 0; |
302 | 305 |
303 // Declare virtual type testers. | 306 // Declare virtual type testers. |
304 #define DECLARE_DO(type) virtual bool Is##type() const { return false; } | 307 #define DECLARE_DO(type) virtual bool Is##type() const { return false; } |
305 LITHIUM_ALL_INSTRUCTION_LIST(DECLARE_DO) | 308 LITHIUM_ALL_INSTRUCTION_LIST(DECLARE_DO) |
306 #undef DECLARE_DO | 309 #undef DECLARE_DO |
307 | 310 |
308 virtual bool IsControl() const { return false; } | 311 virtual bool IsControl() const { return false; } |
309 virtual void SetBranchTargets(int true_block_id, int false_block_id) { } | 312 virtual void SetBranchTargets(int true_block_id, int false_block_id) { } |
310 | 313 |
311 void set_environment(LEnvironment* env) { environment_.set(env); } | 314 void set_environment(LEnvironment* env) { environment_ = env; } |
312 LEnvironment* environment() const { return environment_.get(); } | 315 LEnvironment* environment() const { return environment_; } |
313 bool HasEnvironment() const { return environment_.is_set(); } | 316 bool HasEnvironment() const { return environment_ != NULL; } |
314 | 317 |
315 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); } | 318 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); } |
316 LPointerMap* pointer_map() const { return pointer_map_.get(); } | 319 LPointerMap* pointer_map() const { return pointer_map_.get(); } |
317 bool HasPointerMap() const { return pointer_map_.is_set(); } | 320 bool HasPointerMap() const { return pointer_map_.is_set(); } |
318 | 321 |
319 virtual bool HasResult() const = 0; | |
320 | 322 |
321 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; } | 323 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; } |
322 HValue* hydrogen_value() const { return hydrogen_value_; } | 324 HValue* hydrogen_value() const { return hydrogen_value_; } |
323 | 325 |
| 326 void MarkAsCall() { is_call_ = true; } |
| 327 void MarkAsSaveDoubles() { is_save_doubles_ = true; } |
| 328 |
| 329 // Interface to the register allocator and iterators. |
| 330 bool IsMarkedAsCall() const { return is_call_; } |
| 331 bool IsMarkedAsSaveDoubles() const { return is_save_doubles_; } |
| 332 |
| 333 virtual bool HasResult() const = 0; |
| 334 virtual LOperand* result() = 0; |
| 335 |
| 336 virtual int InputCount() = 0; |
| 337 virtual LOperand* InputAt(int i) = 0; |
| 338 virtual int TempCount() = 0; |
| 339 virtual LOperand* TempAt(int i) = 0; |
| 340 |
| 341 LOperand* FirstInput() { return InputAt(0); } |
| 342 LOperand* Output() { return HasResult() ? result() : NULL; } |
| 343 |
| 344 #ifdef DEBUG |
| 345 void VerifyCall(); |
| 346 #endif |
| 347 |
324 private: | 348 private: |
325 SetOncePointer<LEnvironment> environment_; | 349 LEnvironment* environment_; |
326 SetOncePointer<LPointerMap> pointer_map_; | 350 SetOncePointer<LPointerMap> pointer_map_; |
327 HValue* hydrogen_value_; | 351 HValue* hydrogen_value_; |
| 352 bool is_call_; |
| 353 bool is_save_doubles_; |
328 }; | 354 }; |
329 | 355 |
330 | 356 |
331 template<typename ElementType, int NumElements> | 357 template<typename ElementType, int NumElements> |
332 class OperandContainer { | 358 class OperandContainer { |
333 public: | 359 public: |
334 OperandContainer() { | 360 OperandContainer() { |
335 for (int i = 0; i < NumElements; i++) elems_[i] = NULL; | 361 for (int i = 0; i < NumElements; i++) elems_[i] = NULL; |
336 } | 362 } |
337 int length() { return NumElements; } | 363 int length() { return NumElements; } |
338 ElementType& operator[](int i) { | 364 ElementType& operator[](int i) { |
339 ASSERT(i < length()); | 365 ASSERT(i < length()); |
340 return elems_[i]; | 366 return elems_[i]; |
341 } | 367 } |
342 void PrintOperandsTo(StringStream* stream); | 368 void PrintOperandsTo(StringStream* stream); |
343 | 369 |
344 private: | 370 private: |
345 ElementType elems_[NumElements]; | 371 ElementType elems_[NumElements]; |
346 }; | 372 }; |
347 | 373 |
348 | 374 |
349 template<typename ElementType> | 375 template<typename ElementType> |
350 class OperandContainer<ElementType, 0> { | 376 class OperandContainer<ElementType, 0> { |
351 public: | 377 public: |
352 int length() { return 0; } | 378 int length() { return 0; } |
353 void PrintOperandsTo(StringStream* stream) { } | 379 void PrintOperandsTo(StringStream* stream) { } |
| 380 ElementType& operator[](int i) { |
| 381 UNREACHABLE(); |
| 382 static ElementType t = 0; |
| 383 return t; |
| 384 } |
354 }; | 385 }; |
355 | 386 |
356 | 387 |
357 // R = number of result operands (0 or 1). | 388 // R = number of result operands (0 or 1). |
358 // I = number of input operands. | 389 // I = number of input operands. |
359 // T = number of temporary operands. | 390 // T = number of temporary operands. |
360 template<int R, int I, int T> | 391 template<int R, int I, int T> |
361 class LTemplateInstruction: public LInstruction { | 392 class LTemplateInstruction: public LInstruction { |
362 public: | 393 public: |
363 // Allow 0 or 1 output operands. | 394 // Allow 0 or 1 output operands. |
(...skipping 1433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1797 class LChunkBuilder; | 1828 class LChunkBuilder; |
1798 class LChunk: public ZoneObject { | 1829 class LChunk: public ZoneObject { |
1799 public: | 1830 public: |
1800 explicit LChunk(HGraph* graph) | 1831 explicit LChunk(HGraph* graph) |
1801 : spill_slot_count_(0), | 1832 : spill_slot_count_(0), |
1802 graph_(graph), | 1833 graph_(graph), |
1803 instructions_(32), | 1834 instructions_(32), |
1804 pointer_maps_(8), | 1835 pointer_maps_(8), |
1805 inlined_closures_(1) { } | 1836 inlined_closures_(1) { } |
1806 | 1837 |
1807 int AddInstruction(LInstruction* instruction, HBasicBlock* block); | 1838 void AddInstruction(LInstruction* instruction, HBasicBlock* block); |
1808 LConstantOperand* DefineConstantOperand(HConstant* constant); | 1839 LConstantOperand* DefineConstantOperand(HConstant* constant); |
1809 Handle<Object> LookupLiteral(LConstantOperand* operand) const; | 1840 Handle<Object> LookupLiteral(LConstantOperand* operand) const; |
1810 Representation LookupLiteralRepresentation(LConstantOperand* operand) const; | 1841 Representation LookupLiteralRepresentation(LConstantOperand* operand) const; |
1811 | 1842 |
1812 int GetNextSpillIndex(bool is_double); | 1843 int GetNextSpillIndex(bool is_double); |
1813 LOperand* GetNextSpillSlot(bool is_double); | 1844 LOperand* GetNextSpillSlot(bool is_double); |
1814 | 1845 |
1815 int ParameterAt(int index); | 1846 int ParameterAt(int index); |
1816 int GetParameterStackSlot(int index) const; | 1847 int GetParameterStackSlot(int index) const; |
1817 int spill_slot_count() const { return spill_slot_count_; } | 1848 int spill_slot_count() const { return spill_slot_count_; } |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2004 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder); | 2035 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder); |
2005 }; | 2036 }; |
2006 | 2037 |
2007 #undef DECLARE_HYDROGEN_ACCESSOR | 2038 #undef DECLARE_HYDROGEN_ACCESSOR |
2008 #undef DECLARE_INSTRUCTION | 2039 #undef DECLARE_INSTRUCTION |
2009 #undef DECLARE_CONCRETE_INSTRUCTION | 2040 #undef DECLARE_CONCRETE_INSTRUCTION |
2010 | 2041 |
2011 } } // namespace v8::internal | 2042 } } // namespace v8::internal |
2012 | 2043 |
2013 #endif // V8_IA32_LITHIUM_IA32_H_ | 2044 #endif // V8_IA32_LITHIUM_IA32_H_ |
OLD | NEW |