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

Unified Diff: src/mips/full-codegen-mips.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/lithium.cc ('k') | src/mips/lithium-codegen-mips.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/mips/full-codegen-mips.cc
diff --git a/src/mips/full-codegen-mips.cc b/src/mips/full-codegen-mips.cc
index 78f44ab23eefa573b7983680ff3389c4768530df..34e33a744b19c4f1dc3a35515ace9f4bfdbd30c5 100644
--- a/src/mips/full-codegen-mips.cc
+++ b/src/mips/full-codegen-mips.cc
@@ -1064,10 +1064,35 @@ 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(a1, JSGlobalPropertyCell::kValueOffset);
+
+ __ LoadHeapObject(a1, cell);
+ __ lw(a2, counter);
+ __ Addu(a2, a2, Operand(Smi::FromInt(1)));
+ __ SmiTagCheckOverflow(a2, a3);
+ __ BranchOnNoOverflow(&ok, a3);
+
+ // Decrement on overflow
+ __ Subu(a2, a2, Operand(Smi::FromInt(1)));
+ __ bind(&ok);
+ __ sw(a2, counter);
+ }
+
+ Comment cmnt(masm_, "[ Case body");
VisitStatements(clause->statements());
}
« no previous file with comments | « src/lithium.cc ('k') | src/mips/lithium-codegen-mips.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698