From a1830dde57b204d9e58eb14dab2fcd8bfccbb3e7 Mon Sep 17 00:00:00 2001 From: "sbarati@apple.com" Date: Wed, 20 Apr 2016 08:44:43 +0000 Subject: [PATCH] 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::parseInner): (JSC::Parser::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 | 40 +++++++++++++++++++++++++++++ Source/JavaScriptCore/parser/Nodes.h | 2 -- Source/JavaScriptCore/parser/Parser.cpp | 9 +------ Source/JavaScriptCore/parser/Parser.h | 41 +----------------------------- Source/JavaScriptCore/parser/ParserModes.h | 16 +++++------- 5 files changed, 49 insertions(+), 59 deletions(-) diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog index f707806..12932fe 100644 --- a/Source/JavaScriptCore/ChangeLog +++ b/Source/JavaScriptCore/ChangeLog @@ -1,3 +1,43 @@ +2016-04-20 Saam barati + + 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::parseInner): + (JSC::Parser::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 Unreviewed, fix cloop build after r199754. diff --git a/Source/JavaScriptCore/parser/Nodes.h b/Source/JavaScriptCore/parser/Nodes.h index 62e80f5..5261d68 100644 --- a/Source/JavaScriptCore/parser/Nodes.h +++ b/Source/JavaScriptCore/parser/Nodes.h @@ -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; } diff --git a/Source/JavaScriptCore/parser/Parser.cpp b/Source/JavaScriptCore/parser/Parser.cpp index 6a83d40..4715bc5 100644 --- a/Source/JavaScriptCore/parser/Parser.cpp +++ b/Source/JavaScriptCore/parser/Parser.cpp @@ -297,10 +297,8 @@ String Parser::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::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 TreeExpression Parser::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); diff --git a/Source/JavaScriptCore/parser/Parser.h b/Source/JavaScriptCore/parser/Parser.h index 5f47681..5113f05 100644 --- a/Source/JavaScriptCore/parser/Parser.h +++ b/Source/JavaScriptCore/parser/Parser.h @@ -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 m_usedVariables; UniquedStringImplPtrSet m_sloppyModeHoistableFunctionCandidates; IdentifierSet m_closedVariableCandidates; - UniquedStringImplPtrSet m_writtenVariables; RefPtr 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); diff --git a/Source/JavaScriptCore/parser/ParserModes.h b/Source/JavaScriptCore/parser/ParserModes.h index 3d7c559..f0c3a22 100644 --- a/Source/JavaScriptCore/parser/ParserModes.h +++ b/Source/JavaScriptCore/parser/ParserModes.h @@ -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; -- 1.8.3.1