Bug 1529298 - Remove the useless OwnsState argument from ArrayBufferObject::setDataPointer. r=sfink
authorJeff Walden <jwalden@mit.edu>
Wed, 20 Feb 2019 13:33:17 -0800
changeset 519505 ef4c27821811d19a0dc64e4d9b4d2e7841bb1370
parent 519504 a06864bc83520a544a3412f81b5d3ef0e930138b
child 519506 650bd5a18809655323834c7b56d84ad6c512d752
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs1529298
milestone67.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 1529298 - Remove the useless OwnsState argument from ArrayBufferObject::setDataPointer. r=sfink
js/src/vm/ArrayBufferObject.cpp
js/src/vm/ArrayBufferObject.h
--- a/js/src/vm/ArrayBufferObject.cpp
+++ b/js/src/vm/ArrayBufferObject.cpp
@@ -533,17 +533,17 @@ void ArrayBufferObject::setNewData(FreeO
     //     the call just above in ABO::detach occurs only if this assertion is
     //     true, and the call in ABO::changeContents happens only if
     //     ABO::prepareForAsmJS calls ABO::changeContents, but *that* call is
     //     guarded by an owns-data check.  So no need to touch this right now.
     MOZ_ASSERT(newContents.data() != dataPointer());
     releaseData(fop);
   }
 
-  setDataPointer(newContents, OwnsData);
+  setDataPointer(newContents);
 }
 
 // This is called *only* from changeContents(), below.
 // By construction, every view parameter will be mapping unshared memory (an
 // ArrayBuffer). Hence no reason to worry about shared memory here.
 
 void ArrayBufferObject::changeViewContents(JSContext* cx,
                                            ArrayBufferViewObject* view,
@@ -1052,20 +1052,19 @@ void ArrayBufferObject::releaseData(Free
       }
       break;
     case BAD1:
       MOZ_CRASH("invalid BufferKind encountered");
       break;
   }
 }
 
-void ArrayBufferObject::setDataPointer(BufferContents contents,
-                                       OwnsState ownsData) {
+void ArrayBufferObject::setDataPointer(BufferContents contents) {
   setFixedSlot(DATA_SLOT, PrivateValue(contents.data()));
-  setOwnsData(ownsData);
+  setOwnsData(OwnsData);
   setFlags((flags() & ~KIND_MASK) | contents.kind());
 
   if (isExternal()) {
     auto info = freeInfo();
     info->freeFunc = contents.freeFunc();
     info->freeUserData = contents.freeUserData();
   }
 }
@@ -1147,17 +1146,17 @@ static void CheckStealPreconditions(Hand
     return false;
   }
 
   // Extract the grown contents from |oldBuf|.
   BufferContents oldContents = oldBuf->contents();
 
   // Overwrite |oldBuf|'s data pointer *without* releasing old data.
   BufferContents detachedContents = BufferContents::createNoData();
-  oldBuf->setDataPointer(detachedContents, OwnsData);
+  oldBuf->setDataPointer(detachedContents);
 
   // Detach |oldBuf| now that doing so won't release |oldContents|.
   ArrayBufferObject::detach(cx, oldBuf, detachedContents);
 
   // Set |newBuf|'s contents to |oldBuf|'s original contents.
   newBuf->initialize(newSize, oldContents);
   return true;
 }
@@ -1378,17 +1377,17 @@ ArrayBufferObject* ArrayBufferObject::cr
     return nullptr;
   }
 
   buffer->setByteLength(initialSize);
   buffer->setFlags(0);
   buffer->setFirstView(nullptr);
 
   auto contents = BufferContents::createWasm(rawBuffer->dataPointer());
-  buffer->setDataPointer(contents, OwnsData);
+  buffer->setDataPointer(contents);
 
   cx->updateMallocCounter(initialSize);
 
   return buffer;
 }
 
 /* static */ uint8_t* ArrayBufferObject::stealMallocedContents(
     JSContext* cx, Handle<ArrayBufferObject*> buffer) {
@@ -1398,17 +1397,17 @@ ArrayBufferObject* ArrayBufferObject::cr
     case MALLOCED:
       if (buffer->ownsData()) {
         uint8_t* stolenData = buffer->dataPointer();
         MOZ_ASSERT(stolenData);
 
         // Overwrite the old data pointer *without* releasing the contents
         // being stolen.
         BufferContents newContents = BufferContents::createNoData();
-        buffer->setDataPointer(newContents, OwnsData);
+        buffer->setDataPointer(newContents);
 
         // Detach |buffer| now that doing so won't free |stolenData|.
         ArrayBufferObject::detach(cx, buffer, newContents);
         return stolenData;
       }
       MOZ_FALLTHROUGH;
 
     case INLINE_DATA:
@@ -1465,17 +1464,17 @@ ArrayBufferObject::extractStructuredClon
     }
 
     case MALLOCED:
     case MAPPED: {
       MOZ_ASSERT(contents);
 
       // Overwrite the old data pointer *without* releasing old data.
       BufferContents newContents = BufferContents::createNoData();
-      buffer->setDataPointer(newContents, OwnsData);
+      buffer->setDataPointer(newContents);
 
       // Detach |buffer| now that doing so won't release |oldContents|.
       ArrayBufferObject::detach(cx, buffer, newContents);
       return contents;
     }
 
     case WASM:
       JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr,
--- a/js/src/vm/ArrayBufferObject.h
+++ b/js/src/vm/ArrayBufferObject.h
@@ -444,17 +444,17 @@ class ArrayBufferObject : public ArrayBu
 
   static size_t offsetOfDataSlot() { return getFixedSlotOffset(DATA_SLOT); }
 
   void setHasTypedObjectViews() { setFlags(flags() | TYPED_OBJECT_VIEWS); }
 
   bool ownsData() const { return flags() & OWNS_DATA; }
 
  protected:
-  void setDataPointer(BufferContents contents, OwnsState ownsState);
+  void setDataPointer(BufferContents contents);
   void setByteLength(uint32_t length);
 
   uint32_t flags() const;
   void setFlags(uint32_t flags);
 
   void setOwnsData(OwnsState owns) {
     setFlags(owns ? (flags() | OWNS_DATA) : (flags() & ~OWNS_DATA));
   }
@@ -469,17 +469,17 @@ class ArrayBufferObject : public ArrayBu
     MOZ_ASSERT(isMalloced() || isMapped() || isExternal());
     setFlags(flags() | FOR_ASMJS);
   }
 
   void initialize(size_t byteLength, BufferContents contents) {
     setByteLength(byteLength);
     setFlags(0);
     setFirstView(nullptr);
-    setDataPointer(contents, OwnsData);
+    setDataPointer(contents);
   }
 
   void* initializeToInlineData(size_t byteLength) {
     void* data = inlineDataPointer();
     initialize(byteLength, BufferContents::createInlineData(data));
     return data;
   }
 };