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

Unified Diff: src/ia32/full-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/hydrogen-instructions.cc ('k') | src/ia32/lithium-codegen-ia32.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ia32/full-codegen-ia32.cc
diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc
index 9c08ef3033de13d7a74c3964aea2f50877220b2e..fa96a41925434fd63cd19377e7104c96ba376663 100644
--- a/src/ia32/full-codegen-ia32.cc
+++ b/src/ia32/full-codegen-ia32.cc
@@ -1013,10 +1013,34 @@ void FullCodeGenerator::VisitSwitchStatement(SwitchStatement* stmt) {
// Compile all the case bodies.
for (int i = 0; i < clauses->length(); i++) {
- Comment cmnt(masm_, "[ Case body");
CaseClause* clause = clauses->at(i);
__ bind(clause->body_target());
PrepareForBailoutForId(clause->EntryId(), NO_REGISTERS);
+
+ // Initialize counter
+ { Comment cmnt(masm_, "[ Case hit counter");
+ Handle<JSGlobalPropertyCell> cell =
+ isolate()->factory()->NewJSGlobalPropertyCell(
+ Handle<Object>(Smi::FromInt(0), isolate()));
+ RecordTypeFeedbackCell(clause->CounterId(), cell);
+
+ // Increment counter
+ Label ok;
+ Operand counter = FieldOperand(ebx, JSGlobalPropertyCell::kValueOffset);
+
+ __ LoadHeapObject(ebx, cell);
+ __ mov(ecx, counter);
+ __ AssertSmi(ecx);
+ __ add(ecx, Immediate(Smi::FromInt(1)));
+ __ j(no_overflow, &ok, Label::kNear);
+
+ // Decrement on overflow
+ __ sub(ecx, Immediate(Smi::FromInt(1)));
+ __ bind(&ok);
+ __ mov(counter, ecx);
+ }
+
+ Comment cmnt(masm_, "[ Case body");
VisitStatements(clause->statements());
}
« no previous file with comments | « src/hydrogen-instructions.cc ('k') | src/ia32/lithium-codegen-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698