Changeset 197033 in webkit
- Timestamp:
- Feb 24, 2016 9:36:12 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 10 added
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r197030 r197033 1 2016-02-24 Skachkov Oleksandr <gskachkov@gmail.com> 2 3 [ES6] Arrow function syntax. Emit loading&putting this/super only if they are used in arrow function 4 https://bugs.webkit.org/show_bug.cgi?id=153981 5 6 Reviewed by Saam Barati. 7 8 Added new benchmark tests for invoking arrow function within function, class's constructor and method 9 10 * js/regress/arrowfunction-call-in-class-constructor-expected.txt: Added. 11 * js/regress/arrowfunction-call-in-class-constructor.html: Added. 12 * js/regress/arrowfunction-call-in-class-method-expected.txt: Added. 13 * js/regress/arrowfunction-call-in-class-method.html: Added. 14 * js/regress/arrowfunction-call-in-function-expected.txt: Added. 15 * js/regress/arrowfunction-call-in-function.html: Added. 16 * js/regress/script-tests/arrowfunction-call-in-class-constructor.js: Added. 17 * js/regress/script-tests/arrowfunction-call-in-class-method.js: Added. 18 * js/regress/script-tests/arrowfunction-call-in-function.js: Added. 19 * js/regress/script-tests/arrowfunction-call.js: 20 1 21 2016-02-24 Zalan Bujtas <zalan@apple.com> 2 22 -
trunk/LayoutTests/js/regress/script-tests/arrowfunction-call.js
r188545 r197033 9 9 noInline(bar); 10 10 11 for ( vari = 0; i < 1000000; ++i) {12 varresult = bar(1, 2);11 for (let i = 0; i < 1000000; ++i) { 12 let result = bar(1, 2); 13 13 if (result != 3) 14 14 throw "Error: bad result: " + result; -
trunk/Source/JavaScriptCore/ChangeLog
r197013 r197033 1 2016-02-24 Skachkov Oleksandr <gskachkov@gmail.com> 2 3 [ES6] Arrow function syntax. Emit loading&putting this/super only if they are used in arrow function 4 https://bugs.webkit.org/show_bug.cgi?id=153981 5 6 Reviewed by Saam Barati. 7 8 In first iteration of implemenation arrow function, we emit load and store variables 'this', 'arguments', 9 'super', 'new.target' in case if arrow function is exist even variables are not used in arrow function. 10 Current patch added logic that prevent from emiting those varibles if they are not used in arrow function. 11 During syntax analyze parser store information about using variables in arrow function inside of 12 the ordinary function scope and then put to BytecodeGenerator through UnlinkedCodeBlock 13 14 * bytecode/ExecutableInfo.h: 15 (JSC::ExecutableInfo::ExecutableInfo): 16 (JSC::ExecutableInfo::arrowFunctionCodeFeatures): 17 * bytecode/UnlinkedCodeBlock.cpp: 18 (JSC::UnlinkedCodeBlock::UnlinkedCodeBlock): 19 * bytecode/UnlinkedCodeBlock.h: 20 (JSC::UnlinkedCodeBlock::arrowFunctionCodeFeatures): 21 (JSC::UnlinkedCodeBlock::doAnyInnerArrowFunctionsUseArguments): 22 (JSC::UnlinkedCodeBlock::doAnyInnerArrowFunctionsUseSuperCall): 23 (JSC::UnlinkedCodeBlock::doAnyInnerArrowFunctionsUseSuperProperty): 24 (JSC::UnlinkedCodeBlock::doAnyInnerArrowFunctionsUseEval): 25 (JSC::UnlinkedCodeBlock::doAnyInnerArrowFunctionsUseThis): 26 (JSC::UnlinkedCodeBlock::doAnyInnerArrowFunctionsUseNewTarget): 27 * bytecode/UnlinkedFunctionExecutable.cpp: 28 (JSC::generateUnlinkedFunctionCodeBlock): 29 (JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable): 30 * bytecode/UnlinkedFunctionExecutable.h: 31 * bytecompiler/BytecodeGenerator.cpp: 32 (JSC::BytecodeGenerator::BytecodeGenerator): 33 (JSC::BytecodeGenerator::initializeArrowFunctionContextScopeIfNeeded): 34 (JSC::BytecodeGenerator::emitLoadArrowFunctionLexicalEnvironment): 35 (JSC::BytecodeGenerator::emitLoadThisFromArrowFunctionLexicalEnvironment): 36 (JSC::BytecodeGenerator::emitLoadNewTargetFromArrowFunctionLexicalEnvironment): 37 (JSC::BytecodeGenerator::emitLoadDerivedConstructorFromArrowFunctionLexicalEnvironment): 38 (JSC::BytecodeGenerator::isThisUsedInInnerArrowFunction): 39 (JSC::BytecodeGenerator::isArgumentsUsedInInnerArrowFunction): 40 (JSC::BytecodeGenerator::isNewTargetUsedInInnerArrowFunction): 41 (JSC::BytecodeGenerator::isSuperUsedInInnerArrowFunction): 42 (JSC::BytecodeGenerator::emitPutNewTargetToArrowFunctionContextScope): 43 (JSC::BytecodeGenerator::emitPutDerivedConstructorToArrowFunctionContextScope): 44 (JSC::BytecodeGenerator::emitPutThisToArrowFunctionContextScope): 45 * bytecompiler/BytecodeGenerator.h: 46 * bytecompiler/NodesCodegen.cpp: 47 (JSC::ThisNode::emitBytecode): 48 (JSC::EvalFunctionCallNode::emitBytecode): 49 (JSC::FunctionCallValueNode::emitBytecode): 50 (JSC::FunctionNode::emitBytecode): 51 * parser/ASTBuilder.h: 52 (JSC::ASTBuilder::createFunctionMetadata): 53 * parser/Nodes.cpp: 54 (JSC::FunctionMetadataNode::FunctionMetadataNode): 55 * parser/Nodes.h: 56 * parser/Parser.cpp: 57 (JSC::Parser<LexerType>::parseGeneratorFunctionSourceElements): 58 (JSC::Parser<LexerType>::parseFunctionBody): 59 (JSC::Parser<LexerType>::parseFunctionInfo): 60 (JSC::Parser<LexerType>::parseProperty): 61 (JSC::Parser<LexerType>::parsePrimaryExpression): 62 (JSC::Parser<LexerType>::parseMemberExpression): 63 * parser/Parser.h: 64 (JSC::Scope::Scope): 65 (JSC::Scope::isArrowFunctionBoundary): 66 (JSC::Scope::innerArrowFunctionFeatures): 67 (JSC::Scope::setInnerArrowFunctionUseSuperCall): 68 (JSC::Scope::setInnerArrowFunctionUseSuperProperty): 69 (JSC::Scope::setInnerArrowFunctionUseEval): 70 (JSC::Scope::setInnerArrowFunctionUseThis): 71 (JSC::Scope::setInnerArrowFunctionUseNewTarget): 72 (JSC::Scope::setInnerArrowFunctionUseArguments): 73 (JSC::Scope::setInnerArrowFunctionUseEvalAndUseArgumentsIfNeeded): 74 (JSC::Scope::collectFreeVariables): 75 (JSC::Scope::mergeInnerArrowFunctionFeatures): 76 (JSC::Scope::fillParametersForSourceProviderCache): 77 (JSC::Scope::restoreFromSourceProviderCache): 78 (JSC::Scope::setIsFunction): 79 (JSC::Scope::setIsArrowFunction): 80 (JSC::Parser::closestParentNonArrowFunctionNonLexicalScope): 81 (JSC::Parser::pushScope): 82 (JSC::Parser::popScopeInternal): 83 * parser/ParserModes.h: 84 * parser/SourceProviderCacheItem.h: 85 (JSC::SourceProviderCacheItem::SourceProviderCacheItem): 86 * parser/SyntaxChecker.h: 87 (JSC::SyntaxChecker::createFunctionMetadata): 88 * tests/stress/arrowfunction-lexical-bind-arguments-non-strict-1.js: 89 * tests/stress/arrowfunction-lexical-bind-arguments-strict.js: 90 * tests/stress/arrowfunction-lexical-bind-newtarget.js: 91 * tests/stress/arrowfunction-lexical-bind-superproperty.js: 92 * tests/stress/arrowfunction-lexical-bind-this-8.js: Added. 93 1 94 2016-02-23 Brian Burg <bburg@apple.com> 2 95 -
trunk/Source/JavaScriptCore/bytecode/ExecutableInfo.h
r195876 r197033 36 36 // https://bugs.webkit.org/show_bug.cgi?id=151547 37 37 struct ExecutableInfo { 38 ExecutableInfo(bool usesEval, bool isStrictMode, bool isConstructor, bool isBuiltinFunction, ConstructorKind constructorKind, SuperBinding superBinding, SourceParseMode parseMode, DerivedContextType derivedContextType, bool isArrowFunctionContext, bool isClassContext )38 ExecutableInfo(bool usesEval, bool isStrictMode, bool isConstructor, bool isBuiltinFunction, ConstructorKind constructorKind, SuperBinding superBinding, SourceParseMode parseMode, DerivedContextType derivedContextType, bool isArrowFunctionContext, bool isClassContext, ArrowFunctionCodeFeatures arrowFunctionCodeFeatures = NoArrowFunctionFeatures) 39 39 : m_usesEval(usesEval) 40 40 , m_isStrictMode(isStrictMode) … … 47 47 , m_isArrowFunctionContext(isArrowFunctionContext) 48 48 , m_isClassContext(isClassContext) 49 , m_arrowFunctionCodeFeatures(arrowFunctionCodeFeatures) 49 50 { 50 51 ASSERT(m_constructorKind == static_cast<unsigned>(constructorKind)); … … 62 63 bool isArrowFunctionContext() const { return m_isArrowFunctionContext; } 63 64 bool isClassContext() const { return m_isClassContext; } 65 ArrowFunctionCodeFeatures arrowFunctionCodeFeatures() const { return m_arrowFunctionCodeFeatures; } 64 66 65 67 private: … … 74 76 unsigned m_isArrowFunctionContext : 1; 75 77 unsigned m_isClassContext : 1; 78 ArrowFunctionCodeFeatures m_arrowFunctionCodeFeatures; 76 79 }; 77 80 -
trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp
r196149 r197033 72 72 , m_lineCount(0) 73 73 , m_endColumn(UINT_MAX) 74 , m_arrowFunctionCodeFeatures(info.arrowFunctionCodeFeatures()) 74 75 , m_parseMode(info.parseMode()) 75 76 , m_features(0) -
trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h
r196149 r197033 123 123 bool isArrowFunctionContext() const { return m_isArrowFunctionContext; } 124 124 bool isClassContext() const { return m_isClassContext; } 125 ArrowFunctionCodeFeatures arrowFunctionCodeFeatures() const { return m_arrowFunctionCodeFeatures; } 126 127 bool doAnyInnerArrowFunctionsUseArguments() { return m_arrowFunctionCodeFeatures & ArgumentsArrowFunctionFeature; } 128 bool doAnyInnerArrowFunctionsUseSuperCall() { return m_arrowFunctionCodeFeatures & SuperCallArrowFunctionFeature; } 129 bool doAnyInnerArrowFunctionsUseSuperProperty() { return m_arrowFunctionCodeFeatures & SuperPropertyArrowFunctionFeature; } 130 bool doAnyInnerArrowFunctionsUseEval() { return m_arrowFunctionCodeFeatures & EvalArrowFunctionFeature; } 131 bool doAnyInnerArrowFunctionsUseThis() { return m_arrowFunctionCodeFeatures & ThisArrowFunctionFeature; } 132 bool doAnyInnerArrowFunctionsUseNewTarget() { return m_arrowFunctionCodeFeatures & NewTargetArrowFunctionFeature; } 125 133 126 134 void addExpressionInfo(unsigned instructionOffset, int divot, … … 392 400 unsigned m_lineCount; 393 401 unsigned m_endColumn; 394 402 403 ArrowFunctionCodeFeatures m_arrowFunctionCodeFeatures; 395 404 SourceParseMode m_parseMode; 396 405 CodeFeatures m_features; -
trunk/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp
r195876 r197033 70 70 71 71 UnlinkedFunctionCodeBlock* result = UnlinkedFunctionCodeBlock::create(&vm, FunctionCode, 72 ExecutableInfo(function->usesEval(), function->isStrictMode(), kind == CodeForConstruct, functionKind == UnlinkedBuiltinFunction, executable->constructorKind(), executable->superBinding(), parseMode, executable->derivedContextType(), false, isClassContext ));72 ExecutableInfo(function->usesEval(), function->isStrictMode(), kind == CodeForConstruct, functionKind == UnlinkedBuiltinFunction, executable->constructorKind(), executable->superBinding(), parseMode, executable->derivedContextType(), false, isClassContext, executable->arrowFunctionCodeFeatures())); 73 73 74 74 auto generator(std::make_unique<BytecodeGenerator>(vm, function.get(), result, debuggerMode, profilerMode, executable->parentScopeTDZVariables())); … … 102 102 , m_derivedContextType(static_cast<unsigned>(derivedContextType)) 103 103 , m_sourceParseMode(static_cast<unsigned>(node->parseMode())) 104 , m_arrowFunctionCodeFeatures(node->arrowFunctionCodeFeatures()) 104 105 , m_name(node->ident()) 105 106 , m_inferredName(node->inferredName()) -
trunk/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.h
r195876 r197033 85 85 ConstructorKind constructorKind() const { return static_cast<ConstructorKind>(m_constructorKind); } 86 86 SuperBinding superBinding() const { return static_cast<SuperBinding>(m_superBinding); } 87 ArrowFunctionCodeFeatures arrowFunctionCodeFeatures() const { return m_arrowFunctionCodeFeatures; } 87 88 88 89 unsigned unlinkedFunctionNameStart() const { return m_unlinkedFunctionNameStart; } … … 157 158 unsigned m_derivedContextType: 2; 158 159 unsigned m_sourceParseMode : 4; // SourceParseMode 160 ArrowFunctionCodeFeatures m_arrowFunctionCodeFeatures; 159 161 160 162 WriteBarrier<UnlinkedFunctionCodeBlock> m_unlinkedCodeBlockForCall; -
trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
r195862 r197033 244 244 245 245 bool shouldCaptureAllOfTheThings = m_shouldEmitDebugHooks || codeBlock->usesEval(); 246 bool needsArguments = (functionNode->usesArguments() || codeBlock->usesEval() || (functionNode->usesArrowFunction() && !codeBlock->isArrowFunction() ));246 bool needsArguments = (functionNode->usesArguments() || codeBlock->usesEval() || (functionNode->usesArrowFunction() && !codeBlock->isArrowFunction() && isArgumentsUsedInInnerArrowFunction())); 247 247 248 248 // Generator never provides "arguments". "arguments" reference will be resolved in an upper generator function scope. … … 573 573 // because that function sets up the SymbolTable stack and emitLoadThisFromArrowFunctionLexicalEnvironment() 574 574 // consults the SymbolTable stack 575 if (SourceParseMode::ArrowFunctionMode == parseMode && (functionNode->usesThis() || is DerivedClassContext() || isDerivedConstructorContext()))575 if (SourceParseMode::ArrowFunctionMode == parseMode && (functionNode->usesThis() || isThisUsedInInnerArrowFunction())) 576 576 emitLoadThisFromArrowFunctionLexicalEnvironment(); 577 577 … … 889 889 if (!m_codeBlock->isArrowFunction()) { 890 890 ScopeOffset offset; 891 892 offset = symbolTable->takeNextScopeOffset(); 893 symbolTable->set(propertyNames().thisIdentifier.impl(), SymbolTableEntry(VarOffset(offset))); 894 895 if (m_codeType == FunctionCode) { 891 892 if (isThisUsedInInnerArrowFunction()) { 893 offset = symbolTable->takeNextScopeOffset(); 894 symbolTable->set(propertyNames().thisIdentifier.impl(), SymbolTableEntry(VarOffset(offset))); 895 } 896 897 if (m_codeType == FunctionCode && isNewTargetUsedInInnerArrowFunction()) { 896 898 offset = symbolTable->takeNextScopeOffset(); 897 899 symbolTable->set(propertyNames().newTargetLocalPrivateName.impl(), SymbolTableEntry(VarOffset(offset))); 898 900 } 899 901 900 if (isConstructor() && constructorKind() == ConstructorKind::Derived ) {902 if (isConstructor() && constructorKind() == ConstructorKind::Derived && isSuperUsedInInnerArrowFunction()) { 901 903 offset = symbolTable->takeNextScopeOffset(); 902 904 symbolTable->set(propertyNames().derivedConstructorPrivateName.impl(), SymbolTableEntry(VarOffset(offset))); … … 908 910 909 911 VariableEnvironment environment; 910 auto addResult = environment.add(propertyNames().thisIdentifier); 911 addResult.iterator->value.setIsCaptured(); 912 addResult.iterator->value.setIsConst(); 913 914 if (m_codeType == FunctionCode) { 912 913 if (isThisUsedInInnerArrowFunction()) { 914 auto addResult = environment.add(propertyNames().thisIdentifier); 915 addResult.iterator->value.setIsCaptured(); 916 addResult.iterator->value.setIsConst(); 917 } 918 919 if (m_codeType == FunctionCode && isNewTargetUsedInInnerArrowFunction()) { 915 920 auto addTarget = environment.add(propertyNames().newTargetLocalPrivateName); 916 921 addTarget.iterator->value.setIsCaptured(); … … 918 923 } 919 924 920 if (isConstructor() && constructorKind() == ConstructorKind::Derived ) {925 if (isConstructor() && constructorKind() == ConstructorKind::Derived && isSuperUsedInInnerArrowFunction()) { 921 926 auto derivedConstructor = environment.add(propertyNames().derivedConstructorPrivateName); 922 927 derivedConstructor.iterator->value.setIsCaptured(); … … 924 929 } 925 930 926 size_t size = m_symbolTableStack.size(); 927 pushLexicalScopeInternal(environment, TDZCheckOptimization::Optimize, NestedScopeType::IsNotNested, nullptr, TDZRequirement::UnderTDZ, ScopeType::LetConstScope, ScopeRegisterType::Block); 928 929 ASSERT_UNUSED(size, m_symbolTableStack.size() == size + 1); 930 931 m_arrowFunctionContextLexicalEnvironmentRegister = m_symbolTableStack.last().m_scope; 931 if (environment.size() > 0) { 932 size_t size = m_symbolTableStack.size(); 933 pushLexicalScopeInternal(environment, TDZCheckOptimization::Optimize, NestedScopeType::IsNotNested, nullptr, TDZRequirement::UnderTDZ, ScopeType::LetConstScope, ScopeRegisterType::Block); 934 935 ASSERT_UNUSED(size, m_symbolTableStack.size() == size + 1); 936 937 m_arrowFunctionContextLexicalEnvironmentRegister = m_symbolTableStack.last().m_scope; 938 } 932 939 } 933 940 … … 4001 4008 } 4002 4009 4003 RegisterID* BytecodeGenerator::emitLoadArrowFunctionLexicalEnvironment( )4010 RegisterID* BytecodeGenerator::emitLoadArrowFunctionLexicalEnvironment(const Identifier& identifier) 4004 4011 { 4005 4012 ASSERT(m_codeBlock->isArrowFunction() || m_codeBlock->isArrowFunctionContext() || constructorKind() == ConstructorKind::Derived); 4006 4013 4007 return emitResolveScope(nullptr, variable( propertyNames().thisIdentifier, ThisResolutionType::Scoped));4014 return emitResolveScope(nullptr, variable(identifier, ThisResolutionType::Scoped)); 4008 4015 } 4009 4016 4010 4017 void BytecodeGenerator::emitLoadThisFromArrowFunctionLexicalEnvironment() 4011 4018 { 4012 emitGetFromScope(thisRegister(), emitLoadArrowFunctionLexicalEnvironment( ), variable(propertyNames().thisIdentifier, ThisResolutionType::Scoped), DoNotThrowIfNotFound);4019 emitGetFromScope(thisRegister(), emitLoadArrowFunctionLexicalEnvironment(propertyNames().thisIdentifier), variable(propertyNames().thisIdentifier, ThisResolutionType::Scoped), DoNotThrowIfNotFound); 4013 4020 } 4014 4021 … … 4018 4025 4019 4026 Variable newTargetVar = variable(propertyNames().newTargetLocalPrivateName); 4020 emitMove(m_newTargetRegister, emitGetFromScope(newTemporary(), emitLoadArrowFunctionLexicalEnvironment( ), newTargetVar, ThrowIfNotFound));4027 emitMove(m_newTargetRegister, emitGetFromScope(newTemporary(), emitLoadArrowFunctionLexicalEnvironment(propertyNames().newTargetLocalPrivateName), newTargetVar, ThrowIfNotFound)); 4021 4028 4022 4029 return m_newTargetRegister; … … 4026 4033 { 4027 4034 Variable protoScopeVar = variable(propertyNames().derivedConstructorPrivateName); 4028 return emitGetFromScope(newTemporary(), emitLoadArrowFunctionLexicalEnvironment(), protoScopeVar, ThrowIfNotFound); 4029 } 4030 4035 return emitGetFromScope(newTemporary(), emitLoadArrowFunctionLexicalEnvironment(propertyNames().derivedConstructorPrivateName), protoScopeVar, ThrowIfNotFound); 4036 } 4037 4038 bool BytecodeGenerator::isThisUsedInInnerArrowFunction() 4039 { 4040 return m_codeBlock->doAnyInnerArrowFunctionsUseThis() || m_codeBlock->doAnyInnerArrowFunctionsUseSuperProperty() || m_codeBlock->doAnyInnerArrowFunctionsUseSuperCall() || m_codeBlock->doAnyInnerArrowFunctionsUseEval() || m_codeBlock->usesEval(); 4041 } 4042 4043 bool BytecodeGenerator::isArgumentsUsedInInnerArrowFunction() 4044 { 4045 return m_codeBlock->doAnyInnerArrowFunctionsUseArguments() || m_codeBlock->doAnyInnerArrowFunctionsUseEval(); 4046 } 4047 4048 bool BytecodeGenerator::isNewTargetUsedInInnerArrowFunction() 4049 { 4050 return m_codeBlock->doAnyInnerArrowFunctionsUseNewTarget() || m_codeBlock->doAnyInnerArrowFunctionsUseSuperCall(); 4051 } 4052 4053 bool BytecodeGenerator::isSuperUsedInInnerArrowFunction() 4054 { 4055 return m_codeBlock->doAnyInnerArrowFunctionsUseSuperCall() || m_codeBlock->doAnyInnerArrowFunctionsUseSuperProperty(); 4056 } 4057 4031 4058 void BytecodeGenerator::emitPutNewTargetToArrowFunctionContextScope() 4032 4059 { 4033 ASSERT(m_arrowFunctionContextLexicalEnvironmentRegister != nullptr); 4060 if (isNewTargetUsedInInnerArrowFunction()) { 4061 ASSERT(m_arrowFunctionContextLexicalEnvironmentRegister); 4034 4062 4035 Variable newTargetVar = variable(propertyNames().newTargetLocalPrivateName); 4036 emitPutToScope(m_arrowFunctionContextLexicalEnvironmentRegister, newTargetVar, newTarget(), DoNotThrowIfNotFound, Initialization); 4063 Variable newTargetVar = variable(propertyNames().newTargetLocalPrivateName); 4064 emitPutToScope(m_arrowFunctionContextLexicalEnvironmentRegister, newTargetVar, newTarget(), DoNotThrowIfNotFound, Initialization); 4065 } 4037 4066 } 4038 4067 … … 4040 4069 { 4041 4070 if ((isConstructor() && constructorKind() == ConstructorKind::Derived) || m_codeBlock->isClassContext()) { 4042 ASSERT(m_arrowFunctionContextLexicalEnvironmentRegister); 4071 if (isSuperUsedInInnerArrowFunction()) { 4072 ASSERT(m_arrowFunctionContextLexicalEnvironmentRegister); 4043 4073 4044 Variable protoScope = variable(propertyNames().derivedConstructorPrivateName); 4045 emitPutToScope(m_arrowFunctionContextLexicalEnvironmentRegister, protoScope, &m_calleeRegister, DoNotThrowIfNotFound, Initialization); 4046 } 4047 } 4048 4074 Variable protoScope = variable(propertyNames().derivedConstructorPrivateName); 4075 emitPutToScope(m_arrowFunctionContextLexicalEnvironmentRegister, protoScope, &m_calleeRegister, DoNotThrowIfNotFound, Initialization); 4076 } 4077 } 4078 } 4079 4049 4080 void BytecodeGenerator::emitPutThisToArrowFunctionContextScope() 4050 4081 { 4051 ASSERT(isDerivedConstructorContext() || m_arrowFunctionContextLexicalEnvironmentRegister != nullptr); 4052 4053 Variable thisVar = variable(propertyNames().thisIdentifier, ThisResolutionType::Scoped); 4054 RegisterID* scope = isDerivedConstructorContext() ? emitLoadArrowFunctionLexicalEnvironment() : m_arrowFunctionContextLexicalEnvironmentRegister; 4055 4056 emitPutToScope(scope, thisVar, thisRegister(), DoNotThrowIfNotFound, NotInitialization); 4082 if (isThisUsedInInnerArrowFunction()) { 4083 ASSERT(isDerivedConstructorContext() || m_arrowFunctionContextLexicalEnvironmentRegister != nullptr); 4084 4085 Variable thisVar = variable(propertyNames().thisIdentifier, ThisResolutionType::Scoped); 4086 RegisterID* scope = isDerivedConstructorContext() ? emitLoadArrowFunctionLexicalEnvironment(propertyNames().thisIdentifier) : m_arrowFunctionContextLexicalEnvironmentRegister; 4087 4088 emitPutToScope(scope, thisVar, thisRegister(), ThrowIfNotFound, NotInitialization); 4089 } 4057 4090 } 4058 4091 -
trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h
r195862 r197033 495 495 void emitProfileControlFlow(int); 496 496 497 RegisterID* emitLoadArrowFunctionLexicalEnvironment( );497 RegisterID* emitLoadArrowFunctionLexicalEnvironment(const Identifier&); 498 498 void emitLoadThisFromArrowFunctionLexicalEnvironment(); 499 499 RegisterID* emitLoadNewTargetFromArrowFunctionLexicalEnvironment(); … … 718 718 void emitPushFunctionNameScope(const Identifier& property, RegisterID* value, bool isCaptured); 719 719 void emitNewFunctionExpressionCommon(RegisterID*, BaseFuncExprNode*); 720 721 bool isNewTargetUsedInInnerArrowFunction(); 722 bool isSuperUsedInInnerArrowFunction(); 723 bool isArgumentsUsedInInnerArrowFunction(); 720 724 721 725 public: 726 bool isThisUsedInInnerArrowFunction(); 722 727 void pushLexicalScope(VariableEnvironmentNode*, TDZCheckOptimization, NestedScopeType = NestedScopeType::IsNotNested, RegisterID** constantSymbolTableResult = nullptr); 723 728 void popLexicalScope(VariableEnvironmentNode*); -
trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
r196361 r197033 147 147 RegisterID* ThisNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) 148 148 { 149 if (generator.constructorKind() == ConstructorKind::Derived && generator.needsToUpdateArrowFunctionContext() )149 if (generator.constructorKind() == ConstructorKind::Derived && generator.needsToUpdateArrowFunctionContext() && generator.isThisUsedInInnerArrowFunction()) 150 150 generator.emitLoadThisFromArrowFunctionLexicalEnvironment(); 151 151 … … 724 724 // } 725 725 // } 726 if (generator.constructorKind() == ConstructorKind::Derived && generator.needsToUpdateArrowFunctionContext() )726 if (generator.constructorKind() == ConstructorKind::Derived && generator.needsToUpdateArrowFunctionContext() && generator.isThisUsedInInnerArrowFunction()) 727 727 generator.emitLoadThisFromArrowFunctionLexicalEnvironment(); 728 728 … … 763 763 if (generator.isDerivedConstructorContext() || (isConstructorKindDerived && generator.needsToUpdateArrowFunctionContext())) 764 764 generator.emitPutThisToArrowFunctionContextScope(); 765 765 766 766 return ret; 767 767 } … … 3139 3139 // If there is no return we must automatically insert one. 3140 3140 if (!returnNode) { 3141 if (generator.constructorKind() == ConstructorKind::Derived && generator.needsToUpdateArrowFunctionContext() )3141 if (generator.constructorKind() == ConstructorKind::Derived && generator.needsToUpdateArrowFunctionContext() && generator.isThisUsedInInnerArrowFunction()) 3142 3142 generator.emitLoadThisFromArrowFunctionLexicalEnvironment(); // Arrow function can invoke 'super' in constructor and before leave constructor we need load 'this' from lexical arrow function environment 3143 3143 -
trunk/Source/JavaScriptCore/parser/ASTBuilder.h
r196734 r197033 373 373 unsigned startColumn, unsigned endColumn, int functionKeywordStart, 374 374 int functionNameStart, int parametersStart, bool inStrictContext, 375 ConstructorKind constructorKind, SuperBinding superBinding, unsigned parameterCount, SourceParseMode mode, bool isArrowFunctionBodyExpression )375 ConstructorKind constructorKind, SuperBinding superBinding, unsigned parameterCount, SourceParseMode mode, bool isArrowFunctionBodyExpression, ArrowFunctionCodeFeatures arrowFunctionCodeFeatures = NoArrowFunctionFeatures) 376 376 { 377 377 return new (m_parserArena) FunctionMetadataNode( 378 378 m_parserArena, startLocation, endLocation, startColumn, endColumn, 379 379 functionKeywordStart, functionNameStart, parametersStart, 380 inStrictContext, constructorKind, superBinding, parameterCount, mode, isArrowFunctionBodyExpression );380 inStrictContext, constructorKind, superBinding, parameterCount, mode, isArrowFunctionBodyExpression, arrowFunctionCodeFeatures); 381 381 } 382 382 -
trunk/Source/JavaScriptCore/parser/Nodes.cpp
r196525 r197033 147 147 const JSTokenLocation& endLocation, unsigned startColumn, unsigned endColumn, 148 148 int functionKeywordStart, int functionNameStart, int parametersStart, bool isInStrictContext, 149 ConstructorKind constructorKind, SuperBinding superBinding, unsigned parameterCount, SourceParseMode mode, bool isArrowFunctionBodyExpression )149 ConstructorKind constructorKind, SuperBinding superBinding, unsigned parameterCount, SourceParseMode mode, bool isArrowFunctionBodyExpression, ArrowFunctionCodeFeatures arrowFunctionCodeFeatures) 150 150 : Node(endLocation) 151 151 , m_startColumn(startColumn) … … 161 161 , m_constructorKind(static_cast<unsigned>(constructorKind)) 162 162 , m_isArrowFunctionBodyExpression(isArrowFunctionBodyExpression) 163 , m_arrowFunctionCodeFeatures(arrowFunctionCodeFeatures) 163 164 { 164 165 ASSERT(m_superBinding == static_cast<unsigned>(superBinding)); -
trunk/Source/JavaScriptCore/parser/Nodes.h
r196525 r197033 1825 1825 unsigned startColumn, unsigned endColumn, int functionKeywordStart, 1826 1826 int functionNameStart, int parametersStart, bool isInStrictContext, 1827 ConstructorKind, SuperBinding, unsigned, SourceParseMode, bool isArrowFunctionBodyExpression );1827 ConstructorKind, SuperBinding, unsigned, SourceParseMode, bool isArrowFunctionBodyExpression, ArrowFunctionCodeFeatures = NoArrowFunctionFeatures); 1828 1828 1829 1829 void finishParsing(const SourceCode&, const Identifier&, FunctionMode); … … 1853 1853 ConstructorKind constructorKind() { return static_cast<ConstructorKind>(m_constructorKind); } 1854 1854 bool isArrowFunctionBodyExpression() const { return m_isArrowFunctionBodyExpression; } 1855 ArrowFunctionCodeFeatures arrowFunctionCodeFeatures() const { return m_arrowFunctionCodeFeatures;} 1855 1856 1856 1857 void setLoc(unsigned firstLine, unsigned lastLine, int startOffset, int lineStartOffset) … … 1880 1881 unsigned m_constructorKind : 2; 1881 1882 unsigned m_isArrowFunctionBodyExpression : 1; 1883 ArrowFunctionCodeFeatures m_arrowFunctionCodeFeatures; 1882 1884 }; 1883 1885 -
trunk/Source/JavaScriptCore/parser/Parser.cpp
r196734 r197033 520 520 popScope(generatorBodyScope, TreeBuilder::NeedsFreeVariableInfo); 521 521 } 522 info.body = context.createFunctionMetadata(startLocation, tokenLocation(), startColumn, tokenColumn(), functionKeywordStart, functionNameStart, parametersStart, strictMode(), ConstructorKind::None, m_superBinding, info.parameterCount, SourceParseMode::GeneratorBodyMode, false );522 info.body = context.createFunctionMetadata(startLocation, tokenLocation(), startColumn, tokenColumn(), functionKeywordStart, functionNameStart, parametersStart, strictMode(), ConstructorKind::None, m_superBinding, info.parameterCount, SourceParseMode::GeneratorBodyMode, false, currentFunctionScope()->innerArrowFunctionFeatures()); 523 523 524 524 info.endLine = tokenLine(); … … 1736 1736 if (match(CLOSEBRACE)) { 1737 1737 unsigned endColumn = tokenColumn(); 1738 return context.createFunctionMetadata(startLocation, tokenLocation(), startColumn, endColumn, functionKeywordStart, functionNameStart, parametersStart, strictMode(), constructorKind, superBinding, parameterCount, parseMode, isArrowFunctionBodyExpression );1738 return context.createFunctionMetadata(startLocation, tokenLocation(), startColumn, endColumn, functionKeywordStart, functionNameStart, parametersStart, strictMode(), constructorKind, superBinding, parameterCount, parseMode, isArrowFunctionBodyExpression, currentFunctionScope()->innerArrowFunctionFeatures()); 1739 1739 } 1740 1740 } … … 1748 1748 failIfFalse(parseSourceElements(syntaxChecker, CheckForStrictMode), bodyType == StandardFunctionBodyBlock ? "Cannot parse body of this function" : "Cannot parse body of this arrow function"); 1749 1749 unsigned endColumn = tokenColumn(); 1750 return context.createFunctionMetadata(startLocation, tokenLocation(), startColumn, endColumn, functionKeywordStart, functionNameStart, parametersStart, strictMode(), constructorKind, superBinding, parameterCount, parseMode, isArrowFunctionBodyExpression );1750 return context.createFunctionMetadata(startLocation, tokenLocation(), startColumn, endColumn, functionKeywordStart, functionNameStart, parametersStart, strictMode(), constructorKind, superBinding, parameterCount, parseMode, isArrowFunctionBodyExpression, currentFunctionScope()->innerArrowFunctionFeatures()); 1751 1751 } 1752 1752 … … 1989 1989 startLocation, endLocation, functionInfo.bodyStartColumn, bodyEndColumn, 1990 1990 functionKeywordStart, functionNameStart, parametersStart, 1991 cachedInfo->strictMode, constructorKind, expectedSuperBinding, cachedInfo->parameterCount, mode, functionBodyType == ArrowFunctionBodyExpression );1991 cachedInfo->strictMode, constructorKind, expectedSuperBinding, cachedInfo->parameterCount, mode, functionBodyType == ArrowFunctionBodyExpression, cachedInfo->innerArrowFunctionFeatures); 1992 1992 1993 1993 functionScope->restoreFromSourceProviderCache(cachedInfo); … … 2065 2065 semanticFailIfTrue(functionConstructorKind == ConstructorKind::None, "Cannot call super() outside of a class constructor"); 2066 2066 semanticFailIfTrue(functionConstructorKind != ConstructorKind::Derived, "Cannot call super() in a base class constructor"); 2067 2068 if (functionBodyType == ArrowFunctionBodyBlock || functionBodyType == ArrowFunctionBodyExpression) 2069 functionScope->setInnerArrowFunctionUseSuperCall(); 2067 2070 } 2068 2071 if (functionScope->needsSuperBinding()) { … … 2071 2074 : closestParentNonArrowFunctionNonLexicalScope()->expectedSuperBinding(); 2072 2075 semanticFailIfTrue(functionSuperBinding == SuperBinding::NotNeeded, "super can only be used in a method of a derived class"); 2076 2077 if (functionBodyType == ArrowFunctionBodyBlock || functionBodyType == ArrowFunctionBodyExpression) 2078 functionScope->setInnerArrowFunctionUseSuperProperty(); 2073 2079 } 2074 2080 } … … 3208 3214 JSTokenLocation location(tokenLocation()); 3209 3215 currentScope()->useVariable(ident, m_vm->propertyNames->eval == *ident); 3216 if (currentScope()->isArrowFunction()) 3217 currentScope()->setInnerArrowFunctionUseEval(); 3210 3218 TreeExpression node = context.createResolve(location, *ident, start, lastTokenEndPosition()); 3211 3219 return context.createProperty(ident, node, static_cast<PropertyNode::Type>(PropertyNode::Constant | PropertyNode::Shorthand), PropertyNode::KnownDirect, complete); … … 3621 3629 JSTokenLocation location(tokenLocation()); 3622 3630 next(); 3631 if (currentScope()->isArrowFunction()) 3632 currentScope()->setInnerArrowFunctionUseThis(); 3623 3633 return context.createThisExpr(location, m_thisTDZMode); 3624 3634 } … … 3796 3806 semanticFailIfFalse(currentScope()->isFunction(), "new.target is only valid inside functions"); 3797 3807 baseIsNewTarget = true; 3808 if (currentScope()->isArrowFunction()) 3809 currentScope()->setInnerArrowFunctionUseNewTarget(); 3798 3810 base = context.createNewTargetExpr(location); 3799 3811 newCount--; -
trunk/Source/JavaScriptCore/parser/Parser.h
r196734 r197033 159 159 160 160 struct Scope { 161 Scope(const VM* vm, bool isFunction, bool isGenerator, bool strictMode )161 Scope(const VM* vm, bool isFunction, bool isGenerator, bool strictMode, bool isArrowFunction) 162 162 : m_vm(vm) 163 163 , m_shadowsArguments(false) … … 171 171 , m_isFunction(isFunction) 172 172 , m_isGenerator(isGenerator) 173 , m_isArrowFunction(false) 173 , m_isArrowFunction(isArrowFunction) 174 , m_isArrowFunctionBoundary(false) 174 175 , m_isLexicalScope(false) 175 176 , m_isFunctionBoundary(false) … … 180 181 , m_loopDepth(0) 181 182 , m_switchDepth(0) 183 , m_innerArrowFunctionFeatures(0) 182 184 { 183 185 } … … 196 198 , m_isGenerator(rhs.m_isGenerator) 197 199 , m_isArrowFunction(rhs.m_isArrowFunction) 200 , m_isArrowFunctionBoundary(rhs.m_isArrowFunctionBoundary) 198 201 , m_isLexicalScope(rhs.m_isLexicalScope) 199 202 , m_isFunctionBoundary(rhs.m_isFunctionBoundary) … … 204 207 , m_loopDepth(rhs.m_loopDepth) 205 208 , m_switchDepth(rhs.m_switchDepth) 209 , m_innerArrowFunctionFeatures(rhs.m_innerArrowFunctionFeatures) 206 210 , m_moduleScopeData(rhs.m_moduleScopeData) 207 211 { … … 466 470 void setNeedsFullActivation() { m_needsFullActivation = true; } 467 471 bool needsFullActivation() const { return m_needsFullActivation; } 472 bool isArrowFunctionBoundary() { return m_isArrowFunctionBoundary; } 468 473 bool isArrowFunction() { return m_isArrowFunction; } 469 474 … … 473 478 bool needsSuperBinding() { return m_needsSuperBinding; } 474 479 void setNeedsSuperBinding() { m_needsSuperBinding = true; } 480 481 ArrowFunctionCodeFeatures innerArrowFunctionFeatures() { return m_innerArrowFunctionFeatures; } 475 482 476 483 void setExpectedSuperBinding(SuperBinding superBinding) { m_expectedSuperBinding = static_cast<unsigned>(superBinding); } … … 479 486 ConstructorKind constructorKind() const { return static_cast<ConstructorKind>(m_constructorKind); } 480 487 488 void setInnerArrowFunctionUseSuperCall() { m_innerArrowFunctionFeatures |= SuperCallArrowFunctionFeature; } 489 void setInnerArrowFunctionUseSuperProperty() { m_innerArrowFunctionFeatures |= SuperPropertyArrowFunctionFeature; } 490 void setInnerArrowFunctionUseEval() { m_innerArrowFunctionFeatures |= EvalArrowFunctionFeature; } 491 void setInnerArrowFunctionUseThis() { m_innerArrowFunctionFeatures |= ThisArrowFunctionFeature; } 492 void setInnerArrowFunctionUseNewTarget() { m_innerArrowFunctionFeatures |= NewTargetArrowFunctionFeature; } 493 void setInnerArrowFunctionUseArguments() { m_innerArrowFunctionFeatures |= ArgumentsArrowFunctionFeature; } 494 495 void setInnerArrowFunctionUseEvalAndUseArgumentsIfNeeded() 496 { 497 ASSERT(m_isArrowFunction); 498 499 if (m_usesEval) 500 setInnerArrowFunctionUseEval(); 501 502 if (m_usedVariables.contains(m_vm->propertyNames->arguments.impl())) 503 setInnerArrowFunctionUseArguments(); 504 } 505 481 506 void collectFreeVariables(Scope* nestedScope, bool shouldTrackClosedVariables) 482 507 { … … 490 515 491 516 // "arguments" reference should be resolved at function boudary. 492 if (nestedScope->isFunctionBoundary() && nestedScope->hasArguments() && impl == m_vm->propertyNames->arguments.impl() && !nestedScope->isArrowFunction ())517 if (nestedScope->isFunctionBoundary() && nestedScope->hasArguments() && impl == m_vm->propertyNames->arguments.impl() && !nestedScope->isArrowFunctionBoundary()) 493 518 continue; 494 519 … … 517 542 } 518 543 } 544 } 545 546 void mergeInnerArrowFunctionFeatures(ArrowFunctionCodeFeatures arrowFunctionCodeFeatures) 547 { 548 m_innerArrowFunctionFeatures = m_innerArrowFunctionFeatures | arrowFunctionCodeFeatures; 519 549 } 520 550 … … 569 599 parameters.strictMode = m_strictMode; 570 600 parameters.needsFullActivation = m_needsFullActivation; 601 parameters.innerArrowFunctionFeatures = m_innerArrowFunctionFeatures; 571 602 copyCapturedVariablesToVector(m_writtenVariables, parameters.writtenVariables); 572 603 copyCapturedVariablesToVector(m_usedVariables, parameters.usedVariables); … … 578 609 m_usesEval = info->usesEval; 579 610 m_strictMode = info->strictMode; 611 m_innerArrowFunctionFeatures = info->innerArrowFunctionFeatures; 580 612 m_needsFullActivation = info->needsFullActivation; 581 613 for (unsigned i = 0; i < info->usedVariablesCount; ++i) … … 593 625 setIsLexicalScope(); 594 626 m_isGenerator = false; 627 m_isArrowFunctionBoundary = false; 628 m_isArrowFunction = false; 595 629 } 596 630 … … 611 645 { 612 646 setIsFunction(); 647 m_isArrowFunctionBoundary = true; 613 648 m_isArrowFunction = true; 614 649 } … … 631 666 bool m_isGenerator : 1; 632 667 bool m_isArrowFunction : 1; 668 bool m_isArrowFunctionBoundary : 1; 633 669 bool m_isLexicalScope : 1; 634 670 bool m_isFunctionBoundary : 1; … … 639 675 int m_loopDepth; 640 676 int m_switchDepth; 677 ArrowFunctionCodeFeatures m_innerArrowFunctionFeatures; 641 678 642 679 typedef Vector<ScopeLabelInfo, 2> LabelStack; … … 897 934 unsigned i = m_scopeStack.size() - 1; 898 935 ASSERT(i < m_scopeStack.size() && m_scopeStack.size()); 899 while (i && (!m_scopeStack[i].isFunctionBoundary() || m_scopeStack[i].isArrowFunction ()))936 while (i && (!m_scopeStack[i].isFunctionBoundary() || m_scopeStack[i].isArrowFunctionBoundary())) 900 937 i--; 901 // When reaching the top level scope (it can be non function scope), we return it.902 938 return ScopeRef(&m_scopeStack, i); 903 939 } … … 908 944 bool isStrict = false; 909 945 bool isGenerator = false; 946 bool isArrowFunction = false; 910 947 if (!m_scopeStack.isEmpty()) { 911 948 isStrict = m_scopeStack.last().strictMode(); 912 949 isFunction = m_scopeStack.last().isFunction(); 913 950 isGenerator = m_scopeStack.last().isGenerator(); 914 } 915 m_scopeStack.append(Scope(m_vm, isFunction, isGenerator, isStrict)); 951 isArrowFunction = m_scopeStack.last().isArrowFunction(); 952 } 953 m_scopeStack.append(Scope(m_vm, isFunction, isGenerator, isStrict, isArrowFunction)); 916 954 return currentScope(); 917 955 } … … 922 960 ASSERT(m_scopeStack.size() > 1); 923 961 m_scopeStack[m_scopeStack.size() - 2].collectFreeVariables(&m_scopeStack.last(), shouldTrackClosedVariables); 962 963 if (m_scopeStack.last().isArrowFunction()) 964 m_scopeStack.last().setInnerArrowFunctionUseEvalAndUseArgumentsIfNeeded(); 965 966 if (!(m_scopeStack.last().isFunctionBoundary() && !m_scopeStack.last().isArrowFunctionBoundary())) 967 m_scopeStack[m_scopeStack.size() - 2].mergeInnerArrowFunctionFeatures(m_scopeStack.last().innerArrowFunctionFeatures()); 968 924 969 if (!m_scopeStack.last().isFunctionBoundary() && m_scopeStack.last().needsFullActivation()) 925 970 m_scopeStack[m_scopeStack.size() - 2].setNeedsFullActivation(); -
trunk/Source/JavaScriptCore/parser/ParserModes.h
r195876 r197033 162 162 const CodeFeatures AllFeatures = EvalFeature | ArgumentsFeature | WithFeature | ThisFeature | StrictModeFeature | ShadowsArgumentsFeature | ModifiedParameterFeature | ArrowFunctionFeature | ArrowFunctionContextFeature; 163 163 164 typedef uint8_t ArrowFunctionCodeFeatures; 165 166 const ArrowFunctionCodeFeatures NoArrowFunctionFeatures = 0; 167 const ArrowFunctionCodeFeatures EvalArrowFunctionFeature = 1 << 0; 168 const ArrowFunctionCodeFeatures ArgumentsArrowFunctionFeature = 1 << 1; 169 const ArrowFunctionCodeFeatures ThisArrowFunctionFeature = 1 << 2; 170 const ArrowFunctionCodeFeatures SuperCallArrowFunctionFeature = 1 << 3; 171 const ArrowFunctionCodeFeatures SuperPropertyArrowFunctionFeature = 1 << 4; 172 const ArrowFunctionCodeFeatures NewTargetArrowFunctionFeature = 1 << 5; 173 174 const ArrowFunctionCodeFeatures AllArrowFunctionCodeFeatures = EvalArrowFunctionFeature | ArgumentsArrowFunctionFeature | ThisArrowFunctionFeature | SuperCallArrowFunctionFeature | SuperPropertyArrowFunctionFeature | NewTargetArrowFunctionFeature; 164 175 } // namespace JSC 165 176 -
trunk/Source/JavaScriptCore/parser/SourceProviderCacheItem.h
r186959 r197033 45 45 bool usesEval; 46 46 bool strictMode; 47 ArrowFunctionCodeFeatures innerArrowFunctionFeatures; 47 48 Vector<RefPtr<UniquedStringImpl>> usedVariables; 48 49 Vector<RefPtr<UniquedStringImpl>> writtenVariables; … … 88 89 89 90 bool strictMode : 1; 91 92 ArrowFunctionCodeFeatures innerArrowFunctionFeatures; 90 93 91 94 unsigned lastTockenLineStartOffset; … … 128 131 , usesEval(parameters.usesEval) 129 132 , strictMode(parameters.strictMode) 133 , innerArrowFunctionFeatures(parameters.innerArrowFunctionFeatures) 130 134 , lastTockenLineStartOffset(parameters.lastTockenLineStartOffset) 131 135 , usedVariablesCount(parameters.usedVariables.size()) -
trunk/Source/JavaScriptCore/parser/SyntaxChecker.h
r196734 r197033 184 184 ClassExpression createClassExpr(const JSTokenLocation&, const Identifier&, VariableEnvironment&, ExpressionType, ExpressionType, PropertyList, PropertyList) { return ClassExpr; } 185 185 ExpressionType createFunctionExpr(const JSTokenLocation&, const ParserFunctionInfo<SyntaxChecker>&) { return FunctionExpr; } 186 int createFunctionMetadata(const JSTokenLocation&, const JSTokenLocation&, int, int, bool, int, int, int, ConstructorKind, SuperBinding, unsigned, SourceParseMode, bool ) { return FunctionBodyResult; }186 int createFunctionMetadata(const JSTokenLocation&, const JSTokenLocation&, int, int, bool, int, int, int, ConstructorKind, SuperBinding, unsigned, SourceParseMode, bool, ArrowFunctionCodeFeatures = NoArrowFunctionFeatures) { return FunctionBodyResult; } 187 187 ExpressionType createArrowFunctionExpr(const JSTokenLocation&, const ParserFunctionInfo<SyntaxChecker>&) { return FunctionExpr; } 188 188 void setFunctionNameStart(int, int) { } -
trunk/Source/JavaScriptCore/tests/stress/arrowfunction-lexical-bind-arguments-non-strict-1.js
r196886 r197033 215 215 testCase(boo('A' + i)('B' + i)('D' + i)('E' + i)('G' + i)[0], 'E' + i, txtMsg + "#17"); 216 216 } 217 218 var testValue = 'test-value'; 219 220 function f_args () { 221 if (true) { 222 let someValue = ''; 223 if (true) { 224 let anotherValue = 'value'; 225 return () => () => () => arguments[0]; 226 } 227 } 228 229 return () => 'no-value'; 230 } 231 232 for (var i = 0; i < 10000; i++) { 233 let v = f_args(testValue, 'anotherValue')()()(); 234 testCase(v, testValue); 235 } 236 237 function f_args_eval () { 238 if (true) { 239 let someValue = ''; 240 if (true) { 241 let anotherValue = 'value'; 242 return () => () => () => eval('arguments[0]'); 243 } 244 } 245 246 return () => 'no-value'; 247 } 248 249 for (var i = 0; i < 10000; i++) { 250 let v = f_args_eval(testValue, 'anotherValue')()()(); 251 testCase(v, testValue); 252 } -
trunk/Source/JavaScriptCore/tests/stress/arrowfunction-lexical-bind-arguments-strict.js
r196886 r197033 132 132 133 133 test(); 134 135 var testValue = 'test-value'; 136 137 function f_args () { 138 if (true) { 139 let someValue = ''; 140 if (true) { 141 let anotherValue = 'value'; 142 return () => () => () => arguments[0]; 143 } 144 } 145 146 return () => 'no-value'; 147 } 148 149 for (var i = 0; i < 10000; i++) { 150 let v = f_args(testValue, 'anotherValue')()()(); 151 testCase(v, testValue); 152 } 153 154 function f_args_eval () { 155 if (true) { 156 let someValue = ''; 157 if (true) { 158 let anotherValue = 'value'; 159 return () => () => () => eval('arguments[0]'); 160 } 161 } 162 163 return () => 'no-value'; 164 } 165 166 for (var i = 0; i < 10000; i++) { 167 let v = f_args_eval(testValue, 'anotherValue')()()(); 168 testCase(v, testValue); 169 } -
trunk/Source/JavaScriptCore/tests/stress/arrowfunction-lexical-bind-newtarget.js
r193766 r197033 67 67 } 68 68 catch (e) { 69 result = e instanceof ReferenceError; 69 result = e instanceof ReferenceError; 70 70 } 71 71 … … 77 77 testCase(tryToCreateClass(false), true, "Error: newTargetLocal should be hided variable"); 78 78 } 79 80 function getTargetBlockScope() { 81 if (true) { 82 let someValue = ''; 83 if (true) 84 return x => new.target; 85 } 86 return ()=>value; 87 } 88 89 for (var i = 0; i < 1000; i++) { 90 var undefinedTarget = getTargetBlockScope()() 91 testCase(undefinedTarget, undefined, "Error: new.target is not lexically binded inside of the arrow function #4"); 92 } -
trunk/Source/JavaScriptCore/tests/stress/arrowfunction-lexical-bind-superproperty.js
r196261 r197033 124 124 return super.getValue(); 125 125 } 126 127 getValueBlockScope() { 128 if (true) { 129 var someValue =''; 130 if (true) { 131 return () => { 132 if (true) { 133 let internalValue = ''; 134 return super.getValue(); 135 } 136 } 137 } 138 } 139 } 126 140 }; 127 141 … … 142 156 setValue('new-value'); 143 157 testCase(getValue(), 'new-value', 'Error: Some problem with using arrow and "super" inside of the method that retun arrow function'); 158 getValue = g1.getValueBlockScope(); 159 testCase(getValue(), 'new-value', 'Error: Some problem with using arrow and "super" with deep nesting inside of the method that retun arrow function'); 144 160 } 145 161
Note: See TracChangeset
for help on using the changeset viewer.