Ignore:
Timestamp:
Apr 3, 2016, 12:59:19 AM (9 years ago)
Author:
[email protected]
Message:

[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 Saam Barati.

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:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp

    r194449 r198980  
    190190    ThisTDZMode thisTDZMode = codeBlock.unlinkedCodeBlock()->constructorKind() == ConstructorKind::Derived ? ThisTDZMode::AlwaysCheck : ThisTDZMode::CheckIfNeeded;
    191191
     192    EvalContextType evalContextType;
     193   
     194    if (isFunctionParseMode(codeBlock.unlinkedCodeBlock()->parseMode()))
     195        evalContextType = EvalContextType::FunctionEvalContext;
     196    else if (codeBlock.unlinkedCodeBlock()->codeType() == EvalCode)
     197        evalContextType = codeBlock.unlinkedCodeBlock()->evalContextType();
     198    else
     199        evalContextType = EvalContextType::None;
     200
    192201    VariableEnvironment variablesUnderTDZ;
    193202    JSScope::collectVariablesUnderTDZ(scope()->jsScope(), variablesUnderTDZ);
    194203
    195     EvalExecutable* eval = EvalExecutable::create(callFrame, makeSource(script), codeBlock.isStrictMode(), thisTDZMode, codeBlock.unlinkedCodeBlock()->derivedContextType(), codeBlock.unlinkedCodeBlock()->isArrowFunction(), &variablesUnderTDZ);
     204    EvalExecutable* eval = EvalExecutable::create(callFrame, makeSource(script), codeBlock.isStrictMode(), thisTDZMode, codeBlock.unlinkedCodeBlock()->derivedContextType(), codeBlock.unlinkedCodeBlock()->isArrowFunction(), evalContextType, &variablesUnderTDZ);
    196205    if (vm.exception()) {
    197206        exception = vm.exception();
Note: See TracChangeset for help on using the changeset viewer.