Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(823)

Unified Diff: src/ia32/lithium-codegen-ia32.cc

Issue 16128004: Reorder switch clauses using newly-introduced execution counters in (Closed) Base URL: gh:v8/v8.git@master
Patch Set: tweak heuristic Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ia32/lithium-codegen-ia32.h ('k') | src/ia32/lithium-ia32.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
« no previous file with comments | « src/ia32/lithium-codegen-ia32.h ('k') | src/ia32/lithium-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698