diff options
Diffstat (limited to 'deps/v8/src/ia32/lithium-codegen-ia32.h')
-rw-r--r-- | deps/v8/src/ia32/lithium-codegen-ia32.h | 102 |
1 files changed, 81 insertions, 21 deletions
diff --git a/deps/v8/src/ia32/lithium-codegen-ia32.h b/deps/v8/src/ia32/lithium-codegen-ia32.h index aa8f6c248a..769917f7e2 100644 --- a/deps/v8/src/ia32/lithium-codegen-ia32.h +++ b/deps/v8/src/ia32/lithium-codegen-ia32.h @@ -45,7 +45,7 @@ class LDeferredCode; class LGapNode; class SafepointGenerator; -class LCodeGen BASE_EMBEDDED { +class LCodeGen V8_FINAL BASE_EMBEDDED { public: LCodeGen(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info) : zone_(info->zone()), @@ -68,7 +68,7 @@ class LCodeGen BASE_EMBEDDED { osr_pc_offset_(-1), last_lazy_deopt_pc_(0), frame_is_built_(false), - x87_stack_depth_(0), + x87_stack_(assembler), safepoints_(info->zone()), resolver_(this), expected_safepoint_kind_(Safepoint::kSimple), @@ -122,14 +122,23 @@ class LCodeGen BASE_EMBEDDED { void X87Mov(X87Register reg, Operand src, X87OperandType operand = kX87DoubleOperand); - void X87Mov(Operand src, X87Register reg); + void X87Mov(Operand src, X87Register reg, + X87OperandType operand = kX87DoubleOperand); void X87PrepareBinaryOp( X87Register left, X87Register right, X87Register result); void X87LoadForUsage(X87Register reg); - void X87PrepareToWrite(X87Register reg); - void X87CommitWrite(X87Register reg); + void X87PrepareToWrite(X87Register reg) { x87_stack_.PrepareToWrite(reg); } + void X87CommitWrite(X87Register reg) { x87_stack_.CommitWrite(reg); } + + void X87Fxch(X87Register reg, int other_slot = 0) { + x87_stack_.Fxch(reg, other_slot); + } + + bool X87StackEmpty() { + return x87_stack_.depth() == 0; + } Handle<Object> ToHandle(LConstantOperand* op) const; @@ -154,11 +163,9 @@ class LCodeGen BASE_EMBEDDED { LOperand* value, IntegerSignedness signedness); - void DoDeferredTaggedToI(LTaggedToI* instr); - void DoDeferredTaggedToINoSSE2(LTaggedToINoSSE2* instr); + void DoDeferredTaggedToI(LTaggedToI* instr, Label* done); void DoDeferredMathAbsTaggedHeapNumber(LMathAbs* instr); void DoDeferredStackCheck(LStackCheck* instr); - void DoDeferredRandom(LRandom* instr); void DoDeferredStringCharCodeAt(LStringCharCodeAt* instr); void DoDeferredStringCharFromCode(LStringCharFromCode* instr); void DoDeferredAllocate(LAllocate* instr); @@ -225,6 +232,9 @@ class LCodeGen BASE_EMBEDDED { bool GenerateJumpTable(); bool GenerateSafepointTable(); + // Generates the custom OSR entrypoint and sets the osr_pc_offset. + void GenerateOsrPrologue(); + enum SafepointMode { RECORD_SIMPLE_SAFEPOINT, RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS @@ -399,15 +409,13 @@ class LCodeGen BASE_EMBEDDED { // register, or a stack slot operand. void EmitPushTaggedOperand(LOperand* operand); - void X87Fxch(X87Register reg, int other_slot = 0); void X87Fld(Operand src, X87OperandType opts); - void X87Free(X87Register reg); - void FlushX87StackIfNecessary(LInstruction* instr); void EmitFlushX87ForDeopt(); - bool X87StackContains(X87Register reg); - int X87ArrayIndex(X87Register reg); - int x87_st2idx(int pos); + void FlushX87StackIfNecessary(LInstruction* instr) { + x87_stack_.FlushIfNecessary(instr, this); + } + friend class LGapResolver; #ifdef _MSC_VER // On windows, you may not access the stack more than one page below @@ -438,8 +446,55 @@ class LCodeGen BASE_EMBEDDED { int osr_pc_offset_; int last_lazy_deopt_pc_; bool frame_is_built_; - X87Register x87_stack_[X87Register::kNumAllocatableRegisters]; - int x87_stack_depth_; + + class X87Stack { + public: + explicit X87Stack(MacroAssembler* masm) + : stack_depth_(0), is_mutable_(true), masm_(masm) { } + explicit X87Stack(const X87Stack& other) + : stack_depth_(other.stack_depth_), is_mutable_(false), masm_(masm()) { + for (int i = 0; i < stack_depth_; i++) { + stack_[i] = other.stack_[i]; + } + } + bool operator==(const X87Stack& other) const { + if (stack_depth_ != other.stack_depth_) return false; + for (int i = 0; i < stack_depth_; i++) { + if (!stack_[i].is(other.stack_[i])) return false; + } + return true; + } + bool Contains(X87Register reg); + void Fxch(X87Register reg, int other_slot = 0); + void Free(X87Register reg); + void PrepareToWrite(X87Register reg); + void CommitWrite(X87Register reg); + void FlushIfNecessary(LInstruction* instr, LCodeGen* cgen); + void LeavingBlock(int current_block_id, LGoto* goto_instr); + int depth() const { return stack_depth_; } + void pop() { + ASSERT(is_mutable_); + stack_depth_--; + } + void push(X87Register reg) { + ASSERT(is_mutable_); + ASSERT(stack_depth_ < X87Register::kNumAllocatableRegisters); + stack_[stack_depth_] = reg; + stack_depth_++; + } + + MacroAssembler* masm() const { return masm_; } + + private: + int ArrayIndex(X87Register reg); + int st2idx(int pos); + + X87Register stack_[X87Register::kNumAllocatableRegisters]; + int stack_depth_; + bool is_mutable_; + MacroAssembler* masm_; + }; + X87Stack x87_stack_; // Builder that keeps track of safepoints in the code. The table // itself is emitted at the end of the generated code. @@ -452,7 +507,7 @@ class LCodeGen BASE_EMBEDDED { int old_position_; - class PushSafepointRegistersScope BASE_EMBEDDED { + class PushSafepointRegistersScope V8_FINAL BASE_EMBEDDED { public: explicit PushSafepointRegistersScope(LCodeGen* codegen) : codegen_(codegen) { @@ -479,23 +534,26 @@ class LCodeGen BASE_EMBEDDED { }; -class LDeferredCode: public ZoneObject { +class LDeferredCode : public ZoneObject { public: - explicit LDeferredCode(LCodeGen* codegen) + explicit LDeferredCode(LCodeGen* codegen, const LCodeGen::X87Stack& x87_stack) : codegen_(codegen), external_exit_(NULL), - instruction_index_(codegen->current_instruction_) { + instruction_index_(codegen->current_instruction_), + x87_stack_(x87_stack) { codegen->AddDeferredCode(this); } - virtual ~LDeferredCode() { } + virtual ~LDeferredCode() {} virtual void Generate() = 0; virtual LInstruction* instr() = 0; void SetExit(Label* exit) { external_exit_ = exit; } Label* entry() { return &entry_; } Label* exit() { return external_exit_ != NULL ? external_exit_ : &exit_; } + Label* done() { return codegen_->NeedsDeferredFrame() ? &done_ : exit(); } int instruction_index() const { return instruction_index_; } + const LCodeGen::X87Stack& x87_stack() const { return x87_stack_; } protected: LCodeGen* codegen() const { return codegen_; } @@ -506,7 +564,9 @@ class LDeferredCode: public ZoneObject { Label entry_; Label exit_; Label* external_exit_; + Label done_; int instruction_index_; + LCodeGen::X87Stack x87_stack_; }; } } // namespace v8::internal |