Index: src/mips/lithium-codegen-mips.cc |
diff --git a/src/mips/lithium-codegen-mips.cc b/src/mips/lithium-codegen-mips.cc |
index 25ba16232aa5a7b70f19e86756bcd5809a590e58..7be1748f088b5bb4f1cd5578d2c16bb0f6be06a6 100644 |
--- a/src/mips/lithium-codegen-mips.cc |
+++ b/src/mips/lithium-codegen-mips.cc |
@@ -87,6 +87,7 @@ void LCodeGen::FinishCode(Handle<Code> code) { |
RegisterDependentCodeForEmbeddedMaps(code); |
} |
PopulateDeoptimizationData(code); |
+ PopulateDeoptCounterCells(code); |
for (int i = 0 ; i < prototype_maps_.length(); i++) { |
prototype_maps_.at(i)->AddDependentCode( |
DependentCode::kPrototypeCheckGroup, code); |
@@ -5567,6 +5568,56 @@ 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; |
+ MemOperand counter = |
+ FieldMemOperand(scratch, JSGlobalPropertyCell::kValueOffset); |
+ |
+ ASSERT(instr->delta() != 0); |
+ __ LoadHeapObject(scratch, cell); |
+ __ lw(scratch2, counter); |
+ __ Addu(scratch2, scratch2, Operand(Smi::FromInt(instr->delta()))); |
+ __ Branch(&ok, |
+ le, |
+ scratch2, |
+ Operand(Smi::FromInt(deopt_cell->max_value()))); |
+ |
+ // Limit counter |
+ __ li(scratch2, Operand(Smi::FromInt(deopt_cell->max_value()))); |
+ __ bind(&ok); |
+ __ sw(scratch2, counter); |
+ |
+ // And deoptimize on negative value |
+ DeoptimizeIf(le, |
+ instr->environment(), |
+ Deoptimizer::SOFT, |
+ scratch2, |
+ Operand(Smi::FromInt(0))); |
+ return; |
+ } |
+ UNREACHABLE(); |
+} |
+ |
+ |
void LCodeGen::DoDeoptimize(LDeoptimize* instr) { |
if (instr->hydrogen_value()->IsSoftDeoptimize()) { |
SoftDeoptimize(instr->environment(), zero_reg, Operand(zero_reg)); |