Bug 1529298 - Remove ArrayBufferObject::stealContents now that it's unused. r=sfink
authorJeff Walden <jwalden@mit.edu>
Wed, 20 Feb 2019 13:33:16 -0800
changeset 461617 5cb592de5e03d0df8254bbd779d84760b0d16eef
parent 461616 63536a044a29b3f723e3ee829f260dafc41feb54
child 461618 a7a39ff0615820e92079562b305e996865e7b56f
push id35626
push usercsabou@mozilla.com
push dateThu, 28 Feb 2019 11:31:08 +0000
treeherdermozilla-central@2ea0c1db7e60 [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 ArrayBufferObject::stealContents now that it's unused. r=sfink
js/src/vm/ArrayBufferObject.cpp
js/src/vm/ArrayBufferObject.h
--- a/js/src/vm/ArrayBufferObject.cpp
+++ b/js/src/vm/ArrayBufferObject.cpp
@@ -1497,63 +1497,16 @@ ArrayBufferObject::extractStructuredClon
       MOZ_ASSERT_UNREACHABLE("bad kind when stealing malloc'd data");
       break;
   }
 
   MOZ_ASSERT_UNREACHABLE("garbage kind computed");
   return BufferContents::createFailed();
 }
 
-/* static */ ArrayBufferObject::BufferContents ArrayBufferObject::stealContents(
-    JSContext* cx, Handle<ArrayBufferObject*> buffer,
-    bool hasStealableContents) {
-  CheckStealPreconditions(buffer, cx);
-
-#ifdef DEBUG
-  if (hasStealableContents) {
-    MOZ_ASSERT(!buffer->isInlineData(),
-               "inline data is OwnsData, but it isn't malloc-allocated");
-    MOZ_ASSERT(!buffer->isNoData(),
-               "null |dataPointer()| for the no-data case isn't stealable "
-               "because it would be confused with failure");
-    MOZ_ASSERT(!buffer->hasUserOwnedData(),
-               "user-owned data isn't stealable or necessarily malloc'd");
-
-    // wasm buffers can't be stolen by |JS_StealArrayBufferContents|, but
-    // but *this* function is used internally by the impl of memory growth, so
-    // we can't assert |!buffer->isWasm()|.
-
-    // Mapped buffers can't be stolen by |JS_StealArrayBufferContents| which
-    // only can steal malloc'd data.  But they *can* be stolen when structured
-    // clone code calls this function, so they can appear here.
-
-    MOZ_ASSERT(!buffer->isExternal(),
-               "external data isn't necessarily malloc-allocated");
-  }
-#endif
-
-  BufferContents oldContents = buffer->contents();
-
-  if (hasStealableContents) {
-    buffer->setOwnsData(DoesntOwnData);  // Do not free the stolen data.
-    ArrayBufferObject::detach(cx, buffer, BufferContents::createNoData());
-    return oldContents;
-  }
-
-  // Create a new chunk of memory to return since we cannot steal the
-  // existing contents away from the buffer.
-  uint8_t* dataCopy = NewCopiedBufferContents(cx, buffer);
-  if (!dataCopy) {
-    return BufferContents::createFailed();
-  }
-
-  ArrayBufferObject::detach(cx, buffer, oldContents);
-  return BufferContents::createMalloced(dataCopy);
-}
-
 /* static */ void ArrayBufferObject::addSizeOfExcludingThis(
     JSObject* obj, mozilla::MallocSizeOf mallocSizeOf, JS::ClassInfo* info) {
   ArrayBufferObject& buffer = AsArrayBuffer(obj);
 
   if (!buffer.ownsData()) {
     return;
   }
 
--- a/js/src/vm/ArrayBufferObject.h
+++ b/js/src/vm/ArrayBufferObject.h
@@ -349,20 +349,16 @@ class ArrayBufferObject : public ArrayBu
                        Handle<ArrayBufferObject*> fromBuffer,
                        uint32_t fromIndex, uint32_t count);
 
   static size_t objectMoved(JSObject* obj, JSObject* old);
 
   static uint8_t* stealMallocedContents(JSContext* cx,
                                         Handle<ArrayBufferObject*> buffer);
 
-  static BufferContents stealContents(JSContext* cx,
-                                      Handle<ArrayBufferObject*> buffer,
-                                      bool hasStealableContents);
-
   static BufferContents extractStructuredCloneContents(
       JSContext* cx, Handle<ArrayBufferObject*> buffer);
 
   static void addSizeOfExcludingThis(JSObject* obj,
                                      mozilla::MallocSizeOf mallocSizeOf,
                                      JS::ClassInfo* info);
 
   // ArrayBufferObjects (strongly) store the first view added to them, while