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

Unified Diff: src/x64/full-codegen-x64.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/typing.cc ('k') | src/x64/lithium-codegen-x64.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/x64/full-codegen-x64.cc
diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc
index e03c023ff9ddfe1fb5979b67aa703f91f97936ca..f15165a781865b9f65c72a6fca917143e028a30c 100644
--- a/src/x64/full-codegen-x64.cc
+++ b/src/x64/full-codegen-x64.cc
@@ -1026,10 +1026,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(rbx, JSGlobalPropertyCell::kValueOffset);
+
+ __ LoadHeapObject(rbx, cell);
+ __ movq(rcx, counter);
+ __ AssertSmi(rcx);
+ __ SmiAddConstant(rcx, rcx, Smi::FromInt(1));
+ __ j(no_overflow, &ok, Label::kNear);
+
+ // Decrement on overflow
+ __ SmiAddConstant(rcx, rcx, Smi::FromInt(-1));
+ __ bind(&ok);
+ __ movq(counter, rcx);
+ }
+
+ Comment cmnt(masm_, "[ Case body");
VisitStatements(clause->statements());
}
« no previous file with comments | « src/typing.cc ('k') | src/x64/lithium-codegen-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698