Bug 1557791 - Rename initializeWithCompressedSource so that it's clear it's only used for unretrievable source. r=arai
authorJeff Walden <jwalden@mit.edu>
Thu, 06 Jun 2019 18:40:41 -0700
changeset 478273 b8ab088338aa3d323403213b5f5bfe4eaaaf83bd
parent 478272 313c2c5ec162acb3a1a3d9f4a79a6a9b84ed46ac
child 478274 8c1a8b01ce57a8b4f4b34f90097bdf54116136ba
push id5
push uservporof@mozilla.com
push dateWed, 12 Jun 2019 10:24:37 +0000
reviewersarai
bugs1557791
milestone69.0a1
Bug 1557791 - Rename initializeWithCompressedSource so that it's clear it's only used for unretrievable source. r=arai Differential Revision: https://phabricator.services.mozilla.com/D34205
js/src/vm/JSScript.cpp
js/src/vm/JSScript.h
--- a/js/src/vm/JSScript.cpp
+++ b/js/src/vm/JSScript.cpp
@@ -2255,17 +2255,17 @@ void ScriptSource::triggerConvertToCompr
   // when the last |PinnedUnits| dies.
   MOZ_ASSERT(pendingCompressed_.empty(),
              "shouldn't be multiple conversions happening");
   pendingCompressed_.construct<CompressedData<Unit>>(std::move(compressed),
                                                      uncompressedLength);
 }
 
 template <typename Unit>
-MOZ_MUST_USE bool ScriptSource::initializeWithCompressedSource(
+MOZ_MUST_USE bool ScriptSource::initializeWithUnretrievableCompressedSource(
     JSContext* cx, UniqueChars&& compressed, size_t rawLength,
     size_t sourceLength) {
   MOZ_ASSERT(data.is<Missing>(), "shouldn't be double-initializing");
   MOZ_ASSERT(compressed != nullptr);
 
   auto& cache = cx->zone()->runtimeFromAnyThread()->sharedImmutableStrings();
   auto deduped = cache.getOrCreate(std::move(compressed), rawLength);
   if (!deduped) {
@@ -2710,19 +2710,19 @@ XDRResult ScriptSource::codeCompressedDa
   if (mode == XDR_DECODE) {
     // Compressed data is always single-byte chars.
     auto bytes = xdr->cx()->template make_pod_array<char>(compressedLength);
     if (!bytes) {
       return xdr->fail(JS::TranscodeResult_Throw);
     }
     MOZ_TRY(xdr->codeBytes(bytes.get(), compressedLength));
 
-    if (!ss->initializeWithCompressedSource<Unit>(xdr->cx(), std::move(bytes),
-                                                  compressedLength,
-                                                  uncompressedLength)) {
+    if (!ss->initializeWithUnretrievableCompressedSource<Unit>(
+            xdr->cx(), std::move(bytes), compressedLength,
+            uncompressedLength)) {
       return xdr->fail(JS::TranscodeResult_Throw);
     }
   } else {
     void* bytes =
         const_cast<char*>(ss->data.as<Compressed<Unit>>().raw.chars());
     MOZ_TRY(xdr->codeBytes(bytes, compressedLength));
   }
 
--- a/js/src/vm/JSScript.h
+++ b/js/src/vm/JSScript.h
@@ -1006,23 +1006,21 @@ class ScriptSource {
   //
   // Compressed source is in bytes, no matter that |Unit| might be |char16_t|.
   // |sourceLength| is the length in code units (not bytes) of the uncompressed
   // source.
   template <typename Unit>
   void triggerConvertToCompressedSource(SharedImmutableString compressed,
                                         size_t sourceLength);
 
-  // Initialize a fresh ScriptSource as containing compressed source of the
-  // indicated original encoding.
+  // Initialize a fresh ScriptSource as containing unretrievable compressed
+  // source of the indicated original encoding.
   template <typename Unit>
-  MOZ_MUST_USE bool initializeWithCompressedSource(JSContext* cx,
-                                                   UniqueChars&& raw,
-                                                   size_t rawLength,
-                                                   size_t sourceLength);
+  MOZ_MUST_USE bool initializeWithUnretrievableCompressedSource(
+      JSContext* cx, UniqueChars&& raw, size_t rawLength, size_t sourceLength);
 
 #if defined(JS_BUILD_BINAST)
 
   /*
    * Do not take ownership of the given `buf`. Store the canonical, shared
    * and de-duplicated version. If there is no extant shared version of
    * `buf`, make a copy.
    */