Bug 1498320 - Convert the two CompileModule functions to template functions, then call them inside non-template overloads. r=tcampbell
authorJeff Walden <jwalden@mit.edu>
Fri, 26 Oct 2018 21:28:15 -0700
changeset 446440 a005d87f9e929015e7d56f6ae500d29f35fdc4ad
parent 446439 9d9b2d6342f770aa06a78e4e5932436293551086
child 446441 280587e10c971805d24c8cf1f2798763159043bb
push id109874
push userjwalden@mit.edu
push dateWed, 14 Nov 2018 23:38:56 +0000
treeherdermozilla-inbound@5b0d24759be6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstcampbell
bugs1498320
milestone65.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 1498320 - Convert the two CompileModule functions to template functions, then call them inside non-template overloads. r=tcampbell
js/src/frontend/BytecodeCompiler.cpp
--- a/js/src/frontend/BytecodeCompiler.cpp
+++ b/js/src/frontend/BytecodeCompiler.cpp
@@ -804,20 +804,20 @@ frontend::CompileGlobalBinASTScript(JSCo
     }
 
     assertException.reset();
     return script;
 }
 
 #endif // JS_BUILD_BINAST
 
-ModuleObject*
-frontend::CompileModule(JSContext* cx, const ReadOnlyCompileOptions& optionsInput,
-                        SourceText<char16_t>& srcBuf,
-                        ScriptSourceObject** sourceObjectOut)
+template<typename Unit>
+static ModuleObject*
+CreateModule(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.
@@ -833,18 +833,25 @@ frontend::CompileModule(JSContext* cx, c
         return nullptr;
     }
 
     assertException.reset();
     return module;
 }
 
 ModuleObject*
-frontend::CompileModule(JSContext* cx, const JS::ReadOnlyCompileOptions& options,
-                        SourceText<char16_t>& srcBuf)
+frontend::CompileModule(JSContext* cx, const ReadOnlyCompileOptions& optionsInput,
+                        SourceText<char16_t>& srcBuf, ScriptSourceObject** sourceObjectOut)
+{
+    return CreateModule(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));
@@ -857,16 +864,23 @@ frontend::CompileModule(JSContext* cx, c
     if (!ModuleObject::Freeze(cx, module)) {
         return nullptr;
     }
 
     assertException.reset();
     return module;
 }
 
+ModuleObject*
+frontend::CompileModule(JSContext* cx, const JS::ReadOnlyCompileOptions& options,
+                        SourceText<char16_t>& srcBuf)
+{
+    return CreateModule(cx, options, srcBuf);
+}
+
 // When leaving this scope, the given function should either:
 //   * be linked to a fully compiled script
 //   * remain linking to a lazy script
 class MOZ_STACK_CLASS AutoAssertFunctionDelazificationCompletion
 {
 #ifdef DEBUG
     RootedFunction fun_;
 #endif