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

Unified Diff: src/arm/full-codegen-arm.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 | « no previous file | src/arm/lithium-arm.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/arm/full-codegen-arm.cc
diff --git a/src/arm/full-codegen-arm.cc b/src/arm/full-codegen-arm.cc
index 2b0491493134f5425720a941a17b9e967e1bd784..9e2e3736e9f3337ab844af9a9ad4b03443d75bde 100644
--- a/src/arm/full-codegen-arm.cc
+++ b/src/arm/full-codegen-arm.cc
@@ -1061,10 +1061,33 @@ 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;
+ MemOperand counter =
+ FieldMemOperand(r1, JSGlobalPropertyCell::kValueOffset);
+
+ __ LoadHeapObject(r1, cell);
+ __ AssertSmi(counter);
+ __ ldr(r2, counter);
+ __ add(r2, r2, Operand(Smi::FromInt(1)), SetCC);
+ __ b(vc, &ok);
+ __ sub(r2, r2, Operand(Smi::FromInt(1)), SetCC);
+ __ bind(&ok);
+ __ str(r2, counter);
+ }
+
+ Comment cmnt(masm_, "[ Case body");
VisitStatements(clause->statements());
}
« no previous file with comments | « no previous file | src/arm/lithium-arm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698