diff --git a/js/src/jit-test/tests/ion/bug1158632.js b/js/src/jit-test/tests/ion/bug1158632.js new file mode 100644 index 00000000000..b80dd0351d8 --- /dev/null +++ b/js/src/jit-test/tests/ion/bug1158632.js @@ -0,0 +1,13 @@ +for (var j = 0; j < 1; ++j) { + function f(x) { + x = 4294967295 >>> 4294967295 % x + switch (-1) { + case 1: + // case 0: + case -1: + x = 0; + // default: + } + } + f(); +} diff --git a/js/src/jit/IonBuilder.cpp b/js/src/jit/IonBuilder.cpp index bd94d6f29bb..5fb2b165e93 100644 --- a/js/src/jit/IonBuilder.cpp +++ b/js/src/jit/IonBuilder.cpp @@ -3406,34 +3406,34 @@ IonBuilder::tableSwitch(JSOp op, jssrcnote* sn) casepc = pc + GET_JUMP_OFFSET(pc2); MOZ_ASSERT(casepc >= pc && casepc <= exitpc); + MBasicBlock* caseblock; - MBasicBlock* caseblock = newBlock(current, casepc); - if (!caseblock) - return ControlStatus_Error; - - // If the casepc equals the current pc, it is not a written case, - // but a filled gap. That way we can use a tableswitch instead of - // condswitch, even if not all numbers are consecutive. - // In that case this block goes to the default case if (casepc == pc) { + // If the casepc equals the current pc, it is not a written case, + // but a filled gap. That way we can use a tableswitch instead of + // condswitch, even if not all numbers are consecutive. + // In that case this block goes to the default case + caseblock = newBlock(current, defaultpc); + if (!caseblock) + return ControlStatus_Error; caseblock->end(MGoto::New(alloc(), defaultcase)); if (!defaultcase->addPredecessor(alloc(), caseblock)) return ControlStatus_Error; - } + } else { + // If this is an actual case (not filled gap), + // add this block to the list that still needs to get processed. + caseblock = newBlock(current, casepc); + if (!caseblock) + return ControlStatus_Error; - tableswitch->addCase(tableswitch->addSuccessor(caseblock)); - - // If this is an actual case (not filled gap), - // add this block to the list that still needs to get processed. - if (casepc != pc) { tableswitch->addBlock(caseblock); - // Add constant to indicate which case this is for use by // processNextTableSwitchCase. MConstant* constant = MConstant::New(alloc(), Int32Value(i + low)); caseblock->add(constant); } + tableswitch->addCase(tableswitch->addSuccessor(caseblock)); pc2 += JUMP_OFFSET_LEN; }