Bug 1529298 - Rename JS_NewArrayBufferWithExternalContents to JS_NewArrayBufferWithUserOwnedContents to better accord with the USER_OWNED ArrayBufferKind name, and to avoid namespace overload with the semantically distinct JS_NewExternalArrayBuffer and JS_ExternalizeArrayBufferContents functions. r=sfink
authorJeff Walden <jwalden@mit.edu>
Mon, 18 Feb 2019 22:48:06 -0800
changeset 460379 efd2d5e7ec57c3f347b74ace7ea4605b84bfeac5
parent 460378 9cb1a38c00ed72c33b02781d4ece643fb80ba5fd
child 460380 c0aee08543ad5825d3a08aedf60ea8b1f524625f
push id112085
push userjwalden@mit.edu
push dateFri, 22 Feb 2019 04:41:17 +0000
treeherdermozilla-inbound@5b7a07b449ba [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 - Rename JS_NewArrayBufferWithExternalContents to JS_NewArrayBufferWithUserOwnedContents to better accord with the USER_OWNED ArrayBufferKind name, and to avoid namespace overload with the semantically distinct JS_NewExternalArrayBuffer and JS_ExternalizeArrayBufferContents functions. r=sfink
js/src/jsapi-tests/moz.build
js/src/jsapi-tests/testArrayBufferWithUserOwnedContents.cpp
js/src/jsapi-tests/testAtomicOperations.cpp
js/src/jsapi-tests/testExternalArrayBuffer.cpp
js/src/jsapi.h
js/src/vm/ArrayBufferObject.cpp
toolkit/recordreplay/ipc/ParentGraphics.cpp
--- a/js/src/jsapi-tests/moz.build
+++ b/js/src/jsapi-tests/moz.build
@@ -9,16 +9,17 @@ GeckoProgram('jsapi-tests', linkage=None
 include('../js-cxxflags.mozbuild')
 
 UNIFIED_SOURCES += [
     'selfTest.cpp',
     'testAddPropertyPropcache.cpp',
     'testArgumentsObject.cpp',
     'testArrayBuffer.cpp',
     'testArrayBufferView.cpp',
+    'testArrayBufferWithUserOwnedContents.cpp',
     'testAtomicOperations.cpp',
     'testBoundFunction.cpp',
     'testBug604087.cpp',
     'testCallArgs.cpp',
     'testCallNonGenericMethodOnProxy.cpp',
     'testChromeBuffer.cpp',
     'testCloneScript.cpp',
     'testCompileNonSyntactic.cpp',
@@ -31,17 +32,16 @@ UNIFIED_SOURCES += [
     'testDefinePropertyIgnoredAttributes.cpp',
     'testDeflateStringToUTF8Buffer.cpp',
     'testDifferentNewTargetInvokeConstructor.cpp',
     'testEmptyWindowIsOmitted.cpp',
     'testErrorCopying.cpp',
     'testErrorLineOfContext.cpp',
     'testException.cpp',
     'testExecuteInJSMEnvironment.cpp',
-    'testExternalArrayBuffer.cpp',
     'testExternalStrings.cpp',
     'testFindSCCs.cpp',
     'testForceLexicalInitialization.cpp',
     'testForOfIterator.cpp',
     'testForwardSetProperty.cpp',
     'testFreshGlobalEvalRedefinition.cpp',
     'testFunctionBinding.cpp',
     'testFunctionProperties.cpp',
rename from js/src/jsapi-tests/testExternalArrayBuffer.cpp
rename to js/src/jsapi-tests/testArrayBufferWithUserOwnedContents.cpp
--- a/js/src/jsapi-tests/testExternalArrayBuffer.cpp
+++ b/js/src/jsapi-tests/testArrayBufferWithUserOwnedContents.cpp
@@ -10,20 +10,20 @@ char test_data[] =
     "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
 
 static void GC(JSContext* cx) {
   JS_GC(cx);
   // Trigger another to wait for background finalization to end.
   JS_GC(cx);
 }
 
-BEGIN_TEST(testExternalArrayBuffer) {
+BEGIN_TEST(testArrayBufferWithUserOwnedContents) {
   size_t length = sizeof(test_data);
   JS::RootedObject obj(
-      cx, JS_NewArrayBufferWithExternalContents(cx, length, test_data));
+      cx, JS_NewArrayBufferWithUserOwnedContents(cx, length, test_data));
   GC(cx);
   CHECK(VerifyObject(obj, length));
   GC(cx);
   JS_DetachArrayBuffer(cx, obj);
   GC(cx);
   CHECK(VerifyObject(obj, 0));
 
   return true;
@@ -39,9 +39,9 @@ bool VerifyObject(JS::HandleObject obj, 
   const char* data = reinterpret_cast<const char*>(
       JS_GetArrayBufferData(obj, &sharedDummy, nogc));
   CHECK(data);
   CHECK(test_data == data);
 
   return true;
 }
 
-END_TEST(testExternalArrayBuffer)
+END_TEST(testArrayBufferWithUserOwnedContents)
--- a/js/src/jsapi-tests/testAtomicOperations.cpp
+++ b/js/src/jsapi-tests/testAtomicOperations.cpp
@@ -5,16 +5,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/Alignment.h"
 #include "mozilla/Assertions.h"
 
 #include "jit/AtomicOperations.h"
 #include "jsapi-tests/tests.h"
+#include "vm/ArrayBufferObject.h"
 #include "vm/SharedMem.h"
 #include "wasm/WasmJS.h"
 
 using namespace js;
 
 // Machinery to disguise pointer addresses to the C++ compiler -- quite possibly
 // not thread-safe.
 
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -2065,17 +2065,17 @@ extern JS_PUBLIC_API JSObject* JS_NewExt
     JSContext* cx, size_t nbytes, void* contents,
     JS::BufferContentsFreeFunc freeFunc, void* freeUserData = nullptr);
 
 /**
  * Create a new array buffer with the given contents.  The array buffer does not
  * take ownership of contents.  JS_DetachArrayBuffer must be called before
  * the contents are disposed of by the user; this call will always succeed.
  */
-extern JS_PUBLIC_API JSObject* JS_NewArrayBufferWithExternalContents(
+extern JS_PUBLIC_API JSObject* JS_NewArrayBufferWithUserOwnedContents(
     JSContext* cx, size_t nbytes, void* contents);
 
 /**
  * Steal the contents of the given array buffer. The array buffer has its
  * length set to 0 and its contents array cleared. The caller takes ownership
  * of the return value and must free it or transfer ownership via
  * JS_NewArrayBufferWithContents when done using it.
  */
--- a/js/src/vm/ArrayBufferObject.cpp
+++ b/js/src/vm/ArrayBufferObject.cpp
@@ -1694,19 +1694,19 @@ JS_PUBLIC_API JSObject* JS_NewExternalAr
   ArrayBufferObject::BufferContents contents =
       ArrayBufferObject::BufferContents::createExternal(data, freeFunc,
                                                         freeUserData);
   return ArrayBufferObject::create(cx, nbytes, contents,
                                    ArrayBufferObject::OwnsData,
                                    /* proto = */ nullptr, TenuredObject);
 }
 
-JS_PUBLIC_API JSObject* JS_NewArrayBufferWithExternalContents(JSContext* cx,
-                                                              size_t nbytes,
-                                                              void* data) {
+JS_PUBLIC_API JSObject* JS_NewArrayBufferWithUserOwnedContents(JSContext* cx,
+                                                               size_t nbytes,
+                                                               void* data) {
   AssertHeapIsIdle();
   CHECK_THREAD(cx);
   MOZ_ASSERT_IF(!data, nbytes == 0);
 
   using BufferContents = ArrayBufferObject::BufferContents;
 
   BufferContents contents = BufferContents::createUserOwned(data);
   return ArrayBufferObject::create(cx, nbytes, contents,
--- a/toolkit/recordreplay/ipc/ParentGraphics.cpp
+++ b/toolkit/recordreplay/ipc/ParentGraphics.cpp
@@ -162,28 +162,28 @@ void UpdateGraphicsInUIProcess(const Pai
   }
 
   AutoSafeJSContext cx;
   JSAutoRealm ar(cx, xpc::PrivilegedJunkScope());
 
   // Create an ArrayBuffer whose contents are the externally-provided |memory|.
   JS::RootedObject bufferObject(cx);
   bufferObject =
-      JS_NewArrayBufferWithExternalContents(cx, width * height * 4, memory);
+      JS_NewArrayBufferWithUserOwnedContents(cx, width * height * 4, memory);
   MOZ_RELEASE_ASSERT(bufferObject);
 
   JS::RootedValue buffer(cx, ObjectValue(*bufferObject));
 
   // Call into the graphics module to update the canvas it manages.
   if (NS_FAILED(gGraphics->UpdateCanvas(buffer, width, height, hadFailure))) {
     MOZ_CRASH("UpdateGraphicsInUIProcess");
   }
 
   // Manually detach this ArrayBuffer once this update completes, as the
-  // JS_NewArrayBufferWithExternalContents API mandates.  (The API also
+  // JS_NewArrayBufferWithUserOwnedContents API mandates.  (The API also
   // guarantees that this call always succeeds.)
   MOZ_ALWAYS_TRUE(JS_DetachArrayBuffer(cx, bufferObject));
 }
 
 static void MaybeTriggerExplicitPaint() {
   if (gLastExplicitPaint &&
       gLastExplicitPaint->mCheckpointId == gLastCheckpoint) {
     UpdateGraphicsInUIProcess(gLastExplicitPaint.get());