[INFER] Handle DEFAULTX and CASEX during inference, bug 641235.
authorBrian Hackett <bhackett1024@gmail.com>
Sun, 13 Mar 2011 22:05:24 -0700
changeset 74768 f70363576e62beffec41a3296f305e970717c441
parent 74767 2ac6e8d5509880ead3f09260148dafad518b3075
child 74769 1ce8efbb75cc6122286f9d4e33aba3592fb6a5fb
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
bugs641235
milestone2.0b13pre
[INFER] Handle DEFAULTX and CASEX during inference, bug 641235.
js/src/jit-test/tests/basic/bug641235.js
js/src/jsinfer.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/basic/bug641235.js
@@ -0,0 +1,21 @@
+try {
+function g(code) {
+    code = code.replace(/\/\*DUPTRY\d+\*\//, function(k) {
+        var n = parseInt(k.substr(8), 10);
+        return aa("try{}catch(e){}", n);
+    });
+    var f = new Function(code);
+    f()
+}
+function aa(s, n) {
+    if (n == 1) {
+        return s;
+    }
+    var s2 = s + s;
+    var r = n % 2;
+    var d = (n - r) / 2;
+    var m = aa(s2, d);
+    return r ? m + s : m;
+}
+g("switch(x){default:case l:/*DUPTRY5338*/case 0:x}");
+} catch (e) {}
--- a/js/src/jsinfer.cpp
+++ b/js/src/jsinfer.cpp
@@ -2727,16 +2727,17 @@ AnalyzeBytecode(JSContext *cx, AnalyzeSt
       case JSOP_RETRVAL:
       case JSOP_ENDITER:
       case JSOP_THROWING:
       case JSOP_GOSUB:
       case JSOP_GOSUBX:
       case JSOP_RETSUB:
       case JSOP_CONDSWITCH:
       case JSOP_DEFAULT:
+      case JSOP_DEFAULTX:
       case JSOP_POPN:
       case JSOP_UNBRANDTHIS:
       case JSOP_STARTXML:
       case JSOP_STARTXMLEXPR:
       case JSOP_DEFXMLNS:
       case JSOP_SHARPINIT:
       case JSOP_INDEXBASE:
       case JSOP_INDEXBASE1:
@@ -3377,16 +3378,17 @@ AnalyzeBytecode(JSContext *cx, AnalyzeSt
         pushed[0].addType(cx, TYPE_BOOLEAN);
         break;
 
       case JSOP_LEAVEBLOCKEXPR:
         state.popped(0).types->addSubset(cx, script, &pushed[0]);
         break;
 
       case JSOP_CASE:
+      case JSOP_CASEX:
         state.popped(1).types->addSubset(cx, script, &pushed[0]);
         break;
 
       case JSOP_UNBRAND:
         state.popped(0).types->addSubset(cx, script, &pushed[0]);
         break;
 
       case JSOP_GENERATOR: