Bug 1544882 - Inline ScriptSource::setSource<Unit>(SourceTypeTraits<Unit>::SharedImmutableString) into its two callers for clarity. r=arai
authorJeff Walden <jwalden@mit.edu>
Mon, 15 Apr 2019 18:48:27 -0700
changeset 530258 d137eb73db95e59bc9647eb9d5d284e92c8ca957
parent 530257 d4d8e4bf895f84f9a6a62080b6eebb6100ccd484
child 530259 8be1bf5f1e97eb1a01ecd83e422d18b537027767
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarai
bugs1544882
milestone68.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 1544882 - Inline ScriptSource::setSource<Unit>(SourceTypeTraits<Unit>::SharedImmutableString) into its two callers for clarity. r=arai Differential Revision: https://phabricator.services.mozilla.com/D27773
js/src/vm/JSScript.cpp
js/src/vm/JSScript.h
--- a/js/src/vm/JSScript.cpp
+++ b/js/src/vm/JSScript.cpp
@@ -2088,36 +2088,31 @@ JSFlatString* ScriptSource::functionBody
 
   size_t start =
       parameterListEnd_ + (sizeof(FunctionConstructorMedialSigils) - 1);
   size_t stop = length() - (sizeof(FunctionConstructorFinalBrace) - 1);
   return substring(cx, start, stop);
 }
 
 template <typename Unit>
-void ScriptSource::setSource(
-    typename SourceTypeTraits<Unit>::SharedImmutableString uncompressed) {
-  MOZ_ASSERT(data.is<Missing>());
-  data = SourceType(Uncompressed<Unit>(std::move(uncompressed)));
-}
-
-template <typename Unit>
 MOZ_MUST_USE bool ScriptSource::setSource(JSContext* cx,
                                           EntryUnits<Unit>&& source,
                                           size_t length) {
+  MOZ_ASSERT(data.is<Missing>());
+
   auto& cache = cx->zone()->runtimeFromAnyThread()->sharedImmutableStrings();
 
   auto uniqueChars = SourceTypeTraits<Unit>::toCacheable(std::move(source));
   auto deduped = cache.getOrCreate(std::move(uniqueChars), length);
   if (!deduped) {
     ReportOutOfMemory(cx);
     return false;
   }
 
-  setSource<Unit>(std::move(*deduped));
+  data = SourceType(Uncompressed<Unit>(std::move(*deduped)));
   return true;
 }
 
 template <typename Unit>
 MOZ_MUST_USE bool ScriptSource::setRetrievedSource(JSContext* cx,
                                                    EntryUnits<Unit>&& source,
                                                    size_t length) {
   MOZ_ASSERT(sourceRetrievable_);
@@ -2272,17 +2267,17 @@ bool ScriptSource::assignSource(JSContex
                ? UniquePtr<CharT[], JS::FreePolicy>(srcBuf.takeChars())
                : DuplicateString(srcBuf.get(), srcBuf.length());
   });
   if (!deduped) {
     ReportOutOfMemory(cx);
     return false;
   }
 
-  setSource<Unit>(std::move(*deduped));
+  data = SourceType(Uncompressed<Unit>(std::move(*deduped)));
   return true;
 }
 
 template bool ScriptSource::assignSource(JSContext* cx,
                                          const ReadOnlyCompileOptions& options,
                                          SourceText<char16_t>& srcBuf);
 template bool ScriptSource::assignSource(JSContext* cx,
                                          const ReadOnlyCompileOptions& options,
--- a/js/src/vm/JSScript.h
+++ b/js/src/vm/JSScript.h
@@ -963,20 +963,16 @@ class ScriptSource {
                               size_t length);
 
   // Set the retrieved source for a |ScriptSource| whose source was recorded as
   // missing but retrievable.
   template <typename Unit>
   MOZ_MUST_USE bool setRetrievedSource(JSContext* cx, EntryUnits<Unit>&& source,
                                        size_t length);
 
-  template <typename Unit>
-  void setSource(
-      typename SourceTypeTraits<Unit>::SharedImmutableString uncompressed);
-
   MOZ_MUST_USE bool tryCompressOffThread(JSContext* cx);
 
   // Convert this ScriptSource from storing uncompressed source of the given
   // type, to storing compressed source.  (Raw compressed source is always
   // single-byte; |Unit| just records the encoding of the uncompressed source.)
   template <typename Unit>
   void convertToCompressedSource(SharedImmutableString compressed,
                                  size_t sourceLength);