Modified: trunk/Source/_javascript_Core/ChangeLog (236903 => 236904)
--- trunk/Source/_javascript_Core/ChangeLog 2018-10-07 02:48:38 UTC (rev 236903)
+++ trunk/Source/_javascript_Core/ChangeLog 2018-10-07 09:32:52 UTC (rev 236904)
@@ -1,3 +1,28 @@
+2018-10-07 Yusuke Suzuki <[email protected]>
+
+ [JSC] Avoid creating ProgramExecutable in checkSyntax
+ https://bugs.webkit.org/show_bug.cgi?id=190332
+
+ Reviewed by Mark Lam.
+
+ uglify-js in web-tooling-benchmark executes massive number of Function constructor calls.
+ In Function constructor code, we perform checkSyntax for body and parameters. So fast checkSyntax
+ is important when the performance of Function constructor matters. Current checkSyntax code
+ unnecessarily allocates ProgramExecutable. This patch removes this allocation and improves
+ the benchmark score slightly.
+
+ Before:
+ uglify-js: 2.87 runs/s
+ After:
+ uglify-js: 2.94 runs/s
+
+ * runtime/Completion.cpp:
+ (JSC::checkSyntaxInternal):
+ (JSC::checkSyntax):
+ * runtime/ProgramExecutable.cpp:
+ (JSC::ProgramExecutable::checkSyntax): Deleted.
+ * runtime/ProgramExecutable.h:
+
2018-10-06 Caio Lima <[email protected]>
[ESNext][BigInt] Implement support for "|"
Modified: trunk/Source/_javascript_Core/runtime/Completion.cpp (236903 => 236904)
--- trunk/Source/_javascript_Core/runtime/Completion.cpp 2018-10-07 02:48:38 UTC (rev 236903)
+++ trunk/Source/_javascript_Core/runtime/Completion.cpp 2018-10-07 09:32:52 UTC (rev 236904)
@@ -44,6 +44,13 @@
namespace JSC {
+static inline bool checkSyntaxInternal(VM& vm, const SourceCode& source, ParserError& error)
+{
+ return !!parse<ProgramNode>(
+ &vm, source, Identifier(), JSParserBuiltinMode::NotBuiltin,
+ JSParserStrictMode::NotStrict, JSParserScriptMode::Classic, SourceParseMode::ProgramMode, SuperBinding::NotNeeded, error);
+}
+
bool checkSyntax(ExecState* exec, const SourceCode& source, JSValue* returnedException)
{
VM& vm = exec->vm();
@@ -50,24 +57,20 @@
JSLockHolder lock(vm);
RELEASE_ASSERT(vm.atomicStringTable() == Thread::current().atomicStringTable());
- ProgramExecutable* program = ProgramExecutable::create(exec, source);
- JSObject* error = program->checkSyntax(exec);
- if (error) {
- if (returnedException)
- *returnedException = error;
- return false;
- }
+ ParserError error;
+ if (checkSyntaxInternal(vm, source, error))
+ return true;
+ ASSERT(error.isValid());
+ if (returnedException)
+ *returnedException = error.toErrorObject(exec->lexicalGlobalObject(), source);
+ return false;
+}
- return true;
-}
-
bool checkSyntax(VM& vm, const SourceCode& source, ParserError& error)
{
JSLockHolder lock(vm);
RELEASE_ASSERT(vm.atomicStringTable() == Thread::current().atomicStringTable());
- return !!parse<ProgramNode>(
- &vm, source, Identifier(), JSParserBuiltinMode::NotBuiltin,
- JSParserStrictMode::NotStrict, JSParserScriptMode::Classic, SourceParseMode::ProgramMode, SuperBinding::NotNeeded, error);
+ return checkSyntaxInternal(vm, source, error);
}
bool checkModuleSyntax(ExecState* exec, const SourceCode& source, ParserError& error)
Modified: trunk/Source/_javascript_Core/runtime/ProgramExecutable.cpp (236903 => 236904)
--- trunk/Source/_javascript_Core/runtime/ProgramExecutable.cpp 2018-10-07 02:48:38 UTC (rev 236903)
+++ trunk/Source/_javascript_Core/runtime/ProgramExecutable.cpp 2018-10-07 09:32:52 UTC (rev 236904)
@@ -58,20 +58,6 @@
static_cast<ProgramExecutable*>(cell)->ProgramExecutable::~ProgramExecutable();
}
-JSObject* ProgramExecutable::checkSyntax(ExecState* exec)
-{
- ParserError error;
- VM* vm = &exec->vm();
- JSGlobalObject* lexicalGlobalObject = exec->lexicalGlobalObject();
- std::unique_ptr<ProgramNode> programNode = parse<ProgramNode>(
- vm, m_source, Identifier(), JSParserBuiltinMode::NotBuiltin,
- JSParserStrictMode::NotStrict, JSParserScriptMode::Classic, SourceParseMode::ProgramMode, SuperBinding::NotNeeded, error);
- if (programNode)
- return 0;
- ASSERT(error.isValid());
- return error.toErrorObject(lexicalGlobalObject, m_source);
-}
-
// http://www.ecma-international.org/ecma-262/6.0/index.html#sec-hasrestrictedglobalproperty
static bool hasRestrictedGlobalProperty(ExecState* exec, JSGlobalObject* globalObject, PropertyName propertyName)
{
Modified: trunk/Source/_javascript_Core/runtime/ProgramExecutable.h (236903 => 236904)
--- trunk/Source/_javascript_Core/runtime/ProgramExecutable.h 2018-10-07 02:48:38 UTC (rev 236903)
+++ trunk/Source/_javascript_Core/runtime/ProgramExecutable.h 2018-10-07 09:32:52 UTC (rev 236904)
@@ -59,8 +59,6 @@
return bitwise_cast<ProgramCodeBlock*>(ExecutableToCodeBlockEdge::unwrap(m_programCodeBlock.get()));
}
- JSObject* checkSyntax(ExecState*);
-
Ref<JITCode> generatedJITCode()
{
return generatedJITCodeForCall();