WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-155545-20160331224411.patch (text/plain), 43.68 KB, created by
GSkachkov
on 2016-03-31 12:44:09 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
GSkachkov
Created:
2016-03-31 12:44:09 PDT
Size:
43.68 KB
patch
obsolete
>Subversion Revision: 198849 >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index c112e2883917f5b6553b5b8b83eec436f214e898..5a9aa60c96d74399d411fb7e45defa83d26c1bec 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,58 @@ >+2016-03-31 Skachkov Oleksandr <gskachkov@gmail.com> >+ >+ [ES6] Class syntax. Access to new.target inside of the eval should not lead to SyntaxError >+ https://bugs.webkit.org/show_bug.cgi?id=155545 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Current patch allow to invoke new.target in eval if this eval is executed within function, >+ otherwise this will lead to Syntax error >+ >+ * bytecode/EvalCodeCache.h: >+ (JSC::EvalCodeCache::getSlow): >+ * bytecode/ExecutableInfo.h: >+ (JSC::ExecutableInfo::ExecutableInfo): >+ (JSC::ExecutableInfo::evalContextType): >+ * bytecode/UnlinkedCodeBlock.cpp: >+ (JSC::UnlinkedCodeBlock::UnlinkedCodeBlock): >+ * bytecode/UnlinkedCodeBlock.h: >+ (JSC::UnlinkedCodeBlock::evalContextType): >+ * bytecode/UnlinkedFunctionExecutable.cpp: >+ (JSC::generateUnlinkedFunctionCodeBlock): >+ * debugger/DebuggerCallFrame.cpp: >+ (JSC::DebuggerCallFrame::evaluate): >+ * interpreter/Interpreter.cpp: >+ (JSC::eval): >+ * parser/Parser.cpp: >+ (JSC::Parser<LexerType>::Parser): >+ (JSC::Parser<LexerType>::parseMemberExpression): >+ * parser/Parser.h: >+ (JSC::Scope::Scope): >+ (JSC::Scope::setEvalContextType): >+ (JSC::Scope::evalContextType): >+ (JSC::parse): >+ * runtime/CodeCache.cpp: >+ (JSC::CodeCache::getGlobalCodeBlock): >+ (JSC::CodeCache::getProgramCodeBlock): >+ (JSC::CodeCache::getEvalCodeBlock): >+ (JSC::CodeCache::getModuleProgramCodeBlock): >+ * runtime/CodeCache.h: >+ * runtime/Executable.cpp: >+ (JSC::ScriptExecutable::ScriptExecutable): >+ (JSC::EvalExecutable::create): >+ (JSC::EvalExecutable::EvalExecutable): >+ (JSC::ProgramExecutable::ProgramExecutable): >+ (JSC::ModuleProgramExecutable::ModuleProgramExecutable): >+ (JSC::FunctionExecutable::FunctionExecutable): >+ * runtime/Executable.h: >+ (JSC::ScriptExecutable::evalContextType): >+ * runtime/JSGlobalObject.cpp: >+ (JSC::JSGlobalObject::createEvalCodeBlock): >+ * runtime/JSGlobalObjectFunctions.cpp: >+ (JSC::globalFuncEval): >+ * tests/stress/arrowfunction-lexical-bind-newtarget.js: >+ * tests/stress/new-target.js: >+ > 2016-03-30 Keith Miller <keith_miller@apple.com> > > Unreviewed, buildfix. >diff --git a/Source/JavaScriptCore/bytecode/EvalCodeCache.h b/Source/JavaScriptCore/bytecode/EvalCodeCache.h >index e1c7b2b4716b9b2125c110e33a0de4822ad74b41..8f97010dc0b5649d28b2aed8f8433f5feb04ead3 100644 >--- a/Source/JavaScriptCore/bytecode/EvalCodeCache.h >+++ b/Source/JavaScriptCore/bytecode/EvalCodeCache.h >@@ -98,11 +98,11 @@ namespace JSC { > return nullptr; > } > >- EvalExecutable* getSlow(ExecState* exec, JSCell* owner, bool inStrictContext, ThisTDZMode thisTDZMode, DerivedContextType derivedContextType, bool isArrowFunctionContext, const String& evalSource, JSScope* scope) >+ EvalExecutable* getSlow(ExecState* exec, JSCell* owner, bool inStrictContext, ThisTDZMode thisTDZMode, DerivedContextType derivedContextType, bool isArrowFunctionContext, EvalContextType evalContextType, const String& evalSource, JSScope* scope) > { > VariableEnvironment variablesUnderTDZ; > JSScope::collectVariablesUnderTDZ(scope, variablesUnderTDZ); >- EvalExecutable* evalExecutable = EvalExecutable::create(exec, makeSource(evalSource), inStrictContext, thisTDZMode, derivedContextType, isArrowFunctionContext, &variablesUnderTDZ); >+ EvalExecutable* evalExecutable = EvalExecutable::create(exec, makeSource(evalSource), inStrictContext, thisTDZMode, derivedContextType, isArrowFunctionContext, evalContextType, &variablesUnderTDZ); > if (!evalExecutable) > return nullptr; > >diff --git a/Source/JavaScriptCore/bytecode/ExecutableInfo.h b/Source/JavaScriptCore/bytecode/ExecutableInfo.h >index a45d5039d3fa2cf304216c0242dbb8349ac9edaa..d1cb0cf72136341ab1d8b656e097c06aface5433 100644 >--- a/Source/JavaScriptCore/bytecode/ExecutableInfo.h >+++ b/Source/JavaScriptCore/bytecode/ExecutableInfo.h >@@ -31,11 +31,12 @@ > namespace JSC { > > enum class DerivedContextType : uint8_t { None, DerivedConstructorContext, DerivedMethodContext }; >+enum class EvalContextType : uint8_t { None, ProgramEvalContextType, FunctionEvalContextType }; > > // FIXME: These flags, ParserModes and propagation to XXXCodeBlocks should be reorganized. > // https://bugs.webkit.org/show_bug.cgi?id=151547 > struct ExecutableInfo { >- ExecutableInfo(bool usesEval, bool isStrictMode, bool isConstructor, bool isBuiltinFunction, ConstructorKind constructorKind, SuperBinding superBinding, SourceParseMode parseMode, DerivedContextType derivedContextType, bool isArrowFunctionContext, bool isClassContext) >+ ExecutableInfo(bool usesEval, bool isStrictMode, bool isConstructor, bool isBuiltinFunction, ConstructorKind constructorKind, SuperBinding superBinding, SourceParseMode parseMode, DerivedContextType derivedContextType, bool isArrowFunctionContext, bool isClassContext, EvalContextType evalContextType) > : m_usesEval(usesEval) > , m_isStrictMode(isStrictMode) > , m_isConstructor(isConstructor) >@@ -46,6 +47,7 @@ struct ExecutableInfo { > , m_derivedContextType(static_cast<unsigned>(derivedContextType)) > , m_isArrowFunctionContext(isArrowFunctionContext) > , m_isClassContext(isClassContext) >+ , m_evalContextType(static_cast<unsigned>(evalContextType)) > { > ASSERT(m_constructorKind == static_cast<unsigned>(constructorKind)); > ASSERT(m_superBinding == static_cast<unsigned>(superBinding)); >@@ -59,6 +61,7 @@ struct ExecutableInfo { > SuperBinding superBinding() const { return static_cast<SuperBinding>(m_superBinding); } > SourceParseMode parseMode() const { return m_parseMode; } > DerivedContextType derivedContextType() const { return static_cast<DerivedContextType>(m_derivedContextType); } >+ EvalContextType evalContextType() const { return static_cast<EvalContextType>(m_evalContextType); } > bool isArrowFunctionContext() const { return m_isArrowFunctionContext; } > bool isClassContext() const { return m_isClassContext; } > >@@ -73,6 +76,7 @@ private: > unsigned m_derivedContextType : 2; > unsigned m_isArrowFunctionContext : 1; > unsigned m_isClassContext : 1; >+ unsigned m_evalContextType : 2; > }; > > } // namespace JSC >diff --git a/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp b/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp >index 83d9054a345290cdaa0027d6e8edf5ee7b35ea2d..291065adf1b17830e14757cd9e7e402503d5d74b 100644 >--- a/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp >+++ b/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp >@@ -65,6 +65,7 @@ UnlinkedCodeBlock::UnlinkedCodeBlock(VM* vm, Structure* structure, CodeType code > , m_constructorKind(static_cast<unsigned>(info.constructorKind())) > , m_superBinding(static_cast<unsigned>(info.superBinding())) > , m_derivedContextType(static_cast<unsigned>(info.derivedContextType())) >+ , m_evalContextType(static_cast<unsigned>(info.evalContextType())) > , m_isArrowFunctionContext(info.isArrowFunctionContext()) > , m_isClassContext(info.isClassContext()) > , m_firstLine(0) >diff --git a/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h b/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h >index f5b2b44a92c11e1524073cbc05d94c02a52357cd..c69872a8095f2ad8af61e2313c9995e36e87ff96 100644 >--- a/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h >+++ b/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h >@@ -120,6 +120,7 @@ public: > SourceParseMode parseMode() const { return m_parseMode; } > bool isArrowFunction() const { return m_parseMode == SourceParseMode::ArrowFunctionMode; } > DerivedContextType derivedContextType() const { return static_cast<DerivedContextType>(m_derivedContextType); } >+ EvalContextType evalContextType() const { return static_cast<EvalContextType>(m_evalContextType); } > bool isArrowFunctionContext() const { return m_isArrowFunctionContext; } > bool isClassContext() const { return m_isClassContext; } > >@@ -397,6 +398,7 @@ private: > unsigned m_constructorKind : 2; > unsigned m_superBinding : 1; > unsigned m_derivedContextType : 2; >+ unsigned m_evalContextType : 2; > unsigned m_isArrowFunctionContext : 1; > unsigned m_isClassContext : 1; > unsigned m_firstLine; >diff --git a/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp b/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp >index 2b2cdd9d5f4aac88f0a099ad89db587648472b0b..815d2f03a7595bbc2c929213b9b783eb4c56bcef 100644 >--- a/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp >+++ b/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp >@@ -68,8 +68,7 @@ static UnlinkedFunctionCodeBlock* generateUnlinkedFunctionCodeBlock( > > bool isClassContext = executable->superBinding() == SuperBinding::Needed; > >- UnlinkedFunctionCodeBlock* result = UnlinkedFunctionCodeBlock::create(&vm, FunctionCode, >- ExecutableInfo(function->usesEval(), function->isStrictMode(), kind == CodeForConstruct, functionKind == UnlinkedBuiltinFunction, executable->constructorKind(), executable->superBinding(), parseMode, executable->derivedContextType(), false, isClassContext)); >+ UnlinkedFunctionCodeBlock* result = UnlinkedFunctionCodeBlock::create(&vm, FunctionCode, ExecutableInfo(function->usesEval(), function->isStrictMode(), kind == CodeForConstruct, functionKind == UnlinkedBuiltinFunction, executable->constructorKind(), executable->superBinding(), parseMode, executable->derivedContextType(), false, isClassContext, EvalContextType::FunctionEvalContextType)); > > auto generator(std::make_unique<BytecodeGenerator>(vm, function.get(), result, debuggerMode, profilerMode, executable->parentScopeTDZVariables())); > error = generator->generate(); >diff --git a/Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp b/Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp >index f4794fd4563e0b9f2ac8558b38b3f9ed334a5397..5767416bfa473bf7847be58abe888f1d76e09d94 100644 >--- a/Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp >+++ b/Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp >@@ -189,10 +189,19 @@ JSValue DebuggerCallFrame::evaluate(const String& script, NakedPtr<Exception>& e > auto& codeBlock = *callFrame->codeBlock(); > ThisTDZMode thisTDZMode = codeBlock.unlinkedCodeBlock()->constructorKind() == ConstructorKind::Derived ? ThisTDZMode::AlwaysCheck : ThisTDZMode::CheckIfNeeded; > >+ EvalContextType evalContextType; >+ >+ if (isFunctionParseMode(codeBlock.unlinkedCodeBlock()->parseMode())) >+ evalContextType = EvalContextType::FunctionEvalContextType; >+ else if (codeBlock.unlinkedCodeBlock()->codeType() == EvalCode) >+ evalContextType = codeBlock.unlinkedCodeBlock()->evalContextType(); >+ else >+ evalContextType = EvalContextType::ProgramEvalContextType; >+ > VariableEnvironment variablesUnderTDZ; > JSScope::collectVariablesUnderTDZ(scope()->jsScope(), variablesUnderTDZ); > >- EvalExecutable* eval = EvalExecutable::create(callFrame, makeSource(script), codeBlock.isStrictMode(), thisTDZMode, codeBlock.unlinkedCodeBlock()->derivedContextType(), codeBlock.unlinkedCodeBlock()->isArrowFunction(), &variablesUnderTDZ); >+ EvalExecutable* eval = EvalExecutable::create(callFrame, makeSource(script), codeBlock.isStrictMode(), thisTDZMode, codeBlock.unlinkedCodeBlock()->derivedContextType(), codeBlock.unlinkedCodeBlock()->isArrowFunction(), evalContextType, &variablesUnderTDZ); > if (vm.exception()) { > exception = vm.exception(); > vm.clearException(); >diff --git a/Source/JavaScriptCore/interpreter/Interpreter.cpp b/Source/JavaScriptCore/interpreter/Interpreter.cpp >index bbe77effcce3571f4682802a701835e7d3c3e3b0..760eea74ea63e0935e18de59777ce5d5a5fc6577 100644 >--- a/Source/JavaScriptCore/interpreter/Interpreter.cpp >+++ b/Source/JavaScriptCore/interpreter/Interpreter.cpp >@@ -187,8 +187,18 @@ JSValue eval(CallFrame* callFrame) > ? DerivedContextType::DerivedConstructorContext > : DerivedContextType::DerivedMethodContext; > } >+ >+ EvalContextType evalContextType; >+ >+ if (isFunctionParseMode(callerUnlinkedCodeBlock->parseMode())) >+ evalContextType = EvalContextType::FunctionEvalContextType; >+ else if (callerUnlinkedCodeBlock->codeType() == EvalCode) >+ evalContextType = callerUnlinkedCodeBlock->evalContextType(); >+ else >+ evalContextType = EvalContextType::ProgramEvalContextType; >+ >+ eval = callerCodeBlock->evalCodeCache().getSlow(callFrame, callerCodeBlock, callerCodeBlock->isStrictMode(), thisTDZMode, derivedContextType, isArrowFunctionContext, evalContextType, programSource, callerScopeChain); > >- eval = callerCodeBlock->evalCodeCache().getSlow(callFrame, callerCodeBlock, callerCodeBlock->isStrictMode(), thisTDZMode, derivedContextType, isArrowFunctionContext, programSource, callerScopeChain); > if (!eval) > return jsUndefined(); > } >diff --git a/Source/JavaScriptCore/parser/Parser.cpp b/Source/JavaScriptCore/parser/Parser.cpp >index 7ffb75b21415dd139669f51519d16763f7a9e948..4d38275935faaa8d3954ef75bec9913e97f4db54 100644 >--- a/Source/JavaScriptCore/parser/Parser.cpp >+++ b/Source/JavaScriptCore/parser/Parser.cpp >@@ -192,7 +192,7 @@ void Parser<LexerType>::logError(bool shouldPrintToken, const A& value1, const B > } > > template <typename LexerType> >-Parser<LexerType>::Parser(VM* vm, const SourceCode& source, JSParserBuiltinMode builtinMode, JSParserStrictMode strictMode, SourceParseMode parseMode, SuperBinding superBinding, ConstructorKind defaultConstructorKind, ThisTDZMode thisTDZMode, DerivedContextType derivedContextType, bool isEvalContext) >+Parser<LexerType>::Parser(VM* vm, const SourceCode& source, JSParserBuiltinMode builtinMode, JSParserStrictMode strictMode, SourceParseMode parseMode, SuperBinding superBinding, ConstructorKind defaultConstructorKind, ThisTDZMode thisTDZMode, DerivedContextType derivedContextType, bool isEvalContext, EvalContextType evalContextType) > : m_vm(vm) > , m_source(&source) > , m_hasStackOverflow(false) >@@ -217,6 +217,10 @@ Parser<LexerType>::Parser(VM* vm, const SourceCode& source, JSParserBuiltinMode > ScopeRef scope = pushScope(); > scope->setSourceParseMode(parseMode); > scope->setIsEvalContext(isEvalContext); >+ if (isEvalContext) { >+ ASSERT(evalContextType != EvalContextType::None); >+ scope->setEvalContextType(evalContextType); >+ } > > if (derivedContextType == DerivedContextType::DerivedConstructorContext) { > scope->setConstructorKind(ConstructorKind::Derived); >@@ -3829,7 +3833,7 @@ template <class TreeBuilder> TreeExpression Parser<LexerType>::parseMemberExpres > if (match(IDENT)) { > const Identifier* ident = m_token.m_data.ident; > if (m_vm->propertyNames->target == *ident) { >- semanticFailIfFalse(currentScope()->isFunction(), "new.target is only valid inside functions"); >+ semanticFailIfFalse(currentScope()->isFunction() || (closestParentOrdinaryFunctionNonLexicalScope()->isEvalContext() && closestParentOrdinaryFunctionNonLexicalScope()->evalContextType() == EvalContextType::FunctionEvalContextType), "new.target is only valid inside functions"); > baseIsNewTarget = true; > if (currentScope()->isArrowFunction()) > currentScope()->setInnerArrowFunctionUsesNewTarget(); >diff --git a/Source/JavaScriptCore/parser/Parser.h b/Source/JavaScriptCore/parser/Parser.h >index a96a031b16c0cedea6c4b5cca67663c7f975a4b1..55c1f75342f2a955b13f2bdc5a7a8fbdb60183b8 100644 >--- a/Source/JavaScriptCore/parser/Parser.h >+++ b/Source/JavaScriptCore/parser/Parser.h >@@ -185,6 +185,7 @@ public: > , m_isValidStrictMode(true) > , m_hasArguments(false) > , m_isEvalContext(false) >+ , m_evalContextType(static_cast<unsigned>(EvalContextType::None)) > , m_constructorKind(static_cast<unsigned>(ConstructorKind::None)) > , m_expectedSuperBinding(static_cast<unsigned>(SuperBinding::NotNeeded)) > , m_loopDepth(0) >@@ -480,6 +481,9 @@ public: > bool needsSuperBinding() { return m_needsSuperBinding; } > void setNeedsSuperBinding() { m_needsSuperBinding = true; } > >+ void setEvalContextType(EvalContextType evalContextType) { m_evalContextType = static_cast<unsigned>(evalContextType); } >+ EvalContextType evalContextType() { return static_cast<EvalContextType>(m_evalContextType); } >+ > InnerArrowFunctionCodeFeatures innerArrowFunctionFeatures() { return m_innerArrowFunctionFeatures; } > > void setExpectedSuperBinding(SuperBinding superBinding) { m_expectedSuperBinding = static_cast<unsigned>(superBinding); } >@@ -679,6 +683,7 @@ private: > bool m_isValidStrictMode; > bool m_hasArguments; > bool m_isEvalContext; >+ unsigned m_evalContextType; > unsigned m_constructorKind; > unsigned m_expectedSuperBinding; > int m_loopDepth; >@@ -735,7 +740,7 @@ class Parser { > WTF_MAKE_FAST_ALLOCATED; > > public: >- Parser(VM*, const SourceCode&, JSParserBuiltinMode, JSParserStrictMode, SourceParseMode, SuperBinding, ConstructorKind defaultConstructorKind = ConstructorKind::None, ThisTDZMode = ThisTDZMode::CheckIfNeeded, DerivedContextType = DerivedContextType::None, bool isEvalContext = false); >+ Parser(VM*, const SourceCode&, JSParserBuiltinMode, JSParserStrictMode, SourceParseMode, SuperBinding, ConstructorKind defaultConstructorKind = ConstructorKind::None, ThisTDZMode = ThisTDZMode::CheckIfNeeded, DerivedContextType = DerivedContextType::None, bool isEvalContext = false, EvalContextType = EvalContextType::None); > ~Parser(); > > template <class ParsedNode> >@@ -1617,12 +1622,12 @@ std::unique_ptr<ParsedNode> parse( > const Identifier& name, JSParserBuiltinMode builtinMode, > JSParserStrictMode strictMode, SourceParseMode parseMode, SuperBinding superBinding, > ParserError& error, JSTextPosition* positionBeforeLastNewline = nullptr, >- ConstructorKind defaultConstructorKind = ConstructorKind::None, ThisTDZMode thisTDZMode = ThisTDZMode::CheckIfNeeded, >- DerivedContextType derivedContextType = DerivedContextType::None) >+ ConstructorKind defaultConstructorKind = ConstructorKind::None, ThisTDZMode thisTDZMode = ThisTDZMode::CheckIfNeeded, >+ DerivedContextType derivedContextType = DerivedContextType::None, EvalContextType evalContextType = EvalContextType::None) > { > ASSERT(!source.provider()->source().isNull()); > if (source.provider()->source().is8Bit()) { >- Parser<Lexer<LChar>> parser(vm, source, builtinMode, strictMode, parseMode, superBinding, defaultConstructorKind, thisTDZMode, derivedContextType, isEvalNode<ParsedNode>()); >+ Parser<Lexer<LChar>> parser(vm, source, builtinMode, strictMode, parseMode, superBinding, defaultConstructorKind, thisTDZMode, derivedContextType, isEvalNode<ParsedNode>(), evalContextType); > std::unique_ptr<ParsedNode> result = parser.parse<ParsedNode>(error, name, parseMode); > if (positionBeforeLastNewline) > *positionBeforeLastNewline = parser.positionBeforeLastNewline(); >diff --git a/Source/JavaScriptCore/runtime/CodeCache.cpp b/Source/JavaScriptCore/runtime/CodeCache.cpp >index 63dc24f941991a0d0f749222da857cd644ee8752..debac2b448ffd2f75764660e0e01abfde8ae438e 100644 >--- a/Source/JavaScriptCore/runtime/CodeCache.cpp >+++ b/Source/JavaScriptCore/runtime/CodeCache.cpp >@@ -29,6 +29,7 @@ > > #include "BytecodeGenerator.h" > #include "CodeSpecializationKind.h" >+#include "ExecutableInfo.h" > #include "JSCInlines.h" > #include "Parser.h" > #include "StrongInlines.h" >@@ -83,7 +84,7 @@ template <> struct CacheTypes<UnlinkedModuleProgramCodeBlock> { > }; > > template <class UnlinkedCodeBlockType, class ExecutableType> >-UnlinkedCodeBlockType* CodeCache::getGlobalCodeBlock(VM& vm, ExecutableType* executable, const SourceCode& source, JSParserBuiltinMode builtinMode, JSParserStrictMode strictMode, ThisTDZMode thisTDZMode, bool, DebuggerMode debuggerMode, ProfilerMode profilerMode, ParserError& error, const VariableEnvironment* variablesUnderTDZ) >+UnlinkedCodeBlockType* CodeCache::getGlobalCodeBlock(VM& vm, ExecutableType* executable, const SourceCode& source, JSParserBuiltinMode builtinMode, JSParserStrictMode strictMode, ThisTDZMode thisTDZMode, bool, DebuggerMode debuggerMode, ProfilerMode profilerMode, ParserError& error, EvalContextType evalContextType, const VariableEnvironment* variablesUnderTDZ) > { > SourceCodeKey key = SourceCodeKey(source, String(), CacheTypes<UnlinkedCodeBlockType>::codeType, builtinMode, strictMode, thisTDZMode); > SourceCodeValue* cache = m_sourceCode.findCacheAndUpdateAge(key); >@@ -103,7 +104,7 @@ UnlinkedCodeBlockType* CodeCache::getGlobalCodeBlock(VM& vm, ExecutableType* exe > typedef typename CacheTypes<UnlinkedCodeBlockType>::RootNode RootNode; > DerivedContextType derivedContextType = executable->derivedContextType(); > std::unique_ptr<RootNode> rootNode = parse<RootNode>( >- &vm, source, Identifier(), builtinMode, strictMode, CacheTypes<UnlinkedCodeBlockType>::parseMode, SuperBinding::NotNeeded, error, nullptr, ConstructorKind::None, thisTDZMode, derivedContextType); >+ &vm, source, Identifier(), builtinMode, strictMode, CacheTypes<UnlinkedCodeBlockType>::parseMode, SuperBinding::NotNeeded, error, nullptr, ConstructorKind::None, thisTDZMode, derivedContextType, evalContextType); > if (!rootNode) > return nullptr; > >@@ -133,18 +134,18 @@ UnlinkedCodeBlockType* CodeCache::getGlobalCodeBlock(VM& vm, ExecutableType* exe > UnlinkedProgramCodeBlock* CodeCache::getProgramCodeBlock(VM& vm, ProgramExecutable* executable, const SourceCode& source, JSParserBuiltinMode builtinMode, JSParserStrictMode strictMode, DebuggerMode debuggerMode, ProfilerMode profilerMode, ParserError& error) > { > VariableEnvironment emptyParentTDZVariables; >- return getGlobalCodeBlock<UnlinkedProgramCodeBlock>(vm, executable, source, builtinMode, strictMode, ThisTDZMode::CheckIfNeeded, false, debuggerMode, profilerMode, error, &emptyParentTDZVariables); >+ return getGlobalCodeBlock<UnlinkedProgramCodeBlock>(vm, executable, source, builtinMode, strictMode, ThisTDZMode::CheckIfNeeded, false, debuggerMode, profilerMode, error, EvalContextType::ProgramEvalContextType, &emptyParentTDZVariables); > } > >-UnlinkedEvalCodeBlock* CodeCache::getEvalCodeBlock(VM& vm, EvalExecutable* executable, const SourceCode& source, JSParserBuiltinMode builtinMode, JSParserStrictMode strictMode, ThisTDZMode thisTDZMode, bool isArrowFunctionContext, DebuggerMode debuggerMode, ProfilerMode profilerMode, ParserError& error, const VariableEnvironment* variablesUnderTDZ) >+UnlinkedEvalCodeBlock* CodeCache::getEvalCodeBlock(VM& vm, EvalExecutable* executable, const SourceCode& source, JSParserBuiltinMode builtinMode, JSParserStrictMode strictMode, ThisTDZMode thisTDZMode, bool isArrowFunctionContext, DebuggerMode debuggerMode, ProfilerMode profilerMode, ParserError& error, EvalContextType evalContextType, const VariableEnvironment* variablesUnderTDZ) > { >- return getGlobalCodeBlock<UnlinkedEvalCodeBlock>(vm, executable, source, builtinMode, strictMode, thisTDZMode, isArrowFunctionContext, debuggerMode, profilerMode, error, variablesUnderTDZ); >+ return getGlobalCodeBlock<UnlinkedEvalCodeBlock>(vm, executable, source, builtinMode, strictMode, thisTDZMode, isArrowFunctionContext, debuggerMode, profilerMode, error, evalContextType, variablesUnderTDZ); > } > > UnlinkedModuleProgramCodeBlock* CodeCache::getModuleProgramCodeBlock(VM& vm, ModuleProgramExecutable* executable, const SourceCode& source, JSParserBuiltinMode builtinMode, DebuggerMode debuggerMode, ProfilerMode profilerMode, ParserError& error) > { > VariableEnvironment emptyParentTDZVariables; >- return getGlobalCodeBlock<UnlinkedModuleProgramCodeBlock>(vm, executable, source, builtinMode, JSParserStrictMode::Strict, ThisTDZMode::CheckIfNeeded, false, debuggerMode, profilerMode, error, &emptyParentTDZVariables); >+ return getGlobalCodeBlock<UnlinkedModuleProgramCodeBlock>(vm, executable, source, builtinMode, JSParserStrictMode::Strict, ThisTDZMode::CheckIfNeeded, false, debuggerMode, profilerMode, error, EvalContextType::ProgramEvalContextType, &emptyParentTDZVariables); > } > > // FIXME: There's no need to add the function's name to the key here. It's already in the source code. >diff --git a/Source/JavaScriptCore/runtime/CodeCache.h b/Source/JavaScriptCore/runtime/CodeCache.h >index 2132f0c1946c04440329bec622230e20c1b8334c..6baab02e52bd6f2d3076037c502d79cae0de161b 100644 >--- a/Source/JavaScriptCore/runtime/CodeCache.h >+++ b/Source/JavaScriptCore/runtime/CodeCache.h >@@ -27,6 +27,7 @@ > #define CodeCache_h > > #include "CodeSpecializationKind.h" >+#include "ExecutableInfo.h" > #include "ParserModes.h" > #include "SourceCode.h" > #include "SourceCodeKey.h" >@@ -194,7 +195,7 @@ public: > ~CodeCache(); > > UnlinkedProgramCodeBlock* getProgramCodeBlock(VM&, ProgramExecutable*, const SourceCode&, JSParserBuiltinMode, JSParserStrictMode, DebuggerMode, ProfilerMode, ParserError&); >- UnlinkedEvalCodeBlock* getEvalCodeBlock(VM&, EvalExecutable*, const SourceCode&, JSParserBuiltinMode, JSParserStrictMode, ThisTDZMode, bool, DebuggerMode, ProfilerMode, ParserError&, const VariableEnvironment*); >+ UnlinkedEvalCodeBlock* getEvalCodeBlock(VM&, EvalExecutable*, const SourceCode&, JSParserBuiltinMode, JSParserStrictMode, ThisTDZMode, bool, DebuggerMode, ProfilerMode, ParserError&, EvalContextType, const VariableEnvironment*); > UnlinkedModuleProgramCodeBlock* getModuleProgramCodeBlock(VM&, ModuleProgramExecutable*, const SourceCode&, JSParserBuiltinMode, DebuggerMode, ProfilerMode, ParserError&); > UnlinkedFunctionExecutable* getFunctionExecutableFromGlobalCode(VM&, const Identifier&, const SourceCode&, ParserError&); > >@@ -205,7 +206,7 @@ public: > > private: > template <class UnlinkedCodeBlockType, class ExecutableType> >- UnlinkedCodeBlockType* getGlobalCodeBlock(VM&, ExecutableType*, const SourceCode&, JSParserBuiltinMode, JSParserStrictMode, ThisTDZMode, bool, DebuggerMode, ProfilerMode, ParserError&, const VariableEnvironment*); >+ UnlinkedCodeBlockType* getGlobalCodeBlock(VM&, ExecutableType*, const SourceCode&, JSParserBuiltinMode, JSParserStrictMode, ThisTDZMode, bool, DebuggerMode, ProfilerMode, ParserError&, EvalContextType, const VariableEnvironment*); > > CodeCacheMap m_sourceCode; > }; >diff --git a/Source/JavaScriptCore/runtime/Executable.cpp b/Source/JavaScriptCore/runtime/Executable.cpp >index 2fdb5326939e69e6198d83a7d0cf686d0dbd9f3d..7be73984ee0c852bd2ae16960044380d21a4bd56 100644 >--- a/Source/JavaScriptCore/runtime/Executable.cpp >+++ b/Source/JavaScriptCore/runtime/Executable.cpp >@@ -110,7 +110,7 @@ void NativeExecutable::destroy(JSCell* cell) > > const ClassInfo ScriptExecutable::s_info = { "ScriptExecutable", &ExecutableBase::s_info, 0, CREATE_METHOD_TABLE(ScriptExecutable) }; > >-ScriptExecutable::ScriptExecutable(Structure* structure, VM& vm, const SourceCode& source, bool isInStrictContext, DerivedContextType derivedContextType, bool isInArrowFunctionContext, Intrinsic intrinsic) >+ScriptExecutable::ScriptExecutable(Structure* structure, VM& vm, const SourceCode& source, bool isInStrictContext, DerivedContextType derivedContextType, bool isInArrowFunctionContext, EvalContextType evalContextType, Intrinsic intrinsic) > : ExecutableBase(vm, structure, NUM_PARAMETERS_NOT_COMPILED, intrinsic) > , m_features(isInStrictContext ? StrictModeFeature : 0) > , m_didTryToEnterInLoop(false) >@@ -119,6 +119,7 @@ ScriptExecutable::ScriptExecutable(Structure* structure, VM& vm, const SourceCod > , m_neverOptimize(false) > , m_isArrowFunctionContext(isInArrowFunctionContext) > , m_derivedContextType(static_cast<unsigned>(derivedContextType)) >+ , m_evalContextType(static_cast<unsigned>(evalContextType)) > , m_overrideLineNumber(-1) > , m_firstLine(-1) > , m_lastLine(-1) >@@ -394,7 +395,7 @@ JSObject* ScriptExecutable::prepareForExecutionImpl( > > const ClassInfo EvalExecutable::s_info = { "EvalExecutable", &ScriptExecutable::s_info, 0, CREATE_METHOD_TABLE(EvalExecutable) }; > >-EvalExecutable* EvalExecutable::create(ExecState* exec, const SourceCode& source, bool isInStrictContext, ThisTDZMode thisTDZMode, DerivedContextType derivedContextType, bool isArrowFunctionContext, const VariableEnvironment* variablesUnderTDZ) >+EvalExecutable* EvalExecutable::create(ExecState* exec, const SourceCode& source, bool isInStrictContext, ThisTDZMode thisTDZMode, DerivedContextType derivedContextType, bool isArrowFunctionContext, EvalContextType evalContextType, const VariableEnvironment* variablesUnderTDZ) > { > JSGlobalObject* globalObject = exec->lexicalGlobalObject(); > if (!globalObject->evalEnabled()) { >@@ -402,7 +403,7 @@ EvalExecutable* EvalExecutable::create(ExecState* exec, const SourceCode& source > return 0; > } > >- EvalExecutable* executable = new (NotNull, allocateCell<EvalExecutable>(*exec->heap())) EvalExecutable(exec, source, isInStrictContext, derivedContextType, isArrowFunctionContext); >+ EvalExecutable* executable = new (NotNull, allocateCell<EvalExecutable>(*exec->heap())) EvalExecutable(exec, source, isInStrictContext, derivedContextType, isArrowFunctionContext, evalContextType); > executable->finishCreation(exec->vm()); > > UnlinkedEvalCodeBlock* unlinkedEvalCode = globalObject->createEvalCodeBlock(exec, executable, thisTDZMode, isArrowFunctionContext, variablesUnderTDZ); >@@ -414,8 +415,8 @@ EvalExecutable* EvalExecutable::create(ExecState* exec, const SourceCode& source > return executable; > } > >-EvalExecutable::EvalExecutable(ExecState* exec, const SourceCode& source, bool inStrictContext, DerivedContextType derivedContextType, bool isArrowFunctionContext) >- : ScriptExecutable(exec->vm().evalExecutableStructure.get(), exec->vm(), source, inStrictContext, derivedContextType, isArrowFunctionContext, NoIntrinsic) >+EvalExecutable::EvalExecutable(ExecState* exec, const SourceCode& source, bool inStrictContext, DerivedContextType derivedContextType, bool isArrowFunctionContext, EvalContextType evalContextType) >+ : ScriptExecutable(exec->vm().evalExecutableStructure.get(), exec->vm(), source, inStrictContext, derivedContextType, isArrowFunctionContext, evalContextType, NoIntrinsic) > { > } > >@@ -427,7 +428,7 @@ void EvalExecutable::destroy(JSCell* cell) > const ClassInfo ProgramExecutable::s_info = { "ProgramExecutable", &ScriptExecutable::s_info, 0, CREATE_METHOD_TABLE(ProgramExecutable) }; > > ProgramExecutable::ProgramExecutable(ExecState* exec, const SourceCode& source) >- : ScriptExecutable(exec->vm().programExecutableStructure.get(), exec->vm(), source, false, DerivedContextType::None, false, NoIntrinsic) >+ : ScriptExecutable(exec->vm().programExecutableStructure.get(), exec->vm(), source, false, DerivedContextType::None, false, EvalContextType::None, NoIntrinsic) > { > m_typeProfilingStartOffset = 0; > m_typeProfilingEndOffset = source.length() - 1; >@@ -443,7 +444,7 @@ void ProgramExecutable::destroy(JSCell* cell) > const ClassInfo ModuleProgramExecutable::s_info = { "ModuleProgramExecutable", &ScriptExecutable::s_info, 0, CREATE_METHOD_TABLE(ModuleProgramExecutable) }; > > ModuleProgramExecutable::ModuleProgramExecutable(ExecState* exec, const SourceCode& source) >- : ScriptExecutable(exec->vm().moduleProgramExecutableStructure.get(), exec->vm(), source, false, DerivedContextType::None, false, NoIntrinsic) >+ : ScriptExecutable(exec->vm().moduleProgramExecutableStructure.get(), exec->vm(), source, false, DerivedContextType::None, false, EvalContextType::None, NoIntrinsic) > { > m_typeProfilingStartOffset = 0; > m_typeProfilingEndOffset = source.length() - 1; >@@ -475,7 +476,7 @@ void ModuleProgramExecutable::destroy(JSCell* cell) > const ClassInfo FunctionExecutable::s_info = { "FunctionExecutable", &ScriptExecutable::s_info, 0, CREATE_METHOD_TABLE(FunctionExecutable) }; > > FunctionExecutable::FunctionExecutable(VM& vm, const SourceCode& source, UnlinkedFunctionExecutable* unlinkedExecutable, unsigned firstLine, unsigned lastLine, unsigned startColumn, unsigned endColumn, Intrinsic intrinsic) >- : ScriptExecutable(vm.functionExecutableStructure.get(), vm, source, unlinkedExecutable->isInStrictContext(), unlinkedExecutable->derivedContextType(), false, intrinsic) >+ : ScriptExecutable(vm.functionExecutableStructure.get(), vm, source, unlinkedExecutable->isInStrictContext(), unlinkedExecutable->derivedContextType(), false, EvalContextType::None, intrinsic) > , m_unlinkedExecutable(vm, this, unlinkedExecutable) > { > RELEASE_ASSERT(!source.isNull()); >diff --git a/Source/JavaScriptCore/runtime/Executable.h b/Source/JavaScriptCore/runtime/Executable.h >index 95f077ac5cf0605d152b33c311d01e12886ff60c..537c57c8c196fb4048022177536d5d41b3dd42aa 100644 >--- a/Source/JavaScriptCore/runtime/Executable.h >+++ b/Source/JavaScriptCore/runtime/Executable.h >@@ -351,6 +351,7 @@ public: > bool isArrowFunctionContext() const { return m_isArrowFunctionContext; } > bool isStrictMode() const { return m_features & StrictModeFeature; } > DerivedContextType derivedContextType() const { return static_cast<DerivedContextType>(m_derivedContextType); } >+ EvalContextType evalContextType() const { return static_cast<EvalContextType>(m_evalContextType); } > > ECMAMode ecmaMode() const { return isStrictMode() ? StrictMode : NotStrictMode; } > >@@ -400,7 +401,7 @@ private: > JSObject* prepareForExecutionImpl(ExecState*, JSFunction*, JSScope*, CodeSpecializationKind); > > protected: >- ScriptExecutable(Structure*, VM&, const SourceCode&, bool isInStrictContext, DerivedContextType, bool isInArrowFunctionContext, Intrinsic); >+ ScriptExecutable(Structure*, VM&, const SourceCode&, bool isInStrictContext, DerivedContextType, bool isInArrowFunctionContext, EvalContextType, Intrinsic); > > void finishCreation(VM& vm) > { >@@ -420,6 +421,7 @@ protected: > bool m_neverOptimize : 1; > bool m_isArrowFunctionContext : 1; > unsigned m_derivedContextType : 2; // DerivedContextType >+ unsigned m_evalContextType : 2; // EvalContextType > > int m_overrideLineNumber; > int m_firstLine; >@@ -444,7 +446,7 @@ public: > return m_evalCodeBlock.get(); > } > >- static EvalExecutable* create(ExecState*, const SourceCode&, bool isInStrictContext, ThisTDZMode, DerivedContextType, bool isArrowFunctionContext, const VariableEnvironment*); >+ static EvalExecutable* create(ExecState*, const SourceCode&, bool isInStrictContext, ThisTDZMode, DerivedContextType, bool isArrowFunctionContext, EvalContextType, const VariableEnvironment*); > > PassRefPtr<JITCode> generatedJITCode() > { >@@ -458,7 +460,7 @@ public: > > DECLARE_INFO; > >- ExecutableInfo executableInfo() const { return ExecutableInfo(usesEval(), isStrictMode(), false, false, ConstructorKind::None, SuperBinding::NotNeeded, SourceParseMode::ProgramMode, derivedContextType(), isArrowFunctionContext() , false); } >+ ExecutableInfo executableInfo() const { return ExecutableInfo(usesEval(), isStrictMode(), false, false, ConstructorKind::None, SuperBinding::NotNeeded, SourceParseMode::ProgramMode, derivedContextType(), isArrowFunctionContext(), false, evalContextType()); } > > unsigned numVariables() { return m_unlinkedEvalCodeBlock->numVariables(); } > unsigned numberOfFunctionDecls() { return m_unlinkedEvalCodeBlock->numberOfFunctionDecls(); } >@@ -467,7 +469,7 @@ private: > friend class ExecutableBase; > friend class ScriptExecutable; > >- EvalExecutable(ExecState*, const SourceCode&, bool inStrictContext, DerivedContextType, bool isArrowFunctionContext); >+ EvalExecutable(ExecState*, const SourceCode&, bool inStrictContext, DerivedContextType, bool isArrowFunctionContext, EvalContextType); > > static void visitChildren(JSCell*, SlotVisitor&); > >@@ -512,7 +514,7 @@ public: > > DECLARE_INFO; > >- ExecutableInfo executableInfo() const { return ExecutableInfo(usesEval(), isStrictMode(), false, false, ConstructorKind::None, SuperBinding::NotNeeded, SourceParseMode::ProgramMode, derivedContextType(), isArrowFunctionContext(), false); } >+ ExecutableInfo executableInfo() const { return ExecutableInfo(usesEval(), isStrictMode(), false, false, ConstructorKind::None, SuperBinding::NotNeeded, SourceParseMode::ProgramMode, derivedContextType(), isArrowFunctionContext(), false, EvalContextType::None); } > > private: > friend class ExecutableBase; >@@ -553,7 +555,7 @@ public: > > DECLARE_INFO; > >- ExecutableInfo executableInfo() const { return ExecutableInfo(usesEval(), isStrictMode(), false, false, ConstructorKind::None, SuperBinding::NotNeeded, SourceParseMode::ModuleEvaluateMode, derivedContextType(), isArrowFunctionContext(), false); } >+ ExecutableInfo executableInfo() const { return ExecutableInfo(usesEval(), isStrictMode(), false, false, ConstructorKind::None, SuperBinding::NotNeeded, SourceParseMode::ModuleEvaluateMode, derivedContextType(), isArrowFunctionContext(), false, EvalContextType::None); } > > UnlinkedModuleProgramCodeBlock* unlinkedModuleProgramCodeBlock() { return m_unlinkedModuleProgramCodeBlock.get(); } > >diff --git a/Source/JavaScriptCore/runtime/JSGlobalObject.cpp b/Source/JavaScriptCore/runtime/JSGlobalObject.cpp >index 79d999462df10750d9bf1ee15ea679a070208497..28485e524e448149f1a0baa848e0f09db7d776a7 100644 >--- a/Source/JavaScriptCore/runtime/JSGlobalObject.cpp >+++ b/Source/JavaScriptCore/runtime/JSGlobalObject.cpp >@@ -1026,9 +1026,11 @@ UnlinkedEvalCodeBlock* JSGlobalObject::createEvalCodeBlock(CallFrame* callFrame, > ParserError error; > JSParserStrictMode strictMode = executable->isStrictMode() ? JSParserStrictMode::Strict : JSParserStrictMode::NotStrict; > DebuggerMode debuggerMode = hasInteractiveDebugger() ? DebuggerOn : DebuggerOff; >+ EvalContextType evalContextType = executable->executableInfo().evalContextType(); >+ > ProfilerMode profilerMode = hasLegacyProfiler() ? ProfilerOn : ProfilerOff; > UnlinkedEvalCodeBlock* unlinkedCodeBlock = vm().codeCache()->getEvalCodeBlock( >- vm(), executable, executable->source(), JSParserBuiltinMode::NotBuiltin, strictMode, thisTDZMode, isArrowFunctionContext, debuggerMode, profilerMode, error, variablesUnderTDZ); >+ vm(), executable, executable->source(), JSParserBuiltinMode::NotBuiltin, strictMode, thisTDZMode, isArrowFunctionContext, debuggerMode, profilerMode, error, evalContextType, variablesUnderTDZ); > > if (hasDebugger()) > debugger()->sourceParsed(callFrame, executable->source().provider(), error.line(), error.message()); >diff --git a/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp b/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp >index 11744c465fbbdb8d6f9c95c0286613d07ff6c850..a461a90d6cc59da43a605cea17a94ffe7e065e59 100644 >--- a/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp >+++ b/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp >@@ -589,7 +589,7 @@ EncodedJSValue JSC_HOST_CALL globalFuncEval(ExecState* exec) > > JSGlobalObject* calleeGlobalObject = exec->callee()->globalObject(); > VariableEnvironment emptyTDZVariables; // Indirect eval does not have access to the lexical scope. >- EvalExecutable* eval = EvalExecutable::create(exec, makeSource(s), false, ThisTDZMode::CheckIfNeeded, DerivedContextType::None, false, &emptyTDZVariables); >+ EvalExecutable* eval = EvalExecutable::create(exec, makeSource(s), false, ThisTDZMode::CheckIfNeeded, DerivedContextType::None, false, EvalContextType::ProgramEvalContextType, &emptyTDZVariables); > if (!eval) > return JSValue::encode(jsUndefined()); > >diff --git a/Source/JavaScriptCore/tests/stress/arrowfunction-lexical-bind-newtarget.js b/Source/JavaScriptCore/tests/stress/arrowfunction-lexical-bind-newtarget.js >index 032664d110d55cad340318dcfa8a3b63f8e0865b..636401782614e33c054edb86b1d9ddb152a614f8 100644 >--- a/Source/JavaScriptCore/tests/stress/arrowfunction-lexical-bind-newtarget.js >+++ b/Source/JavaScriptCore/tests/stress/arrowfunction-lexical-bind-newtarget.js >@@ -138,3 +138,57 @@ for (var i = 0; i < 1000; i++) { > var parentNewTarget = e.getParentNewTarget(); > testCase(parentNewTarget, undefined, "Error: new.target is not lexically binded inside of the arrow function #5"); > } >+ >+ >+class F { >+ constructor() { >+ let c; >+ eval('c=(()=>new.target===F)()'); >+ this.result = c; >+ } >+ getNewTargetFromEval() { >+ return eval('(()=>new.target===F)()'); >+ } >+} >+ >+var f = new F(); >+ >+testCase(f.result, true, "Error: new.target is not lexically binded inside of the arrow function #6"); >+testCase(f.getNewTargetFromEval(), false, "Error: new.target is not lexically binded inside of the arrow function #7"); >+ >+class G extends A { >+ constructor() { >+ var arr; >+ super(); >+ eval('arr = () => new.target'); >+ this.arrow = arr; >+ } >+} >+ >+let g = new G(); >+ >+testCase(g.arrow(), G, "Error: new.target is not lexically binded inside of the arrow function #8"); >+ >+class H extends A { >+ constructor() { >+ var arr; >+ super(); >+ eval('arr = () => eval("(() => new.target)()")'); >+ this.arrow = arr; >+ } >+} >+ >+let h = new H(); >+ >+testCase(h.arrow(), H, "Error: new.target is not lexically binded inside of the arrow function #9"); >+ >+class J extends A { >+ constructor() { >+ super(); >+ this.result = eval('eval("(() => new.target)()")'); >+ } >+} >+ >+let j = new J(); >+ >+testCase(j.result, J, "Error: new.target is not lexically binded inside of the arrow function #10"); >diff --git a/Source/JavaScriptCore/tests/stress/new-target.js b/Source/JavaScriptCore/tests/stress/new-target.js >index e24664c1edfb66a33e5070e59aabca4129dcd728..9875236920bff1b6a3b35c42448a0ce6bd3748cb 100644 >--- a/Source/JavaScriptCore/tests/stress/new-target.js >+++ b/Source/JavaScriptCore/tests/stress/new-target.js >@@ -6,6 +6,17 @@ try { > > test(passed, true, "new.target cannot be called in global scope"); > >+passed = true; >+try { >+ eval("eval(\"eval('new.target;')\")"); >+ passed = false; >+} catch(e) { >+ passed = e instanceof SyntaxError; >+} >+ >+test(passed, true, "new.target cannot be called in global scope"); >+ >+ > // Test without class syntax > > function test(result, expected, message) { >@@ -62,3 +73,55 @@ class SubClass extends SuperClass { > > test(new SuperClass().target, SuperClass, "new.target should be the same as the class constructor"); > test(new SubClass().target, SubClass, "new.target should not change when passed through super()"); >+ >+class A {} >+ >+class B extends A { >+ constructor() { >+ super(); >+ this.target = eval('new.target'); >+ } >+} >+ >+class C extends A { >+ constructor() { >+ super(); >+ this.target = eval("eval('new.target')"); >+ } >+} >+ >+class D extends A { >+ constructor() { >+ super(); >+ this.target = eval("eval('(function () { return new.target; })()')"); >+ } >+} >+ >+test(new B().target, B, "new.target should be the same in eval as without eval"); >+test(new C().target, C, "new.target should be the same in double eval as without eval"); >+test(new D().target, undefined, "new.target should be the same in double eval as without eval"); >+ >+var newTargetInEval = function () { >+ var result; >+ var klass = function () { >+ result = eval('new.target'); >+ }; >+ klass(); >+ test(result, undefined, "new.target should be the same in eval as without eval"); >+ new klass(); >+ test(result, klass, "new.target should be the same in eval as without eval"); >+} >+newTargetInEval(); >+ >+var newTargetInFunctionInEval = function () { >+ var result; >+ var klass = function () { >+ result = eval('(function () { return new.target;})()'); >+ }; >+ klass(); >+ test(result, undefined, "new.target should be the same in eval as without eval"); >+ new klass(); >+ test(result, undefined, "new.target should be the same in eval as without eval"); >+ >+}; >+newTargetInFunctionInEval();
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 155545
:
275208
|
275209
|
275212
|
275311
|
275321
|
275411
|
275472