Bug 1529298 - Inline ArrayBufferObject::setNewData into its sole caller. r=sfink
authorJeff Walden <jwalden@mit.edu>
Wed, 20 Feb 2019 13:51:58 -0800
changeset 519510 9103748036d1d9f72d34474014c9ce0267271eb5
parent 519509 ab967077f8a309b0d383297d071cd8397a100f7c
child 519511 bb879a6a95f89fc3319899d3267c77a071d88076
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 - Inline ArrayBufferObject::setNewData into its sole caller. r=sfink
js/src/vm/ArrayBufferObject.cpp
js/src/vm/ArrayBufferObject.h
--- a/js/src/vm/ArrayBufferObject.cpp
+++ b/js/src/vm/ArrayBufferObject.cpp
@@ -512,35 +512,24 @@ static uint8_t* NewCopiedBufferContents(
     innerViews.removeViews(buffer);
   }
   if (JSObject* view = buffer->firstView()) {
     NoteViewBufferWasDetached(&view->as<ArrayBufferViewObject>());
     buffer->setFirstView(nullptr);
   }
 
   if (buffer->dataPointer()) {
-    buffer->setNewData(cx->runtime()->defaultFreeOp(),
-                       BufferContents::createNoData());
+    buffer->releaseData(cx->runtime()->defaultFreeOp());
+    buffer->setDataPointer(BufferContents::createNoData());
   }
 
   buffer->setByteLength(0);
   buffer->setIsDetached();
 }
 
-void ArrayBufferObject::setNewData(FreeOp* fop, BufferContents newContents) {
-  // XXX All callers of this check are changing data pointer, so this assertion
-  //     is fine.  But we might consider just inlining these steps into the
-  //     callers, making the release-operation for changing data pointer
-  //     explicit everywhere it occurs.
-  MOZ_ASSERT(newContents.data() != dataPointer());
-  releaseData(fop);
-
-  setDataPointer(newContents);
-}
-
 /*
  * [SMDOC] WASM Linear Memory structure
  *
  * Wasm Raw Buf Linear Memory Structure
  *
  * The linear heap in Wasm is an mmaped array buffer. Several
  * constants manage its lifetime:
  *
--- a/js/src/vm/ArrayBufferObject.h
+++ b/js/src/vm/ArrayBufferObject.h
@@ -353,18 +353,16 @@ class ArrayBufferObject : public ArrayBu
   // later views are (weakly) stored in the compartment's InnerViewTable
   // below. Buffers usually only have one view, so this slot optimizes for
   // the common case. Avoiding entries in the InnerViewTable saves memory and
   // non-incrementalized sweep time.
   JSObject* firstView();
 
   bool addView(JSContext* cx, JSObject* view);
 
-  void setNewData(FreeOp* fop, BufferContents newContents);
-
   // Detach this buffer from its original memory.  (This necessarily makes
   // views of this buffer unusable for modifying that original memory.)
   static void detach(JSContext* cx, Handle<ArrayBufferObject*> buffer);
 
  private:
   void setFirstView(JSObject* view);
 
   uint8_t* inlineDataPointer() const;