Index: src/ia32/lithium-codegen-ia32.cc |
diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc |
index fb566d1dd1fb4231730cc2856b0a382c4415d5cd..6d26fa656952a456fe117473ec301ebe8557a706 100644 |
--- a/src/ia32/lithium-codegen-ia32.cc |
+++ b/src/ia32/lithium-codegen-ia32.cc |
@@ -106,6 +106,7 @@ void LCodeGen::FinishCode(Handle<Code> code) { |
RegisterDependentCodeForEmbeddedMaps(code); |
} |
PopulateDeoptimizationData(code); |
+ PopulateDeoptCounterCells(code); |
if (!info()->IsStub()) { |
Deoptimizer::EnsureRelocSpaceForLazyDeoptimization(code); |
} |
@@ -6390,6 +6391,52 @@ void LCodeGen::DoLazyBailout(LLazyBailout* instr) { |
} |
+void LCodeGen::DoDeoptCounter(LDeoptCounter* instr) { |
+ Handle<JSGlobalPropertyCell> cell = |
+ isolate()->factory()->NewJSGlobalPropertyCell( |
+ Handle<Object>(Smi::FromInt(instr->initial_value()), isolate())); |
+ LDeoptCounterCell* deopt_cell = |
+ new(zone()) LDeoptCounterCell(instr->id(), instr->max_value(), cell); |
+ deopt_counter_cells_.Add(deopt_cell, zone()); |
+} |
+ |
+ |
+void LCodeGen::DoDeoptCounterAdd(LDeoptCounterAdd* instr) { |
+ for (int i = 0; i < deopt_counter_cells_.length(); ++i) { |
+ LDeoptCounterCell* deopt_cell = deopt_counter_cells_[i]; |
+ if (deopt_cell->id() != instr->counter()) continue; |
+ |
+ Handle<JSGlobalPropertyCell> cell = deopt_cell->cell(); |
+ Register scratch = ToRegister(instr->temp()); |
+ Register scratch2 = ToRegister(instr->temp2()); |
+ |
+ // Increment counter |
+ Label ok; |
+ Operand counter = FieldOperand(scratch, |
+ JSGlobalPropertyCell::kValueOffset); |
+ |
+ ASSERT(instr->delta() != 0); |
+ __ LoadHeapObject(scratch, cell); |
+ __ mov(scratch2, counter); |
+ __ AssertSmi(scratch2); |
+ __ add(scratch2, Immediate(Smi::FromInt(instr->delta()))); |
+ __ cmp(scratch2, Immediate(Smi::FromInt(deopt_cell->max_value()))); |
+ __ j(less_equal, &ok, Label::kNear); |
+ |
+ // Limit counter |
+ __ mov(scratch2, Immediate(Smi::FromInt(deopt_cell->max_value()))); |
+ __ bind(&ok); |
+ __ mov(counter, scratch2); |
+ |
+ // And deoptimize on negative value |
+ __ cmp(scratch2, Immediate(Smi::FromInt(0))); |
+ DeoptimizeIf(less_equal, instr->environment(), Deoptimizer::SOFT); |
+ return; |
+ } |
+ UNREACHABLE(); |
+} |
+ |
+ |
void LCodeGen::DoDeoptimize(LDeoptimize* instr) { |
if (instr->hydrogen_value()->IsSoftDeoptimize()) { |
SoftDeoptimize(instr->environment()); |