Backed out changeset ab611defdc9b (bug 1271407) for slowing down debug mochitests and causing frequent oranges as a result.
authorRyan VanderMeulen <ryanvm@gmail.com>
Tue, 10 May 2016 22:35:29 -0400
changeset 296924 7a1f2d5a9ac02201648f03aa82c303430f8a40c4
parent 296923 12b3ef0b79d089343370cd81e0c3bbfd2bcb2c78
child 296925 a3eea5f8d0a69e46548cd9abee46da29a00edd65
push id30249
push usercbook@mozilla.com
push dateWed, 11 May 2016 12:53:10 +0000
treeherderautoland@3461f3cae784 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1271407
milestone49.0a1
backs outab611defdc9b783adcbd6f517bae68203e812252
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 changeset ab611defdc9b (bug 1271407) for slowing down debug mochitests and causing frequent oranges as a result.
js/src/jsscript.cpp
js/src/jsscript.h
--- a/js/src/jsscript.cpp
+++ b/js/src/jsscript.cpp
@@ -1879,18 +1879,18 @@ ScriptSource::sourceText(JSContext* cx)
 
             const size_t lengthWithNull = ss.length() + 1;
             UniqueTwoByteChars decompressed(js_pod_malloc<char16_t>(lengthWithNull));
             if (!decompressed) {
                 ReportOutOfMemory(cx);
                 return mozilla::Nothing();
             }
 
-            if (!DecompressString((const unsigned char*) c.raw.chars(),
-                                  c.raw.length(),
+            if (!DecompressString((const unsigned char*) ss.compressedData(),
+                                  ss.compressedBytes(),
                                   reinterpret_cast<unsigned char*>(decompressed.get()),
                                   lengthWithNull * sizeof(char16_t)))
             {
                 ReportOutOfMemory(cx);
                 return mozilla::Nothing();
             }
 
             decompressed[ss.length()] = 0;
@@ -2046,29 +2046,25 @@ ScriptSource::setSourceCopy(ExclusiveCon
     }
 
     return true;
 }
 
 SourceCompressionTask::ResultType
 SourceCompressionTask::work()
 {
-    MOZ_ASSERT(ss->data.is<ScriptSource::Uncompressed>());
-
     // Try to keep the maximum memory usage down by only allocating half the
     // size of the string, first.
     size_t inputBytes = ss->length() * sizeof(char16_t);
     size_t firstSize = inputBytes / 2;
     compressed = js_malloc(firstSize);
     if (!compressed)
         return OOM;
 
-    const char16_t* chars = ss->data.as<ScriptSource::Uncompressed>().string.chars();
-    Compressor comp(reinterpret_cast<const unsigned char*>(chars),
-                    inputBytes);
+    Compressor comp(reinterpret_cast<const unsigned char*>(ss->uncompressedChars()), inputBytes);
     if (!comp.init())
         return OOM;
 
     comp.setOutput((unsigned char*) compressed, firstSize);
     bool cont = true;
     while (cont) {
         if (abort_)
             return Aborted;
@@ -2126,17 +2122,17 @@ ScriptSource::performXDR(XDRState<mode>*
     {
         using ReturnType = size_t;
 
         ReturnType match(Uncompressed&) {
             return 0;
         }
 
         ReturnType match(Compressed& c) {
-            return c.raw.length();
+            return c.nbytes();
         }
 
         ReturnType match(Missing&) {
             MOZ_CRASH("Missing source data in ScriptSource::performXDR");
             return 0;
         }
     };
 
--- a/js/src/jsscript.h
+++ b/js/src/jsscript.h
@@ -615,22 +615,24 @@ class ScriptSource
         explicit Uncompressed(SharedImmutableTwoByteString&& str)
           : string(mozilla::Move(str))
         { }
     };
 
     struct Compressed
     {
         SharedImmutableString raw;
-        size_t uncompressedLength;
-
-        Compressed(SharedImmutableString&& raw, size_t uncompressedLength)
+        size_t length;
+
+        Compressed(SharedImmutableString&& raw, size_t length)
           : raw(mozilla::Move(raw))
-          , uncompressedLength(uncompressedLength)
+          , length(length)
         { }
+
+        size_t nbytes() const { return raw.length(); }
     };
 
     using SourceType = mozilla::Variant<Missing, Uncompressed, Compressed>;
     SourceType data;
 
     // The filename of this script.
     UniqueChars filename_;
 
@@ -717,17 +719,17 @@ class ScriptSource
         {
             using ReturnType = size_t;
 
             ReturnType match(const Uncompressed& u) {
                 return u.string.length();
             }
 
             ReturnType match(const Compressed& c) {
-                return c.uncompressedLength;
+                return c.length;
             }
 
             ReturnType match(const Missing& m) {
                 MOZ_CRASH("ScriptSource::length on a missing source");
                 return 0;
             }
         };
 
@@ -744,16 +746,28 @@ class ScriptSource
     // OOM failure.
     MOZ_MUST_USE mozilla::Maybe<SharedImmutableTwoByteString> sourceText(JSContext* cx);
 
     JSFlatString* substring(JSContext* cx, uint32_t start, uint32_t stop);
     JSFlatString* substringDontDeflate(JSContext* cx, uint32_t start, uint32_t stop);
     void addSizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf,
                                 JS::ScriptSourceInfo* info) const;
 
+    const char16_t* uncompressedChars() const {
+        return data.as<Uncompressed>().string.chars();
+    }
+
+    const void* compressedData() const {
+        return static_cast<const void*>(data.as<Compressed>().raw.chars());
+    }
+
+    size_t compressedBytes() const {
+        return data.as<Compressed>().nbytes();
+    }
+
     MOZ_MUST_USE bool setSource(ExclusiveContext* cx,
                                 mozilla::UniquePtr<char16_t[], JS::FreePolicy>&& source,
                                 size_t length);
     void setSource(SharedImmutableTwoByteString&& string);
 
     MOZ_MUST_USE bool setCompressedSource(
         ExclusiveContext* cx,
         mozilla::UniquePtr<char[], JS::FreePolicy>&& raw,