| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 #endif | 299 #endif |
| 300 }; | 300 }; |
| 301 | 301 |
| 302 | 302 |
| 303 // Instructions are computations. The represent non-trivial source | 303 // Instructions are computations. The represent non-trivial source |
| 304 // expressions: typically ones that have side effects and require code to | 304 // expressions: typically ones that have side effects and require code to |
| 305 // be generated. | 305 // be generated. |
| 306 class Instruction : public ZoneObject { | 306 class Instruction : public ZoneObject { |
| 307 public: | 307 public: |
| 308 // Every instruction has a location where its result is stored (which may | 308 // Every instruction has a location where its result is stored (which may |
| 309 // be Effect). | 309 // be Effect, the default). |
| 310 Instruction() : loc_(CfgGlobals::current()->effect_location()) {} |
| 311 |
| 310 explicit Instruction(Location* loc) : loc_(loc) {} | 312 explicit Instruction(Location* loc) : loc_(loc) {} |
| 311 | 313 |
| 312 virtual ~Instruction() {} | 314 virtual ~Instruction() {} |
| 313 | 315 |
| 314 // Accessors. | 316 // Accessors. |
| 315 Location* location() { return loc_; } | 317 Location* location() { return loc_; } |
| 316 void set_location(Location* loc) { loc_ = loc; } | 318 void set_location(Location* loc) { loc_ = loc; } |
| 317 | 319 |
| 318 // Support for fast-compilation mode: | 320 // Support for fast-compilation mode: |
| 319 | 321 |
| 320 // Emit code to perform the instruction. | 322 // Emit code to perform the instruction. |
| 321 virtual void Compile(MacroAssembler* masm) = 0; | 323 virtual void Compile(MacroAssembler* masm) = 0; |
| 322 | 324 |
| 323 // Allocate a temporary which is the result of the immediate predecessor | 325 // Allocate a temporary which is the result of the immediate predecessor |
| 324 // instruction. It is allocated to the accumulator register if it is used | 326 // instruction. It is allocated to the accumulator register if it is used |
| 325 // as an operand to this instruction, otherwise to the stack. | 327 // as an operand to this instruction, otherwise to the stack. |
| 326 virtual void FastAllocate(TempLocation* temp) = 0; | 328 virtual void FastAllocate(TempLocation* temp) = 0; |
| 327 | 329 |
| 328 #ifdef DEBUG | 330 #ifdef DEBUG |
| 329 virtual void Print() = 0; | 331 virtual void Print() = 0; |
| 330 #endif | 332 #endif |
| 331 | 333 |
| 332 protected: | 334 protected: |
| 333 Location* loc_; | 335 Location* loc_; |
| 334 }; | 336 }; |
| 335 | 337 |
| 336 | 338 |
| 339 // A phantom instruction that indicates the start of a statement. It |
| 340 // causes the statement position to be recorded in the relocation |
| 341 // information but generates no code. |
| 342 class PositionInstr : public Instruction { |
| 343 public: |
| 344 explicit PositionInstr(int pos) : pos_(pos) {} |
| 345 |
| 346 // Support for fast-compilation mode. |
| 347 void Compile(MacroAssembler* masm); |
| 348 |
| 349 // This should not be called. The last instruction of the previous |
| 350 // statement should not have a temporary as its location. |
| 351 void FastAllocate(TempLocation* temp) { UNREACHABLE(); } |
| 352 |
| 353 #ifdef DEBUG |
| 354 // Printing support. Print nothing. |
| 355 void Print() {} |
| 356 #endif |
| 357 |
| 358 private: |
| 359 int pos_; |
| 360 }; |
| 361 |
| 362 |
| 337 // Perform a (non-short-circuited) binary operation on a pair of values, | 363 // Perform a (non-short-circuited) binary operation on a pair of values, |
| 338 // leaving the result in a location. | 364 // leaving the result in a location. |
| 339 class BinaryOpInstr : public Instruction { | 365 class BinaryOpInstr : public Instruction { |
| 340 public: | 366 public: |
| 341 BinaryOpInstr(Location* loc, Token::Value op, Value* val0, Value* val1) | 367 BinaryOpInstr(Location* loc, Token::Value op, Value* val0, Value* val1) |
| 342 : Instruction(loc), op_(op), val0_(val0), val1_(val1) { | 368 : Instruction(loc), op_(op), val0_(val0), val1_(val1) { |
| 343 } | 369 } |
| 344 | 370 |
| 345 // Support for fast-compilation mode. | 371 // Support for fast-compilation mode. |
| 346 void Compile(MacroAssembler* masm); | 372 void Compile(MacroAssembler* masm); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 358 | 384 |
| 359 | 385 |
| 360 // Return a value. Has the side effect of moving its value into the return | 386 // Return a value. Has the side effect of moving its value into the return |
| 361 // value register. Can only occur as the last instruction in an instruction | 387 // value register. Can only occur as the last instruction in an instruction |
| 362 // block, and implies that the block is closed (cannot have instructions | 388 // block, and implies that the block is closed (cannot have instructions |
| 363 // appended or graph fragments concatenated to the end) and that the block's | 389 // appended or graph fragments concatenated to the end) and that the block's |
| 364 // successor is the global exit node for the current function. | 390 // successor is the global exit node for the current function. |
| 365 class ReturnInstr : public Instruction { | 391 class ReturnInstr : public Instruction { |
| 366 public: | 392 public: |
| 367 // Location is always Effect. | 393 // Location is always Effect. |
| 368 explicit ReturnInstr(Value* value) | 394 explicit ReturnInstr(Value* value) : value_(value) {} |
| 369 : Instruction(CfgGlobals::current()->effect_location()), | |
| 370 value_(value) { | |
| 371 } | |
| 372 | 395 |
| 373 virtual ~ReturnInstr() {} | 396 virtual ~ReturnInstr() {} |
| 374 | 397 |
| 375 // Support for fast-compilation mode. | 398 // Support for fast-compilation mode. |
| 376 void Compile(MacroAssembler* masm); | 399 void Compile(MacroAssembler* masm); |
| 377 void FastAllocate(TempLocation* temp); | 400 void FastAllocate(TempLocation* temp); |
| 378 | 401 |
| 379 #ifdef DEBUG | 402 #ifdef DEBUG |
| 380 void Print(); | 403 void Print(); |
| 381 #endif | 404 #endif |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 #undef DECLARE_VISIT | 652 #undef DECLARE_VISIT |
| 630 | 653 |
| 631 private: | 654 private: |
| 632 Cfg* cfg_; | 655 Cfg* cfg_; |
| 633 }; | 656 }; |
| 634 | 657 |
| 635 | 658 |
| 636 } } // namespace v8::internal | 659 } } // namespace v8::internal |
| 637 | 660 |
| 638 #endif // V8_CFG_H_ | 661 #endif // V8_CFG_H_ |
| OLD | NEW |