[INFER] Fold integer values across TOID. r=bhackett
authorShu-yu Guo <shu@rfrn.org>
Wed, 10 Aug 2011 16:06:36 -0700
changeset 76114 b99f3928f69cf0b177ca08d86122f34a2f1a7ece
parent 76113 3cf701fb5962e3734bdc435d42222b8782517e04
child 76115 e0b67d8cc908ec54dd7d79255e50ee58ae579ba8
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersbhackett
milestone8.0a1
[INFER] Fold integer values across TOID. r=bhackett
js/src/jsanalyze.cpp
--- a/js/src/jsanalyze.cpp
+++ b/js/src/jsanalyze.cpp
@@ -1999,16 +1999,29 @@ CrossScriptSSA::foldValue(const CrossSSA
              */
             if (v.pushedIndex() == 1) {
                 ScriptAnalysis *analysis = frame.script->analysis();
                 return foldValue(CrossSSAValue(cv.frame, analysis->poppedValue(pc, 0)));
             }
             break;
           }
 
+          case JSOP_TOID: {
+            /*
+             * TOID acts as identity for integers, so to get better precision
+             * we should propagate its popped values forward if it acted as
+             * identity.
+             */
+            ScriptAnalysis *analysis = frame.script->analysis();
+            SSAValue toidv = analysis->poppedValue(pc, 0);
+            if (analysis->getValueTypes(toidv)->getKnownTypeTag(cx) == JSVAL_TYPE_INT32)
+                return foldValue(CrossSSAValue(cv.frame, toidv));
+            break;
+          }
+
           default:;
         }
     }
 
     return cv;
 }
 
 #ifdef DEBUG