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()); |
} |