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

Unified Diff: src/codegen-arm.cc

Issue 28066: Experimental: fix two issues with ARM fast (jump table) switches.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/toiger/
Patch Set: '' Created 11 years, 10 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 | test/mjsunit/compare-constants.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codegen-arm.cc
===================================================================
--- src/codegen-arm.cc (revision 1339)
+++ src/codegen-arm.cc (working copy)
@@ -1448,18 +1448,25 @@
Vector<Label*> case_targets,
Vector<Label> case_labels) {
VirtualFrame::SpilledScope spilled_scope(this);
+ JumpTarget setup_default(this);
+ JumpTarget is_smi(this);
+
+ // A non-null default label pointer indicates a default case among
+ // the case labels. Otherwise we use the break target as a
+ // "default".
+ JumpTarget* default_target =
+ (default_label == NULL) ? node->break_target() : &setup_default;
+
ASSERT(kSmiTag == 0 && kSmiTagSize <= 2);
-
frame_->EmitPop(r0);
// Test for a Smi value in a HeapNumber.
- JumpTarget is_smi(this);
__ tst(r0, Operand(kSmiTagMask));
is_smi.Branch(eq);
__ ldr(r1, MemOperand(r0, HeapObject::kMapOffset - kHeapObjectTag));
__ ldrb(r1, MemOperand(r1, Map::kInstanceTypeOffset - kHeapObjectTag));
__ cmp(r1, Operand(HEAP_NUMBER_TYPE));
- __ b(ne, default_label);
+ default_target->Branch(ne);
frame_->EmitPush(r0);
frame_->CallRuntime(Runtime::kNumberToSmi, 1);
is_smi.Bind();
@@ -1479,17 +1486,25 @@
}
}
__ tst(r0, Operand(0x80000000 | kSmiTagMask));
- __ b(ne, default_label);
+ default_target->Branch(ne);
__ cmp(r0, Operand(Smi::FromInt(range)));
- __ b(ge, default_label);
+ default_target->Branch(ge);
+ VirtualFrame* start_frame = new VirtualFrame(frame_);
__ SmiJumpTable(r0, case_targets);
- VirtualFrame* start_frame = new VirtualFrame(frame_);
- // Table containing branch operations.
- for (int i = 0; i < range; i++) {
- __ jmp(case_targets[i]);
+ GenerateFastCaseSwitchCases(node, case_labels, start_frame);
+
+ // If there was a default case, we need to emit the code to match
+ // it.
Lasse Reichstein 2009/02/24 11:55:06 This comment should be more descriptive.
Kevin Millikin (Chromium) 2009/02/24 12:33:19 Descriptified.
+ if (default_label != NULL) {
+ node->break_target()->Jump();
+ setup_default.Bind();
+ frame_->MergeTo(start_frame);
+ __ b(default_label);
+ DeleteFrame();
}
- GenerateFastCaseSwitchCases(node, case_labels, start_frame);
+ node->break_target()->Bind();
+
delete start_frame;
}
« no previous file with comments | « no previous file | test/mjsunit/compare-constants.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698