Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (176753 => 176754)
--- trunk/Source/_javascript_Core/ChangeLog 2014-12-03 21:53:36 UTC (rev 176753)
+++ trunk/Source/_javascript_Core/ChangeLog 2014-12-03 21:54:53 UTC (rev 176754)
@@ -1,3 +1,70 @@
+2014-12-03 Geoffrey Garen <[email protected]>
+
+ The parser should allocate all pieces of the AST
+ https://bugs.webkit.org/show_bug.cgi?id=139230
+
+ Reviewed by Oliver Hunt.
+
+ This is a step toward a 14% parsing speedup.
+
+ Previously, allocation was split between the parser and certain node
+ constructor functions. This made for some duplicated code and circular
+ dependencies.
+
+ * parser/ASTBuilder.h:
+ (JSC::ASTBuilder::createGetterOrSetterProperty): No need to pass through
+ the VM, since our callee no longer needs to allocate anything.
+
+ (JSC::ASTBuilder::createProperty): Allocate the identifier for our
+ callee, since that is simpler than requiring our callee to notice that
+ we didn't do so, and do it for us.
+
+ (JSC::ASTBuilder::createForInLoop): Allocate the DeconstructingAssignmentNode
+ for our callee, since that is simpler than requiring our callee to notice
+ that we didn't do so, and do it for us.
+
+ Also, reuse some code instead of duplicating it.
+
+ (JSC::ASTBuilder::createForOfLoop): Ditto.
+
+ (JSC::ASTBuilder::createArrayPattern):
+ (JSC::ASTBuilder::createObjectPattern):
+ (JSC::ASTBuilder::createBindingLocation): No need to pass through a VM
+ pointer, since our callee no longer needs to allocate anything.
+
+ (JSC::ASTBuilder::createBreakStatement): Deleted.
+ (JSC::ASTBuilder::createContinueStatement): Deleted.
+
+ * parser/NodeConstructors.h:
+ (JSC::PropertyNode::PropertyNode):
+ (JSC::DeconstructionPatternNode::DeconstructionPatternNode):
+ (JSC::ArrayPatternNode::ArrayPatternNode):
+ (JSC::ArrayPatternNode::create):
+ (JSC::ObjectPatternNode::ObjectPatternNode):
+ (JSC::ObjectPatternNode::create):
+ (JSC::BindingNode::create):
+ (JSC::BindingNode::BindingNode):
+ (JSC::ContinueNode::ContinueNode): Deleted.
+ (JSC::BreakNode::BreakNode): Deleted.
+ (JSC::EnumerationNode::EnumerationNode): Deleted.
+ (JSC::ForInNode::ForInNode): Deleted.
+ (JSC::ForOfNode::ForOfNode): Deleted. Deleted a bunch of special cases
+ that don't exist anymore, now that the parser allocates all pieces of
+ the AST unconditionally.
+
+ * parser/Nodes.h: Ditto.
+
+ * parser/Parser.cpp:
+ (JSC::Parser<LexerType>::parseBreakStatement):
+ (JSC::Parser<LexerType>::parseContinueStatement): Allocate the null
+ identifier for our callee, since that is simpler than requiring our
+ callee to notice that we didn't do so, and do it for us.
+
+ (JSC::Parser<LexerType>::parseProperty):
+ * parser/SyntaxChecker.h:
+ (JSC::SyntaxChecker::createProperty): No need to pass through a VM
+ pointer, since our callee no longer needs to allocate anything.
+
2014-12-03 Zsolt Borbely <[email protected]>
Remove unused JSC runtime options
Modified: trunk/Source/_javascript_Core/parser/ASTBuilder.h (176753 => 176754)
--- trunk/Source/_javascript_Core/parser/ASTBuilder.h 2014-12-03 21:53:36 UTC (rev 176753)
+++ trunk/Source/_javascript_Core/parser/ASTBuilder.h 2014-12-03 21:54:53 UTC (rev 176754)
@@ -299,13 +299,13 @@
ASSERT(name);
body->setLoc(bodyStartLine, bodyEndLine, location.startOffset, location.lineStartOffset);
body->setInferredName(*name);
- return new (m_vm) PropertyNode(m_vm, *name, new (m_vm) FuncExprNode(location, m_vm->propertyNames->nullIdentifier, body, m_sourceCode->subExpression(openBraceOffset, closeBraceOffset, bodyStartLine, bodyStartColumn), params), type);
+ return new (m_vm) PropertyNode(*name, new (m_vm) FuncExprNode(location, m_vm->propertyNames->nullIdentifier, body, m_sourceCode->subExpression(openBraceOffset, closeBraceOffset, bodyStartLine, bodyStartColumn), params), type);
}
NEVER_INLINE PropertyNode* createGetterOrSetterProperty(VM*, const JSTokenLocation& location, PropertyNode::Type type, bool, double name, ParameterNode* params, FunctionBodyNode* body, unsigned openBraceOffset, unsigned closeBraceOffset, int bodyStartLine, int bodyEndLine, unsigned bodyStartColumn)
{
body->setLoc(bodyStartLine, bodyEndLine, location.startOffset, location.lineStartOffset);
- return new (m_vm) PropertyNode(m_vm, name, new (m_vm) FuncExprNode(location, m_vm->propertyNames->nullIdentifier, body, m_sourceCode->subExpression(openBraceOffset, closeBraceOffset, bodyStartLine, bodyStartColumn), params), type);
+ return new (m_vm) PropertyNode(m_vm->parserArena->identifierArena().makeNumericIdentifier(m_vm, name), new (m_vm) FuncExprNode(location, m_vm->propertyNames->nullIdentifier, body, m_sourceCode->subExpression(openBraceOffset, closeBraceOffset, bodyStartLine, bodyStartColumn), params), type);
}
ArgumentsNode* createArguments() { return new (m_vm) ArgumentsNode(); }
@@ -317,10 +317,13 @@
{
if (node->isFuncExprNode())
static_cast<FuncExprNode*>(node)->body()->setInferredName(*propertyName);
- return new (m_vm) PropertyNode(m_vm, *propertyName, node, type);
+ return new (m_vm) PropertyNode(*propertyName, node, type);
}
- PropertyNode* createProperty(VM*, double propertyName, ExpressionNode* node, PropertyNode::Type type, bool) { return new (m_vm) PropertyNode(m_vm, propertyName, node, type); }
- PropertyNode* createProperty(VM*, ExpressionNode* propertyName, ExpressionNode* node, PropertyNode::Type type, bool) { return new (m_vm) PropertyNode(m_vm, propertyName, node, type); }
+ PropertyNode* createProperty(VM*, double propertyName, ExpressionNode* node, PropertyNode::Type type, bool)
+ {
+ return new (m_vm) PropertyNode(m_vm->parserArena->identifierArena().makeNumericIdentifier(m_vm, propertyName), node, type);
+ }
+ PropertyNode* createProperty(ExpressionNode* propertyName, ExpressionNode* node, PropertyNode::Type type, bool) { return new (m_vm) PropertyNode(propertyName, node, type); }
PropertyListNode* createPropertyList(const JSTokenLocation& location, PropertyNode* property) { return new (m_vm) PropertyListNode(location, property); }
PropertyListNode* createPropertyList(const JSTokenLocation& location, PropertyNode* property, PropertyListNode* tail) { return new (m_vm) PropertyListNode(location, property, tail); }
@@ -384,10 +387,8 @@
StatementNode* createForInLoop(const JSTokenLocation& location, PassRefPtr<DeconstructionPatternNode> pattern, ExpressionNode* iter, StatementNode* statements, const JSTextPosition& eStart, const JSTextPosition& eDivot, const JSTextPosition& eEnd, int start, int end)
{
- ForInNode* result = new (m_vm) ForInNode(m_vm, location, pattern.get(), iter, statements);
- result->setLoc(start, end, location.startOffset, location.lineStartOffset);
- setExceptionLocation(result, eStart, eDivot, eEnd);
- return result;
+ auto lexpr = new (m_vm) DeconstructingAssignmentNode(location, pattern.get(), 0);
+ return createForInLoop(location, lexpr, iter, statements, eStart, eDivot, eEnd, start, end);
}
StatementNode* createForOfLoop(const JSTokenLocation& location, ExpressionNode* lhs, ExpressionNode* iter, StatementNode* statements, const JSTextPosition& eStart, const JSTextPosition& eDivot, const JSTextPosition& eEnd, int start, int end)
@@ -400,10 +401,8 @@
StatementNode* createForOfLoop(const JSTokenLocation& location, PassRefPtr<DeconstructionPatternNode> pattern, ExpressionNode* iter, StatementNode* statements, const JSTextPosition& eStart, const JSTextPosition& eDivot, const JSTextPosition& eEnd, int start, int end)
{
- ForOfNode* result = new (m_vm) ForOfNode(m_vm, location, pattern.get(), iter, statements);
- result->setLoc(start, end, location.startOffset, location.lineStartOffset);
- setExceptionLocation(result, eStart, eDivot, eEnd);
- return result;
+ auto lexpr = new (m_vm) DeconstructingAssignmentNode(location, pattern.get(), 0);
+ return createForOfLoop(location, lexpr, iter, statements, eStart, eDivot, eEnd, start, end);
}
bool isBindingNode(const DeconstructionPattern& pattern)
@@ -434,14 +433,6 @@
return result;
}
- StatementNode* createBreakStatement(const JSTokenLocation& location, const JSTextPosition& start, const JSTextPosition& end)
- {
- BreakNode* result = new (m_vm) BreakNode(m_vm, location);
- setExceptionLocation(result, start, end, end);
- result->setLoc(start.line, end.line, start.offset, start.lineStartOffset);
- return result;
- }
-
StatementNode* createBreakStatement(const JSTokenLocation& location, const Identifier* ident, const JSTextPosition& start, const JSTextPosition& end)
{
BreakNode* result = new (m_vm) BreakNode(location, *ident);
@@ -450,14 +441,6 @@
return result;
}
- StatementNode* createContinueStatement(const JSTokenLocation& location, const JSTextPosition& start, const JSTextPosition& end)
- {
- ContinueNode* result = new (m_vm) ContinueNode(m_vm, location);
- setExceptionLocation(result, start, end, end);
- result->setLoc(start.line, end.line, start.offset, start.lineStartOffset);
- return result;
- }
-
StatementNode* createContinueStatement(const JSTokenLocation& location, const Identifier* ident, const JSTextPosition& start, const JSTextPosition& end)
{
ContinueNode* result = new (m_vm) ContinueNode(location, *ident);
@@ -659,7 +642,7 @@
ArrayPattern createArrayPattern(const JSTokenLocation&)
{
- return ArrayPatternNode::create(m_vm);
+ return ArrayPatternNode::create();
}
void appendArrayPatternSkipEntry(ArrayPattern node, const JSTokenLocation& location)
@@ -674,7 +657,7 @@
ObjectPattern createObjectPattern(const JSTokenLocation&)
{
- return ObjectPatternNode::create(m_vm);
+ return ObjectPatternNode::create();
}
void appendObjectPatternEntry(ObjectPattern node, const JSTokenLocation& location, bool wasString, const Identifier& identifier, DeconstructionPattern pattern)
@@ -684,7 +667,7 @@
BindingPattern createBindingLocation(const JSTokenLocation&, const Identifier& boundProperty, const JSTextPosition& start, const JSTextPosition& end)
{
- return BindingNode::create(m_vm, boundProperty, start, end);
+ return BindingNode::create(boundProperty, start, end);
}
void setEndOffset(Node* node, int offset)
Modified: trunk/Source/_javascript_Core/parser/NodeConstructors.h (176753 => 176754)
--- trunk/Source/_javascript_Core/parser/NodeConstructors.h 2014-12-03 21:53:36 UTC (rev 176753)
+++ trunk/Source/_javascript_Core/parser/NodeConstructors.h 2014-12-03 21:54:53 UTC (rev 176754)
@@ -147,21 +147,14 @@
{
}
- inline PropertyNode::PropertyNode(VM*, const Identifier& name, ExpressionNode* assign, Type type)
+ inline PropertyNode::PropertyNode(const Identifier& name, ExpressionNode* assign, Type type)
: m_name(&name)
, m_assign(assign)
, m_type(type)
{
}
- inline PropertyNode::PropertyNode(VM* vm, double name, ExpressionNode* assign, Type type)
- : m_name(&vm->parserArena->identifierArena().makeNumericIdentifier(vm, name))
- , m_assign(assign)
- , m_type(type)
- {
- }
-
- inline PropertyNode::PropertyNode(VM*, ExpressionNode* name, ExpressionNode* assign, Type type)
+ inline PropertyNode::PropertyNode(ExpressionNode* name, ExpressionNode* assign, Type type)
: m_name(0)
, m_expression(name)
, m_assign(assign)
@@ -694,24 +687,12 @@
ASSERT(statement);
}
- inline ContinueNode::ContinueNode(VM* vm, const JSTokenLocation& location)
- : StatementNode(location)
- , m_ident(vm->propertyNames->nullIdentifier)
- {
- }
-
inline ContinueNode::ContinueNode(const JSTokenLocation& location, const Identifier& ident)
: StatementNode(location)
, m_ident(ident)
{
}
- inline BreakNode::BreakNode(VM* vm, const JSTokenLocation& location)
- : StatementNode(location)
- , m_ident(vm->propertyNames->nullIdentifier)
- {
- }
-
inline BreakNode::BreakNode(const JSTokenLocation& location, const Identifier& ident)
: StatementNode(location)
, m_ident(ident)
@@ -841,66 +822,47 @@
ASSERT(l);
}
- inline EnumerationNode::EnumerationNode(VM* vm, const JSTokenLocation& location, DeconstructionPatternNode* pattern, ExpressionNode* expr, StatementNode* statement)
- : StatementNode(location)
- , m_lexpr(new (vm) DeconstructingAssignmentNode(location, pattern, 0))
- , m_expr(expr)
- , m_statement(statement)
- {
- ASSERT(pattern);
- }
-
inline ForInNode::ForInNode(const JSTokenLocation& location, ExpressionNode* l, ExpressionNode* expr, StatementNode* statement)
: EnumerationNode(location, l, expr, statement)
{
}
- inline ForInNode::ForInNode(VM* vm, const JSTokenLocation& location, DeconstructionPatternNode* pattern, ExpressionNode* expr, StatementNode* statement)
- : EnumerationNode(vm, location, pattern, expr, statement)
- {
- }
-
inline ForOfNode::ForOfNode(const JSTokenLocation& location, ExpressionNode* l, ExpressionNode* expr, StatementNode* statement)
: EnumerationNode(location, l, expr, statement)
{
}
- inline ForOfNode::ForOfNode(VM* vm, const JSTokenLocation& location, DeconstructionPatternNode* pattern, ExpressionNode* expr, StatementNode* statement)
- : EnumerationNode(vm, location, pattern, expr, statement)
+ inline DeconstructionPatternNode::DeconstructionPatternNode()
{
}
-
- inline DeconstructionPatternNode::DeconstructionPatternNode(VM*)
- {
- }
- inline ArrayPatternNode::ArrayPatternNode(VM* vm)
- : DeconstructionPatternNode(vm)
+ inline ArrayPatternNode::ArrayPatternNode()
+ : DeconstructionPatternNode()
{
}
- inline PassRefPtr<ArrayPatternNode> ArrayPatternNode::create(VM* vm)
+ inline PassRefPtr<ArrayPatternNode> ArrayPatternNode::create()
{
- return adoptRef(new ArrayPatternNode(vm));
+ return adoptRef(new ArrayPatternNode);
}
- inline ObjectPatternNode::ObjectPatternNode(VM* vm)
- : DeconstructionPatternNode(vm)
+ inline ObjectPatternNode::ObjectPatternNode()
+ : DeconstructionPatternNode()
{
}
- inline PassRefPtr<ObjectPatternNode> ObjectPatternNode::create(VM* vm)
+ inline PassRefPtr<ObjectPatternNode> ObjectPatternNode::create()
{
- return adoptRef(new ObjectPatternNode(vm));
+ return adoptRef(new ObjectPatternNode);
}
- inline PassRefPtr<BindingNode> BindingNode::create(VM* vm, const Identifier& boundProperty, const JSTextPosition& start, const JSTextPosition& end)
+ inline PassRefPtr<BindingNode> BindingNode::create(const Identifier& boundProperty, const JSTextPosition& start, const JSTextPosition& end)
{
- return adoptRef(new BindingNode(vm, boundProperty, start, end));
+ return adoptRef(new BindingNode(boundProperty, start, end));
}
- inline BindingNode::BindingNode(VM* vm, const Identifier& boundProperty, const JSTextPosition& start, const JSTextPosition& end)
- : DeconstructionPatternNode(vm)
+ inline BindingNode::BindingNode(const Identifier& boundProperty, const JSTextPosition& start, const JSTextPosition& end)
+ : DeconstructionPatternNode()
, m_divotStart(start)
, m_divotEnd(end)
, m_boundProperty(boundProperty)
Modified: trunk/Source/_javascript_Core/parser/Nodes.h (176753 => 176754)
--- trunk/Source/_javascript_Core/parser/Nodes.h 2014-12-03 21:53:36 UTC (rev 176753)
+++ trunk/Source/_javascript_Core/parser/Nodes.h 2014-12-03 21:54:53 UTC (rev 176754)
@@ -483,9 +483,8 @@
public:
enum Type { Constant = 1, Getter = 2, Setter = 4 };
- PropertyNode(VM*, const Identifier&, ExpressionNode*, Type);
- PropertyNode(VM*, double, ExpressionNode*, Type);
- PropertyNode(VM*, ExpressionNode* propertyName, ExpressionNode*, Type);
+ PropertyNode(const Identifier&, ExpressionNode*, Type);
+ PropertyNode(ExpressionNode* propertyName, ExpressionNode*, Type);
ExpressionNode* expressionName() const { return m_expression; }
const Identifier* name() const { return m_name; }
@@ -1280,7 +1279,6 @@
class EnumerationNode : public StatementNode, public ThrowableExpressionData {
public:
EnumerationNode(const JSTokenLocation&, ExpressionNode*, ExpressionNode*, StatementNode*);
- EnumerationNode(VM*, const JSTokenLocation&, DeconstructionPatternNode*, ExpressionNode*, StatementNode*);
protected:
ExpressionNode* m_lexpr;
@@ -1291,7 +1289,6 @@
class ForInNode : public EnumerationNode {
public:
ForInNode(const JSTokenLocation&, ExpressionNode*, ExpressionNode*, StatementNode*);
- ForInNode(VM*, const JSTokenLocation&, DeconstructionPatternNode*, ExpressionNode*, StatementNode*);
private:
RegisterID* tryGetBoundLocal(BytecodeGenerator&);
@@ -1304,7 +1301,6 @@
class ForOfNode : public EnumerationNode {
public:
ForOfNode(const JSTokenLocation&, ExpressionNode*, ExpressionNode*, StatementNode*);
- ForOfNode(VM*, const JSTokenLocation&, DeconstructionPatternNode*, ExpressionNode*, StatementNode*);
private:
virtual void emitBytecode(BytecodeGenerator&, RegisterID* = 0) override;
@@ -1312,7 +1308,6 @@
class ContinueNode : public StatementNode, public ThrowableExpressionData {
public:
- ContinueNode(VM*, const JSTokenLocation&);
ContinueNode(const JSTokenLocation&, const Identifier&);
Label* trivialTarget(BytecodeGenerator&);
@@ -1325,7 +1320,6 @@
class BreakNode : public StatementNode, public ThrowableExpressionData {
public:
- BreakNode(VM*, const JSTokenLocation&);
BreakNode(const JSTokenLocation&, const Identifier&);
Label* trivialTarget(BytecodeGenerator&);
@@ -1618,19 +1612,19 @@
virtual ~DeconstructionPatternNode() = 0;
protected:
- DeconstructionPatternNode(VM*);
+ DeconstructionPatternNode();
};
class ArrayPatternNode : public DeconstructionPatternNode {
public:
- static PassRefPtr<ArrayPatternNode> create(VM*);
+ static PassRefPtr<ArrayPatternNode> create();
void appendIndex(const JSTokenLocation&, DeconstructionPatternNode* node)
{
m_targetPatterns.append(node);
}
private:
- ArrayPatternNode(VM*);
+ ArrayPatternNode();
virtual void collectBoundIdentifiers(Vector<Identifier>&) const override;
virtual void bindValue(BytecodeGenerator&, RegisterID*) const override;
virtual RegisterID* emitDirectBinding(BytecodeGenerator&, RegisterID* dst, ExpressionNode*) override;
@@ -1641,14 +1635,14 @@
class ObjectPatternNode : public DeconstructionPatternNode {
public:
- static PassRefPtr<ObjectPatternNode> create(VM*);
+ static PassRefPtr<ObjectPatternNode> create();
void appendEntry(const JSTokenLocation&, const Identifier& identifier, bool wasString, DeconstructionPatternNode* pattern)
{
m_targetPatterns.append(Entry(identifier, wasString, pattern));
}
private:
- ObjectPatternNode(VM*);
+ ObjectPatternNode();
virtual void collectBoundIdentifiers(Vector<Identifier>&) const override;
virtual void bindValue(BytecodeGenerator&, RegisterID*) const override;
virtual void toString(StringBuilder&) const override;
@@ -1668,14 +1662,14 @@
class BindingNode : public DeconstructionPatternNode {
public:
- static PassRefPtr<BindingNode> create(VM*, const Identifier& boundProperty, const JSTextPosition& start, const JSTextPosition& end);
+ static PassRefPtr<BindingNode> create(const Identifier& boundProperty, const JSTextPosition& start, const JSTextPosition& end);
const Identifier& boundProperty() const { return m_boundProperty; }
const JSTextPosition& divotStart() const { return m_divotStart; }
const JSTextPosition& divotEnd() const { return m_divotEnd; }
private:
- BindingNode(VM*, const Identifier& boundProperty, const JSTextPosition& start, const JSTextPosition& end);
+ BindingNode(const Identifier& boundProperty, const JSTextPosition& start, const JSTextPosition& end);
virtual void collectBoundIdentifiers(Vector<Identifier>&) const override;
virtual void bindValue(BytecodeGenerator&, RegisterID*) const override;
Modified: trunk/Source/_javascript_Core/parser/Parser.cpp (176753 => 176754)
--- trunk/Source/_javascript_Core/parser/Parser.cpp 2014-12-03 21:53:36 UTC (rev 176753)
+++ trunk/Source/_javascript_Core/parser/Parser.cpp 2014-12-03 21:54:53 UTC (rev 176754)
@@ -863,7 +863,7 @@
if (autoSemiColon()) {
semanticFailIfFalse(breakIsValid(), "'break' is only valid inside a switch or loop statement");
- return context.createBreakStatement(location, start, end);
+ return context.createBreakStatement(location, &m_vm->propertyNames->nullIdentifier, start, end);
}
matchOrFail(IDENT, "Expected an identifier as the target for a break statement");
const Identifier* ident = m_token.m_data.ident;
@@ -885,7 +885,7 @@
if (autoSemiColon()) {
semanticFailIfFalse(continueIsValid(), "'continue' is only valid inside a loop statement");
- return context.createContinueStatement(location, start, end);
+ return context.createContinueStatement(location, &m_vm->propertyNames->nullIdentifier, start, end);
}
matchOrFail(IDENT, "Expected an identifier as the target for a continue statement");
const Identifier* ident = m_token.m_data.ident;
@@ -1827,7 +1827,7 @@
TreeExpression node = parseAssignmentExpression(context);
failIfFalse(node, "Cannot parse _expression_ for property declaration");
context.setEndOffset(node, m_lexer->currentOffset());
- return context.createProperty(const_cast<VM*>(m_vm), propertyName, node, PropertyNode::Constant, complete);
+ return context.createProperty(propertyName, node, PropertyNode::Constant, complete);
}
default:
failIfFalse(m_token.m_type & KeywordTokenFlag, "Expected a property name");
Modified: trunk/Source/_javascript_Core/parser/SyntaxChecker.h (176753 => 176754)
--- trunk/Source/_javascript_Core/parser/SyntaxChecker.h 2014-12-03 21:53:36 UTC (rev 176753)
+++ trunk/Source/_javascript_Core/parser/SyntaxChecker.h 2014-12-03 21:54:53 UTC (rev 176754)
@@ -180,7 +180,7 @@
return Property(type);
return Property(&vm->parserArena->identifierArena().makeNumericIdentifier(vm, name), type);
}
- Property createProperty(VM*, ExpressionNode*, int, PropertyNode::Type type, bool)
+ Property createProperty(int, int, PropertyNode::Type type, bool)
{
return Property(type);
}