From 7549b16413372c628f24f2f55178819e707a1f68 Mon Sep 17 00:00:00 2001 From: "fschneider@chromium.org" Date: Fri, 2 Dec 2011 15:15:23 +0000 Subject: [PATCH] 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 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10145 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/hydrogen.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/hydrogen.cc b/src/hydrogen.cc index ea3548a..2d9d58a 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -2756,10 +2756,13 @@ void HGraphBuilder::VisitSwitchStatement(SwitchStatement* stmt) { } // 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 @@ void HGraphBuilder::VisitSwitchStatement(SwitchStatement* stmt) { 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, -- 2.7.4