Commit 7669decc authored by olivf@chromium.org's avatar olivf@chromium.org

Reland "Fix missing x87 tracking for deferred code."

Fixed mac build.

BUG=
R=mstarzinger@chromium.org

Review URL: https://codereview.chromium.org/23490022

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16449 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 25d86eac
...@@ -423,6 +423,8 @@ bool LCodeGen::GenerateDeferredCode() { ...@@ -423,6 +423,8 @@ bool LCodeGen::GenerateDeferredCode() {
if (deferred_.length() > 0) { if (deferred_.length() > 0) {
for (int i = 0; !is_aborted() && i < deferred_.length(); i++) { for (int i = 0; !is_aborted() && i < deferred_.length(); i++) {
LDeferredCode* code = deferred_[i]; LDeferredCode* code = deferred_[i];
X87Stack copy(code->x87_stack());
x87_stack_ = copy;
int pos = instructions_->at(code->instruction_index())->position(); int pos = instructions_->at(code->instruction_index())->position();
RecordAndUpdatePosition(pos); RecordAndUpdatePosition(pos);
...@@ -503,6 +505,7 @@ void LCodeGen::X87LoadForUsage(X87Register reg) { ...@@ -503,6 +505,7 @@ void LCodeGen::X87LoadForUsage(X87Register reg) {
void LCodeGen::X87Stack::Fxch(X87Register reg, int other_slot) { void LCodeGen::X87Stack::Fxch(X87Register reg, int other_slot) {
ASSERT(is_mutable_);
ASSERT(Contains(reg) && stack_depth_ > other_slot); ASSERT(Contains(reg) && stack_depth_ > other_slot);
int i = ArrayIndex(reg); int i = ArrayIndex(reg);
int st = st2idx(i); int st = st2idx(i);
...@@ -547,6 +550,7 @@ bool LCodeGen::X87Stack::Contains(X87Register reg) { ...@@ -547,6 +550,7 @@ bool LCodeGen::X87Stack::Contains(X87Register reg) {
void LCodeGen::X87Stack::Free(X87Register reg) { void LCodeGen::X87Stack::Free(X87Register reg) {
ASSERT(is_mutable_);
ASSERT(Contains(reg)); ASSERT(Contains(reg));
int i = ArrayIndex(reg); int i = ArrayIndex(reg);
int st = st2idx(i); int st = st2idx(i);
...@@ -606,6 +610,7 @@ void LCodeGen::X87Mov(Operand dst, X87Register src, X87OperandType opts) { ...@@ -606,6 +610,7 @@ void LCodeGen::X87Mov(Operand dst, X87Register src, X87OperandType opts) {
void LCodeGen::X87Stack::PrepareToWrite(X87Register reg) { void LCodeGen::X87Stack::PrepareToWrite(X87Register reg) {
ASSERT(is_mutable_);
if (Contains(reg)) { if (Contains(reg)) {
Free(reg); Free(reg);
} }
...@@ -615,6 +620,7 @@ void LCodeGen::X87Stack::PrepareToWrite(X87Register reg) { ...@@ -615,6 +620,7 @@ void LCodeGen::X87Stack::PrepareToWrite(X87Register reg) {
void LCodeGen::X87Stack::CommitWrite(X87Register reg) { void LCodeGen::X87Stack::CommitWrite(X87Register reg) {
ASSERT(is_mutable_);
// Assert the reg is prepared to write, but not on the virtual stack yet // Assert the reg is prepared to write, but not on the virtual stack yet
ASSERT(!Contains(reg) && stack_[stack_depth_].is(reg) && ASSERT(!Contains(reg) && stack_[stack_depth_].is(reg) &&
stack_depth_ < X87Register::kNumAllocatableRegisters); stack_depth_ < X87Register::kNumAllocatableRegisters);
...@@ -2841,8 +2847,9 @@ void LCodeGen::DoInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr) { ...@@ -2841,8 +2847,9 @@ void LCodeGen::DoInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr) {
class DeferredInstanceOfKnownGlobal V8_FINAL : public LDeferredCode { class DeferredInstanceOfKnownGlobal V8_FINAL : public LDeferredCode {
public: public:
DeferredInstanceOfKnownGlobal(LCodeGen* codegen, DeferredInstanceOfKnownGlobal(LCodeGen* codegen,
LInstanceOfKnownGlobal* instr) LInstanceOfKnownGlobal* instr,
: LDeferredCode(codegen), instr_(instr) { } const X87Stack& x87_stack)
: LDeferredCode(codegen, x87_stack), instr_(instr) { }
virtual void Generate() V8_OVERRIDE { virtual void Generate() V8_OVERRIDE {
codegen()->DoDeferredInstanceOfKnownGlobal(instr_, &map_check_); codegen()->DoDeferredInstanceOfKnownGlobal(instr_, &map_check_);
} }
...@@ -2854,7 +2861,7 @@ void LCodeGen::DoInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr) { ...@@ -2854,7 +2861,7 @@ void LCodeGen::DoInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr) {
}; };
DeferredInstanceOfKnownGlobal* deferred; DeferredInstanceOfKnownGlobal* deferred;
deferred = new(zone()) DeferredInstanceOfKnownGlobal(this, instr); deferred = new(zone()) DeferredInstanceOfKnownGlobal(this, instr, x87_stack_);
Label done, false_result; Label done, false_result;
Register object = ToRegister(instr->value()); Register object = ToRegister(instr->value());
...@@ -3808,8 +3815,10 @@ void LCodeGen::DoMathAbs(LMathAbs* instr) { ...@@ -3808,8 +3815,10 @@ void LCodeGen::DoMathAbs(LMathAbs* instr) {
// Class for deferred case. // Class for deferred case.
class DeferredMathAbsTaggedHeapNumber V8_FINAL : public LDeferredCode { class DeferredMathAbsTaggedHeapNumber V8_FINAL : public LDeferredCode {
public: public:
DeferredMathAbsTaggedHeapNumber(LCodeGen* codegen, LMathAbs* instr) DeferredMathAbsTaggedHeapNumber(LCodeGen* codegen,
: LDeferredCode(codegen), instr_(instr) { } LMathAbs* instr,
const X87Stack& x87_stack)
: LDeferredCode(codegen, x87_stack), instr_(instr) { }
virtual void Generate() V8_OVERRIDE { virtual void Generate() V8_OVERRIDE {
codegen()->DoDeferredMathAbsTaggedHeapNumber(instr_); codegen()->DoDeferredMathAbsTaggedHeapNumber(instr_);
} }
...@@ -3832,7 +3841,7 @@ void LCodeGen::DoMathAbs(LMathAbs* instr) { ...@@ -3832,7 +3841,7 @@ void LCodeGen::DoMathAbs(LMathAbs* instr) {
EmitIntegerMathAbs(instr); EmitIntegerMathAbs(instr);
} else { // Tagged case. } else { // Tagged case.
DeferredMathAbsTaggedHeapNumber* deferred = DeferredMathAbsTaggedHeapNumber* deferred =
new(zone()) DeferredMathAbsTaggedHeapNumber(this, instr); new(zone()) DeferredMathAbsTaggedHeapNumber(this, instr, x87_stack_);
Register input_reg = ToRegister(instr->value()); Register input_reg = ToRegister(instr->value());
// Smi check. // Smi check.
__ JumpIfNotSmi(input_reg, deferred->entry()); __ JumpIfNotSmi(input_reg, deferred->entry());
...@@ -4048,15 +4057,18 @@ void LCodeGen::DoPower(LPower* instr) { ...@@ -4048,15 +4057,18 @@ void LCodeGen::DoPower(LPower* instr) {
void LCodeGen::DoRandom(LRandom* instr) { void LCodeGen::DoRandom(LRandom* instr) {
class DeferredDoRandom V8_FINAL : public LDeferredCode { class DeferredDoRandom V8_FINAL : public LDeferredCode {
public: public:
DeferredDoRandom(LCodeGen* codegen, LRandom* instr) DeferredDoRandom(LCodeGen* codegen,
: LDeferredCode(codegen), instr_(instr) { } LRandom* instr,
const X87Stack& x87_stack)
: LDeferredCode(codegen, x87_stack), instr_(instr) { }
virtual void Generate() V8_OVERRIDE { codegen()->DoDeferredRandom(instr_); } virtual void Generate() V8_OVERRIDE { codegen()->DoDeferredRandom(instr_); }
virtual LInstruction* instr() V8_OVERRIDE { return instr_; } virtual LInstruction* instr() V8_OVERRIDE { return instr_; }
private: private:
LRandom* instr_; LRandom* instr_;
}; };
DeferredDoRandom* deferred = new(zone()) DeferredDoRandom(this, instr); DeferredDoRandom* deferred =
new(zone()) DeferredDoRandom(this, instr, x87_stack_);
CpuFeatureScope scope(masm(), SSE2); CpuFeatureScope scope(masm(), SSE2);
// Having marked this instruction as a call we can use any // Having marked this instruction as a call we can use any
...@@ -4791,8 +4803,10 @@ void LCodeGen::DoTransitionElementsKind(LTransitionElementsKind* instr) { ...@@ -4791,8 +4803,10 @@ void LCodeGen::DoTransitionElementsKind(LTransitionElementsKind* instr) {
void LCodeGen::DoStringCharCodeAt(LStringCharCodeAt* instr) { void LCodeGen::DoStringCharCodeAt(LStringCharCodeAt* instr) {
class DeferredStringCharCodeAt V8_FINAL : public LDeferredCode { class DeferredStringCharCodeAt V8_FINAL : public LDeferredCode {
public: public:
DeferredStringCharCodeAt(LCodeGen* codegen, LStringCharCodeAt* instr) DeferredStringCharCodeAt(LCodeGen* codegen,
: LDeferredCode(codegen), instr_(instr) { } LStringCharCodeAt* instr,
const X87Stack& x87_stack)
: LDeferredCode(codegen, x87_stack), instr_(instr) { }
virtual void Generate() V8_OVERRIDE { virtual void Generate() V8_OVERRIDE {
codegen()->DoDeferredStringCharCodeAt(instr_); codegen()->DoDeferredStringCharCodeAt(instr_);
} }
...@@ -4802,7 +4816,7 @@ void LCodeGen::DoStringCharCodeAt(LStringCharCodeAt* instr) { ...@@ -4802,7 +4816,7 @@ void LCodeGen::DoStringCharCodeAt(LStringCharCodeAt* instr) {
}; };
DeferredStringCharCodeAt* deferred = DeferredStringCharCodeAt* deferred =
new(zone()) DeferredStringCharCodeAt(this, instr); new(zone()) DeferredStringCharCodeAt(this, instr, x87_stack_);
StringCharLoadGenerator::Generate(masm(), StringCharLoadGenerator::Generate(masm(),
factory(), factory(),
...@@ -4848,8 +4862,10 @@ void LCodeGen::DoDeferredStringCharCodeAt(LStringCharCodeAt* instr) { ...@@ -4848,8 +4862,10 @@ void LCodeGen::DoDeferredStringCharCodeAt(LStringCharCodeAt* instr) {
void LCodeGen::DoStringCharFromCode(LStringCharFromCode* instr) { void LCodeGen::DoStringCharFromCode(LStringCharFromCode* instr) {
class DeferredStringCharFromCode V8_FINAL : public LDeferredCode { class DeferredStringCharFromCode V8_FINAL : public LDeferredCode {
public: public:
DeferredStringCharFromCode(LCodeGen* codegen, LStringCharFromCode* instr) DeferredStringCharFromCode(LCodeGen* codegen,
: LDeferredCode(codegen), instr_(instr) { } LStringCharFromCode* instr,
const X87Stack& x87_stack)
: LDeferredCode(codegen, x87_stack), instr_(instr) { }
virtual void Generate() V8_OVERRIDE { virtual void Generate() V8_OVERRIDE {
codegen()->DoDeferredStringCharFromCode(instr_); codegen()->DoDeferredStringCharFromCode(instr_);
} }
...@@ -4859,7 +4875,7 @@ void LCodeGen::DoStringCharFromCode(LStringCharFromCode* instr) { ...@@ -4859,7 +4875,7 @@ void LCodeGen::DoStringCharFromCode(LStringCharFromCode* instr) {
}; };
DeferredStringCharFromCode* deferred = DeferredStringCharFromCode* deferred =
new(zone()) DeferredStringCharFromCode(this, instr); new(zone()) DeferredStringCharFromCode(this, instr, x87_stack_);
ASSERT(instr->hydrogen()->value()->representation().IsInteger32()); ASSERT(instr->hydrogen()->value()->representation().IsInteger32());
Register char_code = ToRegister(instr->char_code()); Register char_code = ToRegister(instr->char_code());
...@@ -4947,8 +4963,10 @@ void LCodeGen::DoUint32ToDouble(LUint32ToDouble* instr) { ...@@ -4947,8 +4963,10 @@ void LCodeGen::DoUint32ToDouble(LUint32ToDouble* instr) {
void LCodeGen::DoNumberTagI(LNumberTagI* instr) { void LCodeGen::DoNumberTagI(LNumberTagI* instr) {
class DeferredNumberTagI V8_FINAL : public LDeferredCode { class DeferredNumberTagI V8_FINAL : public LDeferredCode {
public: public:
DeferredNumberTagI(LCodeGen* codegen, LNumberTagI* instr) DeferredNumberTagI(LCodeGen* codegen,
: LDeferredCode(codegen), instr_(instr) { } LNumberTagI* instr,
const X87Stack& x87_stack)
: LDeferredCode(codegen, x87_stack), instr_(instr) { }
virtual void Generate() V8_OVERRIDE { virtual void Generate() V8_OVERRIDE {
codegen()->DoDeferredNumberTagI(instr_, instr_->value(), SIGNED_INT32); codegen()->DoDeferredNumberTagI(instr_, instr_->value(), SIGNED_INT32);
} }
...@@ -4961,7 +4979,8 @@ void LCodeGen::DoNumberTagI(LNumberTagI* instr) { ...@@ -4961,7 +4979,8 @@ void LCodeGen::DoNumberTagI(LNumberTagI* instr) {
ASSERT(input->IsRegister() && input->Equals(instr->result())); ASSERT(input->IsRegister() && input->Equals(instr->result()));
Register reg = ToRegister(input); Register reg = ToRegister(input);
DeferredNumberTagI* deferred = new(zone()) DeferredNumberTagI(this, instr); DeferredNumberTagI* deferred =
new(zone()) DeferredNumberTagI(this, instr, x87_stack_);
__ SmiTag(reg); __ SmiTag(reg);
__ j(overflow, deferred->entry()); __ j(overflow, deferred->entry());
__ bind(deferred->exit()); __ bind(deferred->exit());
...@@ -4971,8 +4990,10 @@ void LCodeGen::DoNumberTagI(LNumberTagI* instr) { ...@@ -4971,8 +4990,10 @@ void LCodeGen::DoNumberTagI(LNumberTagI* instr) {
void LCodeGen::DoNumberTagU(LNumberTagU* instr) { void LCodeGen::DoNumberTagU(LNumberTagU* instr) {
class DeferredNumberTagU V8_FINAL : public LDeferredCode { class DeferredNumberTagU V8_FINAL : public LDeferredCode {
public: public:
DeferredNumberTagU(LCodeGen* codegen, LNumberTagU* instr) DeferredNumberTagU(LCodeGen* codegen,
: LDeferredCode(codegen), instr_(instr) { } LNumberTagU* instr,
const X87Stack& x87_stack)
: LDeferredCode(codegen, x87_stack), instr_(instr) { }
virtual void Generate() V8_OVERRIDE { virtual void Generate() V8_OVERRIDE {
codegen()->DoDeferredNumberTagI(instr_, instr_->value(), UNSIGNED_INT32); codegen()->DoDeferredNumberTagI(instr_, instr_->value(), UNSIGNED_INT32);
} }
...@@ -4985,7 +5006,8 @@ void LCodeGen::DoNumberTagU(LNumberTagU* instr) { ...@@ -4985,7 +5006,8 @@ void LCodeGen::DoNumberTagU(LNumberTagU* instr) {
ASSERT(input->IsRegister() && input->Equals(instr->result())); ASSERT(input->IsRegister() && input->Equals(instr->result()));
Register reg = ToRegister(input); Register reg = ToRegister(input);
DeferredNumberTagU* deferred = new(zone()) DeferredNumberTagU(this, instr); DeferredNumberTagU* deferred =
new(zone()) DeferredNumberTagU(this, instr, x87_stack_);
__ cmp(reg, Immediate(Smi::kMaxValue)); __ cmp(reg, Immediate(Smi::kMaxValue));
__ j(above, deferred->entry()); __ j(above, deferred->entry());
__ SmiTag(reg); __ SmiTag(reg);
...@@ -5074,8 +5096,10 @@ void LCodeGen::DoDeferredNumberTagI(LInstruction* instr, ...@@ -5074,8 +5096,10 @@ void LCodeGen::DoDeferredNumberTagI(LInstruction* instr,
void LCodeGen::DoNumberTagD(LNumberTagD* instr) { void LCodeGen::DoNumberTagD(LNumberTagD* instr) {
class DeferredNumberTagD V8_FINAL : public LDeferredCode { class DeferredNumberTagD V8_FINAL : public LDeferredCode {
public: public:
DeferredNumberTagD(LCodeGen* codegen, LNumberTagD* instr) DeferredNumberTagD(LCodeGen* codegen,
: LDeferredCode(codegen), instr_(instr) { } LNumberTagD* instr,
const X87Stack& x87_stack)
: LDeferredCode(codegen, x87_stack), instr_(instr) { }
virtual void Generate() V8_OVERRIDE { virtual void Generate() V8_OVERRIDE {
codegen()->DoDeferredNumberTagD(instr_); codegen()->DoDeferredNumberTagD(instr_);
} }
...@@ -5093,7 +5117,8 @@ void LCodeGen::DoNumberTagD(LNumberTagD* instr) { ...@@ -5093,7 +5117,8 @@ void LCodeGen::DoNumberTagD(LNumberTagD* instr) {
X87LoadForUsage(src); X87LoadForUsage(src);
} }
DeferredNumberTagD* deferred = new(zone()) DeferredNumberTagD(this, instr); DeferredNumberTagD* deferred =
new(zone()) DeferredNumberTagD(this, instr, x87_stack_);
if (FLAG_inline_new) { if (FLAG_inline_new) {
Register tmp = ToRegister(instr->temp()); Register tmp = ToRegister(instr->temp());
__ AllocateHeapNumber(reg, tmp, no_reg, deferred->entry()); __ AllocateHeapNumber(reg, tmp, no_reg, deferred->entry());
...@@ -5375,8 +5400,10 @@ void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr) { ...@@ -5375,8 +5400,10 @@ void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr) {
void LCodeGen::DoTaggedToI(LTaggedToI* instr) { void LCodeGen::DoTaggedToI(LTaggedToI* instr) {
class DeferredTaggedToI V8_FINAL : public LDeferredCode { class DeferredTaggedToI V8_FINAL : public LDeferredCode {
public: public:
DeferredTaggedToI(LCodeGen* codegen, LTaggedToI* instr) DeferredTaggedToI(LCodeGen* codegen,
: LDeferredCode(codegen), instr_(instr) { } LTaggedToI* instr,
const X87Stack& x87_stack)
: LDeferredCode(codegen, x87_stack), instr_(instr) { }
virtual void Generate() V8_OVERRIDE { virtual void Generate() V8_OVERRIDE {
codegen()->DoDeferredTaggedToI(instr_); codegen()->DoDeferredTaggedToI(instr_);
} }
...@@ -5390,7 +5417,8 @@ void LCodeGen::DoTaggedToI(LTaggedToI* instr) { ...@@ -5390,7 +5417,8 @@ void LCodeGen::DoTaggedToI(LTaggedToI* instr) {
Register input_reg = ToRegister(input); Register input_reg = ToRegister(input);
ASSERT(input_reg.is(ToRegister(instr->result()))); ASSERT(input_reg.is(ToRegister(instr->result())));
DeferredTaggedToI* deferred = new(zone()) DeferredTaggedToI(this, instr); DeferredTaggedToI* deferred =
new(zone()) DeferredTaggedToI(this, instr, x87_stack_);
__ JumpIfNotSmi(input_reg, deferred->entry()); __ JumpIfNotSmi(input_reg, deferred->entry());
__ SmiUntag(input_reg); __ SmiUntag(input_reg);
...@@ -5536,8 +5564,10 @@ void LCodeGen::DoDeferredTaggedToINoSSE2(LTaggedToINoSSE2* instr) { ...@@ -5536,8 +5564,10 @@ void LCodeGen::DoDeferredTaggedToINoSSE2(LTaggedToINoSSE2* instr) {
void LCodeGen::DoTaggedToINoSSE2(LTaggedToINoSSE2* instr) { void LCodeGen::DoTaggedToINoSSE2(LTaggedToINoSSE2* instr) {
class DeferredTaggedToINoSSE2 V8_FINAL : public LDeferredCode { class DeferredTaggedToINoSSE2 V8_FINAL : public LDeferredCode {
public: public:
DeferredTaggedToINoSSE2(LCodeGen* codegen, LTaggedToINoSSE2* instr) DeferredTaggedToINoSSE2(LCodeGen* codegen,
: LDeferredCode(codegen), instr_(instr) { } LTaggedToINoSSE2* instr,
const X87Stack& x87_stack)
: LDeferredCode(codegen, x87_stack), instr_(instr) { }
virtual void Generate() V8_OVERRIDE { virtual void Generate() V8_OVERRIDE {
codegen()->DoDeferredTaggedToINoSSE2(instr_); codegen()->DoDeferredTaggedToINoSSE2(instr_);
} }
...@@ -5552,7 +5582,7 @@ void LCodeGen::DoTaggedToINoSSE2(LTaggedToINoSSE2* instr) { ...@@ -5552,7 +5582,7 @@ void LCodeGen::DoTaggedToINoSSE2(LTaggedToINoSSE2* instr) {
ASSERT(input_reg.is(ToRegister(instr->result()))); ASSERT(input_reg.is(ToRegister(instr->result())));
DeferredTaggedToINoSSE2* deferred = DeferredTaggedToINoSSE2* deferred =
new(zone()) DeferredTaggedToINoSSE2(this, instr); new(zone()) DeferredTaggedToINoSSE2(this, instr, x87_stack_);
// Smi check. // Smi check.
__ JumpIfNotSmi(input_reg, deferred->entry()); __ JumpIfNotSmi(input_reg, deferred->entry());
...@@ -5832,8 +5862,11 @@ void LCodeGen::DoDeferredInstanceMigration(LCheckMaps* instr, Register object) { ...@@ -5832,8 +5862,11 @@ void LCodeGen::DoDeferredInstanceMigration(LCheckMaps* instr, Register object) {
void LCodeGen::DoCheckMaps(LCheckMaps* instr) { void LCodeGen::DoCheckMaps(LCheckMaps* instr) {
class DeferredCheckMaps V8_FINAL : public LDeferredCode { class DeferredCheckMaps V8_FINAL : public LDeferredCode {
public: public:
DeferredCheckMaps(LCodeGen* codegen, LCheckMaps* instr, Register object) DeferredCheckMaps(LCodeGen* codegen,
: LDeferredCode(codegen), instr_(instr), object_(object) { LCheckMaps* instr,
Register object,
const X87Stack& x87_stack)
: LDeferredCode(codegen, x87_stack), instr_(instr), object_(object) {
SetExit(check_maps()); SetExit(check_maps());
} }
virtual void Generate() V8_OVERRIDE { virtual void Generate() V8_OVERRIDE {
...@@ -5857,7 +5890,7 @@ void LCodeGen::DoCheckMaps(LCheckMaps* instr) { ...@@ -5857,7 +5890,7 @@ void LCodeGen::DoCheckMaps(LCheckMaps* instr) {
DeferredCheckMaps* deferred = NULL; DeferredCheckMaps* deferred = NULL;
if (instr->hydrogen()->has_migration_target()) { if (instr->hydrogen()->has_migration_target()) {
deferred = new(zone()) DeferredCheckMaps(this, instr, reg); deferred = new(zone()) DeferredCheckMaps(this, instr, reg, x87_stack_);
__ bind(deferred->check_maps()); __ bind(deferred->check_maps());
} }
...@@ -6055,8 +6088,10 @@ void LCodeGen::DoClampTToUint8NoSSE2(LClampTToUint8NoSSE2* instr) { ...@@ -6055,8 +6088,10 @@ void LCodeGen::DoClampTToUint8NoSSE2(LClampTToUint8NoSSE2* instr) {
void LCodeGen::DoAllocate(LAllocate* instr) { void LCodeGen::DoAllocate(LAllocate* instr) {
class DeferredAllocate V8_FINAL : public LDeferredCode { class DeferredAllocate V8_FINAL : public LDeferredCode {
public: public:
DeferredAllocate(LCodeGen* codegen, LAllocate* instr) DeferredAllocate(LCodeGen* codegen,
: LDeferredCode(codegen), instr_(instr) { } LAllocate* instr,
const X87Stack& x87_stack)
: LDeferredCode(codegen, x87_stack), instr_(instr) { }
virtual void Generate() V8_OVERRIDE { virtual void Generate() V8_OVERRIDE {
codegen()->DoDeferredAllocate(instr_); codegen()->DoDeferredAllocate(instr_);
} }
...@@ -6066,7 +6101,7 @@ void LCodeGen::DoAllocate(LAllocate* instr) { ...@@ -6066,7 +6101,7 @@ void LCodeGen::DoAllocate(LAllocate* instr) {
}; };
DeferredAllocate* deferred = DeferredAllocate* deferred =
new(zone()) DeferredAllocate(this, instr); new(zone()) DeferredAllocate(this, instr, x87_stack_);
Register result = ToRegister(instr->result()); Register result = ToRegister(instr->result());
Register temp = ToRegister(instr->temp()); Register temp = ToRegister(instr->temp());
...@@ -6406,8 +6441,10 @@ void LCodeGen::DoDeferredStackCheck(LStackCheck* instr) { ...@@ -6406,8 +6441,10 @@ void LCodeGen::DoDeferredStackCheck(LStackCheck* instr) {
void LCodeGen::DoStackCheck(LStackCheck* instr) { void LCodeGen::DoStackCheck(LStackCheck* instr) {
class DeferredStackCheck V8_FINAL : public LDeferredCode { class DeferredStackCheck V8_FINAL : public LDeferredCode {
public: public:
DeferredStackCheck(LCodeGen* codegen, LStackCheck* instr) DeferredStackCheck(LCodeGen* codegen,
: LDeferredCode(codegen), instr_(instr) { } LStackCheck* instr,
const X87Stack& x87_stack)
: LDeferredCode(codegen, x87_stack), instr_(instr) { }
virtual void Generate() V8_OVERRIDE { virtual void Generate() V8_OVERRIDE {
codegen()->DoDeferredStackCheck(instr_); codegen()->DoDeferredStackCheck(instr_);
} }
...@@ -6441,7 +6478,7 @@ void LCodeGen::DoStackCheck(LStackCheck* instr) { ...@@ -6441,7 +6478,7 @@ void LCodeGen::DoStackCheck(LStackCheck* instr) {
ASSERT(instr->hydrogen()->is_backwards_branch()); ASSERT(instr->hydrogen()->is_backwards_branch());
// Perform stack overflow check if this goto needs it before jumping. // Perform stack overflow check if this goto needs it before jumping.
DeferredStackCheck* deferred_stack_check = DeferredStackCheck* deferred_stack_check =
new(zone()) DeferredStackCheck(this, instr); new(zone()) DeferredStackCheck(this, instr, x87_stack_);
ExternalReference stack_limit = ExternalReference stack_limit =
ExternalReference::address_of_stack_limit(isolate()); ExternalReference::address_of_stack_limit(isolate());
__ cmp(esp, Operand::StaticVariable(stack_limit)); __ cmp(esp, Operand::StaticVariable(stack_limit));
......
...@@ -448,10 +448,10 @@ class LCodeGen V8_FINAL BASE_EMBEDDED { ...@@ -448,10 +448,10 @@ class LCodeGen V8_FINAL BASE_EMBEDDED {
class X87Stack { class X87Stack {
public: public:
explicit X87Stack(MacroAssembler* masm) : stack_depth_(0), masm_(masm) { } explicit X87Stack(MacroAssembler* masm)
: stack_depth_(0), is_mutable_(true), masm_(masm) { }
explicit X87Stack(const X87Stack& other) explicit X87Stack(const X87Stack& other)
: stack_depth_(0), masm_(other.masm_) { : stack_depth_(other.stack_depth_), is_mutable_(false), masm_(masm()) {
stack_depth_ = other.stack_depth_;
for (int i = 0; i < stack_depth_; i++) { for (int i = 0; i < stack_depth_; i++) {
stack_[i] = other.stack_[i]; stack_[i] = other.stack_[i];
} }
...@@ -470,8 +470,12 @@ class LCodeGen V8_FINAL BASE_EMBEDDED { ...@@ -470,8 +470,12 @@ class LCodeGen V8_FINAL BASE_EMBEDDED {
void CommitWrite(X87Register reg); void CommitWrite(X87Register reg);
void FlushIfNecessary(LInstruction* instr, LCodeGen* cgen); void FlushIfNecessary(LInstruction* instr, LCodeGen* cgen);
int depth() const { return stack_depth_; } int depth() const { return stack_depth_; }
void pop() { stack_depth_--; } void pop() {
ASSERT(is_mutable_);
stack_depth_--;
}
void push(X87Register reg) { void push(X87Register reg) {
ASSERT(is_mutable_);
ASSERT(stack_depth_ < X87Register::kNumAllocatableRegisters); ASSERT(stack_depth_ < X87Register::kNumAllocatableRegisters);
stack_[stack_depth_] = reg; stack_[stack_depth_] = reg;
stack_depth_++; stack_depth_++;
...@@ -482,9 +486,11 @@ class LCodeGen V8_FINAL BASE_EMBEDDED { ...@@ -482,9 +486,11 @@ class LCodeGen V8_FINAL BASE_EMBEDDED {
private: private:
int ArrayIndex(X87Register reg); int ArrayIndex(X87Register reg);
int st2idx(int pos); int st2idx(int pos);
X87Register stack_[X87Register::kNumAllocatableRegisters]; X87Register stack_[X87Register::kNumAllocatableRegisters];
int stack_depth_; int stack_depth_;
MacroAssembler* const masm_; bool is_mutable_;
MacroAssembler* masm_;
}; };
X87Stack x87_stack_; X87Stack x87_stack_;
...@@ -528,10 +534,11 @@ class LCodeGen V8_FINAL BASE_EMBEDDED { ...@@ -528,10 +534,11 @@ class LCodeGen V8_FINAL BASE_EMBEDDED {
class LDeferredCode : public ZoneObject { class LDeferredCode : public ZoneObject {
public: public:
explicit LDeferredCode(LCodeGen* codegen) explicit LDeferredCode(LCodeGen* codegen, const LCodeGen::X87Stack& x87_stack)
: codegen_(codegen), : codegen_(codegen),
external_exit_(NULL), external_exit_(NULL),
instruction_index_(codegen->current_instruction_) { instruction_index_(codegen->current_instruction_),
x87_stack_(x87_stack) {
codegen->AddDeferredCode(this); codegen->AddDeferredCode(this);
} }
...@@ -543,6 +550,7 @@ class LDeferredCode : public ZoneObject { ...@@ -543,6 +550,7 @@ class LDeferredCode : public ZoneObject {
Label* entry() { return &entry_; } Label* entry() { return &entry_; }
Label* exit() { return external_exit_ != NULL ? external_exit_ : &exit_; } Label* exit() { return external_exit_ != NULL ? external_exit_ : &exit_; }
int instruction_index() const { return instruction_index_; } int instruction_index() const { return instruction_index_; }
const LCodeGen::X87Stack& x87_stack() const { return x87_stack_; }
protected: protected:
LCodeGen* codegen() const { return codegen_; } LCodeGen* codegen() const { return codegen_; }
...@@ -554,6 +562,7 @@ class LDeferredCode : public ZoneObject { ...@@ -554,6 +562,7 @@ class LDeferredCode : public ZoneObject {
Label exit_; Label exit_;
Label* external_exit_; Label* external_exit_;
int instruction_index_; int instruction_index_;
LCodeGen::X87Stack x87_stack_;
}; };
} } // namespace v8::internal } } // namespace v8::internal
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment