Changeset 172717 in webkit
- Timestamp:
- Aug 18, 2014 12:11:41 PM (10 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r172707 r172717 1 2014-08-18 Saam Barati <sbarati@apple.com> 2 3 The parser should generate AST nodes the var declarations with no initializers 4 https://bugs.webkit.org/show_bug.cgi?id=135545 5 6 Reviewed by Geoffrey Garen. 7 8 Currently, JSC's parser ignores variable declarations 9 that have no assignment initializer value because all 10 variables are implicitly assigned to undefined. But, 11 type profiling needs an AST node to be generated for these 12 empty variable declarations because it needs to be able to 13 profile their text locations and to see that their type 14 is undefined. 15 16 * bytecompiler/NodesCodegen.cpp: 17 (JSC::EmptyVarExpression::emitBytecode): 18 * parser/ASTBuilder.h: 19 (JSC::ASTBuilder::createVarStatement): 20 (JSC::ASTBuilder::createEmptyVarExpression): 21 * parser/NodeConstructors.h: 22 (JSC::EmptyVarExpression::EmptyVarExpression): 23 * parser/Nodes.h: 24 * parser/Parser.cpp: 25 (JSC::Parser<LexerType>::parseVarDeclarationList): 26 * parser/SyntaxChecker.h: 27 (JSC::SyntaxChecker::createEmptyVarExpression): 28 1 29 2014-08-18 Diego Pino Garcia <dpino@igalia.com> 2 30 -
trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
r172614 r172717 1783 1783 } 1784 1784 1785 // ------------------------------ EmptyVarExpression ---------------------------- 1786 1787 RegisterID* EmptyVarExpression::emitBytecode(BytecodeGenerator& generator, RegisterID*) 1788 { 1789 if (!generator.isProfilingTypesWithHighFidelity()) 1790 return nullptr; 1791 1792 if (Local local = generator.local(m_ident)) 1793 generator.emitProfileTypesWithHighFidelity(local.get(), ProfileTypesBytecodeHasGlobalID, nullptr); 1794 else { 1795 RefPtr<RegisterID> scope = generator.emitResolveScope(generator.newTemporary(), m_ident); 1796 RefPtr<RegisterID> value = generator.emitGetFromScope(generator.newTemporary(), scope.get(), m_ident, DoNotThrowIfNotFound); 1797 generator.emitProfileTypesWithHighFidelity(value.get(), ProfileTypesBytecodeGetFromScope, &m_ident); 1798 } 1799 1800 generator.emitHighFidelityTypeProfilingExpressionInfo(position(), JSTextPosition(-1, position().offset + m_ident.length(), -1)); 1801 1802 // It's safe to return null here because this node will always be a child node of VarStatementNode which ignores our return value. 1803 return nullptr; 1804 } 1805 1785 1806 // ------------------------------ IfElseNode --------------------------------------- 1786 1807 -
trunk/Source/JavaScriptCore/parser/ASTBuilder.h
r168107 r172717 417 417 { 418 418 StatementNode* result; 419 if (!expr) 420 result = new (m_vm) EmptyStatementNode(location); 421 else 422 result = new (m_vm) VarStatementNode(location, expr); 419 result = new (m_vm) VarStatementNode(location, expr); 423 420 result->setLoc(start, end, location.startOffset, location.lineStartOffset); 424 421 return result; 422 } 423 424 ExpressionNode* createEmptyVarExpression(const JSTokenLocation& location, const Identifier& identifier) 425 { 426 return new (m_vm) EmptyVarExpression(location, identifier); 425 427 } 426 428 -
trunk/Source/JavaScriptCore/parser/NodeConstructors.h
r163321 r172717 656 656 { 657 657 } 658 659 inline EmptyVarExpression::EmptyVarExpression(const JSTokenLocation& location, const Identifier& ident) 660 : ExpressionNode(location) 661 , m_ident(ident) 662 { 663 } 658 664 659 665 inline IfElseNode::IfElseNode(const JSTokenLocation& location, ExpressionNode* condition, StatementNode* ifBlock, StatementNode* elseBlock) -
trunk/Source/JavaScriptCore/parser/Nodes.h
r172176 r172717 1213 1213 }; 1214 1214 1215 class EmptyVarExpression : public ExpressionNode { 1216 public: 1217 EmptyVarExpression(const JSTokenLocation&, const Identifier&); 1218 1219 private: 1220 virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; 1221 1222 const Identifier& m_ident; 1223 }; 1224 1225 1215 1226 class IfElseNode : public StatementNode { 1216 1227 public: -
trunk/Source/JavaScriptCore/parser/Parser.cpp
r172381 r172717 459 459 if (match(IDENT)) { 460 460 JSTextPosition varStart = tokenStartPosition(); 461 JSTokenLocation varStartLocation(tokenLocation()); 461 462 identStart = varStart; 462 463 const Identifier* name = m_token.m_data.ident; … … 476 477 477 478 node = context.createAssignResolve(location, *name, initializer, varStart, varDivot, lastTokenEndPosition()); 478 } 479 } else 480 node = context.createEmptyVarExpression(varStartLocation, *name); 479 481 } else { 480 482 lastIdent = 0; … … 491 493 } 492 494 493 if (hasInitializer) { 494 if (!varDecls) 495 varDecls = node; 496 else 497 varDecls = context.combineCommaNodes(location, varDecls, node); 498 } 495 if (!varDecls) 496 varDecls = node; 497 else 498 varDecls = context.combineCommaNodes(location, varDecls, node); 499 499 } while (match(COMMA)); 500 500 if (lastIdent) -
trunk/Source/JavaScriptCore/parser/SyntaxChecker.h
r168107 r172717 159 159 ExpressionType createConditionalExpr(const JSTokenLocation&, ExpressionType, ExpressionType, ExpressionType) { return ConditionalExpr; } 160 160 ExpressionType createAssignResolve(const JSTokenLocation&, const Identifier&, ExpressionType, int, int, int) { return AssignmentExpr; } 161 ExpressionType createEmptyVarExpression(const JSTokenLocation&, const Identifier&) { return AssignmentExpr; } 161 162 ExpressionType createFunctionExpr(const JSTokenLocation&, const Identifier*, int, int, int, int, int, int, int) { return FunctionExpr; } 162 163 int createFunctionBody(const JSTokenLocation&, const JSTokenLocation&, int, int, bool) { return FunctionBodyResult; }
Note: See TracChangeset
for help on using the changeset viewer.