Index: src/x64/lithium-codegen-x64.cc |
diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc |
index c94af7d909734ff1554e1a311bfacb0f02117ced..ab588e4403603faec35ea7c39a11561564608e7e 100644 |
--- a/src/x64/lithium-codegen-x64.cc |
+++ b/src/x64/lithium-codegen-x64.cc |
@@ -92,6 +92,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); |
@@ -5491,6 +5492,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); |
+ __ movq(scratch2, counter); |
+ __ AssertSmi(scratch2); |
+ __ SmiAddConstant(scratch2, scratch2, Smi::FromInt(instr->delta())); |
+ __ SmiCompare(scratch2, Smi::FromInt(deopt_cell->max_value())); |
+ __ j(less_equal, &ok, Label::kNear); |
+ |
+ // Limit counter |
+ __ Move(scratch2, Smi::FromInt(deopt_cell->max_value())); |
+ __ bind(&ok); |
+ __ movq(counter, scratch2); |
+ |
+ // And deoptimize on negative value |
+ __ SmiCompare(scratch2, 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()); |