Bug 1325551 - Add MOZ_MUST_USE to ScriptSource r=jimb
authorJon Coppeard <jcoppeard@mozilla.com>
Wed, 01 Feb 2017 17:10:17 +0000
changeset 332045 2e232a53e2dbc84cfc7694dff8d1c1ca4915559d
parent 332044 086495e416900fcf3e397cb4a54ecb0ff47c591a
child 332046 209dd2a63640e6db4e8653b14927c34198dab6f9
push id36770
push userkwierso@gmail.com
push dateThu, 02 Feb 2017 00:30:59 +0000
treeherderautoland@634b7e5fb104 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimb
bugs1325551
milestone54.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 1325551 - Add MOZ_MUST_USE to ScriptSource r=jimb
js/src/jsscript.cpp
js/src/jsscript.h
--- a/js/src/jsscript.cpp
+++ b/js/src/jsscript.cpp
@@ -520,17 +520,19 @@ js::XDRScript(XDRState<mode>* xdr, Handl
             ScriptSourceHolder ssHolder(ss);
 
             /*
              * We use this CompileOptions only to initialize the
              * ScriptSourceObject. Most CompileOptions fields aren't used by
              * ScriptSourceObject, and those that are (element; elementAttributeName)
              * aren't preserved by XDR. So this can be simple.
              */
-            ss->initFromOptions(cx, *options);
+            if (!ss->initFromOptions(cx, *options))
+                return false;
+
             sourceObject = ScriptSourceObject::create(cx, ss);
             if (xdr->hasScriptSourceObjectOut()) {
                 // When the ScriptSourceObjectOut is provided by ParseTask, it
                 // is stored in a location which is traced by the GC.
                 *xdr->scriptSourceObjectOut() = sourceObject;
             } else {
                 if (!sourceObject ||
                     !ScriptSourceObject::initFromOptions(cx->asJSContext(), sourceObject, *options))
--- a/js/src/jsscript.h
+++ b/js/src/jsscript.h
@@ -469,21 +469,22 @@ class ScriptSource
     }
 
     void incref() { refs++; }
     void decref() {
         MOZ_ASSERT(refs != 0);
         if (--refs == 0)
             js_delete(this);
     }
-    bool initFromOptions(ExclusiveContext* cx, const ReadOnlyCompileOptions& options,
-                         mozilla::Maybe<uint32_t> parameterListEnd = mozilla::Nothing());
-    bool setSourceCopy(ExclusiveContext* cx,
-                       JS::SourceBufferHolder& srcBuf,
-                       SourceCompressionTask* tok);
+    MOZ_MUST_USE bool initFromOptions(ExclusiveContext* cx,
+                                      const ReadOnlyCompileOptions& options,
+                                      mozilla::Maybe<uint32_t> parameterListEnd = mozilla::Nothing());
+    MOZ_MUST_USE bool setSourceCopy(ExclusiveContext* cx,
+                                    JS::SourceBufferHolder& srcBuf,
+                                    SourceCompressionTask* tok);
     void setSourceRetrievable() { sourceRetrievable_ = true; }
     bool sourceRetrievable() const { return sourceRetrievable_; }
     bool hasSourceData() const { return !data.is<Missing>(); }
     bool hasCompressedSource() const { return data.is<Compressed>(); }
 
     size_t length() const {
         struct LengthMatcher
         {
@@ -517,56 +518,55 @@ class ScriptSource
         return parameterListEnd_ != 0;
     }
     JSFlatString* functionBodyString(JSContext* cx);
 
     void addSizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf,
                                 JS::ScriptSourceInfo* info) const;
 
     MOZ_MUST_USE bool setSource(ExclusiveContext* cx,
-                                mozilla::UniquePtr<char16_t[], JS::FreePolicy>&& source,
+                                UniqueTwoByteChars&& source,
                                 size_t length);
     void setSource(SharedImmutableTwoByteString&& string);
 
-    MOZ_MUST_USE bool setCompressedSource(
-        ExclusiveContext* cx,
-        mozilla::UniquePtr<char[], JS::FreePolicy>&& raw,
-        size_t rawLength,
-        size_t sourceLength);
+    MOZ_MUST_USE bool setCompressedSource(ExclusiveContext* cx,
+                                          UniqueChars&& raw,
+                                          size_t rawLength,
+                                          size_t sourceLength);
     void setCompressedSource(SharedImmutableString&& raw, size_t sourceLength);
 
     // XDR handling
     template <XDRMode mode>
-    bool performXDR(XDRState<mode>* xdr);
-
-    bool setFilename(ExclusiveContext* cx, const char* filename);
+    MOZ_MUST_USE bool performXDR(XDRState<mode>* xdr);
+
+    MOZ_MUST_USE bool setFilename(ExclusiveContext* cx, const char* filename);
     const char* introducerFilename() const {
         return introducerFilename_ ? introducerFilename_.get() : filename_.get();
     }
     bool hasIntroductionType() const {
         return introductionType_;
     }
     const char* introductionType() const {
         MOZ_ASSERT(hasIntroductionType());
         return introductionType_;
     }
     const char* filename() const {
         return filename_.get();
     }
 
     // Display URLs
-    bool setDisplayURL(ExclusiveContext* cx, const char16_t* displayURL);
+    MOZ_MUST_USE bool setDisplayURL(ExclusiveContext* cx, const char16_t* displayURL);
     bool hasDisplayURL() const { return displayURL_ != nullptr; }
     const char16_t * displayURL() {
         MOZ_ASSERT(hasDisplayURL());
         return displayURL_.get();
     }
 
     // Source maps
-    bool setSourceMapURL(ExclusiveContext* cx, const char16_t* sourceMapURL);
+    MOZ_MUST_USE bool setSourceMapURL(ExclusiveContext* cx, const char16_t* sourceMapURL);
     bool hasSourceMapURL() const { return sourceMapURL_ != nullptr; }
     const char16_t * sourceMapURL() {
         MOZ_ASSERT(hasSourceMapURL());
         return sourceMapURL_.get();
     }
 
     bool mutedErrors() const { return mutedErrors_; }