Revision: 10145
Author:   [email protected]
Date:     Fri Dec  2 07:15:23 2011
Log: Fix a bug with deoptimization from inside the default-clause of a switch-statement.

When generating a string-switch we have to use the correct ast id when
there is a default clause present.
Review URL: http://codereview.chromium.org/8776048
http://code.google.com/p/v8/source/detail?r=10145

Modified:
 /branches/bleeding_edge/src/hydrogen.cc

=======================================
--- /branches/bleeding_edge/src/hydrogen.cc     Fri Dec  2 04:42:35 2011
+++ /branches/bleeding_edge/src/hydrogen.cc     Fri Dec  2 07:15:23 2011
@@ -2756,10 +2756,13 @@
   }

   // 2. Build all the tests, with dangling true branches
+  int default_id = AstNode::kNoNumber;
   for (int i = 0; i < clause_count; ++i) {
     CaseClause* clause = clauses->at(i);
-    if (clause->is_default()) continue;
-
+    if (clause->is_default()) {
+      default_id = clause->EntryId();
+      continue;
+    }
     if (switch_type == SMI_SWITCH) {
       clause->RecordTypeFeedback(oracle());
     }
@@ -2806,7 +2809,10 @@
   HBasicBlock* last_block = current_block();

   if (not_string_block != NULL) {
-    last_block = CreateJoin(last_block, not_string_block, stmt->ExitId());
+    int join_id = (default_id != AstNode::kNoNumber)
+        ? default_id
+        : stmt->ExitId();
+    last_block = CreateJoin(last_block, not_string_block, join_id);
   }

   // 3. Loop over the clauses and the linked list of tests in lockstep,

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to