[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
oliver at apple.com
oliver at apple.com
Wed Dec 22 13:44:53 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit c159fdb9e07cf2a7137f24bc61ad99ebb0d0950f
Author: oliver at apple.com <oliver at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Sep 24 20:54:48 2010 +0000
2010-09-24 Oliver Hunt <oliver at apple.com>
Reviewed by Geoffrey Garen.
Variable declarations inside a catch scope don't get propogated to the parent scope
https://bugs.webkit.org/show_bug.cgi?id=46501
Add logic to make variable declaration look for a scope for the
new variable. This allows us to create a scope (eg. for catch)
and then seal it, so that additional variable declarations
contained are propogated to the correct target. Strangely this
comes out as a performance win, but I think it's mostly cache
effects.
* parser/JSParser.cpp:
(JSC::JSParser::Scope::Scope):
(JSC::JSParser::Scope::preventNewDecls):
(JSC::JSParser::Scope::allowsNewDecls):
(JSC::JSParser::declareVariable):
(JSC::JSParser::parseVarDeclarationList):
(JSC::JSParser::parseConstDeclarationList):
(JSC::JSParser::parseTryStatement):
(JSC::JSParser::parseFormalParameters):
(JSC::JSParser::parseFunctionDeclaration):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@68288 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index a40745b..84aeb39 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,28 @@
+2010-09-24 Oliver Hunt <oliver at apple.com>
+
+ Reviewed by Geoffrey Garen.
+
+ Variable declarations inside a catch scope don't get propogated to the parent scope
+ https://bugs.webkit.org/show_bug.cgi?id=46501
+
+ Add logic to make variable declaration look for a scope for the
+ new variable. This allows us to create a scope (eg. for catch)
+ and then seal it, so that additional variable declarations
+ contained are propogated to the correct target. Strangely this
+ comes out as a performance win, but I think it's mostly cache
+ effects.
+
+ * parser/JSParser.cpp:
+ (JSC::JSParser::Scope::Scope):
+ (JSC::JSParser::Scope::preventNewDecls):
+ (JSC::JSParser::Scope::allowsNewDecls):
+ (JSC::JSParser::declareVariable):
+ (JSC::JSParser::parseVarDeclarationList):
+ (JSC::JSParser::parseConstDeclarationList):
+ (JSC::JSParser::parseTryStatement):
+ (JSC::JSParser::parseFormalParameters):
+ (JSC::JSParser::parseFunctionDeclaration):
+
2010-09-24 İsmail Dönmez <ismail at namtrac.org>
Reviewed by Csaba Osztrogonác.
diff --git a/JavaScriptCore/parser/JSParser.cpp b/JavaScriptCore/parser/JSParser.cpp
index 540dc3b..0e526ac 100644
--- a/JavaScriptCore/parser/JSParser.cpp
+++ b/JavaScriptCore/parser/JSParser.cpp
@@ -204,6 +204,7 @@ private:
Scope()
: m_usesEval(false)
, m_needsFullActivation(false)
+ , m_allowsNewDecls(true)
{
}
@@ -212,6 +213,9 @@ private:
m_declaredVariables.add(ident->ustring().impl());
}
+ void preventNewDecls() { m_allowsNewDecls = false; }
+ bool allowsNewDecls() const { return m_allowsNewDecls; }
+
void useVariable(const Identifier* ident, bool isEval)
{
m_usesEval |= isEval;
@@ -249,6 +253,7 @@ private:
private:
bool m_usesEval;
bool m_needsFullActivation;
+ bool m_allowsNewDecls;
IdentifierSet m_declaredVariables;
IdentifierSet m_usedVariables;
IdentifierSet m_closedVariables;
@@ -287,6 +292,17 @@ private:
m_scopeStack[m_scopeStack.size() - 2].collectFreeVariables(&m_scopeStack.last(), shouldTrackClosedVariables);
m_scopeStack.removeLast();
}
+
+ void declareVariable(const Identifier* ident)
+ {
+ unsigned i = m_scopeStack.size() - 1;
+ ASSERT(i < m_scopeStack.size());
+ while (!m_scopeStack[i].allowsNewDecls()) {
+ i--;
+ ASSERT(i < m_scopeStack.size());
+ }
+ m_scopeStack[i].declareVariable(ident);
+ }
ScopeStack m_scopeStack;
};
@@ -425,7 +441,7 @@ template <class TreeBuilder> TreeExpression JSParser::parseVarDeclarationList(Tr
lastIdent = name;
next();
bool hasInitializer = match(EQUAL);
- currentScope()->declareVariable(name);
+ declareVariable(name);
context.addVar(name, (hasInitializer || (!m_allowsIn && match(INTOKEN))) ? DeclarationStacks::HasInitializer : 0);
if (hasInitializer) {
int varDivot = tokenStart() + 1;
@@ -457,7 +473,7 @@ template <class TreeBuilder> TreeConstDeclList JSParser::parseConstDeclarationLi
const Identifier* name = m_token.m_data.ident;
next();
bool hasInitializer = match(EQUAL);
- currentScope()->declareVariable(name);
+ declareVariable(name);
context.addVar(name, DeclarationStacks::IsConstant | (hasInitializer ? DeclarationStacks::HasInitializer : 0));
TreeExpression initializer = 0;
if (hasInitializer) {
@@ -759,6 +775,7 @@ template <class TreeBuilder> TreeStatement JSParser::parseTryStatement(TreeBuild
next();
ScopeRef catchScope = pushScope();
catchScope->declareVariable(ident);
+ catchScope->preventNewDecls();
consumeOrFail(CLOSEPAREN);
matchOrFail(OPENBRACE);
int initialEvalCount = context.evalCount();
@@ -862,7 +879,7 @@ template <class TreeBuilder> TreeFormalParameterList JSParser::parseFormalParame
{
matchOrFail(IDENT);
usesArguments = m_globalData->propertyNames->arguments == *m_token.m_data.ident;
- currentScope()->declareVariable(m_token.m_data.ident);
+ declareVariable(m_token.m_data.ident);
TreeFormalParameterList list = context.createFormalParameterList(*m_token.m_data.ident);
TreeFormalParameterList tail = list;
next();
@@ -870,7 +887,7 @@ template <class TreeBuilder> TreeFormalParameterList JSParser::parseFormalParame
next();
matchOrFail(IDENT);
const Identifier* ident = m_token.m_data.ident;
- currentScope()->declareVariable(ident);
+ declareVariable(ident);
next();
usesArguments = usesArguments || m_globalData->propertyNames->arguments == *ident;
tail = context.createFormalParameterList(tail, *ident);
@@ -933,7 +950,7 @@ template <class TreeBuilder> TreeStatement JSParser::parseFunctionDeclaration(Tr
int bodyStartLine = 0;
failIfFalse((parseFunctionInfo<FunctionNeedsName, true>(context, name, parameters, body, openBracePos, closeBracePos, bodyStartLine)));
failIfFalse(name);
- currentScope()->declareVariable(name);
+ declareVariable(name);
return context.createFuncDeclStatement(name, body, parameters, openBracePos, closeBracePos, bodyStartLine, m_lastLine);
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list