Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (259130 => 259131)
--- trunk/Source/_javascript_Core/ChangeLog 2020-03-27 18:30:08 UTC (rev 259130)
+++ trunk/Source/_javascript_Core/ChangeLog 2020-03-27 18:39:46 UTC (rev 259131)
@@ -1,3 +1,57 @@
+2020-03-19 Tadeu Zagallo <[email protected]>
+
+ Fix instances of new.target that should be syntax errors
+ https://bugs.webkit.org/show_bug.cgi?id=208040
+ <rdar://problem/59653142>
+
+ Reviewed by Michael Saboff.
+
+ We were not throwing the appropriate syntax errors for the following usages of new.target:
+ - Class field initializers outside ordinary functions: we were missing a check that the
+ closestOrdinaryFunctionScope was not the global scope.
+ - Within an eval inside an arrow function: we were only checking that the EvalContextType should
+ be FunctionEvalContext, but that does not tell us whether it's an arrow function or an ordinary
+ function. To fix that we must thread that information from the executables to the parser.
+
+ * bytecode/CodeBlock.cpp:
+ (JSC::CodeBlock::finishCreation):
+ * bytecode/UnlinkedFunctionExecutable.cpp:
+ (JSC::UnlinkedFunctionExecutable::link):
+ * bytecode/UnlinkedFunctionExecutable.h:
+ * debugger/DebuggerCallFrame.cpp:
+ (JSC::DebuggerCallFrame::evaluateWithScopeExtension):
+ * interpreter/Interpreter.cpp:
+ (JSC::eval):
+ * parser/Parser.cpp:
+ (JSC::Parser<LexerType>::Parser):
+ (JSC::Parser<LexerType>::parseMemberExpression):
+ * parser/Parser.h:
+ (JSC::parse):
+ * runtime/CodeCache.cpp:
+ (JSC::generateUnlinkedCodeBlockImpl):
+ * runtime/DirectEvalExecutable.cpp:
+ (JSC::DirectEvalExecutable::create):
+ (JSC::DirectEvalExecutable::DirectEvalExecutable):
+ * runtime/DirectEvalExecutable.h:
+ * runtime/EvalExecutable.cpp:
+ (JSC::EvalExecutable::EvalExecutable):
+ * runtime/EvalExecutable.h:
+ * runtime/FunctionExecutable.cpp:
+ (JSC::FunctionExecutable::FunctionExecutable):
+ * runtime/FunctionExecutable.h:
+ * runtime/GlobalExecutable.h:
+ (JSC::GlobalExecutable::GlobalExecutable):
+ * runtime/IndirectEvalExecutable.cpp:
+ (JSC::IndirectEvalExecutable::IndirectEvalExecutable):
+ * runtime/ModuleProgramExecutable.cpp:
+ (JSC::ModuleProgramExecutable::ModuleProgramExecutable):
+ * runtime/ProgramExecutable.cpp:
+ (JSC::ProgramExecutable::ProgramExecutable):
+ * runtime/ScriptExecutable.cpp:
+ (JSC::ScriptExecutable::ScriptExecutable):
+ * runtime/ScriptExecutable.h:
+ (JSC::ScriptExecutable::isInsideOrdinaryFunction const):
+
2020-03-27 Keith Miller <[email protected]>
Add missing scope release to DataView's buffer getter
Modified: trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp (259130 => 259131)
--- trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp 2020-03-27 18:30:08 UTC (rev 259130)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp 2020-03-27 18:39:46 UTC (rev 259131)
@@ -424,7 +424,7 @@
UnlinkedFunctionExecutable* unlinkedExecutable = unlinkedCodeBlock->functionDecl(i);
if (shouldUpdateFunctionHasExecutedCache)
vm.functionHasExecutedCache()->insertUnexecutedRange(ownerExecutable->sourceID(), unlinkedExecutable->typeProfilingStartOffset(), unlinkedExecutable->typeProfilingEndOffset());
- m_functionDecls[i].set(vm, this, unlinkedExecutable->link(vm, topLevelExecutable, ownerExecutable->source()));
+ m_functionDecls[i].set(vm, this, unlinkedExecutable->link(vm, topLevelExecutable, ownerExecutable->source(), WTF::nullopt, NoIntrinsic, ownerExecutable->isInsideOrdinaryFunction()));
}
m_functionExprs = RefCountedArray<WriteBarrier<FunctionExecutable>>(unlinkedCodeBlock->numberOfFunctionExprs());
@@ -432,7 +432,7 @@
UnlinkedFunctionExecutable* unlinkedExecutable = unlinkedCodeBlock->functionExpr(i);
if (shouldUpdateFunctionHasExecutedCache)
vm.functionHasExecutedCache()->insertUnexecutedRange(ownerExecutable->sourceID(), unlinkedExecutable->typeProfilingStartOffset(), unlinkedExecutable->typeProfilingEndOffset());
- m_functionExprs[i].set(vm, this, unlinkedExecutable->link(vm, topLevelExecutable, ownerExecutable->source()));
+ m_functionExprs[i].set(vm, this, unlinkedExecutable->link(vm, topLevelExecutable, ownerExecutable->source(), WTF::nullopt, NoIntrinsic, ownerExecutable->isInsideOrdinaryFunction()));
}
if (unlinkedCodeBlock->hasRareData()) {
Modified: trunk/Source/_javascript_Core/bytecode/UnlinkedFunctionExecutable.cpp (259130 => 259131)
--- trunk/Source/_javascript_Core/bytecode/UnlinkedFunctionExecutable.cpp 2020-03-27 18:30:08 UTC (rev 259130)
+++ trunk/Source/_javascript_Core/bytecode/UnlinkedFunctionExecutable.cpp 2020-03-27 18:39:46 UTC (rev 259131)
@@ -173,7 +173,7 @@
return SourceCode(parentSource.provider(), startOffset, startOffset + m_sourceLength, firstLine, startColumn);
}
-FunctionExecutable* UnlinkedFunctionExecutable::link(VM& vm, ScriptExecutable* topLevelExecutable, const SourceCode& passedParentSource, Optional<int> overrideLineNumber, Intrinsic intrinsic)
+FunctionExecutable* UnlinkedFunctionExecutable::link(VM& vm, ScriptExecutable* topLevelExecutable, const SourceCode& passedParentSource, Optional<int> overrideLineNumber, Intrinsic intrinsic, bool isInsideOrdinaryFunction)
{
SourceCode source = linkedSourceCode(passedParentSource);
FunctionOverrides::OverrideInfo overrideInfo;
@@ -181,7 +181,7 @@
if (UNLIKELY(Options::functionOverrides()))
hasFunctionOverride = FunctionOverrides::initializeOverrideFor(source, overrideInfo);
- FunctionExecutable* result = FunctionExecutable::create(vm, topLevelExecutable, source, this, intrinsic);
+ FunctionExecutable* result = FunctionExecutable::create(vm, topLevelExecutable, source, this, intrinsic, isInsideOrdinaryFunction);
if (overrideLineNumber)
result->setOverrideLineNumber(*overrideLineNumber);
Modified: trunk/Source/_javascript_Core/bytecode/UnlinkedFunctionExecutable.h (259130 => 259131)
--- trunk/Source/_javascript_Core/bytecode/UnlinkedFunctionExecutable.h 2020-03-27 18:30:08 UTC (rev 259130)
+++ trunk/Source/_javascript_Core/bytecode/UnlinkedFunctionExecutable.h 2020-03-27 18:39:46 UTC (rev 259131)
@@ -125,7 +125,7 @@
int overrideLineNumber, Optional<int> functionConstructorParametersEndPosition);
SourceCode linkedSourceCode(const SourceCode&) const;
- JS_EXPORT_PRIVATE FunctionExecutable* link(VM&, ScriptExecutable* topLevelExecutable, const SourceCode& parentSource, Optional<int> overrideLineNumber = WTF::nullopt, Intrinsic = NoIntrinsic);
+ JS_EXPORT_PRIVATE FunctionExecutable* link(VM&, ScriptExecutable* topLevelExecutable, const SourceCode& parentSource, Optional<int> overrideLineNumber = WTF::nullopt, Intrinsic = NoIntrinsic, bool isInsideOrdinaryFunction = false);
void clearCode(VM& vm)
{
Modified: trunk/Source/_javascript_Core/debugger/DebuggerCallFrame.cpp (259130 => 259131)
--- trunk/Source/_javascript_Core/debugger/DebuggerCallFrame.cpp 2020-03-27 18:30:08 UTC (rev 259130)
+++ trunk/Source/_javascript_Core/debugger/DebuggerCallFrame.cpp 2020-03-27 18:39:46 UTC (rev 259131)
@@ -253,7 +253,7 @@
VariableEnvironment variablesUnderTDZ;
JSScope::collectClosureVariablesUnderTDZ(scope()->jsScope(), variablesUnderTDZ);
- auto* eval = DirectEvalExecutable::create(globalObject, makeSource(script, callFrame->callerSourceOrigin(vm)), codeBlock->isStrictMode(), codeBlock->unlinkedCodeBlock()->derivedContextType(), codeBlock->unlinkedCodeBlock()->needsClassFieldInitializer(), codeBlock->unlinkedCodeBlock()->isArrowFunction(), evalContextType, &variablesUnderTDZ);
+ auto* eval = DirectEvalExecutable::create(globalObject, makeSource(script, callFrame->callerSourceOrigin(vm)), codeBlock->isStrictMode(), codeBlock->unlinkedCodeBlock()->derivedContextType(), codeBlock->unlinkedCodeBlock()->needsClassFieldInitializer(), codeBlock->unlinkedCodeBlock()->isArrowFunction(), codeBlock->ownerExecutable()->isInsideOrdinaryFunction(), evalContextType, &variablesUnderTDZ);
if (UNLIKELY(catchScope.exception())) {
exception = catchScope.exception();
catchScope.clearException();
Modified: trunk/Source/_javascript_Core/interpreter/Interpreter.cpp (259130 => 259131)
--- trunk/Source/_javascript_Core/interpreter/Interpreter.cpp 2020-03-27 18:30:08 UTC (rev 259130)
+++ trunk/Source/_javascript_Core/interpreter/Interpreter.cpp 2020-03-27 18:39:46 UTC (rev 259131)
@@ -165,7 +165,7 @@
VariableEnvironment variablesUnderTDZ;
JSScope::collectClosureVariablesUnderTDZ(callerScopeChain, variablesUnderTDZ);
- eval = DirectEvalExecutable::create(globalObject, makeSource(programSource, callerCodeBlock->source().provider()->sourceOrigin()), callerCodeBlock->isStrictMode(), derivedContextType, callerUnlinkedCodeBlock->needsClassFieldInitializer(), isArrowFunctionContext, evalContextType, &variablesUnderTDZ);
+ eval = DirectEvalExecutable::create(globalObject, makeSource(programSource, callerCodeBlock->source().provider()->sourceOrigin()), callerCodeBlock->isStrictMode(), derivedContextType, callerUnlinkedCodeBlock->needsClassFieldInitializer(), isArrowFunctionContext, callerCodeBlock->ownerExecutable()->isInsideOrdinaryFunction(), evalContextType, &variablesUnderTDZ);
EXCEPTION_ASSERT(!!scope.exception() == !eval);
if (!eval)
return jsUndefined();
Modified: trunk/Source/_javascript_Core/parser/Parser.cpp (259130 => 259131)
--- trunk/Source/_javascript_Core/parser/Parser.cpp 2020-03-27 18:30:08 UTC (rev 259130)
+++ trunk/Source/_javascript_Core/parser/Parser.cpp 2020-03-27 18:39:46 UTC (rev 259131)
@@ -127,7 +127,7 @@
}
template <typename LexerType>
-Parser<LexerType>::Parser(VM& vm, const SourceCode& source, JSParserBuiltinMode builtinMode, JSParserStrictMode strictMode, JSParserScriptMode scriptMode, SourceParseMode parseMode, SuperBinding superBinding, ConstructorKind defaultConstructorKindForTopLevelFunction, DerivedContextType derivedContextType, bool isEvalContext, EvalContextType evalContextType, DebuggerParseData* debuggerParseData)
+Parser<LexerType>::Parser(VM& vm, const SourceCode& source, JSParserBuiltinMode builtinMode, JSParserStrictMode strictMode, JSParserScriptMode scriptMode, SourceParseMode parseMode, SuperBinding superBinding, ConstructorKind defaultConstructorKindForTopLevelFunction, DerivedContextType derivedContextType, bool isEvalContext, EvalContextType evalContextType, DebuggerParseData* debuggerParseData, bool isInsideOrdinaryFunction)
: m_vm(vm)
, m_source(&source)
, m_hasStackOverflow(false)
@@ -139,6 +139,7 @@
, m_defaultConstructorKindForTopLevelFunction(defaultConstructorKindForTopLevelFunction)
, m_immediateParentAllowsFunctionDeclarationInStatement(false)
, m_debuggerParseData(debuggerParseData)
+ , m_isInsideOrdinaryFunction(isInsideOrdinaryFunction)
{
m_lexer = makeUnique<LexerType>(vm, builtinMode, scriptMode);
m_lexer->setCode(source, &m_parserArena);
@@ -4802,9 +4803,8 @@
next();
if (matchContextualKeyword(m_vm.propertyNames->target)) {
ScopeRef closestOrdinaryFunctionScope = closestParentOrdinaryFunctionNonLexicalScope();
- ScopeRef classScope = closestClassScopeOrTopLevelScope();
- bool isClassFieldInitializer = classScope.index() > closestOrdinaryFunctionScope.index();
- bool isFunctionEvalContextType = closestOrdinaryFunctionScope->evalContextType() == EvalContextType::FunctionEvalContext || closestOrdinaryFunctionScope->evalContextType() == EvalContextType::InstanceFieldEvalContext;
+ bool isClassFieldInitializer = m_parserState.isParsingClassFieldInitializer;
+ bool isFunctionEvalContextType = m_isInsideOrdinaryFunction && (closestOrdinaryFunctionScope->evalContextType() == EvalContextType::FunctionEvalContext || closestOrdinaryFunctionScope->evalContextType() == EvalContextType::InstanceFieldEvalContext);
semanticFailIfFalse(currentScope()->isFunction() || isFunctionEvalContextType || isClassFieldInitializer, "new.target is only valid inside functions");
baseIsNewTarget = true;
if (currentScope()->isArrowFunction()) {
Modified: trunk/Source/_javascript_Core/parser/Parser.h (259130 => 259131)
--- trunk/Source/_javascript_Core/parser/Parser.h 2020-03-27 18:30:08 UTC (rev 259130)
+++ trunk/Source/_javascript_Core/parser/Parser.h 2020-03-27 18:39:46 UTC (rev 259131)
@@ -906,7 +906,7 @@
WTF_MAKE_FAST_ALLOCATED;
public:
- Parser(VM&, const SourceCode&, JSParserBuiltinMode, JSParserStrictMode, JSParserScriptMode, SourceParseMode, SuperBinding, ConstructorKind defaultConstructorKindForTopLevelFunction = ConstructorKind::None, DerivedContextType = DerivedContextType::None, bool isEvalContext = false, EvalContextType = EvalContextType::None, DebuggerParseData* = nullptr);
+ Parser(VM&, const SourceCode&, JSParserBuiltinMode, JSParserStrictMode, JSParserScriptMode, SourceParseMode, SuperBinding, ConstructorKind defaultConstructorKindForTopLevelFunction = ConstructorKind::None, DerivedContextType = DerivedContextType::None, bool isEvalContext = false, EvalContextType = EvalContextType::None, DebuggerParseData* = nullptr, bool isInsideOrdinaryFunction = false);
~Parser();
template <class ParsedNode>
@@ -1950,6 +1950,7 @@
DebuggerParseData* m_debuggerParseData;
CallOrApplyDepthScope* m_callOrApplyDepthScope { nullptr };
bool m_seenTaggedTemplate { false };
+ bool m_isInsideOrdinaryFunction;
};
@@ -2054,7 +2055,8 @@
DerivedContextType derivedContextType = DerivedContextType::None,
EvalContextType evalContextType = EvalContextType::None,
DebuggerParseData* debuggerParseData = nullptr,
- const Vector<JSTextPosition>* instanceFieldLocations = nullptr)
+ const Vector<JSTextPosition>* instanceFieldLocations = nullptr,
+ bool isInsideOrdinaryFunction = false)
{
ASSERT(!source.provider()->source().isNull());
@@ -2064,7 +2066,7 @@
std::unique_ptr<ParsedNode> result;
if (source.provider()->source().is8Bit()) {
- Parser<Lexer<LChar>> parser(vm, source, builtinMode, strictMode, scriptMode, parseMode, superBinding, defaultConstructorKindForTopLevelFunction, derivedContextType, isEvalNode<ParsedNode>(), evalContextType, debuggerParseData);
+ Parser<Lexer<LChar>> parser(vm, source, builtinMode, strictMode, scriptMode, parseMode, superBinding, defaultConstructorKindForTopLevelFunction, derivedContextType, isEvalNode<ParsedNode>(), evalContextType, debuggerParseData, isInsideOrdinaryFunction);
result = parser.parse<ParsedNode>(error, name, parseMode, isEvalNode<ParsedNode>() ? ParsingContext::Eval : ParsingContext::Program, WTF::nullopt, instanceFieldLocations);
if (positionBeforeLastNewline)
*positionBeforeLastNewline = parser.positionBeforeLastNewline();
@@ -2077,7 +2079,7 @@
}
} else {
ASSERT_WITH_MESSAGE(defaultConstructorKindForTopLevelFunction == ConstructorKind::None, "BuiltinExecutables's special constructors should always use a 8-bit string");
- Parser<Lexer<UChar>> parser(vm, source, builtinMode, strictMode, scriptMode, parseMode, superBinding, defaultConstructorKindForTopLevelFunction, derivedContextType, isEvalNode<ParsedNode>(), evalContextType, debuggerParseData);
+ Parser<Lexer<UChar>> parser(vm, source, builtinMode, strictMode, scriptMode, parseMode, superBinding, defaultConstructorKindForTopLevelFunction, derivedContextType, isEvalNode<ParsedNode>(), evalContextType, debuggerParseData, isInsideOrdinaryFunction);
result = parser.parse<ParsedNode>(error, name, parseMode, isEvalNode<ParsedNode>() ? ParsingContext::Eval : ParsingContext::Program, WTF::nullopt, instanceFieldLocations);
if (positionBeforeLastNewline)
*positionBeforeLastNewline = parser.positionBeforeLastNewline();
Modified: trunk/Source/_javascript_Core/runtime/CodeCache.cpp (259130 => 259131)
--- trunk/Source/_javascript_Core/runtime/CodeCache.cpp 2020-03-27 18:30:08 UTC (rev 259130)
+++ trunk/Source/_javascript_Core/runtime/CodeCache.cpp 2020-03-27 18:39:46 UTC (rev 259131)
@@ -75,8 +75,9 @@
UnlinkedCodeBlockType* generateUnlinkedCodeBlockImpl(VM& vm, const SourceCode& source, JSParserStrictMode strictMode, JSParserScriptMode scriptMode, OptionSet<CodeGenerationMode> codeGenerationMode, ParserError& error, EvalContextType evalContextType, DerivedContextType derivedContextType, bool isArrowFunctionContext, const VariableEnvironment* variablesUnderTDZ, ExecutableType* executable = nullptr)
{
typedef typename CacheTypes<UnlinkedCodeBlockType>::RootNode RootNode;
+ bool isInsideOrdinaryFunction = executable && executable->isInsideOrdinaryFunction();
std::unique_ptr<RootNode> rootNode = parse<RootNode>(
- vm, source, Identifier(), JSParserBuiltinMode::NotBuiltin, strictMode, scriptMode, CacheTypes<UnlinkedCodeBlockType>::parseMode, SuperBinding::NotNeeded, error, nullptr, ConstructorKind::None, derivedContextType, evalContextType);
+ vm, source, Identifier(), JSParserBuiltinMode::NotBuiltin, strictMode, scriptMode, CacheTypes<UnlinkedCodeBlockType>::parseMode, SuperBinding::NotNeeded, error, nullptr, ConstructorKind::None, derivedContextType, evalContextType, nullptr, nullptr, isInsideOrdinaryFunction);
if (!rootNode)
return nullptr;
Modified: trunk/Source/_javascript_Core/runtime/DirectEvalExecutable.cpp (259130 => 259131)
--- trunk/Source/_javascript_Core/runtime/DirectEvalExecutable.cpp 2020-03-27 18:30:08 UTC (rev 259130)
+++ trunk/Source/_javascript_Core/runtime/DirectEvalExecutable.cpp 2020-03-27 18:39:46 UTC (rev 259131)
@@ -35,7 +35,7 @@
namespace JSC {
-DirectEvalExecutable* DirectEvalExecutable::create(JSGlobalObject* globalObject, const SourceCode& source, bool isInStrictContext, DerivedContextType derivedContextType, NeedsClassFieldInitializer needsClassFieldInitializer, bool isArrowFunctionContext, EvalContextType evalContextType, const VariableEnvironment* variablesUnderTDZ)
+DirectEvalExecutable* DirectEvalExecutable::create(JSGlobalObject* globalObject, const SourceCode& source, bool isInStrictContext, DerivedContextType derivedContextType, NeedsClassFieldInitializer needsClassFieldInitializer, bool isArrowFunctionContext, bool isInsideOrdinaryFunction, EvalContextType evalContextType, const VariableEnvironment* variablesUnderTDZ)
{
VM& vm = globalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
@@ -45,7 +45,7 @@
return 0;
}
- auto* executable = new (NotNull, allocateCell<DirectEvalExecutable>(vm.heap)) DirectEvalExecutable(globalObject, source, isInStrictContext, derivedContextType, needsClassFieldInitializer, isArrowFunctionContext, evalContextType);
+ auto* executable = new (NotNull, allocateCell<DirectEvalExecutable>(vm.heap)) DirectEvalExecutable(globalObject, source, isInStrictContext, derivedContextType, needsClassFieldInitializer, isArrowFunctionContext, isInsideOrdinaryFunction, evalContextType);
executable->finishCreation(vm);
ParserError error;
@@ -68,8 +68,8 @@
return executable;
}
-DirectEvalExecutable::DirectEvalExecutable(JSGlobalObject* globalObject, const SourceCode& source, bool inStrictContext, DerivedContextType derivedContextType, NeedsClassFieldInitializer needsClassFieldInitializer, bool isArrowFunctionContext, EvalContextType evalContextType)
- : EvalExecutable(globalObject, source, inStrictContext, derivedContextType, isArrowFunctionContext, evalContextType, needsClassFieldInitializer)
+DirectEvalExecutable::DirectEvalExecutable(JSGlobalObject* globalObject, const SourceCode& source, bool inStrictContext, DerivedContextType derivedContextType, NeedsClassFieldInitializer needsClassFieldInitializer, bool isArrowFunctionContext, bool isInsideOrdinaryFunction, EvalContextType evalContextType)
+ : EvalExecutable(globalObject, source, inStrictContext, derivedContextType, isArrowFunctionContext, isInsideOrdinaryFunction, evalContextType, needsClassFieldInitializer)
{
ASSERT(needsClassFieldInitializer == NeedsClassFieldInitializer::No || derivedContextType == DerivedContextType::DerivedConstructorContext);
}
Modified: trunk/Source/_javascript_Core/runtime/DirectEvalExecutable.h (259130 => 259131)
--- trunk/Source/_javascript_Core/runtime/DirectEvalExecutable.h 2020-03-27 18:30:08 UTC (rev 259130)
+++ trunk/Source/_javascript_Core/runtime/DirectEvalExecutable.h 2020-03-27 18:39:46 UTC (rev 259131)
@@ -31,9 +31,9 @@
class DirectEvalExecutable final : public EvalExecutable {
public:
- static DirectEvalExecutable* create(JSGlobalObject*, const SourceCode&, bool isInStrictContext, DerivedContextType, NeedsClassFieldInitializer, bool isArrowFunctionContext, EvalContextType, const VariableEnvironment*);
+ static DirectEvalExecutable* create(JSGlobalObject*, const SourceCode&, bool isInStrictContext, DerivedContextType, NeedsClassFieldInitializer, bool isArrowFunctionContext, bool isInsideOrdinaryFunction, EvalContextType, const VariableEnvironment*);
private:
- DirectEvalExecutable(JSGlobalObject*, const SourceCode&, bool inStrictContext, DerivedContextType, NeedsClassFieldInitializer, bool isArrowFunctionContext, EvalContextType);
+ DirectEvalExecutable(JSGlobalObject*, const SourceCode&, bool inStrictContext, DerivedContextType, NeedsClassFieldInitializer, bool isArrowFunctionContext, bool isInsideOrdinaryFunction, EvalContextType);
};
static_assert(sizeof(DirectEvalExecutable) == sizeof(EvalExecutable), "");
Modified: trunk/Source/_javascript_Core/runtime/EvalExecutable.cpp (259130 => 259131)
--- trunk/Source/_javascript_Core/runtime/EvalExecutable.cpp 2020-03-27 18:30:08 UTC (rev 259130)
+++ trunk/Source/_javascript_Core/runtime/EvalExecutable.cpp 2020-03-27 18:39:46 UTC (rev 259131)
@@ -33,8 +33,8 @@
const ClassInfo EvalExecutable::s_info = { "EvalExecutable", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(EvalExecutable) };
-EvalExecutable::EvalExecutable(JSGlobalObject* globalObject, const SourceCode& source, bool inStrictContext, DerivedContextType derivedContextType, bool isArrowFunctionContext, EvalContextType evalContextType, NeedsClassFieldInitializer needsClassFieldInitializer)
- : Base(globalObject->vm().evalExecutableStructure.get(), globalObject->vm(), source, inStrictContext, derivedContextType, isArrowFunctionContext, evalContextType, NoIntrinsic)
+EvalExecutable::EvalExecutable(JSGlobalObject* globalObject, const SourceCode& source, bool inStrictContext, DerivedContextType derivedContextType, bool isArrowFunctionContext, bool isInsideOrdinaryFunction, EvalContextType evalContextType, NeedsClassFieldInitializer needsClassFieldInitializer)
+ : Base(globalObject->vm().evalExecutableStructure.get(), globalObject->vm(), source, inStrictContext, derivedContextType, isArrowFunctionContext, isInsideOrdinaryFunction, evalContextType, NoIntrinsic)
, m_needsClassFieldInitializer(static_cast<unsigned>(needsClassFieldInitializer))
{
ASSERT(source.provider()->sourceType() == SourceProviderSourceType::Program);
Modified: trunk/Source/_javascript_Core/runtime/EvalExecutable.h (259130 => 259131)
--- trunk/Source/_javascript_Core/runtime/EvalExecutable.h 2020-03-27 18:30:08 UTC (rev 259130)
+++ trunk/Source/_javascript_Core/runtime/EvalExecutable.h 2020-03-27 18:39:46 UTC (rev 259131)
@@ -76,7 +76,7 @@
friend class ScriptExecutable;
using Base::finishCreation;
- EvalExecutable(JSGlobalObject*, const SourceCode&, bool inStrictContext, DerivedContextType, bool isArrowFunctionContext, EvalContextType, NeedsClassFieldInitializer);
+ EvalExecutable(JSGlobalObject*, const SourceCode&, bool inStrictContext, DerivedContextType, bool isArrowFunctionContext, bool isInsideOrdinaryFunction, EvalContextType, NeedsClassFieldInitializer);
static void visitChildren(JSCell*, SlotVisitor&);
Modified: trunk/Source/_javascript_Core/runtime/FunctionExecutable.cpp (259130 => 259131)
--- trunk/Source/_javascript_Core/runtime/FunctionExecutable.cpp 2020-03-27 18:30:08 UTC (rev 259130)
+++ trunk/Source/_javascript_Core/runtime/FunctionExecutable.cpp 2020-03-27 18:39:46 UTC (rev 259131)
@@ -42,8 +42,8 @@
const ClassInfo FunctionExecutable::s_info = { "FunctionExecutable", &ScriptExecutable::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(FunctionExecutable) };
-FunctionExecutable::FunctionExecutable(VM& vm, const SourceCode& source, UnlinkedFunctionExecutable* unlinkedExecutable, Intrinsic intrinsic)
- : ScriptExecutable(vm.functionExecutableStructure.get(), vm, source, unlinkedExecutable->isInStrictContext(), unlinkedExecutable->derivedContextType(), false, EvalContextType::None, intrinsic)
+FunctionExecutable::FunctionExecutable(VM& vm, const SourceCode& source, UnlinkedFunctionExecutable* unlinkedExecutable, Intrinsic intrinsic, bool isInsideOrdinaryFunction)
+ : ScriptExecutable(vm.functionExecutableStructure.get(), vm, source, unlinkedExecutable->isInStrictContext(), unlinkedExecutable->derivedContextType(), false, isInsideOrdinaryFunction || !unlinkedExecutable->isArrowFunction(), EvalContextType::None, intrinsic)
, m_unlinkedExecutable(vm, this, unlinkedExecutable)
{
RELEASE_ASSERT(!source.isNull());
Modified: trunk/Source/_javascript_Core/runtime/FunctionExecutable.h (259130 => 259131)
--- trunk/Source/_javascript_Core/runtime/FunctionExecutable.h 2020-03-27 18:30:08 UTC (rev 259130)
+++ trunk/Source/_javascript_Core/runtime/FunctionExecutable.h 2020-03-27 18:39:46 UTC (rev 259131)
@@ -48,9 +48,9 @@
return &vm.functionExecutableSpace.space;
}
- static FunctionExecutable* create(VM& vm, ScriptExecutable* topLevelExecutable, const SourceCode& source, UnlinkedFunctionExecutable* unlinkedExecutable, Intrinsic intrinsic)
+ static FunctionExecutable* create(VM& vm, ScriptExecutable* topLevelExecutable, const SourceCode& source, UnlinkedFunctionExecutable* unlinkedExecutable, Intrinsic intrinsic, bool isInsideOrdinaryFunction)
{
- FunctionExecutable* executable = new (NotNull, allocateCell<FunctionExecutable>(vm.heap)) FunctionExecutable(vm, source, unlinkedExecutable, intrinsic);
+ FunctionExecutable* executable = new (NotNull, allocateCell<FunctionExecutable>(vm.heap)) FunctionExecutable(vm, source, unlinkedExecutable, intrinsic, isInsideOrdinaryFunction);
executable->finishCreation(vm, topLevelExecutable);
return executable;
}
@@ -287,7 +287,7 @@
private:
friend class ExecutableBase;
- FunctionExecutable(VM&, const SourceCode&, UnlinkedFunctionExecutable*, Intrinsic);
+ FunctionExecutable(VM&, const SourceCode&, UnlinkedFunctionExecutable*, Intrinsic, bool isInsideOrdinaryFunction);
void finishCreation(VM&, ScriptExecutable* topLevelExecutable);
Modified: trunk/Source/_javascript_Core/runtime/GlobalExecutable.h (259130 => 259131)
--- trunk/Source/_javascript_Core/runtime/GlobalExecutable.h 2020-03-27 18:30:08 UTC (rev 259130)
+++ trunk/Source/_javascript_Core/runtime/GlobalExecutable.h 2020-03-27 18:39:46 UTC (rev 259131)
@@ -49,8 +49,8 @@
}
protected:
- GlobalExecutable(Structure* structure, VM& vm, const SourceCode& sourceCode, bool isInStrictContext, DerivedContextType derivedContextType, bool isInArrowFunctionContext, EvalContextType evalContextType, Intrinsic intrinsic)
- : Base(structure, vm, sourceCode, isInStrictContext, derivedContextType, isInArrowFunctionContext, evalContextType, intrinsic)
+ GlobalExecutable(Structure* structure, VM& vm, const SourceCode& sourceCode, bool isInStrictContext, DerivedContextType derivedContextType, bool isInArrowFunctionContext, bool isInsideOrdinaryFunction, EvalContextType evalContextType, Intrinsic intrinsic)
+ : Base(structure, vm, sourceCode, isInStrictContext, derivedContextType, isInArrowFunctionContext, isInsideOrdinaryFunction, evalContextType, intrinsic)
{
}
Modified: trunk/Source/_javascript_Core/runtime/IndirectEvalExecutable.cpp (259130 => 259131)
--- trunk/Source/_javascript_Core/runtime/IndirectEvalExecutable.cpp 2020-03-27 18:30:08 UTC (rev 259130)
+++ trunk/Source/_javascript_Core/runtime/IndirectEvalExecutable.cpp 2020-03-27 18:39:46 UTC (rev 259131)
@@ -69,7 +69,7 @@
}
IndirectEvalExecutable::IndirectEvalExecutable(JSGlobalObject* globalObject, const SourceCode& source, bool inStrictContext, DerivedContextType derivedContextType, bool isArrowFunctionContext, EvalContextType evalContextType)
- : EvalExecutable(globalObject, source, inStrictContext, derivedContextType, isArrowFunctionContext, evalContextType, NeedsClassFieldInitializer::No)
+ : EvalExecutable(globalObject, source, inStrictContext, derivedContextType, isArrowFunctionContext, false, evalContextType, NeedsClassFieldInitializer::No)
{
}
Modified: trunk/Source/_javascript_Core/runtime/ModuleProgramExecutable.cpp (259130 => 259131)
--- trunk/Source/_javascript_Core/runtime/ModuleProgramExecutable.cpp 2020-03-27 18:30:08 UTC (rev 259130)
+++ trunk/Source/_javascript_Core/runtime/ModuleProgramExecutable.cpp 2020-03-27 18:39:46 UTC (rev 259131)
@@ -43,7 +43,7 @@
const ClassInfo ModuleProgramExecutable::s_info = { "ModuleProgramExecutable", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(ModuleProgramExecutable) };
ModuleProgramExecutable::ModuleProgramExecutable(JSGlobalObject* globalObject, const SourceCode& source)
- : Base(globalObject->vm().moduleProgramExecutableStructure.get(), globalObject->vm(), source, false, DerivedContextType::None, false, EvalContextType::None, NoIntrinsic)
+ : Base(globalObject->vm().moduleProgramExecutableStructure.get(), globalObject->vm(), source, false, DerivedContextType::None, false, false, EvalContextType::None, NoIntrinsic)
{
ASSERT(source.provider()->sourceType() == SourceProviderSourceType::Module);
VM& vm = globalObject->vm();
Modified: trunk/Source/_javascript_Core/runtime/ProgramExecutable.cpp (259130 => 259131)
--- trunk/Source/_javascript_Core/runtime/ProgramExecutable.cpp 2020-03-27 18:30:08 UTC (rev 259130)
+++ trunk/Source/_javascript_Core/runtime/ProgramExecutable.cpp 2020-03-27 18:39:46 UTC (rev 259131)
@@ -44,7 +44,7 @@
const ClassInfo ProgramExecutable::s_info = { "ProgramExecutable", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(ProgramExecutable) };
ProgramExecutable::ProgramExecutable(JSGlobalObject* globalObject, const SourceCode& source)
- : Base(globalObject->vm().programExecutableStructure.get(), globalObject->vm(), source, false, DerivedContextType::None, false, EvalContextType::None, NoIntrinsic)
+ : Base(globalObject->vm().programExecutableStructure.get(), globalObject->vm(), source, false, DerivedContextType::None, false, false, EvalContextType::None, NoIntrinsic)
{
ASSERT(source.provider()->sourceType() == SourceProviderSourceType::Program);
VM& vm = globalObject->vm();
Modified: trunk/Source/_javascript_Core/runtime/ScriptExecutable.cpp (259130 => 259131)
--- trunk/Source/_javascript_Core/runtime/ScriptExecutable.cpp 2020-03-27 18:30:08 UTC (rev 259130)
+++ trunk/Source/_javascript_Core/runtime/ScriptExecutable.cpp 2020-03-27 18:39:46 UTC (rev 259131)
@@ -47,7 +47,7 @@
const ClassInfo ScriptExecutable::s_info = { "ScriptExecutable", &ExecutableBase::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(ScriptExecutable) };
-ScriptExecutable::ScriptExecutable(Structure* structure, VM& vm, const SourceCode& source, bool isInStrictContext, DerivedContextType derivedContextType, bool isInArrowFunctionContext, EvalContextType evalContextType, Intrinsic intrinsic)
+ScriptExecutable::ScriptExecutable(Structure* structure, VM& vm, const SourceCode& source, bool isInStrictContext, DerivedContextType derivedContextType, bool isInArrowFunctionContext, bool isInsideOrdinaryFunction, EvalContextType evalContextType, Intrinsic intrinsic)
: ExecutableBase(vm, structure)
, m_source(source)
, m_intrinsic(intrinsic)
@@ -59,6 +59,7 @@
, m_isArrowFunctionContext(isInArrowFunctionContext)
, m_canUseOSRExitFuzzing(true)
, m_codeForGeneratorBodyWasGenerated(false)
+ , m_isInsideOrdinaryFunction(isInsideOrdinaryFunction)
, m_derivedContextType(static_cast<unsigned>(derivedContextType))
, m_evalContextType(static_cast<unsigned>(evalContextType))
{
Modified: trunk/Source/_javascript_Core/runtime/ScriptExecutable.h (259130 => 259131)
--- trunk/Source/_javascript_Core/runtime/ScriptExecutable.h 2020-03-27 18:30:08 UTC (rev 259130)
+++ trunk/Source/_javascript_Core/runtime/ScriptExecutable.h 2020-03-27 18:39:46 UTC (rev 259131)
@@ -78,6 +78,7 @@
bool isInliningCandidate() const { return !neverInline(); }
bool isOkToOptimize() const { return !neverOptimize(); }
bool canUseOSRExitFuzzing() const { return m_canUseOSRExitFuzzing; }
+ bool isInsideOrdinaryFunction() const { return m_isInsideOrdinaryFunction; }
bool* addressOfDidTryToEnterInLoop() { return &m_didTryToEnterInLoop; }
@@ -128,7 +129,7 @@
TemplateObjectMap& ensureTemplateObjectMap(VM&);
protected:
- ScriptExecutable(Structure*, VM&, const SourceCode&, bool isInStrictContext, DerivedContextType, bool isInArrowFunctionContext, EvalContextType, Intrinsic);
+ ScriptExecutable(Structure*, VM&, const SourceCode&, bool isInStrictContext, DerivedContextType, bool isInArrowFunctionContext, bool isInsideOrdinaryFunction, EvalContextType, Intrinsic);
void finishCreation(VM& vm)
{
@@ -160,6 +161,7 @@
bool m_isArrowFunctionContext : 1;
bool m_canUseOSRExitFuzzing : 1;
bool m_codeForGeneratorBodyWasGenerated : 1;
+ bool m_isInsideOrdinaryFunction : 1;
unsigned m_derivedContextType : 2; // DerivedContextType
unsigned m_evalContextType : 2; // EvalContextType
};