Bug 1529298 - Remove the useless OwnsState argument from ArrayBufferObject::initialize. r=sfink
authorJeff Walden <jwalden@mit.edu>
Wed, 20 Feb 2019 13:33:17 -0800
changeset 519504 a06864bc83520a544a3412f81b5d3ef0e930138b
parent 519503 f4101f4427821666a773c683fc893e977c81946b
child 519505 ef4c27821811d19a0dc64e4d9b4d2e7841bb1370
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::initialize. r=sfink
js/src/vm/ArrayBufferObject.cpp
js/src/vm/ArrayBufferObject.h
--- a/js/src/vm/ArrayBufferObject.cpp
+++ b/js/src/vm/ArrayBufferObject.cpp
@@ -1153,17 +1153,17 @@ static void CheckStealPreconditions(Hand
   // Overwrite |oldBuf|'s data pointer *without* releasing old data.
   BufferContents detachedContents = BufferContents::createNoData();
   oldBuf->setDataPointer(detachedContents, OwnsData);
 
   // 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, OwnsData);
+  newBuf->initialize(newSize, oldContents);
   return true;
 }
 
 #ifndef WASM_HUGE_MEMORY
 /* static */ bool ArrayBufferObject::wasmMovingGrowToSize(
     uint32_t newSize, HandleArrayBufferObject oldBuf,
     MutableHandleArrayBufferObject newBuf, JSContext* cx) {
   // On failure, do not throw and ensure that the original buffer is
@@ -1186,17 +1186,17 @@ static void CheckStealPreconditions(Hand
 
   WasmArrayRawBuffer* newRawBuf =
       WasmArrayRawBuffer::Allocate(newSize, Nothing());
   if (!newRawBuf) {
     return false;
   }
   BufferContents contents =
       BufferContents::createWasm(newRawBuf->dataPointer());
-  newBuf->initialize(newSize, contents, OwnsData);
+  newBuf->initialize(newSize, contents);
 
   memcpy(newBuf->dataPointer(), oldBuf->dataPointer(), oldBuf->byteLength());
   ArrayBufferObject::detach(cx, oldBuf, BufferContents::createNoData());
   return true;
 }
 
 uint32_t ArrayBufferObject::wasmBoundsCheckLimit() const {
   if (isWasm()) {
@@ -1295,17 +1295,17 @@ ArrayBufferObject* ArrayBufferObject::cr
   if (!buffer) {
     return nullptr;
   }
 
   MOZ_ASSERT(!gc::IsInsideNursery(buffer),
              "ArrayBufferObject has a finalizer that must be called to not "
              "leak in some cases, so it can't be nursery-allocated");
 
-  buffer->initialize(nbytes, contents, OwnsData);
+  buffer->initialize(nbytes, contents);
 
   return buffer;
 }
 
 ArrayBufferObject* ArrayBufferObject::createZeroed(
     JSContext* cx, uint32_t nbytes, HandleObject proto /* = nullptr */) {
   // 24.1.1.1, step 3 (Inlined 6.2.6.1 CreateByteDataBlock, step 2).
   if (!CheckArrayBufferTooLarge(cx, nbytes)) {
@@ -1344,33 +1344,33 @@ ArrayBufferObject* ArrayBufferObject::cr
     return nullptr;
   }
 
   MOZ_ASSERT(!gc::IsInsideNursery(buffer),
              "ArrayBufferObject has a finalizer that must be called to not "
              "leak in some cases, so it can't be nursery-allocated");
 
   if (data) {
-    buffer->initialize(nbytes, BufferContents::createMalloced(data), OwnsData);
+    buffer->initialize(nbytes, BufferContents::createMalloced(data));
   } else {
     void* inlineData = buffer->initializeToInlineData(nbytes);
     memset(inlineData, 0, nbytes);
   }
 
   return buffer;
 }
 
 ArrayBufferObject* ArrayBufferObject::createEmpty(JSContext* cx) {
   AutoSetNewObjectMetadata metadata(cx);
   ArrayBufferObject* obj = NewBuiltinClassInstance<ArrayBufferObject>(cx);
   if (!obj) {
     return nullptr;
   }
 
-  obj->initialize(0, BufferContents::createNoData(), OwnsData);
+  obj->initialize(0, BufferContents::createNoData());
   return obj;
 }
 
 ArrayBufferObject* ArrayBufferObject::createFromNewRawBuffer(
     JSContext* cx, WasmArrayRawBuffer* rawBuffer, uint32_t initialSize) {
   AutoSetNewObjectMetadata metadata(cx);
   ArrayBufferObject* buffer = NewBuiltinClassInstance<ArrayBufferObject>(cx);
   if (!buffer) {
--- a/js/src/vm/ArrayBufferObject.h
+++ b/js/src/vm/ArrayBufferObject.h
@@ -465,27 +465,26 @@ class ArrayBufferObject : public ArrayBu
   void setIsPreparedForAsmJS() {
     MOZ_ASSERT(!isWasm());
     MOZ_ASSERT(!hasUserOwnedData());
     MOZ_ASSERT(!isInlineData());
     MOZ_ASSERT(isMalloced() || isMapped() || isExternal());
     setFlags(flags() | FOR_ASMJS);
   }
 
-  void initialize(size_t byteLength, BufferContents contents,
-                  OwnsState ownsState) {
+  void initialize(size_t byteLength, BufferContents contents) {
     setByteLength(byteLength);
     setFlags(0);
     setFirstView(nullptr);
-    setDataPointer(contents, ownsState);
+    setDataPointer(contents, OwnsData);
   }
 
   void* initializeToInlineData(size_t byteLength) {
     void* data = inlineDataPointer();
-    initialize(byteLength, BufferContents::createInlineData(data), OwnsData);
+    initialize(byteLength, BufferContents::createInlineData(data));
     return data;
   }
 };
 
 typedef Rooted<ArrayBufferObject*> RootedArrayBufferObject;
 typedef Handle<ArrayBufferObject*> HandleArrayBufferObject;
 typedef MutableHandle<ArrayBufferObject*> MutableHandleArrayBufferObject;