Bug 976047 - Simplify jsanalyze.cpp now that locals no longer alias the stack r=jandem
authorAndy Wingo <wingo@igalia.com>
Tue, 25 Feb 2014 18:46:13 +0100
changeset 170781 6967361e6aeb085e5030074f856720b278225e4a
parent 170780 cc698e2ff036745b0a62597024fb478d5f6c7b05
child 170782 f0516583976066555ba08caf87e4f25af7455e18
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersjandem
bugs976047
milestone30.0a1
Bug 976047 - Simplify jsanalyze.cpp now that locals no longer alias the stack r=jandem
js/src/jsanalyze.cpp
js/src/jsanalyze.h
--- a/js/src/jsanalyze.cpp
+++ b/js/src/jsanalyze.cpp
@@ -659,18 +659,17 @@ inline bool
 ScriptAnalysis::trackUseChain(const SSAValue &v)
 {
     JS_ASSERT_IF(v.kind() == SSAValue::VAR, trackSlot(v.varSlot()));
     return v.kind() != SSAValue::EMPTY &&
         (v.kind() != SSAValue::VAR || !v.varInitial());
 }
 
 /*
- * Get the use chain for an SSA value. May be invalid for some opcodes in
- * scripts where localsAliasStack(). You have been warned!
+ * Get the use chain for an SSA value.
  */
 inline SSAUseChain *&
 ScriptAnalysis::useChain(const SSAValue &v)
 {
     JS_ASSERT(trackUseChain(v));
     if (v.kind() == SSAValue::PUSHED)
         return getCode(v.pushedOffset()).pushedUses[v.pushedIndex()];
     if (v.kind() == SSAValue::VAR)
@@ -929,20 +928,16 @@ ScriptAnalysis::analyzeBytecode(JSContex
           }
 
           case JSOP_GETLOCAL:
           case JSOP_CALLLOCAL:
           case JSOP_SETLOCAL:
             JS_ASSERT(GET_LOCALNO(pc) < script_->nfixed());
             break;
 
-          case JSOP_PUSHBLOCKSCOPE:
-            localsAliasStack_ = true;
-            break;
-
           default:
             break;
         }
 
         bool jump = IsJumpOpcode(op);
 
         /* Check basic jump opcodes, which may or may not have a fallthrough. */
         if (jump) {
@@ -2292,23 +2287,16 @@ ScriptAnalysis::needsArgsObj(JSContext *
      *
      * New accesses on 'arguments' can occur through 'eval' or the debugger
      * statement. In the former case, we will dynamically detect the use and
      * mark the arguments optimization as having failed.
      */
     if (script_->bindingsAccessedDynamically())
         return false;
 
-    /*
-     * Since let variables and are not tracked, we cannot soundly perform this
-     * analysis in their presence.
-     */
-    if (localsAliasStack())
-        return true;
-
     unsigned pcOff = script_->pcToOffset(script_->argumentsBytecode());
 
     SeenVector seen(cx);
     if (needsArgsObj(cx, seen, SSAValue::PushedValue(pcOff, 0)))
         return true;
 
     /*
      * If a script explicitly accesses the contents of 'arguments', and has
--- a/js/src/jsanalyze.h
+++ b/js/src/jsanalyze.h
@@ -55,17 +55,16 @@ class ScriptAnalysis
 
 #ifdef DEBUG
     /* Whether the compartment was in debug mode when we performed the analysis. */
     bool originalDebugMode_: 1;
 #endif
 
     /* --------- Bytecode analysis --------- */
 
-    bool localsAliasStack_:1;
     bool canTrackVars:1;
     bool argumentsContentsObserved_:1;
 
     /* --------- Lifetime analysis --------- */
 
     LifetimeVariable *lifetimes;
 
   public:
@@ -75,22 +74,16 @@ class ScriptAnalysis
 #ifdef DEBUG
         this->originalDebugMode_ = script_->compartment()->debugMode();
 #endif
     }
 
     MOZ_WARN_UNUSED_RESULT
     bool analyzeBytecode(JSContext *cx);
 
-    /*
-     * True if there are any LOCAL opcodes aliasing values on the stack (above
-     * script_->nfixed).
-     */
-    bool localsAliasStack() { return localsAliasStack_; }
-
     bool isReachable(const jsbytecode *pc) { return maybeCode(pc); }
 
   private:
     MOZ_WARN_UNUSED_RESULT
     bool analyzeSSA(JSContext *cx);
     MOZ_WARN_UNUSED_RESULT
     bool analyzeLifetimes(JSContext *cx);
 
@@ -115,18 +108,17 @@ class ScriptAnalysis
     inline const SSAValue &poppedValue(const jsbytecode *pc, uint32_t which);
 
     inline const SlotValue *newValues(uint32_t offset);
     inline const SlotValue *newValues(const jsbytecode *pc);
 
     inline bool trackUseChain(const SSAValue &v);
 
     /*
-     * Get the use chain for an SSA value. May be invalid for some opcodes in
-     * scripts where localsAliasStack(). You have been warned!
+     * Get the use chain for an SSA value.
      */
     inline SSAUseChain *& useChain(const SSAValue &v);
 
 
     /* For a JSOP_CALL* op, get the pc of the corresponding JSOP_CALL/NEW/etc. */
     inline jsbytecode *getCallPC(jsbytecode *pc);
 
     /* Accessors for local variable information. */