Remove unused m_writtenVariables from the parser and related bits
authorsbarati@apple.com <sbarati@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Apr 2016 08:44:43 +0000 (08:44 +0000)
committersbarati@apple.com <sbarati@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Apr 2016 08:44:43 +0000 (08:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=156784

Reviewed by Yusuke Suzuki.

This isn't a octane/codeload speedup even though we're doing less work in
collectFreeVariables. But it's good to get rid of things that are not used.

* parser/Nodes.h:
(JSC::ScopeNode::usesEval):
(JSC::ScopeNode::usesArguments):
(JSC::ScopeNode::usesArrowFunction):
(JSC::ScopeNode::isStrictMode):
(JSC::ScopeNode::setUsesArguments):
(JSC::ScopeNode::usesThis):
(JSC::ScopeNode::modifiesParameter): Deleted.
(JSC::ScopeNode::modifiesArguments): Deleted.
* parser/Parser.cpp:
(JSC::Parser<LexerType>::parseInner):
(JSC::Parser<LexerType>::parseAssignmentExpression):
* parser/Parser.h:
(JSC::Scope::Scope):
(JSC::Scope::hasDeclaredParameter):
(JSC::Scope::preventAllVariableDeclarations):
(JSC::Scope::collectFreeVariables):
(JSC::Scope::mergeInnerArrowFunctionFeatures):
(JSC::Scope::getSloppyModeHoistedFunctions):
(JSC::Scope::getCapturedVars):
(JSC::Scope::setStrictMode):
(JSC::Scope::strictMode):
(JSC::Scope::fillParametersForSourceProviderCache):
(JSC::Scope::restoreFromSourceProviderCache):
(JSC::Parser::hasDeclaredParameter):
(JSC::Parser::exportName):
(JSC::Scope::declareWrite): Deleted.
(JSC::Parser::declareWrite): Deleted.
* parser/ParserModes.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@199768 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/parser/Nodes.h
Source/JavaScriptCore/parser/Parser.cpp
Source/JavaScriptCore/parser/Parser.h
Source/JavaScriptCore/parser/ParserModes.h

index f707806..12932fe 100644 (file)
@@ -1,3 +1,43 @@
+2016-04-20  Saam barati  <sbarati@apple.com>
+
+        Remove unused m_writtenVariables from the parser and related bits
+        https://bugs.webkit.org/show_bug.cgi?id=156784
+
+        Reviewed by Yusuke Suzuki.
+
+        This isn't a octane/codeload speedup even though we're doing less work in
+        collectFreeVariables. But it's good to get rid of things that are not used.
+
+        * parser/Nodes.h:
+        (JSC::ScopeNode::usesEval):
+        (JSC::ScopeNode::usesArguments):
+        (JSC::ScopeNode::usesArrowFunction):
+        (JSC::ScopeNode::isStrictMode):
+        (JSC::ScopeNode::setUsesArguments):
+        (JSC::ScopeNode::usesThis):
+        (JSC::ScopeNode::modifiesParameter): Deleted.
+        (JSC::ScopeNode::modifiesArguments): Deleted.
+        * parser/Parser.cpp:
+        (JSC::Parser<LexerType>::parseInner):
+        (JSC::Parser<LexerType>::parseAssignmentExpression):
+        * parser/Parser.h:
+        (JSC::Scope::Scope):
+        (JSC::Scope::hasDeclaredParameter):
+        (JSC::Scope::preventAllVariableDeclarations):
+        (JSC::Scope::collectFreeVariables):
+        (JSC::Scope::mergeInnerArrowFunctionFeatures):
+        (JSC::Scope::getSloppyModeHoistedFunctions):
+        (JSC::Scope::getCapturedVars):
+        (JSC::Scope::setStrictMode):
+        (JSC::Scope::strictMode):
+        (JSC::Scope::fillParametersForSourceProviderCache):
+        (JSC::Scope::restoreFromSourceProviderCache):
+        (JSC::Parser::hasDeclaredParameter):
+        (JSC::Parser::exportName):
+        (JSC::Scope::declareWrite): Deleted.
+        (JSC::Parser::declareWrite): Deleted.
+        * parser/ParserModes.h:
+
 2016-04-19  Saam barati  <sbarati@apple.com>
 
         Unreviewed, fix cloop build after r199754.
index 62e80f5..5261d68 100644 (file)
@@ -1592,8 +1592,6 @@ namespace JSC {
         bool usesEval() const { return m_features & EvalFeature; }
         bool usesArguments() const { return (m_features & ArgumentsFeature) && !(m_features & ShadowsArgumentsFeature); }
         bool usesArrowFunction() const { return m_features & ArrowFunctionFeature; }
-        bool modifiesParameter() const { return m_features & ModifiedParameterFeature; }
-        bool modifiesArguments() const { return m_features & (EvalFeature | ModifiedArgumentsFeature); }
         bool isStrictMode() const { return m_features & StrictModeFeature; }
         void setUsesArguments() { m_features |= ArgumentsFeature; }
         bool usesThis() const { return m_features & ThisFeature; }
index 6a83d40..4715bc5 100644 (file)
@@ -297,10 +297,8 @@ String Parser<LexerType>::parseInner(const Identifier& calleeName, SourceParseMo
 
     IdentifierSet capturedVariables;
     UniquedStringImplPtrSet sloppyModeHoistedFunctions;
-    bool modifiedParameter = false;
-    bool modifiedArguments = false;
     scope->getSloppyModeHoistedFunctions(sloppyModeHoistedFunctions);
-    scope->getCapturedVars(capturedVariables,  modifiedParameter, modifiedArguments);
+    scope->getCapturedVars(capturedVariables);
 
     VariableEnvironment& varDeclarations = scope->declaredVariables();
     for (auto& entry : capturedVariables)
@@ -316,10 +314,6 @@ String Parser<LexerType>::parseInner(const Identifier& calleeName, SourceParseMo
         features |= StrictModeFeature;
     if (scope->shadowsArguments())
         features |= ShadowsArgumentsFeature;
-    if (modifiedParameter)
-        features |= ModifiedParameterFeature;
-    if (modifiedArguments)
-        features |= ModifiedArgumentsFeature;
 
 #ifndef NDEBUG
     if (m_parsingBuiltin && isProgramParseMode(parseMode)) {
@@ -3122,7 +3116,6 @@ template <typename TreeBuilder> TreeExpression Parser<LexerType>::parseAssignmen
         if (strictMode() && m_parserState.lastIdentifier && context.isResolve(lhs)) {
             failIfTrueIfStrict(m_vm->propertyNames->eval == *m_parserState.lastIdentifier, "Cannot modify 'eval' in strict mode");
             failIfTrueIfStrict(m_vm->propertyNames->arguments == *m_parserState.lastIdentifier, "Cannot modify 'arguments' in strict mode");
-            declareWrite(m_parserState.lastIdentifier);
             m_parserState.lastIdentifier = 0;
         }
         lhs = parseAssignmentExpression(context);
index 5f47681..5113f05 100644 (file)
@@ -213,7 +213,6 @@ public:
         , m_lexicalVariables(WTFMove(other.m_lexicalVariables))
         , m_usedVariables(WTFMove(other.m_usedVariables))
         , m_closedVariableCandidates(WTFMove(other.m_closedVariableCandidates))
-        , m_writtenVariables(WTFMove(other.m_writtenVariables))
         , m_moduleScopeData(WTFMove(other.m_moduleScopeData))
         , m_functionDeclarations(WTFMove(other.m_functionDeclarations))
     {
@@ -465,12 +464,6 @@ public:
         return m_declaredParameters.contains(ident.get()) || hasDeclaredVariable(ident);
     }
     
-    void declareWrite(const Identifier* ident)
-    {
-        ASSERT(m_strictMode);
-        m_writtenVariables.add(ident->impl());
-    }
-
     void preventAllVariableDeclarations()
     {
         m_allowsVarDeclarations = false; 
@@ -598,14 +591,6 @@ public:
             IdentifierSet::iterator begin = nestedScope->m_closedVariableCandidates.begin();
             m_closedVariableCandidates.add(begin, end);
         }
-
-        if (nestedScope->m_writtenVariables.size()) {
-            for (UniquedStringImpl* impl : nestedScope->m_writtenVariables) {
-                if (nestedScope->m_declaredVariables.contains(impl) || nestedScope->m_lexicalVariables.contains(impl))
-                    continue;
-                m_writtenVariables.add(impl);
-            }
-        }
     }
     
     void mergeInnerArrowFunctionFeatures(InnerArrowFunctionCodeFeatures arrowFunctionCodeFeatures)
@@ -632,10 +617,9 @@ public:
         }
     }
 
-    void getCapturedVars(IdentifierSet& capturedVariables, bool& modifiedParameter, bool& modifiedArguments)
+    void getCapturedVars(IdentifierSet& capturedVariables)
     {
         if (m_needsFullActivation || m_usesEval) {
-            modifiedParameter = true;
             for (auto& entry : m_declaredVariables)
                 capturedVariables.add(entry.key);
             return;
@@ -646,19 +630,6 @@ public:
                 continue;
             capturedVariables.add(*ptr);
         }
-        modifiedParameter = false;
-        if (shadowsArguments())
-            modifiedArguments = true;
-        if (m_declaredParameters.size()) {
-            for (UniquedStringImpl* impl : m_writtenVariables) {
-                if (impl == m_vm->propertyNames->arguments.impl())
-                    modifiedArguments = true;
-                if (!m_declaredParameters.contains(impl))
-                    continue;
-                modifiedParameter = true;
-                break;
-            }
-        }
     }
     void setStrictMode() { m_strictMode = true; }
     bool strictMode() const { return m_strictMode; }
@@ -681,7 +652,6 @@ public:
         parameters.strictMode = m_strictMode;
         parameters.needsFullActivation = m_needsFullActivation;
         parameters.innerArrowFunctionFeatures = m_innerArrowFunctionFeatures;
-        copyCapturedVariablesToVector(m_writtenVariables, parameters.writtenVariables);
         for (const UniquedStringImplPtrSet& set : m_usedVariables)
             copyCapturedVariablesToVector(set, parameters.usedVariables);
     }
@@ -696,8 +666,6 @@ public:
         UniquedStringImplPtrSet& destSet = m_usedVariables.last();
         for (unsigned i = 0; i < info->usedVariablesCount; ++i)
             destSet.add(info->usedVariables()[i]);
-        for (unsigned i = 0; i < info->writtenVariablesCount; ++i)
-            m_writtenVariables.add(info->writtenVariables()[i]);
     }
 
 private:
@@ -773,7 +741,6 @@ private:
     Vector<UniquedStringImplPtrSet, 6> m_usedVariables;
     UniquedStringImplPtrSet m_sloppyModeHoistableFunctionCandidates;
     IdentifierSet m_closedVariableCandidates;
-    UniquedStringImplPtrSet m_writtenVariables;
     RefPtr<ModuleScopeData> m_moduleScopeData;
     DeclarationStacks::FunctionStack m_functionDeclarations;
 };
@@ -1175,12 +1142,6 @@ private:
         return m_scopeStack[i].hasDeclaredParameter(ident);
     }
     
-    void declareWrite(const Identifier* ident)
-    {
-        if (!m_syntaxAlreadyValidated || strictMode())
-            m_scopeStack.last().declareWrite(ident);
-    }
-
     bool exportName(const Identifier& ident)
     {
         ASSERT(currentScope().index() == 0);
index 3d7c559..f0c3a22 100644 (file)
@@ -154,15 +154,13 @@ const CodeFeatures WithFeature =                 1 << 2;
 const CodeFeatures ThisFeature =                 1 << 3;
 const CodeFeatures StrictModeFeature =           1 << 4;
 const CodeFeatures ShadowsArgumentsFeature =     1 << 5;
-const CodeFeatures ModifiedParameterFeature =    1 << 6;
-const CodeFeatures ModifiedArgumentsFeature =    1 << 7;
-const CodeFeatures ArrowFunctionFeature =        1 << 8;
-const CodeFeatures ArrowFunctionContextFeature = 1 << 9;
-const CodeFeatures SuperCallFeature =            1 << 10;
-const CodeFeatures SuperPropertyFeature =        1 << 11;
-const CodeFeatures NewTargetFeature =            1 << 12;
-
-const CodeFeatures AllFeatures = EvalFeature | ArgumentsFeature | WithFeature | ThisFeature | StrictModeFeature | ShadowsArgumentsFeature | ModifiedParameterFeature | ArrowFunctionFeature | ArrowFunctionContextFeature |
+const CodeFeatures ArrowFunctionFeature =        1 << 6;
+const CodeFeatures ArrowFunctionContextFeature = 1 << 7;
+const CodeFeatures SuperCallFeature =            1 << 8;
+const CodeFeatures SuperPropertyFeature =        1 << 9;
+const CodeFeatures NewTargetFeature =            1 << 10;
+
+const CodeFeatures AllFeatures = EvalFeature | ArgumentsFeature | WithFeature | ThisFeature | StrictModeFeature | ShadowsArgumentsFeature | ArrowFunctionFeature | ArrowFunctionContextFeature |
     SuperCallFeature | SuperPropertyFeature | NewTargetFeature;
 
 typedef uint8_t InnerArrowFunctionCodeFeatures;