Bug 1552979 - Rename one CompileModule overload to ParseModule to make it easier to distinguish them, both mentally and in searches. r=arai
authorJeff Walden <jwalden@mit.edu>
Mon, 20 May 2019 02:42:16 -0700
changeset 475404 3ce85949f2e16fa924f40aaa8e8b69df918dcd1b
parent 475403 41adfcfb70bf8e12c98eb15d11185c97dc6afabd
child 475405 cb71e51f8cadbe76fe68739fb022e6f91233ded4
push id36061
push usercbrindusan@mozilla.com
push dateFri, 24 May 2019 21:49:59 +0000
treeherdermozilla-central@5d3e1ea77693 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarai
bugs1552979
milestone69.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1552979 - Rename one CompileModule overload to ParseModule to make it easier to distinguish them, both mentally and in searches. r=arai Differential Revision: https://phabricator.services.mozilla.com/D31894
js/src/frontend/BytecodeCompiler.cpp
js/src/frontend/BytecodeCompiler.h
js/src/vm/HelperThreads.cpp
--- a/js/src/frontend/BytecodeCompiler.cpp
+++ b/js/src/frontend/BytecodeCompiler.cpp
@@ -799,20 +799,19 @@ JSScript* frontend::CompileGlobalBinASTS
 
   assertException.reset();
   return script;
 }
 
 #endif  // JS_BUILD_BINAST
 
 template <typename Unit>
-static ModuleObject* CreateModule(JSContext* cx,
-                                  const ReadOnlyCompileOptions& optionsInput,
-                                  SourceText<Unit>& srcBuf,
-                                  ScriptSourceObject** sourceObjectOut) {
+static ModuleObject* InternalParseModule(
+    JSContext* cx, const ReadOnlyCompileOptions& optionsInput,
+    SourceText<Unit>& srcBuf, ScriptSourceObject** sourceObjectOut) {
   MOZ_ASSERT(srcBuf.get());
   MOZ_ASSERT_IF(sourceObjectOut, *sourceObjectOut == nullptr);
 
   AutoAssertReportedException assertException(cx);
 
   CompileOptions options(cx, optionsInput);
   options.maybeMakeStrictMode(
       true);  // ES6 10.2.1 Module code is always strict mode code.
@@ -827,33 +826,34 @@ static ModuleObject* CreateModule(JSCont
   if (!module) {
     return nullptr;
   }
 
   assertException.reset();
   return module;
 }
 
-ModuleObject* frontend::CompileModule(
-    JSContext* cx, const ReadOnlyCompileOptions& optionsInput,
-    SourceText<char16_t>& srcBuf, ScriptSourceObject** sourceObjectOut) {
-  return CreateModule(cx, optionsInput, srcBuf, sourceObjectOut);
+ModuleObject* frontend::ParseModule(JSContext* cx,
+                                    const ReadOnlyCompileOptions& optionsInput,
+                                    SourceText<char16_t>& srcBuf,
+                                    ScriptSourceObject** sourceObjectOut) {
+  return InternalParseModule(cx, optionsInput, srcBuf, sourceObjectOut);
 }
 
 template <typename Unit>
 static ModuleObject* CreateModule(JSContext* cx,
                                   const JS::ReadOnlyCompileOptions& options,
                                   SourceText<Unit>& srcBuf) {
   AutoAssertReportedException assertException(cx);
 
   if (!GlobalObject::ensureModulePrototypesCreated(cx, cx->global())) {
     return nullptr;
   }
 
-  RootedModuleObject module(cx, CompileModule(cx, options, srcBuf, nullptr));
+  RootedModuleObject module(cx, ParseModule(cx, options, srcBuf, nullptr));
   if (!module) {
     return nullptr;
   }
 
   // This happens in GlobalHelperThreadState::finishModuleParseTask() when a
   // module is compiled off thread.
   if (!ModuleObject::Freeze(cx, module)) {
     return nullptr;
--- a/js/src/frontend/BytecodeCompiler.h
+++ b/js/src/frontend/BytecodeCompiler.h
@@ -115,24 +115,27 @@ JSScript* CompileGlobalBinASTScript(
     ScriptSourceObject** sourceObjectOut = nullptr);
 
 MOZ_MUST_USE bool CompileLazyBinASTFunction(JSContext* cx,
                                             Handle<LazyScript*> lazy,
                                             const uint8_t* buf, size_t length);
 
 #endif  // JS_BUILD_BINAST
 
+// Compile a module of the given source using the given options.
 ModuleObject* CompileModule(JSContext* cx,
                             const JS::ReadOnlyCompileOptions& options,
                             JS::SourceText<char16_t>& srcBuf);
 
-ModuleObject* CompileModule(JSContext* cx,
-                            const JS::ReadOnlyCompileOptions& options,
-                            JS::SourceText<char16_t>& srcBuf,
-                            ScriptSourceObject** sourceObjectOut);
+// Parse a module of the given source.  This is an internal API; if you want to
+// compile a module as a user, use CompileModule above.
+ModuleObject* ParseModule(JSContext* cx,
+                          const JS::ReadOnlyCompileOptions& options,
+                          JS::SourceText<char16_t>& srcBuf,
+                          ScriptSourceObject** sourceObjectOut);
 
 //
 // Compile a single function. The source in srcBuf must match the ECMA-262
 // FunctionExpression production.
 //
 // If nonzero, parameterListEnd is the offset within srcBuf where the parameter
 // list is expected to end. During parsing, if we find that it ends anywhere
 // else, it's a SyntaxError. This is used to implement the Function constructor;
--- a/js/src/vm/HelperThreads.cpp
+++ b/js/src/vm/HelperThreads.cpp
@@ -575,17 +575,17 @@ ModuleParseTask<Unit>::ModuleParseTask(J
 
 template <typename Unit>
 void ModuleParseTask<Unit>::parse(JSContext* cx) {
   MOZ_ASSERT(cx->helperThread());
 
   Rooted<ScriptSourceObject*> sourceObject(cx);
 
   ModuleObject* module =
-      frontend::CompileModule(cx, options, data, &sourceObject.get());
+      frontend::ParseModule(cx, options, data, &sourceObject.get());
   if (module) {
     scripts.infallibleAppend(module->script());
     if (sourceObject) {
       sourceObjects.infallibleAppend(sourceObject);
     }
   }
 }