Backed out 3 changesets (bug 1504788) for mochitest failures on test_script_loader_js_cache.
authorCosmin Sabou <csabou@mozilla.com>
Tue, 13 Nov 2018 03:26:04 +0200
changeset 502401 97e52e72ecfe5058bd9b760d1157e2005f893858
parent 502400 297ca8fa0cef4dbe4e40daa4e0a22c565f641f76
child 502402 5e300fa7763de6a1ce4b210e222645276163f690
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1504788
milestone65.0a1
backs out8ed6a977ba83dfc52f46d4b9305e258a054c76c1
2fba05049f9c293ab22b9a3930261d12b3f31dd2
3f6dc8af5bca9425844b78c6973252f4a3127f13
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
Backed out 3 changesets (bug 1504788) for mochitest failures on test_script_loader_js_cache. Backed out changeset 8ed6a977ba83 (bug 1504788) Backed out changeset 2fba05049f9c (bug 1504788) Backed out changeset 3f6dc8af5bca (bug 1504788)
dom/script/ScriptLoadHandler.cpp
js/src/vm/JSScript.cpp
--- a/dom/script/ScriptLoadHandler.cpp
+++ b/dom/script/ScriptLoadHandler.cpp
@@ -288,52 +288,55 @@ ScriptLoadHandler::EnsureKnownDataType(n
   MOZ_ASSERT(mRequest->IsUnknownDataType());
   MOZ_ASSERT(mRequest->IsLoading());
 
   nsCOMPtr<nsIRequest> req;
   nsresult rv = aLoader->GetRequest(getter_AddRefs(req));
   MOZ_ASSERT(req, "StreamLoader's request went away prematurely");
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsCOMPtr<nsICacheInfoChannel> cic(do_QueryInterface(req));
-  if (cic) {
-    nsAutoCString altDataType;
-    cic->GetAlternativeDataType(altDataType);
-    if (altDataType.Equals(nsContentUtils::JSBytecodeMimeType())) {
-      mRequest->SetBytecode();
-      TRACE_FOR_TEST(mRequest->Element(), "scriptloader_load_bytecode");
-      return NS_OK;
-    }
-    MOZ_ASSERT(altDataType.IsEmpty());
-  }
-
   if (ScriptLoader::BinASTEncodingEnabled()) {
     nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(req);
     if (httpChannel) {
       nsAutoCString mimeType;
       httpChannel->GetContentType(mimeType);
       if (mimeType.LowerCaseEqualsASCII(APPLICATION_JAVASCRIPT_BINAST)) {
         if (mRequest->ShouldAcceptBinASTEncoding()) {
           mRequest->SetBinASTSource();
           TRACE_FOR_TEST(mRequest->Element(), "scriptloader_load_source");
           return NS_OK;
+        } else {
+          return NS_ERROR_FAILURE;
         }
-        return NS_ERROR_FAILURE;
       }
     }
   }
 
   if (mRequest->IsLoadingSource()) {
     mRequest->SetTextSource();
     TRACE_FOR_TEST(mRequest->Element(), "scriptloader_load_source");
     return NS_OK;
   }
 
-  mRequest->SetTextSource();
-  TRACE_FOR_TEST(mRequest->Element(), "scriptloader_load_source");
+  nsCOMPtr<nsICacheInfoChannel> cic(do_QueryInterface(req));
+  if (cic) {
+    nsAutoCString altDataType;
+    cic->GetAlternativeDataType(altDataType);
+    if (altDataType.Equals(nsContentUtils::JSBytecodeMimeType())) {
+      mRequest->SetBytecode();
+      TRACE_FOR_TEST(mRequest->Element(), "scriptloader_load_bytecode");
+    } else {
+      MOZ_ASSERT(altDataType.IsEmpty());
+      mRequest->SetTextSource();
+      TRACE_FOR_TEST(mRequest->Element(), "scriptloader_load_source");
+    }
+  } else {
+    mRequest->SetTextSource();
+    TRACE_FOR_TEST(mRequest->Element(), "scriptloader_load_source");
+  }
 
   MOZ_ASSERT(!mRequest->IsUnknownDataType());
   MOZ_ASSERT(mRequest->IsLoading());
   return NS_OK;
 }
 
 NS_IMETHODIMP
 ScriptLoadHandler::OnStreamComplete(nsIIncrementalStreamLoader* aLoader,
--- a/js/src/vm/JSScript.cpp
+++ b/js/src/vm/JSScript.cpp
@@ -2374,16 +2374,37 @@ ScriptSource::performXDR(XDRState<mode>*
 
     if ((hasSource || hasBinSource) && !sourceRetrievable_) {
         uint32_t uncompressedLength = 0;
         if (mode == XDR_ENCODE) {
             uncompressedLength = length();
         }
         MOZ_TRY(xdr->codeUint32(&uncompressedLength));
 
+        // A compressed length of 0 indicates source is uncompressed (or is
+        // BinAST if |hasBinSource|).
+        uint32_t compressedLength;
+        if (mode == XDR_ENCODE) {
+            compressedLength = compressedLengthOrZero();
+        }
+        MOZ_TRY(xdr->codeUint32(&compressedLength));
+
+        uint8_t srcCharSize;
+        if (mode == XDR_ENCODE) {
+            srcCharSize = sourceCharSize();
+        }
+        MOZ_TRY(xdr->codeUint8(&srcCharSize));
+
+        if (srcCharSize != 1 && srcCharSize != 2) {
+            // Fail in debug, but only soft-fail in release, if the source-char
+            // size is invalid.
+            MOZ_ASSERT_UNREACHABLE("bad XDR source chars size");
+            return xdr->fail(JS::TranscodeResult_Failure_BadDecode);
+        }
+
         if (hasBinSource) {
             if (mode == XDR_DECODE) {
 #if defined(JS_BUILD_BINAST)
                 auto bytes =
                     xdr->cx()->template make_pod_array<char>(Max<size_t>(uncompressedLength, 1));
                 if (!bytes) {
                     return xdr->fail(JS::TranscodeResult_Throw);
                 }
@@ -2395,63 +2416,41 @@ ScriptSource::performXDR(XDRState<mode>*
 #else
                 MOZ_ASSERT(mode != XDR_ENCODE);
                 return xdr->fail(JS::TranscodeResult_Throw);
 #endif /* JS_BUILD_BINAST */
             } else {
                 void* bytes = binASTData();
                 MOZ_TRY(xdr->codeBytes(bytes, uncompressedLength));
             }
-        } else {
-            // A compressed length of 0 indicates source is uncompressed
-            uint32_t compressedLength;
-            if (mode == XDR_ENCODE) {
-                compressedLength = compressedLengthOrZero();
-            }
-            MOZ_TRY(xdr->codeUint32(&compressedLength));
-
-            uint8_t srcCharSize;
-            if (mode == XDR_ENCODE) {
-                srcCharSize = sourceCharSize();
-            }
-            MOZ_TRY(xdr->codeUint8(&srcCharSize));
-
-            if (srcCharSize != 1 && srcCharSize != 2) {
-                // Fail in debug, but only soft-fail in release, if the source-char
-                // size is invalid.
-                MOZ_ASSERT_UNREACHABLE("bad XDR source chars size");
-                return xdr->fail(JS::TranscodeResult_Failure_BadDecode);
-            }
-
-            if (compressedLength) {
-                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 (!(srcCharSize == 1
-                          ? setCompressedSource<Utf8Unit>(xdr->cx(), std::move(bytes),
-                                                          compressedLength, uncompressedLength)
-                          : setCompressedSource<char16_t>(xdr->cx(), std::move(bytes),
-                                                          compressedLength, uncompressedLength)))
-                    {
-                        return xdr->fail(JS::TranscodeResult_Throw);
-                    }
-                } else {
-                    void* bytes = srcCharSize == 1
-                                  ? compressedData<Utf8Unit>()
-                                  : compressedData<char16_t>();
-                    MOZ_TRY(xdr->codeBytes(bytes, compressedLength));
+        } else if (compressedLength) {
+            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 (!(srcCharSize == 1
+                      ? setCompressedSource<Utf8Unit>(xdr->cx(), std::move(bytes),
+                                                      compressedLength, uncompressedLength)
+                      : setCompressedSource<char16_t>(xdr->cx(), std::move(bytes),
+                                                      compressedLength, uncompressedLength)))
+                {
+                    return xdr->fail(JS::TranscodeResult_Throw);
                 }
             } else {
-                MOZ_TRY(xdrUncompressedSource(xdr, srcCharSize, uncompressedLength));
+                void* bytes = srcCharSize == 1
+                              ? compressedData<Utf8Unit>()
+                              : compressedData<char16_t>();
+                MOZ_TRY(xdr->codeBytes(bytes, compressedLength));
             }
+        } else {
+            MOZ_TRY(xdrUncompressedSource(xdr, srcCharSize, uncompressedLength));
         }
 
         uint8_t hasMetadata = !!binASTMetadata_;
         MOZ_TRY(xdr->codeUint8(&hasMetadata));
         if (hasMetadata) {
 #if defined(JS_BUILD_BINAST)
             uint32_t numBinKinds;
             uint32_t numStrings;
@@ -2460,23 +2459,22 @@ ScriptSource::performXDR(XDRState<mode>*
                 numStrings = binASTMetadata_->numStrings();
             }
             MOZ_TRY(xdr->codeUint32(&numBinKinds));
             MOZ_TRY(xdr->codeUint32(&numStrings));
 
             if (mode == XDR_DECODE) {
                 // Use calloc, since we're storing this immediately, and filling it might GC, to
                 // avoid marking bogus atoms.
-                auto metadata = static_cast<frontend::BinASTSourceMetadata*>(
-                    js_calloc(frontend::BinASTSourceMetadata::totalSize(numBinKinds, numStrings)));
-                if (!metadata) {
+                setBinASTSourceMetadata(
+                    static_cast<frontend::BinASTSourceMetadata*>(
+                        js_calloc(frontend::BinASTSourceMetadata::totalSize(numBinKinds, numStrings))));
+                if (!binASTMetadata_) {
                     return xdr->fail(JS::TranscodeResult_Throw);
                 }
-                new (metadata) frontend::BinASTSourceMetadata(numBinKinds, numStrings);
-                setBinASTSourceMetadata(metadata);
             }
 
             for (uint32_t i = 0; i < numBinKinds; i++) {
                 frontend::BinKind* binKindBase = binASTMetadata_->binKindBase();
                 MOZ_TRY(xdr->codeEnum32(&binKindBase[i]));
             }
 
             RootedAtom atom(xdr->cx());