Changeset 156910 in webkit
- Timestamp:
- Oct 4, 2013 1:35:24 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 11 added
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r156905 r156910 1 2013-10-04 Oliver Hunt <oliver@apple.com> 2 3 Support for-of syntax 4 https://bugs.webkit.org/show_bug.cgi?id=122339 5 6 Reviewed by Geoffrey Garen. 7 8 Add test cases for the one type that supports for-of so far 9 10 * js/basic-for-of-expected.txt: Added. 11 * js/basic-for-of.html: Added. 12 * js/regress/for-of-iterate-array-entries.html: Added. 13 * js/regress/for-of-iterate-array-keys.html: Added. 14 * js/regress/for-of-iterate-array-values.html: Added. 15 * js/regress/script-tests/for-of-iterate-array-entries.js: Added. 16 (foo): 17 * js/regress/script-tests/for-of-iterate-array-keys.js: Added. 18 (foo): 19 * js/regress/script-tests/for-of-iterate-array-values.js: Added. 20 (foo): 21 1 22 2013-10-04 Bear Travis <betravis@adobe.com> 2 23 -
trunk/LayoutTests/js/parser-syntax-check-expected.txt
r155724 r156910 580 580 PASS Invalid: "var a.b;" 581 581 PASS Invalid: "function f() { var a.b; }" 582 PASS Valid: "for (of of of){}" 583 PASS Valid: "function f() { for (of of of){} }" 584 PASS Valid: "for (of; of; of){}" 585 PASS Valid: "function f() { for (of; of; of){} }" 586 PASS Valid: "for (var of of of){}" 587 PASS Valid: "function f() { for (var of of of){} }" 588 PASS Valid: "for (var of; of; of){}" 589 PASS Valid: "function f() { for (var of; of; of){} }" 590 PASS Invalid: "for (var of.of of of){}" 591 PASS Invalid: "function f() { for (var of.of of of){} }" 592 PASS Invalid: "for (var of[of] of of){}" 593 PASS Invalid: "function f() { for (var of[of] of of){} }" 594 PASS Valid: "for (of.of of of){}" 595 PASS Valid: "function f() { for (of.of of of){} }" 596 PASS Valid: "for (of[of] of of){}" 597 PASS Valid: "function f() { for (of[of] of of){} }" 598 PASS Valid: "for (var [of] of of){}" 599 PASS Valid: "function f() { for (var [of] of of){} }" 600 PASS Valid: "for (var {of} of of){}" 601 PASS Valid: "function f() { for (var {of} of of){} }" 602 PASS Valid: "for (of in of){}" 603 PASS Valid: "function f() { for (of in of){} }" 604 PASS Valid: "for (var of in of){}" 605 PASS Valid: "function f() { for (var of in of){} }" 606 PASS Invalid: "for (var of.of in of){}" 607 PASS Invalid: "function f() { for (var of.of in of){} }" 608 PASS Valid: "for (of.of in of){}" 609 PASS Valid: "function f() { for (of.of in of){} }" 610 PASS Valid: "for (of[of] in of){}" 611 PASS Valid: "function f() { for (of[of] in of){} }" 612 PASS Invalid: "for (var of[of] in of){}" 613 PASS Invalid: "function f() { for (var of[of] in of){} }" 614 PASS Valid: "for (var [of] in of){}" 615 PASS Valid: "function f() { for (var [of] in of){} }" 616 PASS Valid: "for (var {of} in of){}" 617 PASS Valid: "function f() { for (var {of} in of){} }" 618 PASS Invalid: "for (of of of of){}" 619 PASS Invalid: "function f() { for (of of of of){} }" 620 PASS Invalid: "for (of of; of; of){}" 621 PASS Invalid: "function f() { for (of of; of; of){} }" 622 PASS Invalid: "for (of of []; of; of){}" 623 PASS Invalid: "function f() { for (of of []; of; of){} }" 624 PASS Invalid: "for (of of){}" 625 PASS Invalid: "function f() { for (of of){} }" 626 PASS Invalid: "for (var of of){}" 627 PASS Invalid: "function f() { for (var of of){} }" 628 PASS Invalid: "for (of of in of){}" 629 PASS Invalid: "function f() { for (of of in of){} }" 630 PASS Invalid: "for (of in){}" 631 PASS Invalid: "function f() { for (of in){} }" 632 PASS Invalid: "for (var of in){}" 633 PASS Invalid: "function f() { for (var of in){} }" 582 634 PASS e.line is 1 583 635 PASS foo is 'PASS' -
trunk/LayoutTests/js/script-tests/parser-syntax-check.js
r155724 r156910 370 370 invalid("var a.b;"); 371 371 372 valid("for (of of of){}") 373 valid("for (of; of; of){}") 374 valid("for (var of of of){}") 375 valid("for (var of; of; of){}") 376 invalid("for (var of.of of of){}") 377 invalid("for (var of[of] of of){}") 378 valid("for (of.of of of){}") 379 valid("for (of[of] of of){}") 380 valid("for (var [of] of of){}") 381 valid("for (var {of} of of){}") 382 valid("for (of in of){}") 383 valid("for (var of in of){}") 384 invalid("for (var of.of in of){}") 385 valid("for (of.of in of){}") 386 valid("for (of[of] in of){}") 387 invalid("for (var of[of] in of){}") 388 valid("for (var [of] in of){}") 389 valid("for (var {of} in of){}") 390 391 392 invalid("for (of of of of){}") 393 invalid("for (of of; of; of){}") 394 invalid("for (of of []; of; of){}") 395 invalid("for (of of){}") 396 invalid("for (var of of){}") 397 invalid("for (of of in of){}") 398 invalid("for (of in){}") 399 invalid("for (var of in){}") 400 401 402 372 403 try { eval("a.b.c = {};"); } catch(e1) { e=e1; shouldBe("e.line", "1") } 373 404 foo = 'FAIL'; -
trunk/Source/JavaScriptCore/ChangeLog
r156906 r156910 1 2013-10-04 Oliver Hunt <oliver@apple.com> 2 3 Support for-of syntax 4 https://bugs.webkit.org/show_bug.cgi?id=122339 5 6 Reviewed by Geoffrey Garen. 7 8 Add support for for-of syntax to JSC. As part of doing this I had to make 9 us support unique empty strings as identifiers. In a follow on patch i'm 10 going to remove the distinction entirely as it's purely a complicating 11 separation. 12 13 Otherwise the logic here is fairly self-explanatory. 14 15 * bytecompiler/BytecodeGenerator.cpp: 16 (JSC::BytecodeGenerator::addConstant): 17 (JSC::BytecodeGenerator::emitCall): 18 * bytecompiler/BytecodeGenerator.h: 19 * bytecompiler/NodesCodegen.cpp: 20 (JSC::CallArguments::CallArguments): 21 (JSC::ForOfNode::emitBytecode): 22 * jit/JITOperations.cpp: 23 * parser/ASTBuilder.h: 24 (JSC::ASTBuilder::createForOfLoop): 25 * parser/NodeConstructors.h: 26 (JSC::EnumerationNode::EnumerationNode): 27 (JSC::ForInNode::ForInNode): 28 (JSC::ForOfNode::ForOfNode): 29 * parser/Nodes.h: 30 * parser/Parser.cpp: 31 (JSC::::parseVarDeclarationList): 32 (JSC::::parseForStatement): 33 * parser/Parser.h: 34 (JSC::Parser::isofToken): 35 * parser/SyntaxChecker.h: 36 (JSC::SyntaxChecker::createForOfLoop): 37 * runtime/ArrayIteratorPrototype.cpp: 38 (JSC::ArrayIteratorPrototype::finishCreation): 39 (JSC::arrayIteratorPrototypeIterate): 40 * runtime/ArrayPrototype.cpp: 41 (JSC::ArrayPrototype::create): 42 (JSC::ArrayPrototype::finishCreation): 43 * runtime/ArrayPrototype.h: 44 * runtime/CommonIdentifiers.cpp: 45 (JSC::CommonIdentifiers::CommonIdentifiers): 46 * runtime/CommonIdentifiers.h: 47 * runtime/Identifier.h: 48 (JSC::Identifier::from): 49 * runtime/JSCJSValue.cpp: 50 (JSC::JSValue::dumpInContext): 51 * runtime/JSGlobalObject.cpp: 52 (JSC::JSGlobalObject::reset): 53 * runtime/JSObject.cpp: 54 (JSC::JSObject::putDirectNativeFunction): 55 * runtime/PrivateName.h: 56 (JSC::PrivateName::PrivateName): 57 * runtime/PropertyName.h: 58 (JSC::PropertyName::PropertyName): 59 1 60 2013-10-04 Michael Saboff <msaboff@apple.com> 2 61 -
trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
r156787 r156910 958 958 IdentifierMap::AddResult result = m_identifierMap.add(rep, m_codeBlock->numberOfIdentifiers()); 959 959 if (result.isNewEntry) 960 m_codeBlock->addIdentifier( Identifier(m_vm, rep));960 m_codeBlock->addIdentifier(ident); 961 961 962 962 return result.iterator->value; … … 1694 1694 // Generate code for arguments. 1695 1695 unsigned argument = 0; 1696 for (ArgumentListNode* n = callArguments.argumentsNode()->m_listNode; n; n = n->m_next) 1697 emitNode(callArguments.argumentRegister(argument++), n); 1698 1696 if (callArguments.argumentsNode()) { 1697 for (ArgumentListNode* n = callArguments.argumentsNode()->m_listNode; n; n = n->m_next) 1698 emitNode(callArguments.argumentRegister(argument++), n); 1699 } 1700 1699 1701 // Reserve space for call frame. 1700 1702 Vector<RefPtr<RegisterID>, JSStack::CallFrameHeaderSize, UnsafeVectorOverflow> callFrame; -
trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h
r156785 r156910 63 63 class CallArguments { 64 64 public: 65 CallArguments(BytecodeGenerator& generator, ArgumentsNode* argumentsNode);65 CallArguments(BytecodeGenerator&, ArgumentsNode*, unsigned additionalArguments = 0); 66 66 67 67 RegisterID* thisRegister() { return m_argv[0].get(); } -
trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
r156785 r156910 380 380 } 381 381 382 inline CallArguments::CallArguments(BytecodeGenerator& generator, ArgumentsNode* argumentsNode )382 inline CallArguments::CallArguments(BytecodeGenerator& generator, ArgumentsNode* argumentsNode, unsigned additionalArguments) 383 383 : m_argumentsNode(argumentsNode) 384 384 { … … 386 386 m_profileHookRegister = generator.newTemporary(); 387 387 388 size_t argumentCountIncludingThis = 1 ; // 'this' register.388 size_t argumentCountIncludingThis = 1 + additionalArguments; // 'this' register. 389 389 if (argumentsNode) { 390 390 for (ArgumentListNode* node = argumentsNode->m_listNode; node; node = node->m_next) … … 1760 1760 } 1761 1761 1762 // ------------------------------ ForOfNode ------------------------------------ 1763 1764 void ForOfNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) 1765 { 1766 LabelScopePtr scope = generator.newLabelScope(LabelScope::Loop); 1767 1768 if (!m_lexpr->isLocation()) { 1769 emitThrowReferenceError(generator, "Left side of for-of statement is not a reference."); 1770 return; 1771 } 1772 1773 generator.emitDebugHook(WillExecuteStatement, firstLine(), startOffset(), lineStartOffset()); 1774 RefPtr<RegisterID> subject = generator.emitNode(m_expr); 1775 RefPtr<RegisterID> iterator = generator.emitGetById(generator.newTemporary(), subject.get(), generator.propertyNames().iteratorPrivateName); 1776 { 1777 CallArguments args(generator, 0); 1778 generator.emitMove(args.thisRegister(), subject.get()); 1779 generator.emitCall(iterator.get(), iterator.get(), NoExpectedFunction, args, divot(), divotStart(), divotEnd()); 1780 } 1781 RefPtr<RegisterID> iteratorNext = generator.emitGetById(generator.newTemporary(), iterator.get(), generator.propertyNames().next); 1782 RefPtr<RegisterID> value = generator.newTemporary(); 1783 generator.emitLoad(value.get(), jsUndefined()); 1784 1785 generator.emitJump(scope->continueTarget()); 1786 1787 RefPtr<Label> loopStart = generator.newLabel(); 1788 generator.emitLabel(loopStart.get()); 1789 generator.emitLoopHint(); 1790 1791 if (m_lexpr->isResolveNode()) { 1792 const Identifier& ident = static_cast<ResolveNode*>(m_lexpr)->identifier(); 1793 if (Local local = generator.local(ident)) 1794 generator.emitMove(local.get(), value.get()); 1795 else { 1796 if (generator.isStrictMode()) 1797 generator.emitExpressionInfo(divot(), divotStart(), divotEnd()); 1798 RegisterID* scope = generator.emitResolveScope(generator.newTemporary(), ident); 1799 generator.emitExpressionInfo(divot(), divotStart(), divotEnd()); 1800 generator.emitPutToScope(scope, ident, value.get(), generator.isStrictMode() ? ThrowIfNotFound : DoNotThrowIfNotFound); 1801 } 1802 } else if (m_lexpr->isDotAccessorNode()) { 1803 DotAccessorNode* assignNode = static_cast<DotAccessorNode*>(m_lexpr); 1804 const Identifier& ident = assignNode->identifier(); 1805 RefPtr<RegisterID> base = generator.emitNode(assignNode->base()); 1806 1807 generator.emitExpressionInfo(assignNode->divot(), assignNode->divotStart(), assignNode->divotEnd()); 1808 generator.emitPutById(base.get(), ident, value.get()); 1809 } else if (m_lexpr->isBracketAccessorNode()) { 1810 BracketAccessorNode* assignNode = static_cast<BracketAccessorNode*>(m_lexpr); 1811 RefPtr<RegisterID> base = generator.emitNode(assignNode->base()); 1812 RegisterID* subscript = generator.emitNode(assignNode->subscript()); 1813 1814 generator.emitExpressionInfo(assignNode->divot(), assignNode->divotStart(), assignNode->divotEnd()); 1815 generator.emitPutByVal(base.get(), subscript, value.get()); 1816 } else { 1817 ASSERT(m_lexpr->isDeconstructionNode()); 1818 DeconstructingAssignmentNode* assignNode = static_cast<DeconstructingAssignmentNode*>(m_lexpr); 1819 assignNode->bindings()->emitBytecode(generator, value.get()); 1820 } 1821 1822 generator.emitNode(dst, m_statement); 1823 1824 generator.emitLabel(scope->continueTarget()); 1825 RefPtr<RegisterID> result = generator.newTemporary(); 1826 CallArguments nextArguments(generator, 0, 1); 1827 generator.emitMove(nextArguments.thisRegister(), iterator.get()); 1828 generator.emitMove(nextArguments.argumentRegister(0), value.get()); 1829 generator.emitCall(result.get(), iteratorNext.get(), NoExpectedFunction, nextArguments, divot(), divotStart(), divotEnd()); 1830 generator.emitGetById(value.get(), result.get(), generator.propertyNames().value); 1831 RefPtr<RegisterID> done = generator.emitGetById(generator.newTemporary(), result.get(), generator.propertyNames().done); 1832 generator.emitJumpIfFalse(done.get(), loopStart.get()); 1833 generator.emitDebugHook(WillExecuteStatement, firstLine(), startOffset(), lineStartOffset()); 1834 generator.emitLabel(scope->breakTarget()); 1835 } 1836 1762 1837 // ------------------------------ ContinueNode --------------------------------- 1763 1838 -
trunk/Source/JavaScriptCore/jit/JITOperations.cpp
r156896 r156910 75 75 VM* vm = &exec->vm(); 76 76 NativeCallFrameTracer tracer(vm, exec); 77 78 Identifier ident(vm, uid); 77 Identifier ident = uid->isEmptyUnique() ? Identifier::from(PrivateName(uid)) : Identifier(vm, uid); 79 78 StructureStubInfo& stubInfo = exec->codeBlock()->getStubInfo(returnAddress); 80 79 AccessType accessType = static_cast<AccessType>(stubInfo.accessType); -
trunk/Source/JavaScriptCore/parser/ASTBuilder.h
r156785 r156910 381 381 return result; 382 382 } 383 384 StatementNode* createForOfLoop(const JSTokenLocation& location, ExpressionNode* lhs, ExpressionNode* iter, StatementNode* statements, const JSTextPosition& eStart, const JSTextPosition& eDivot, const JSTextPosition& eEnd, int start, int end) 385 { 386 ForOfNode* result = new (m_vm) ForOfNode(location, lhs, iter, statements); 387 result->setLoc(start, end, location.startOffset, location.lineStartOffset); 388 setExceptionLocation(result, eStart, eDivot, eEnd); 389 return result; 390 } 391 392 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) 393 { 394 ForOfNode* result = new (m_vm) ForOfNode(m_vm, location, pattern.get(), iter, statements); 395 result->setLoc(start, end, location.startOffset, location.lineStartOffset); 396 setExceptionLocation(result, eStart, eDivot, eEnd); 397 return result; 398 } 383 399 384 400 StatementNode* createEmptyStatement(const JSTokenLocation& location) { return new (m_vm) EmptyStatementNode(location); } -
trunk/Source/JavaScriptCore/parser/NodeConstructors.h
r156785 r156910 812 812 } 813 813 814 inline EnumerationNode::EnumerationNode(const JSTokenLocation& location, ExpressionNode* l, ExpressionNode* expr, StatementNode* statement) 815 : StatementNode(location) 816 , m_lexpr(l) 817 , m_expr(expr) 818 , m_statement(statement) 819 { 820 ASSERT(l); 821 } 822 823 inline EnumerationNode::EnumerationNode(VM* vm, const JSTokenLocation& location, DeconstructionPatternNode* pattern, ExpressionNode* expr, StatementNode* statement) 824 : StatementNode(location) 825 , m_lexpr(new (vm) DeconstructingAssignmentNode(location, pattern, 0)) 826 , m_expr(expr) 827 , m_statement(statement) 828 { 829 ASSERT(pattern); 830 } 831 814 832 inline ForInNode::ForInNode(const JSTokenLocation& location, ExpressionNode* l, ExpressionNode* expr, StatementNode* statement) 815 : StatementNode(location) 816 , m_lexpr(l) 817 , m_expr(expr) 818 , m_statement(statement) 819 { 820 ASSERT(l); 833 : EnumerationNode(location, l, expr, statement) 834 { 821 835 } 822 836 823 837 inline ForInNode::ForInNode(VM* vm, const JSTokenLocation& location, DeconstructionPatternNode* pattern, ExpressionNode* expr, StatementNode* statement) 824 : StatementNode(location) 825 , m_lexpr(new (vm) DeconstructingAssignmentNode(location, pattern, 0)) 826 , m_expr(expr) 827 , m_statement(statement) 828 { 829 ASSERT(pattern); 838 : EnumerationNode(vm, location, pattern, expr, statement) 839 { 840 } 841 842 inline ForOfNode::ForOfNode(const JSTokenLocation& location, ExpressionNode* l, ExpressionNode* expr, StatementNode* statement) 843 : EnumerationNode(location, l, expr, statement) 844 { 845 } 846 847 inline ForOfNode::ForOfNode(VM* vm, const JSTokenLocation& location, DeconstructionPatternNode* pattern, ExpressionNode* expr, StatementNode* statement) 848 : EnumerationNode(vm, location, pattern, expr, statement) 849 { 830 850 } 831 851 -
trunk/Source/JavaScriptCore/parser/Nodes.h
r156785 r156910 1243 1243 1244 1244 class DeconstructionPatternNode; 1245 1246 class ForInNode : public StatementNode, public ThrowableExpressionData { 1247 public: 1248 ForInNode(const JSTokenLocation&, ExpressionNode*, ExpressionNode*, StatementNode*); 1249 ForInNode(VM*, const JSTokenLocation&, DeconstructionPatternNode*, ExpressionNode*, StatementNode*); 1250 1251 private: 1252 virtual void emitBytecode(BytecodeGenerator&, RegisterID* = 0); 1253 1245 1246 class EnumerationNode : public StatementNode, public ThrowableExpressionData { 1247 public: 1248 EnumerationNode(const JSTokenLocation&, ExpressionNode*, ExpressionNode*, StatementNode*); 1249 EnumerationNode(VM*, const JSTokenLocation&, DeconstructionPatternNode*, ExpressionNode*, StatementNode*); 1250 1251 protected: 1254 1252 ExpressionNode* m_lexpr; 1255 1253 ExpressionNode* m_expr; 1256 1254 StatementNode* m_statement; 1255 }; 1256 1257 class ForInNode : public EnumerationNode { 1258 public: 1259 ForInNode(const JSTokenLocation&, ExpressionNode*, ExpressionNode*, StatementNode*); 1260 ForInNode(VM*, const JSTokenLocation&, DeconstructionPatternNode*, ExpressionNode*, StatementNode*); 1261 1262 private: 1263 virtual void emitBytecode(BytecodeGenerator&, RegisterID* = 0); 1264 }; 1265 1266 class ForOfNode : public EnumerationNode { 1267 public: 1268 ForOfNode(const JSTokenLocation&, ExpressionNode*, ExpressionNode*, StatementNode*); 1269 ForOfNode(VM*, const JSTokenLocation&, DeconstructionPatternNode*, ExpressionNode*, StatementNode*); 1270 1271 private: 1272 virtual void emitBytecode(BytecodeGenerator&, RegisterID* = 0); 1257 1273 }; 1258 1274 -
trunk/Source/JavaScriptCore/parser/Parser.cpp
r156785 r156910 295 295 hasInitializer = match(EQUAL); 296 296 failIfFalseIfStrictWithNameAndMessage(declareVariable(name), "Cannot declare a variable named", name->impl(), "in strict mode."); 297 context.addVar(name, (hasInitializer || (!m_allowsIn && match(INTOKEN))) ? DeclarationStacks::HasInitializer : 0);297 context.addVar(name, (hasInitializer || (!m_allowsIn && (match(INTOKEN) || isofToken()))) ? DeclarationStacks::HasInitializer : 0); 298 298 if (hasInitializer) { 299 299 JSTextPosition varDivot = tokenStartPosition() + 1; … … 318 318 node = context.createDeconstructingAssignment(location, pattern, rhs); 319 319 } 320 ASSERT(node);321 320 } 322 321 … … 502 501 // Handle for-in with var declaration 503 502 JSTextPosition inLocation = tokenStartPosition(); 504 consumeOrFail(INTOKEN); 503 bool isOfEnumeration = false; 504 if (!consume(INTOKEN)) { 505 failIfFalseWithMessage(match(IDENT) && *m_token.m_data.ident == m_vm->propertyNames->of, "Expected either 'in' or 'of' in enumeration syntax"); 506 isOfEnumeration = true; 507 next(); 508 } 505 509 506 510 TreeExpression expr = parseExpression(context); … … 516 520 endLoop(); 517 521 failIfFalse(statement); 522 if (isOfEnumeration) 523 return context.createForOfLoop(location, forInTarget, expr, statement, declsStart, inLocation, exprEnd, startLine, endLine); 518 524 return context.createForInLoop(location, forInTarget, expr, statement, declsStart, inLocation, exprEnd, startLine, endLine); 519 525 } … … 557 563 // For-in loop 558 564 failIfFalse(nonLHSCount == m_nonLHSCount); 559 consumeOrFail(INTOKEN); 565 bool isOfEnumeration = false; 566 if (!consume(INTOKEN)) { 567 failIfFalseWithMessage(match(IDENT) && *m_token.m_data.ident == m_vm->propertyNames->of, "Expected either 'in' or 'of' in enumeration syntax"); 568 isOfEnumeration = true; 569 next(); 570 } 560 571 TreeExpression expr = parseExpression(context); 561 572 failIfFalse(expr); … … 568 579 endLoop(); 569 580 failIfFalse(statement); 570 581 if (isOfEnumeration) 582 return context.createForOfLoop(location, decls, expr, statement, declsStart, declsEnd, exprEnd, startLine, endLine); 571 583 return context.createForInLoop(location, decls, expr, statement, declsStart, declsEnd, exprEnd, startLine, endLine); 572 584 } -
trunk/Source/JavaScriptCore/parser/Parser.h
r156785 r156910 554 554 { 555 555 return m_token.m_type == expected; 556 } 557 558 ALWAYS_INLINE bool isofToken() 559 { 560 return m_token.m_type == IDENT && *m_token.m_data.ident == m_vm->propertyNames->of; 556 561 } 557 562 -
trunk/Source/JavaScriptCore/parser/SyntaxChecker.h
r156785 r156910 190 190 int createForLoop(const JSTokenLocation&, int, int, int, int, int, int) { return 1; } 191 191 int createForInLoop(const JSTokenLocation&, int, int, int, int, int, int, int, int) { return 1; } 192 int createForOfLoop(const JSTokenLocation&, int, int, int, int, int, int, int, int) { return 1; } 192 193 int createEmptyStatement(const JSTokenLocation&) { return 1; } 193 194 int createVarStatement(const JSTokenLocation&, int, int, int) { return 1; } -
trunk/Source/JavaScriptCore/runtime/ArrayIteratorPrototype.cpp
r156791 r156910 38 38 39 39 static EncodedJSValue JSC_HOST_CALL arrayIteratorPrototypeNext(ExecState*); 40 static EncodedJSValue JSC_HOST_CALL arrayIteratorPrototypeIterate(ExecState*); 40 41 41 42 void ArrayIteratorPrototype::finishCreation(VM& vm, JSGlobalObject* globalObject) … … 46 47 47 48 JSC_NATIVE_FUNCTION(vm.propertyNames->next, arrayIteratorPrototypeNext, DontEnum, 0); 49 JSC_NATIVE_FUNCTION(vm.propertyNames->iteratorPrivateName, arrayIteratorPrototypeIterate, DontEnum, 0); 48 50 } 49 51 … … 77 79 return JSValue::encode(resultObject); 78 80 } 79 81 80 82 EncodedJSValue JSC_HOST_CALL arrayIteratorPrototypeNext(CallFrame* callFrame) 81 83 { … … 130 132 } 131 133 134 EncodedJSValue JSC_HOST_CALL arrayIteratorPrototypeIterate(CallFrame* callFrame) 135 { 136 return JSValue::encode(callFrame->thisValue()); 132 137 } 138 139 } -
trunk/Source/JavaScriptCore/runtime/ArrayPrototype.cpp
r156791 r156910 123 123 */ 124 124 125 ArrayPrototype* ArrayPrototype::create(VM& vm, Structure* structure)125 ArrayPrototype* ArrayPrototype::create(VM& vm, JSGlobalObject* globalObject, Structure* structure) 126 126 { 127 127 ArrayPrototype* prototype = new (NotNull, allocateCell<ArrayPrototype>(vm.heap)) ArrayPrototype(vm, structure); 128 prototype->finishCreation(vm );128 prototype->finishCreation(vm, globalObject); 129 129 return prototype; 130 130 } … … 136 136 } 137 137 138 void ArrayPrototype::finishCreation(VM& vm )138 void ArrayPrototype::finishCreation(VM& vm, JSGlobalObject* globalObject) 139 139 { 140 140 Base::finishCreation(vm); 141 141 ASSERT(inherits(info())); 142 142 vm.prototypeMap.addPrototype(this); 143 JSC_NATIVE_FUNCTION(vm.propertyNames->iteratorPrivateName, arrayProtoFuncValues, DontEnum, 0); 143 144 } 144 145 -
trunk/Source/JavaScriptCore/runtime/ArrayPrototype.h
r156621 r156910 34 34 typedef JSArray Base; 35 35 36 static ArrayPrototype* create(VM&, Structure*);36 static ArrayPrototype* create(VM&, JSGlobalObject*, Structure*); 37 37 38 38 static bool getOwnPropertySlot(JSObject*, ExecState*, PropertyName, PropertySlot&); … … 46 46 47 47 protected: 48 void finishCreation(VM& );48 void finishCreation(VM&, JSGlobalObject*); 49 49 }; 50 50 -
trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.cpp
r148696 r156910 22 22 #include "CommonIdentifiers.h" 23 23 24 #include "PrivateName.h" 25 24 26 namespace JSC { 25 27 … … 33 35 , thisIdentifier(vm, "this") 34 36 , useStrictIdentifier(vm, "use strict") 37 , iteratorPrivateName(Identifier::from(PrivateName())) 38 , hasNextIdentifier(vm, "hasNext") 35 39 JSC_COMMON_IDENTIFIERS_EACH_KEYWORD(INITIALIZE_KEYWORD) 36 40 JSC_COMMON_IDENTIFIERS_EACH_PROPERTY_NAME(INITIALIZE_PROPERTY_NAME) -
trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h
r156791 r156910 114 114 macro(numInlinedGetByIds) \ 115 115 macro(numInlinedPutByIds) \ 116 macro(of) \ 116 117 macro(opcode) \ 117 118 macro(origin) \ … … 212 213 const Identifier thisIdentifier; 213 214 const Identifier useStrictIdentifier; 214 const PrivateName iteratorPrivateName; 215 const Identifier iteratorPrivateName; 216 const Identifier hasNextIdentifier; 215 217 216 218 -
trunk/Source/JavaScriptCore/runtime/Identifier.h
r156791 r156910 62 62 CString utf8() const { return m_string.utf8(); } 63 63 64 static Identifier createEmptyUnique(VM* vm) 65 { 66 return Identifier(vm, String(StringImpl::createEmptyUnique())); 64 static Identifier from(const PrivateName& name) 65 { 66 Identifier result; 67 result.m_string = name.uid(); 68 return result; 67 69 } 68 70 -
trunk/Source/JavaScriptCore/runtime/JSArrayIterator.cpp
r156791 r156910 40 40 m_iteratedObject.set(vm, this, iteratedObject); 41 41 } 42 43 44 void JSArrayIterator::visitChildren(JSCell* cell, SlotVisitor& visitor) 45 { 46 JSArrayIterator* thisObject = jsCast<JSArrayIterator*>(cell); 47 ASSERT_GC_OBJECT_INHERITS(thisObject, info()); 48 COMPILE_ASSERT(StructureFlags & OverridesVisitChildren, OverridesVisitChildrenWithoutSettingFlag); 49 ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren()); 50 51 Base::visitChildren(thisObject, visitor); 52 visitor.append(&thisObject->m_iteratedObject); 42 53 43 54 } 55 56 } -
trunk/Source/JavaScriptCore/runtime/JSArrayIterator.h
r156791 r156910 70 70 private: 71 71 72 static const unsigned StructureFlags = Base::StructureFlags ;72 static const unsigned StructureFlags = Base::StructureFlags | OverridesVisitChildren; 73 73 74 74 JSArrayIterator(VM& vm, Structure* structure) … … 79 79 80 80 void finishCreation(VM&, JSGlobalObject*, ArrayIterationKind, JSObject* iteratedObject); 81 static void visitChildren(JSCell*, SlotVisitor&); 81 82 82 83 ArrayIterationKind m_iterationKind; -
trunk/Source/JavaScriptCore/runtime/JSCJSValue.cpp
r156597 r156910 217 217 if (impl->isIdentifier()) 218 218 out.print(" (identifier)"); 219 if (impl->isEmptyUnique()) 220 out.print(" (unique)"); 219 221 } else 220 222 out.print(" (unresolved)"); -
trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp
r156791 r156910 287 287 #endif 288 288 289 m_arrayPrototype.set(vm, this, ArrayPrototype::create(vm, ArrayPrototype::createStructure(vm, this, m_objectPrototype.get())));289 m_arrayPrototype.set(vm, this, ArrayPrototype::create(vm, this, ArrayPrototype::createStructure(vm, this, m_objectPrototype.get()))); 290 290 291 291 m_originalArrayStructureForIndexingShape[UndecidedShape >> IndexingShapeShift].set(vm, this, JSArray::createStructure(vm, this, m_arrayPrototype.get(), ArrayWithUndecided)); -
trunk/Source/JavaScriptCore/runtime/JSObject.cpp
r156679 r156910 2205 2205 { 2206 2206 StringImpl* name = propertyName.publicName(); 2207 if (!name) 2208 name = vm.propertyNames->anonymous.impl(); 2207 2209 ASSERT(name); 2208 2210 -
trunk/Source/JavaScriptCore/runtime/PrivateName.h
r117859 r156910 37 37 { 38 38 } 39 explicit PrivateName(StringImpl* uid) 40 : m_impl(uid) 41 { 42 ASSERT(m_impl->isEmptyUnique()); 43 } 39 44 40 45 StringImpl* uid() const { return m_impl.get(); } -
trunk/Source/JavaScriptCore/runtime/PropertyName.h
r117859 r156910 82 82 : m_impl(propertyName.impl()) 83 83 { 84 ASSERT(!m_impl || m_impl->isIdentifier() );84 ASSERT(!m_impl || m_impl->isIdentifier() || m_impl->isEmptyUnique()); 85 85 } 86 86 -
trunk/Source/WTF/ChangeLog
r156862 r156910 1 2013-10-04 Oliver Hunt <oliver@apple.com> 2 3 Support for-of syntax 4 https://bugs.webkit.org/show_bug.cgi?id=122339 5 6 Reviewed by Geoffrey Garen. 7 8 Update assertions and add a helper function to StringImpl 9 to save repeated unique or identifier calls. 10 11 * wtf/text/StringImpl.h: 12 (WTF::StringImpl::isIdentifierOrUnique): 13 (WTF::StringImpl::setIsIdentifier): 14 (WTF::StringImpl::setIsAtomic): 15 1 16 2013-10-02 Brent Fulgham <bfulgham@apple.com> 2 17 -
trunk/Source/WTF/wtf/text/StringImpl.h
r156775 r156910 502 502 WTF_EXPORT_STRING_API void upconvertCharacters(unsigned, unsigned) const; 503 503 bool isIdentifier() const { return m_hashAndFlags & s_hashFlagIsIdentifier; } 504 bool isIdentifierOrUnique() const { return isIdentifier() || isEmptyUnique(); } 504 505 void setIsIdentifier(bool isIdentifier) 505 506 { 506 507 ASSERT(!isStatic()); 508 ASSERT(!isEmptyUnique()); 507 509 if (isIdentifier) 508 510 m_hashAndFlags |= s_hashFlagIsIdentifier; … … 520 522 { 521 523 ASSERT(!isStatic()); 524 ASSERT(!isEmptyUnique()); 522 525 if (isAtomic) 523 526 m_hashAndFlags |= s_hashFlagIsAtomic;
Note: See TracChangeset
for help on using the changeset viewer.