Changeset 176754 in webkit
- Timestamp:
- Dec 3, 2014, 1:54:53 PM (12 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 6 edited
-
ChangeLog (modified) (1 diff)
-
parser/ASTBuilder.h (modified) (9 diffs)
-
parser/NodeConstructors.h (modified) (7 diffs)
-
parser/Nodes.h (modified) (12 diffs)
-
parser/Parser.cpp (modified) (3 diffs)
-
parser/SyntaxChecker.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r176716 r176754 1 2014-12-03 Geoffrey Garen <ggaren@apple.com> 2 3 The parser should allocate all pieces of the AST 4 https://bugs.webkit.org/show_bug.cgi?id=139230 5 6 Reviewed by Oliver Hunt. 7 8 This is a step toward a 14% parsing speedup. 9 10 Previously, allocation was split between the parser and certain node 11 constructor functions. This made for some duplicated code and circular 12 dependencies. 13 14 * parser/ASTBuilder.h: 15 (JSC::ASTBuilder::createGetterOrSetterProperty): No need to pass through 16 the VM, since our callee no longer needs to allocate anything. 17 18 (JSC::ASTBuilder::createProperty): Allocate the identifier for our 19 callee, since that is simpler than requiring our callee to notice that 20 we didn't do so, and do it for us. 21 22 (JSC::ASTBuilder::createForInLoop): Allocate the DeconstructingAssignmentNode 23 for our callee, since that is simpler than requiring our callee to notice 24 that we didn't do so, and do it for us. 25 26 Also, reuse some code instead of duplicating it. 27 28 (JSC::ASTBuilder::createForOfLoop): Ditto. 29 30 (JSC::ASTBuilder::createArrayPattern): 31 (JSC::ASTBuilder::createObjectPattern): 32 (JSC::ASTBuilder::createBindingLocation): No need to pass through a VM 33 pointer, since our callee no longer needs to allocate anything. 34 35 (JSC::ASTBuilder::createBreakStatement): Deleted. 36 (JSC::ASTBuilder::createContinueStatement): Deleted. 37 38 * parser/NodeConstructors.h: 39 (JSC::PropertyNode::PropertyNode): 40 (JSC::DeconstructionPatternNode::DeconstructionPatternNode): 41 (JSC::ArrayPatternNode::ArrayPatternNode): 42 (JSC::ArrayPatternNode::create): 43 (JSC::ObjectPatternNode::ObjectPatternNode): 44 (JSC::ObjectPatternNode::create): 45 (JSC::BindingNode::create): 46 (JSC::BindingNode::BindingNode): 47 (JSC::ContinueNode::ContinueNode): Deleted. 48 (JSC::BreakNode::BreakNode): Deleted. 49 (JSC::EnumerationNode::EnumerationNode): Deleted. 50 (JSC::ForInNode::ForInNode): Deleted. 51 (JSC::ForOfNode::ForOfNode): Deleted. Deleted a bunch of special cases 52 that don't exist anymore, now that the parser allocates all pieces of 53 the AST unconditionally. 54 55 * parser/Nodes.h: Ditto. 56 57 * parser/Parser.cpp: 58 (JSC::Parser<LexerType>::parseBreakStatement): 59 (JSC::Parser<LexerType>::parseContinueStatement): Allocate the null 60 identifier for our callee, since that is simpler than requiring our 61 callee to notice that we didn't do so, and do it for us. 62 63 (JSC::Parser<LexerType>::parseProperty): 64 * parser/SyntaxChecker.h: 65 (JSC::SyntaxChecker::createProperty): No need to pass through a VM 66 pointer, since our callee no longer needs to allocate anything. 67 1 68 2014-12-03 Zsolt Borbely <zsborbely.u-szeged@partner.samsung.com> 2 69 -
trunk/Source/JavaScriptCore/parser/ASTBuilder.h
r175396 r176754 300 300 body->setLoc(bodyStartLine, bodyEndLine, location.startOffset, location.lineStartOffset); 301 301 body->setInferredName(*name); 302 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);302 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); 303 303 } 304 304 … … 306 306 { 307 307 body->setLoc(bodyStartLine, bodyEndLine, location.startOffset, location.lineStartOffset); 308 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);308 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); 309 309 } 310 310 … … 318 318 if (node->isFuncExprNode()) 319 319 static_cast<FuncExprNode*>(node)->body()->setInferredName(*propertyName); 320 return new (m_vm) PropertyNode(m_vm, *propertyName, node, type); 321 } 322 PropertyNode* createProperty(VM*, double propertyName, ExpressionNode* node, PropertyNode::Type type, bool) { return new (m_vm) PropertyNode(m_vm, propertyName, node, type); } 323 PropertyNode* createProperty(VM*, ExpressionNode* propertyName, ExpressionNode* node, PropertyNode::Type type, bool) { return new (m_vm) PropertyNode(m_vm, propertyName, node, type); } 320 return new (m_vm) PropertyNode(*propertyName, node, type); 321 } 322 PropertyNode* createProperty(VM*, double propertyName, ExpressionNode* node, PropertyNode::Type type, bool) 323 { 324 return new (m_vm) PropertyNode(m_vm->parserArena->identifierArena().makeNumericIdentifier(m_vm, propertyName), node, type); 325 } 326 PropertyNode* createProperty(ExpressionNode* propertyName, ExpressionNode* node, PropertyNode::Type type, bool) { return new (m_vm) PropertyNode(propertyName, node, type); } 324 327 PropertyListNode* createPropertyList(const JSTokenLocation& location, PropertyNode* property) { return new (m_vm) PropertyListNode(location, property); } 325 328 PropertyListNode* createPropertyList(const JSTokenLocation& location, PropertyNode* property, PropertyListNode* tail) { return new (m_vm) PropertyListNode(location, property, tail); } … … 385 388 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) 386 389 { 387 ForInNode* result = new (m_vm) ForInNode(m_vm, location, pattern.get(), iter, statements); 388 result->setLoc(start, end, location.startOffset, location.lineStartOffset); 389 setExceptionLocation(result, eStart, eDivot, eEnd); 390 return result; 390 auto lexpr = new (m_vm) DeconstructingAssignmentNode(location, pattern.get(), 0); 391 return createForInLoop(location, lexpr, iter, statements, eStart, eDivot, eEnd, start, end); 391 392 } 392 393 … … 401 402 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) 402 403 { 403 ForOfNode* result = new (m_vm) ForOfNode(m_vm, location, pattern.get(), iter, statements); 404 result->setLoc(start, end, location.startOffset, location.lineStartOffset); 405 setExceptionLocation(result, eStart, eDivot, eEnd); 406 return result; 404 auto lexpr = new (m_vm) DeconstructingAssignmentNode(location, pattern.get(), 0); 405 return createForOfLoop(location, lexpr, iter, statements, eStart, eDivot, eEnd, start, end); 407 406 } 408 407 … … 435 434 } 436 435 437 StatementNode* createBreakStatement(const JSTokenLocation& location, const JSTextPosition& start, const JSTextPosition& end)438 {439 BreakNode* result = new (m_vm) BreakNode(m_vm, location);440 setExceptionLocation(result, start, end, end);441 result->setLoc(start.line, end.line, start.offset, start.lineStartOffset);442 return result;443 }444 445 436 StatementNode* createBreakStatement(const JSTokenLocation& location, const Identifier* ident, const JSTextPosition& start, const JSTextPosition& end) 446 437 { 447 438 BreakNode* result = new (m_vm) BreakNode(location, *ident); 448 setExceptionLocation(result, start, end, end);449 result->setLoc(start.line, end.line, start.offset, start.lineStartOffset);450 return result;451 }452 453 StatementNode* createContinueStatement(const JSTokenLocation& location, const JSTextPosition& start, const JSTextPosition& end)454 {455 ContinueNode* result = new (m_vm) ContinueNode(m_vm, location);456 439 setExceptionLocation(result, start, end, end); 457 440 result->setLoc(start.line, end.line, start.offset, start.lineStartOffset); … … 660 643 ArrayPattern createArrayPattern(const JSTokenLocation&) 661 644 { 662 return ArrayPatternNode::create( m_vm);645 return ArrayPatternNode::create(); 663 646 } 664 647 … … 675 658 ObjectPattern createObjectPattern(const JSTokenLocation&) 676 659 { 677 return ObjectPatternNode::create( m_vm);660 return ObjectPatternNode::create(); 678 661 } 679 662 … … 685 668 BindingPattern createBindingLocation(const JSTokenLocation&, const Identifier& boundProperty, const JSTextPosition& start, const JSTextPosition& end) 686 669 { 687 return BindingNode::create( m_vm,boundProperty, start, end);670 return BindingNode::create(boundProperty, start, end); 688 671 } 689 672 -
trunk/Source/JavaScriptCore/parser/NodeConstructors.h
r172717 r176754 148 148 } 149 149 150 inline PropertyNode::PropertyNode( VM*,const Identifier& name, ExpressionNode* assign, Type type)150 inline PropertyNode::PropertyNode(const Identifier& name, ExpressionNode* assign, Type type) 151 151 : m_name(&name) 152 152 , m_assign(assign) … … 155 155 } 156 156 157 inline PropertyNode::PropertyNode(VM* vm, double name, ExpressionNode* assign, Type type) 158 : m_name(&vm->parserArena->identifierArena().makeNumericIdentifier(vm, name)) 159 , m_assign(assign) 160 , m_type(type) 161 { 162 } 163 164 inline PropertyNode::PropertyNode(VM*, ExpressionNode* name, ExpressionNode* assign, Type type) 157 inline PropertyNode::PropertyNode(ExpressionNode* name, ExpressionNode* assign, Type type) 165 158 : m_name(0) 166 159 , m_expression(name) … … 695 688 } 696 689 697 inline ContinueNode::ContinueNode(VM* vm, const JSTokenLocation& location)698 : StatementNode(location)699 , m_ident(vm->propertyNames->nullIdentifier)700 {701 }702 703 690 inline ContinueNode::ContinueNode(const JSTokenLocation& location, const Identifier& ident) 704 691 : StatementNode(location) … … 707 694 } 708 695 709 inline BreakNode::BreakNode(VM* vm, const JSTokenLocation& location)710 : StatementNode(location)711 , m_ident(vm->propertyNames->nullIdentifier)712 {713 }714 715 696 inline BreakNode::BreakNode(const JSTokenLocation& location, const Identifier& ident) 716 697 : StatementNode(location) … … 842 823 } 843 824 844 inline EnumerationNode::EnumerationNode(VM* vm, const JSTokenLocation& location, DeconstructionPatternNode* pattern, ExpressionNode* expr, StatementNode* statement)845 : StatementNode(location)846 , m_lexpr(new (vm) DeconstructingAssignmentNode(location, pattern, 0))847 , m_expr(expr)848 , m_statement(statement)849 {850 ASSERT(pattern);851 }852 853 825 inline ForInNode::ForInNode(const JSTokenLocation& location, ExpressionNode* l, ExpressionNode* expr, StatementNode* statement) 854 826 : EnumerationNode(location, l, expr, statement) … … 856 828 } 857 829 858 inline ForInNode::ForInNode(VM* vm, const JSTokenLocation& location, DeconstructionPatternNode* pattern, ExpressionNode* expr, StatementNode* statement)859 : EnumerationNode(vm, location, pattern, expr, statement)860 {861 }862 863 830 inline ForOfNode::ForOfNode(const JSTokenLocation& location, ExpressionNode* l, ExpressionNode* expr, StatementNode* statement) 864 831 : EnumerationNode(location, l, expr, statement) … … 866 833 } 867 834 868 inline ForOfNode::ForOfNode(VM* vm, const JSTokenLocation& location, DeconstructionPatternNode* pattern, ExpressionNode* expr, StatementNode* statement) 869 : EnumerationNode(vm, location, pattern, expr, statement) 870 { 871 } 872 873 inline DeconstructionPatternNode::DeconstructionPatternNode(VM*) 874 { 875 } 876 877 inline ArrayPatternNode::ArrayPatternNode(VM* vm) 878 : DeconstructionPatternNode(vm) 879 { 880 } 881 882 inline PassRefPtr<ArrayPatternNode> ArrayPatternNode::create(VM* vm) 883 { 884 return adoptRef(new ArrayPatternNode(vm)); 885 } 886 887 inline ObjectPatternNode::ObjectPatternNode(VM* vm) 888 : DeconstructionPatternNode(vm) 889 { 890 } 891 892 inline PassRefPtr<ObjectPatternNode> ObjectPatternNode::create(VM* vm) 893 { 894 return adoptRef(new ObjectPatternNode(vm)); 895 } 896 897 inline PassRefPtr<BindingNode> BindingNode::create(VM* vm, const Identifier& boundProperty, const JSTextPosition& start, const JSTextPosition& end) 898 { 899 return adoptRef(new BindingNode(vm, boundProperty, start, end)); 900 } 901 902 inline BindingNode::BindingNode(VM* vm, const Identifier& boundProperty, const JSTextPosition& start, const JSTextPosition& end) 903 : DeconstructionPatternNode(vm) 835 inline DeconstructionPatternNode::DeconstructionPatternNode() 836 { 837 } 838 839 inline ArrayPatternNode::ArrayPatternNode() 840 : DeconstructionPatternNode() 841 { 842 } 843 844 inline PassRefPtr<ArrayPatternNode> ArrayPatternNode::create() 845 { 846 return adoptRef(new ArrayPatternNode); 847 } 848 849 inline ObjectPatternNode::ObjectPatternNode() 850 : DeconstructionPatternNode() 851 { 852 } 853 854 inline PassRefPtr<ObjectPatternNode> ObjectPatternNode::create() 855 { 856 return adoptRef(new ObjectPatternNode); 857 } 858 859 inline PassRefPtr<BindingNode> BindingNode::create(const Identifier& boundProperty, const JSTextPosition& start, const JSTextPosition& end) 860 { 861 return adoptRef(new BindingNode(boundProperty, start, end)); 862 } 863 864 inline BindingNode::BindingNode(const Identifier& boundProperty, const JSTextPosition& start, const JSTextPosition& end) 865 : DeconstructionPatternNode() 904 866 , m_divotStart(start) 905 867 , m_divotEnd(end) -
trunk/Source/JavaScriptCore/parser/Nodes.h
r175396 r176754 484 484 enum Type { Constant = 1, Getter = 2, Setter = 4 }; 485 485 486 PropertyNode(VM*, const Identifier&, ExpressionNode*, Type); 487 PropertyNode(VM*, double, ExpressionNode*, Type); 488 PropertyNode(VM*, ExpressionNode* propertyName, ExpressionNode*, Type); 486 PropertyNode(const Identifier&, ExpressionNode*, Type); 487 PropertyNode(ExpressionNode* propertyName, ExpressionNode*, Type); 489 488 490 489 ExpressionNode* expressionName() const { return m_expression; } … … 1281 1280 public: 1282 1281 EnumerationNode(const JSTokenLocation&, ExpressionNode*, ExpressionNode*, StatementNode*); 1283 EnumerationNode(VM*, const JSTokenLocation&, DeconstructionPatternNode*, ExpressionNode*, StatementNode*);1284 1282 1285 1283 protected: … … 1292 1290 public: 1293 1291 ForInNode(const JSTokenLocation&, ExpressionNode*, ExpressionNode*, StatementNode*); 1294 ForInNode(VM*, const JSTokenLocation&, DeconstructionPatternNode*, ExpressionNode*, StatementNode*);1295 1292 1296 1293 private: … … 1305 1302 public: 1306 1303 ForOfNode(const JSTokenLocation&, ExpressionNode*, ExpressionNode*, StatementNode*); 1307 ForOfNode(VM*, const JSTokenLocation&, DeconstructionPatternNode*, ExpressionNode*, StatementNode*);1308 1304 1309 1305 private: … … 1313 1309 class ContinueNode : public StatementNode, public ThrowableExpressionData { 1314 1310 public: 1315 ContinueNode(VM*, const JSTokenLocation&);1316 1311 ContinueNode(const JSTokenLocation&, const Identifier&); 1317 1312 Label* trivialTarget(BytecodeGenerator&); … … 1326 1321 class BreakNode : public StatementNode, public ThrowableExpressionData { 1327 1322 public: 1328 BreakNode(VM*, const JSTokenLocation&);1329 1323 BreakNode(const JSTokenLocation&, const Identifier&); 1330 1324 Label* trivialTarget(BytecodeGenerator&); … … 1619 1613 1620 1614 protected: 1621 DeconstructionPatternNode( VM*);1615 DeconstructionPatternNode(); 1622 1616 }; 1623 1617 1624 1618 class ArrayPatternNode : public DeconstructionPatternNode { 1625 1619 public: 1626 static PassRefPtr<ArrayPatternNode> create( VM*);1620 static PassRefPtr<ArrayPatternNode> create(); 1627 1621 void appendIndex(const JSTokenLocation&, DeconstructionPatternNode* node) 1628 1622 { … … 1631 1625 1632 1626 private: 1633 ArrayPatternNode( VM*);1627 ArrayPatternNode(); 1634 1628 virtual void collectBoundIdentifiers(Vector<Identifier>&) const override; 1635 1629 virtual void bindValue(BytecodeGenerator&, RegisterID*) const override; … … 1642 1636 class ObjectPatternNode : public DeconstructionPatternNode { 1643 1637 public: 1644 static PassRefPtr<ObjectPatternNode> create( VM*);1638 static PassRefPtr<ObjectPatternNode> create(); 1645 1639 void appendEntry(const JSTokenLocation&, const Identifier& identifier, bool wasString, DeconstructionPatternNode* pattern) 1646 1640 { … … 1649 1643 1650 1644 private: 1651 ObjectPatternNode( VM*);1645 ObjectPatternNode(); 1652 1646 virtual void collectBoundIdentifiers(Vector<Identifier>&) const override; 1653 1647 virtual void bindValue(BytecodeGenerator&, RegisterID*) const override; … … 1669 1663 class BindingNode : public DeconstructionPatternNode { 1670 1664 public: 1671 static PassRefPtr<BindingNode> create( VM*,const Identifier& boundProperty, const JSTextPosition& start, const JSTextPosition& end);1665 static PassRefPtr<BindingNode> create(const Identifier& boundProperty, const JSTextPosition& start, const JSTextPosition& end); 1672 1666 const Identifier& boundProperty() const { return m_boundProperty; } 1673 1667 … … 1676 1670 1677 1671 private: 1678 BindingNode( VM*,const Identifier& boundProperty, const JSTextPosition& start, const JSTextPosition& end);1672 BindingNode(const Identifier& boundProperty, const JSTextPosition& start, const JSTextPosition& end); 1679 1673 1680 1674 virtual void collectBoundIdentifiers(Vector<Identifier>&) const override; -
trunk/Source/JavaScriptCore/parser/Parser.cpp
r175396 r176754 864 864 if (autoSemiColon()) { 865 865 semanticFailIfFalse(breakIsValid(), "'break' is only valid inside a switch or loop statement"); 866 return context.createBreakStatement(location, start, end);866 return context.createBreakStatement(location, &m_vm->propertyNames->nullIdentifier, start, end); 867 867 } 868 868 matchOrFail(IDENT, "Expected an identifier as the target for a break statement"); … … 886 886 if (autoSemiColon()) { 887 887 semanticFailIfFalse(continueIsValid(), "'continue' is only valid inside a loop statement"); 888 return context.createContinueStatement(location, start, end);888 return context.createContinueStatement(location, &m_vm->propertyNames->nullIdentifier, start, end); 889 889 } 890 890 matchOrFail(IDENT, "Expected an identifier as the target for a continue statement"); … … 1828 1828 failIfFalse(node, "Cannot parse expression for property declaration"); 1829 1829 context.setEndOffset(node, m_lexer->currentOffset()); 1830 return context.createProperty( const_cast<VM*>(m_vm),propertyName, node, PropertyNode::Constant, complete);1830 return context.createProperty(propertyName, node, PropertyNode::Constant, complete); 1831 1831 } 1832 1832 default: -
trunk/Source/JavaScriptCore/parser/SyntaxChecker.h
r175396 r176754 181 181 return Property(&vm->parserArena->identifierArena().makeNumericIdentifier(vm, name), type); 182 182 } 183 Property createProperty( VM*, ExpressionNode*, int, PropertyNode::Type type, bool)183 Property createProperty(int, int, PropertyNode::Type type, bool) 184 184 { 185 185 return Property(type);
Note:
See TracChangeset
for help on using the changeset viewer.