| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 class LGapNode; | 45 class LGapNode; |
| 46 class SafepointGenerator; | 46 class SafepointGenerator; |
| 47 | 47 |
| 48 class LCodeGen V8_FINAL BASE_EMBEDDED { | 48 class LCodeGen V8_FINAL BASE_EMBEDDED { |
| 49 public: | 49 public: |
| 50 LCodeGen(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info) | 50 LCodeGen(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info) |
| 51 : zone_(info->zone()), | 51 : zone_(info->zone()), |
| 52 chunk_(static_cast<LPlatformChunk*>(chunk)), | 52 chunk_(static_cast<LPlatformChunk*>(chunk)), |
| 53 masm_(assembler), | 53 masm_(assembler), |
| 54 info_(info), | 54 info_(info), |
| 55 current_block_(-1), | 55 current_block_(NULL), |
| 56 current_instruction_(-1), | 56 current_instruction_(-1), |
| 57 instructions_(chunk->instructions()), | 57 instructions_(chunk->instructions()), |
| 58 deoptimizations_(4, info->zone()), | 58 deoptimizations_(4, info->zone()), |
| 59 jump_table_(4, info->zone()), | 59 jump_table_(4, info->zone()), |
| 60 deoptimization_literals_(8, info->zone()), | 60 deoptimization_literals_(8, info->zone()), |
| 61 inlined_function_count_(0), | 61 inlined_function_count_(0), |
| 62 scope_(info->scope()), | 62 scope_(info->scope()), |
| 63 status_(UNUSED), | 63 status_(UNUSED), |
| 64 translations_(info->zone()), | 64 translations_(info->zone()), |
| 65 deferred_(8, info->zone()), | 65 deferred_(8, info->zone()), |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 Immediate ToImmediate(LOperand* op, const Representation& r) const { | 113 Immediate ToImmediate(LOperand* op, const Representation& r) const { |
| 114 return Immediate(ToRepresentation(LConstantOperand::cast(op), r)); | 114 return Immediate(ToRepresentation(LConstantOperand::cast(op), r)); |
| 115 } | 115 } |
| 116 double ToDouble(LConstantOperand* op) const; | 116 double ToDouble(LConstantOperand* op) const; |
| 117 | 117 |
| 118 // Support for non-sse2 (x87) floating point stack handling. | 118 // Support for non-sse2 (x87) floating point stack handling. |
| 119 // These functions maintain the mapping of physical stack registers to our | 119 // These functions maintain the mapping of physical stack registers to our |
| 120 // virtual registers between instructions. | 120 // virtual registers between instructions. |
| 121 enum X87OperandType { kX87DoubleOperand, kX87FloatOperand, kX87IntOperand }; | 121 enum X87OperandType { kX87DoubleOperand, kX87FloatOperand, kX87IntOperand }; |
| 122 | 122 |
| 123 void X87Mov(X87Register reg, X87Register src); |
| 123 void X87Mov(X87Register reg, Operand src, | 124 void X87Mov(X87Register reg, Operand src, |
| 124 X87OperandType operand = kX87DoubleOperand); | 125 X87OperandType operand = kX87DoubleOperand); |
| 125 void X87Mov(Operand src, X87Register reg, | 126 void X87Mov(Operand src, X87Register reg, |
| 126 X87OperandType operand = kX87DoubleOperand); | 127 X87OperandType operand = kX87DoubleOperand); |
| 127 | 128 |
| 128 void X87PrepareBinaryOp( | 129 void X87PrepareBinaryOp( |
| 129 X87Register left, X87Register right, X87Register result); | 130 X87Register left, X87Register right, X87Register result); |
| 130 | 131 |
| 131 void X87LoadForUsage(X87Register reg); | 132 void X87LoadForUsage(X87Register reg); |
| 132 void X87PrepareToWrite(X87Register reg) { x87_stack_.PrepareToWrite(reg); } | 133 void X87PrepareToWrite(X87Register reg) { x87_stack_.PrepareToWrite(reg); } |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 // Emits code for pushing either a tagged constant, a (non-double) | 408 // Emits code for pushing either a tagged constant, a (non-double) |
| 408 // register, or a stack slot operand. | 409 // register, or a stack slot operand. |
| 409 void EmitPushTaggedOperand(LOperand* operand); | 410 void EmitPushTaggedOperand(LOperand* operand); |
| 410 | 411 |
| 411 void X87Fld(Operand src, X87OperandType opts); | 412 void X87Fld(Operand src, X87OperandType opts); |
| 412 | 413 |
| 413 void EmitFlushX87ForDeopt(); | 414 void EmitFlushX87ForDeopt(); |
| 414 void FlushX87StackIfNecessary(LInstruction* instr) { | 415 void FlushX87StackIfNecessary(LInstruction* instr) { |
| 415 x87_stack_.FlushIfNecessary(instr, this); | 416 x87_stack_.FlushIfNecessary(instr, this); |
| 416 } | 417 } |
| 418 void RestoreX87StackIfNecessary(LInstruction* instr) { |
| 419 x87_stack_.RestoreIfNecessary(instr, this); |
| 420 } |
| 421 void PreRecordX87StackUsage(); |
| 422 |
| 417 friend class LGapResolver; | 423 friend class LGapResolver; |
| 418 | 424 |
| 419 #ifdef _MSC_VER | 425 #ifdef _MSC_VER |
| 420 // On windows, you may not access the stack more than one page below | 426 // On windows, you may not access the stack more than one page below |
| 421 // the most recently mapped page. To make the allocated area randomly | 427 // the most recently mapped page. To make the allocated area randomly |
| 422 // accessible, we write an arbitrary value to each page in range | 428 // accessible, we write an arbitrary value to each page in range |
| 423 // esp + offset - page_size .. esp in turn. | 429 // esp + offset - page_size .. esp in turn. |
| 424 void MakeSureStackPagesMapped(int offset); | 430 void MakeSureStackPagesMapped(int offset); |
| 425 #endif | 431 #endif |
| 426 | 432 |
| 427 Zone* zone_; | 433 Zone* zone_; |
| 428 LPlatformChunk* const chunk_; | 434 LPlatformChunk* const chunk_; |
| 429 MacroAssembler* const masm_; | 435 MacroAssembler* const masm_; |
| 430 CompilationInfo* const info_; | 436 CompilationInfo* const info_; |
| 431 | 437 |
| 432 int current_block_; | 438 HBasicBlock* current_block_; |
| 433 int current_instruction_; | 439 int current_instruction_; |
| 434 const ZoneList<LInstruction*>* instructions_; | 440 const ZoneList<LInstruction*>* instructions_; |
| 435 ZoneList<LEnvironment*> deoptimizations_; | 441 ZoneList<LEnvironment*> deoptimizations_; |
| 436 ZoneList<Deoptimizer::JumpTableEntry> jump_table_; | 442 ZoneList<Deoptimizer::JumpTableEntry> jump_table_; |
| 437 ZoneList<Handle<Object> > deoptimization_literals_; | 443 ZoneList<Handle<Object> > deoptimization_literals_; |
| 438 int inlined_function_count_; | 444 int inlined_function_count_; |
| 439 Scope* const scope_; | 445 Scope* const scope_; |
| 440 Status status_; | 446 Status status_; |
| 441 TranslationBuffer translations_; | 447 TranslationBuffer translations_; |
| 442 ZoneList<LDeferredCode*> deferred_; | 448 ZoneList<LDeferredCode*> deferred_; |
| 443 bool dynamic_frame_alignment_; | 449 bool dynamic_frame_alignment_; |
| 444 bool support_aligned_spilled_doubles_; | 450 bool support_aligned_spilled_doubles_; |
| 445 int osr_pc_offset_; | 451 int osr_pc_offset_; |
| 446 int last_lazy_deopt_pc_; | 452 int last_lazy_deopt_pc_; |
| 447 bool frame_is_built_; | 453 bool frame_is_built_; |
| 448 | 454 |
| 449 class X87Stack { | 455 class X87Stack { |
| 450 public: | 456 public: |
| 451 explicit X87Stack(MacroAssembler* masm) : stack_depth_(0), masm_(masm) { } | 457 explicit X87Stack(MacroAssembler* masm) : stack_depth_(0), masm_(masm) { |
| 452 explicit X87Stack(const X87Stack& other) | 458 for (int i = 0; i < X87Register::kNumAllocatableRegisters; i++) { |
| 453 : stack_depth_(0), masm_(other.masm_) { | 459 first_defined_[i] = NULL; |
| 454 stack_depth_ = other.stack_depth_; | |
| 455 for (int i = 0; i < stack_depth_; i++) { | |
| 456 stack_[i] = other.stack_[i]; | |
| 457 } | 460 } |
| 458 } | 461 } |
| 459 bool operator==(const X87Stack& other) const { | |
| 460 if (stack_depth_ != other.stack_depth_) return false; | |
| 461 for (int i = 0; i < stack_depth_; i++) { | |
| 462 if (!stack_[i].is(other.stack_[i])) return false; | |
| 463 } | |
| 464 return true; | |
| 465 } | |
| 466 bool Contains(X87Register reg); | 462 bool Contains(X87Register reg); |
| 467 void Fxch(X87Register reg, int other_slot = 0); | 463 void Fxch(X87Register reg, int other_slot = 0); |
| 464 void Fxch(X87Register reg, X87Register src); |
| 468 void Free(X87Register reg); | 465 void Free(X87Register reg); |
| 469 void PrepareToWrite(X87Register reg); | 466 void PrepareToWrite(X87Register reg); |
| 470 void CommitWrite(X87Register reg); | 467 void CommitWrite(X87Register reg); |
| 471 void FlushIfNecessary(LInstruction* instr, LCodeGen* cgen); | 468 void FlushIfNecessary(LInstruction* instr, LCodeGen* cgen); |
| 469 void RestoreIfNecessary(LInstruction* instr, LCodeGen* cgen); |
| 470 int PhysicalPos(X87Register reg); |
| 472 int depth() const { return stack_depth_; } | 471 int depth() const { return stack_depth_; } |
| 473 void pop() { stack_depth_--; } | 472 void pop() { stack_depth_--; } |
| 473 |
| 474 void push(X87Register reg) { | 474 void push(X87Register reg) { |
| 475 ASSERT(stack_depth_ < X87Register::kNumAllocatableRegisters); | 475 ASSERT(stack_depth_ < X87Register::kNumAllocatableRegisters); |
| 476 stack_[stack_depth_] = reg; | 476 stack_[stack_depth_] = reg; |
| 477 stack_depth_++; | 477 stack_depth_++; |
| 478 } | 478 } |
| 479 | 479 |
| 480 void leaving(HBasicBlock* block, HBasicBlock* next); |
| 481 void record_usage(X87Register reg, HBasicBlock* block); |
| 482 void record_definition(X87Register reg, HBasicBlock* block); |
| 483 |
| 480 MacroAssembler* masm() const { return masm_; } | 484 MacroAssembler* masm() const { return masm_; } |
| 481 | 485 |
| 482 private: | 486 private: |
| 483 int ArrayIndex(X87Register reg); | 487 int ArrayIndex(X87Register reg); |
| 484 int st2idx(int pos); | 488 int st2idx(int pos); |
| 485 X87Register stack_[X87Register::kNumAllocatableRegisters]; | 489 X87Register stack_[X87Register::kNumAllocatableRegisters]; |
| 490 HBasicBlock* first_defined_[X87Register::kNumAllocatableRegisters]; |
| 491 HBasicBlock* dominated_[X87Register::kNumAllocatableRegisters]; |
| 486 int stack_depth_; | 492 int stack_depth_; |
| 487 MacroAssembler* const masm_; | 493 MacroAssembler* const masm_; |
| 488 }; | 494 }; |
| 489 X87Stack x87_stack_; | 495 X87Stack x87_stack_; |
| 490 | 496 |
| 491 // Builder that keeps track of safepoints in the code. The table | 497 // Builder that keeps track of safepoints in the code. The table |
| 492 // itself is emitted at the end of the generated code. | 498 // itself is emitted at the end of the generated code. |
| 493 SafepointTableBuilder safepoints_; | 499 SafepointTableBuilder safepoints_; |
| 494 | 500 |
| 495 // Compiler from a set of parallel moves to a sequential list of moves. | 501 // Compiler from a set of parallel moves to a sequential list of moves. |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 LCodeGen* codegen_; | 558 LCodeGen* codegen_; |
| 553 Label entry_; | 559 Label entry_; |
| 554 Label exit_; | 560 Label exit_; |
| 555 Label* external_exit_; | 561 Label* external_exit_; |
| 556 int instruction_index_; | 562 int instruction_index_; |
| 557 }; | 563 }; |
| 558 | 564 |
| 559 } } // namespace v8::internal | 565 } } // namespace v8::internal |
| 560 | 566 |
| 561 #endif // V8_IA32_LITHIUM_CODEGEN_IA32_H_ | 567 #endif // V8_IA32_LITHIUM_CODEGEN_IA32_H_ |
| OLD | NEW |