Bug 1529298 - Remove ArrayBufferObject::hasData and perform its operation in its sole caller in a more straightforward manner. r=sfink
☠☠ backed out by eed1098d0d6c ☠ ☠
authorJeff Walden <jwalden@mit.edu>
Mon, 18 Feb 2019 22:52:41 -0800
changeset 460364 5be8cb19ad3d9f581bacf4a6acf9a7dba43dd5da
parent 460363 432b2e88c651908122e95cc5bdca63aed1758217
child 460365 1477b8eb544268bdd7deacd909077bfbebc59f0e
push id112082
push userjwalden@mit.edu
push dateFri, 22 Feb 2019 02:22:21 +0000
treeherdermozilla-inbound@d80b681a68e6 [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::hasData and perform its operation in its sole caller in a more straightforward manner. r=sfink
js/src/jsfriendapi.h
js/src/vm/ArrayBufferObject.cpp
js/src/vm/ArrayBufferObject.h
--- a/js/src/jsfriendapi.h
+++ b/js/src/jsfriendapi.h
@@ -1800,18 +1800,18 @@ extern JS_FRIEND_API bool JS_IsSharedArr
  * that it would pass such a test: it is an ArrayBuffer or a wrapper of an
  * ArrayBuffer, and the unwrapping will succeed.
  */
 extern JS_FRIEND_API uint32_t JS_GetArrayBufferByteLength(JSObject* obj);
 
 extern JS_FRIEND_API uint32_t JS_GetSharedArrayBufferByteLength(JSObject* obj);
 
 /**
- * Return true if the arrayBuffer contains any data. This will return false for
- * ArrayBuffer.prototype and detached ArrayBuffers.
+ * Return true if the ArrayBuffer |obj| contains any data, i.e. it is not a
+ * detached ArrayBuffer.  (ArrayBuffer.prototype is not an ArrayBuffer.)
  *
  * |obj| must have passed a JS_IsArrayBufferObject test, or somehow be known
  * that it would pass such a test: it is an ArrayBuffer or a wrapper of an
  * ArrayBuffer, and the unwrapping will succeed.
  */
 extern JS_FRIEND_API bool JS_ArrayBufferHasData(JSObject* obj);
 
 /**
--- a/js/src/vm/ArrayBufferObject.cpp
+++ b/js/src/vm/ArrayBufferObject.cpp
@@ -1702,17 +1702,17 @@ JS_PUBLIC_API JSObject* JS_NewArrayBuffe
                                    /* proto = */ nullptr, TenuredObject);
 }
 
 JS_FRIEND_API bool JS_IsArrayBufferObject(JSObject* obj) {
   return obj->canUnwrapAs<ArrayBufferObject>();
 }
 
 JS_FRIEND_API bool JS_ArrayBufferHasData(JSObject* obj) {
-  return obj->unwrapAs<ArrayBufferObject>().hasData();
+  return !obj->unwrapAs<ArrayBufferObject>().isDetached();
 }
 
 JS_FRIEND_API JSObject* js::UnwrapArrayBuffer(JSObject* obj) {
   return obj->maybeUnwrapIf<ArrayBufferObject>();
 }
 
 JS_FRIEND_API JSObject* js::UnwrapSharedArrayBuffer(JSObject* obj) {
   return obj->maybeUnwrapIf<SharedArrayBufferObject>();
--- a/js/src/vm/ArrayBufferObject.h
+++ b/js/src/vm/ArrayBufferObject.h
@@ -394,22 +394,16 @@ class ArrayBufferObject : public ArrayBu
                             freeInfo()->freeUserData);
     }
     return BufferContents(dataPointer(), bufferKind());
   }
   bool hasInlineData() const { return dataPointer() == inlineDataPointer(); }
 
   void releaseData(FreeOp* fop);
 
-  /*
-   * Check if the arrayBuffer contains any data. This will return false for
-   * ArrayBuffer.prototype and detached ArrayBuffers.
-   */
-  bool hasData() const { return getClass() == &class_; }
-
   BufferKind bufferKind() const {
     return BufferKind(flags() & BUFFER_KIND_MASK);
   }
 
   bool isInlineData() const { return bufferKind() == INLINE_DATA; }
   bool isMalloced() const { return bufferKind() == MALLOCED; }
   bool hasUserOwnedData() const { return bufferKind() == USER_OWNED; }