diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index 7e641b0185e2..42533dd67f32 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -5680,12 +5680,6 @@ def getJSToNativeConversionInfo( "%s" % (firstCap(sourceDescription), exceptionCode) ) - def onFailureIsLarge(): - return CGGeneric( - 'cx.ThrowErrorMessage("%s");\n' - "%s" % (firstCap(sourceDescription), exceptionCode) - ) - def onFailureNotCallable(failureCode): return CGGeneric( failureCode @@ -6905,37 +6899,21 @@ def getJSToNativeConversionInfo( objRef=objRef, badType=onFailureBadType(failureCode, type.name).define(), ) - if type.isBufferSource(): + if not isAllowShared and type.isBufferSource(): if type.isArrayBuffer(): isSharedMethod = "JS::IsSharedArrayBufferObject" - isLargeMethod = "JS::IsLargeArrayBufferMaybeShared" else: assert type.isArrayBufferView() or type.isTypedArray() isSharedMethod = "JS::IsArrayBufferViewShared" - isLargeMethod = "JS::IsLargeArrayBufferView" - if not isAllowShared: - template += fill( - """ - if (${isSharedMethod}(${objRef}.Obj())) { - $*{badType} - } - """, - isSharedMethod=isSharedMethod, - objRef=objRef, - badType=onFailureIsShared().define(), - ) - # For now reject large (> 2 GB) ArrayBuffers and ArrayBufferViews. - # Supporting this will require changing dom::TypedArray and - # consumers. template += fill( """ - if (${isLargeMethod}(${objRef}.Obj())) { + if (${isSharedMethod}(${objRef}.Obj())) { $*{badType} } """, - isLargeMethod=isLargeMethod, + isSharedMethod=isSharedMethod, objRef=objRef, - badType=onFailureIsLarge().define(), + badType=onFailureIsShared().define(), ) template = wrapObjectTemplate( template, type, "${declName}.SetNull();\n", failureCode diff --git a/dom/bindings/Errors.msg b/dom/bindings/Errors.msg index 013948539d6d..2a1026fac8de 100644 --- a/dom/bindings/Errors.msg +++ b/dom/bindings/Errors.msg @@ -72,7 +72,6 @@ MSG_DEF(MSG_IS_NOT_PROMISE, 1, true, JSEXN_TYPEERR, "{0}Argument is not a Promis MSG_DEF(MSG_SW_INSTALL_ERROR, 3, true, JSEXN_TYPEERR, "{0}ServiceWorker script at {1} for scope {2} encountered an error during installation.") MSG_DEF(MSG_SW_SCRIPT_THREW, 3, true, JSEXN_TYPEERR, "{0}ServiceWorker script at {1} for scope {2} threw an exception during script evaluation.") MSG_DEF(MSG_TYPEDARRAY_IS_SHARED, 2, true, JSEXN_TYPEERR, "{0}{1} can't be a SharedArrayBuffer or an ArrayBufferView backed by a SharedArrayBuffer") -MSG_DEF(MSG_TYPEDARRAY_IS_LARGE, 2, true, JSEXN_TYPEERR, "{0}{1} can't be an ArrayBuffer or an ArrayBufferView larger than 2 GB") MSG_DEF(MSG_CACHE_ADD_FAILED_RESPONSE, 4, true, JSEXN_TYPEERR, "{0}Cache got {1} response with bad status {2} while trying to add request {3}") MSG_DEF(MSG_SW_UPDATE_BAD_REGISTRATION, 3, true, JSEXN_TYPEERR, "{0}Failed to update the ServiceWorker for scope {1} because the registration has been {2} since the update was scheduled.") MSG_DEF(MSG_INVALID_DURATION_ERROR, 2, true, JSEXN_TYPEERR, "{0}Invalid duration '{1}'.") diff --git a/dom/bindings/TypedArray.h b/dom/bindings/TypedArray.h index 1435775cf502..bd2f655e568f 100644 --- a/dom/bindings/TypedArray.h +++ b/dom/bindings/TypedArray.h @@ -132,11 +132,7 @@ struct TypedArray_base : public SpiderMonkeyInterfaceObjectStorage, inline void ComputeState() const { MOZ_ASSERT(inited()); MOZ_ASSERT(!mComputed); - uint32_t length; - GetLengthAndDataAndSharedness(mImplObj, &length, &mShared, &mData); - MOZ_RELEASE_ASSERT(length <= INT32_MAX, - "Bindings must have checked ArrayBuffer{View} length"); - mLength = length; + GetLengthAndDataAndSharedness(mImplObj, &mLength, &mShared, &mData); mComputed = true; } diff --git a/dom/bindings/test/mochitest.ini b/dom/bindings/test/mochitest.ini index b93e76ecd401..fa6cc595feab 100644 --- a/dom/bindings/test/mochitest.ini +++ b/dom/bindings/test/mochitest.ini @@ -7,8 +7,6 @@ support-files = file_proxies_via_xray.html forOf_iframe.html !/js/xpconnect/tests/mochitest/file_empty.html -prefs = - javascript.options.large_arraybuffers=true [test_async_stacks.html] [test_ByteString.html] @@ -90,5 +88,3 @@ skip-if = debug == false skip-if = debug == false [test_attributes_on_types.html] skip-if = debug == false -[test_large_arraybuffers.html] -skip-if = bits == 32 # Large ArrayBuffers are only supported on 64-bit platforms. diff --git a/dom/bindings/test/test_large_arraybuffers.html b/dom/bindings/test/test_large_arraybuffers.html deleted file mode 100644 index 64f6fc7276c3..000000000000 --- a/dom/bindings/test/test_large_arraybuffers.html +++ /dev/null @@ -1,97 +0,0 @@ - - - - - - Test for large ArrayBuffers and views - - - - -Mozilla Bug 1688616 -

- -
-
- - - diff --git a/js/public/ArrayBuffer.h b/js/public/ArrayBuffer.h index 165f22132041..95704d32f2c7 100644 --- a/js/public/ArrayBuffer.h +++ b/js/public/ArrayBuffer.h @@ -259,12 +259,6 @@ extern JS_PUBLIC_API bool DetachArrayBuffer(JSContext* cx, extern JS_PUBLIC_API void* StealArrayBufferContents(JSContext* cx, Handle obj); -/** - * Enable or disable support for large (>= 2 GB) ArrayBuffers on 64-bit builds. - * Has no effect on 32-bit builds. - */ -extern JS_PUBLIC_API void SetLargeArrayBuffersEnabled(bool enable); - } // namespace JS #endif /* js_ArrayBuffer_h */ diff --git a/js/public/ArrayBufferMaybeShared.h b/js/public/ArrayBufferMaybeShared.h index 1fe4b5871f3d..3281b6903d3c 100644 --- a/js/public/ArrayBufferMaybeShared.h +++ b/js/public/ArrayBufferMaybeShared.h @@ -89,14 +89,6 @@ extern JS_PUBLIC_API void GetArrayBufferMaybeSharedLengthAndData( extern JS_PUBLIC_API uint8_t* GetArrayBufferMaybeSharedData( JSObject* obj, bool* isSharedMemory, const AutoRequireNoGC&); -/** - * Returns whether the passed array buffer is 'large': its byteLength >= 2 GB. - * See also SetLargeArrayBuffersEnabled. - * - * |obj| must pass a JS::IsArrayBufferObjectMaybeShared test. - */ -extern JS_FRIEND_API bool IsLargeArrayBufferMaybeShared(JSObject* obj); - } // namespace JS #endif /* js_ArrayBufferMaybeShared_h */ diff --git a/js/public/experimental/TypedData.h b/js/public/experimental/TypedData.h index 9673fa54af48..405d5dfe5583 100644 --- a/js/public/experimental/TypedData.h +++ b/js/public/experimental/TypedData.h @@ -419,16 +419,4 @@ JS_FRIEND_API JSObject* JS_NewDataView(JSContext* cx, JS::Handle buffer, size_t byteOffset, size_t byteLength); -namespace JS { - -/* - * Returns whether the passed array buffer view is 'large': its byteLength >= 2 - * GB. See also SetLargeArrayBuffersEnabled. - * - * |obj| must pass a JS_IsArrayBufferViewObject test. - */ -JS_FRIEND_API bool IsLargeArrayBufferView(JSObject* obj); - -} // namespace JS - #endif // js_experimental_TypedData_h diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index ef8bdda813f5..8aa237c6c82e 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -10852,7 +10852,7 @@ static bool SetContextOptions(JSContext* cx, const OptionParser& op) { } if (op.getBoolOption("enable-large-buffers")) { - JS::SetLargeArrayBuffersEnabled(true); + ArrayBufferObject::supportLargeBuffers = true; } if (op.getBoolOption("disable-bailout-loop-check")) { diff --git a/js/src/vm/ArrayBufferObject.cpp b/js/src/vm/ArrayBufferObject.cpp index 1d287a8e1375..8a89baddf164 100644 --- a/js/src/vm/ArrayBufferObject.cpp +++ b/js/src/vm/ArrayBufferObject.cpp @@ -1846,10 +1846,6 @@ JS_PUBLIC_API void* JS::StealArrayBufferContents(JSContext* cx, return ArrayBufferObject::stealMallocedContents(cx, unwrappedBuffer); } -JS_PUBLIC_API void JS::SetLargeArrayBuffersEnabled(bool enable) { - ArrayBufferObject::supportLargeBuffers = enable; -} - JS_PUBLIC_API JSObject* JS::NewMappedArrayBufferWithContents(JSContext* cx, size_t nbytes, void* data) { diff --git a/js/src/vm/ArrayBufferObject.h b/js/src/vm/ArrayBufferObject.h index 8c59a2796d44..3b68610e5be1 100644 --- a/js/src/vm/ArrayBufferObject.h +++ b/js/src/vm/ArrayBufferObject.h @@ -184,8 +184,6 @@ class ArrayBufferObject : public ArrayBufferObjectMaybeShared { static bool supportLargeBuffers; - static constexpr size_t MaxByteLengthForSmallBuffer = INT32_MAX; - // The length of an ArrayBuffer or SharedArrayBuffer can be at most // INT32_MAX. Allow a larger limit on 64-bit platforms if the experimental // large-buffers flag is used. @@ -195,7 +193,7 @@ class ArrayBufferObject : public ArrayBufferObjectMaybeShared { return size_t(8) * 1024 * 1024 * 1024; // 8 GB. } #endif - return MaxByteLengthForSmallBuffer; + return INT32_MAX; } /** The largest number of bytes that can be stored inline. */ diff --git a/js/src/vm/ArrayBufferObjectMaybeShared.cpp b/js/src/vm/ArrayBufferObjectMaybeShared.cpp index 6c915d21654a..f5e544255a74 100644 --- a/js/src/vm/ArrayBufferObjectMaybeShared.cpp +++ b/js/src/vm/ArrayBufferObjectMaybeShared.cpp @@ -58,19 +58,3 @@ JS_PUBLIC_API uint8_t* JS::GetArrayBufferMaybeSharedData( return nullptr; } - -JS_PUBLIC_API bool JS::IsLargeArrayBufferMaybeShared(JSObject* obj) { -#ifdef JS_64BIT - obj = UnwrapArrayBufferMaybeShared(obj); - MOZ_ASSERT(obj); - size_t len = obj->is() - ? obj->as().byteLength().get() - : obj->as().byteLength().get(); - return len > ArrayBufferObject::MaxByteLengthForSmallBuffer; -#else - // Large ArrayBuffers are not supported on 32-bit. - MOZ_ASSERT(ArrayBufferObject::maxBufferByteLength() == - ArrayBufferObject::MaxByteLengthForSmallBuffer); - return false; -#endif -} diff --git a/js/src/vm/ArrayBufferViewObject.cpp b/js/src/vm/ArrayBufferViewObject.cpp index 5605eb345b53..afccdfb97541 100644 --- a/js/src/vm/ArrayBufferViewObject.cpp +++ b/js/src/vm/ArrayBufferViewObject.cpp @@ -296,18 +296,3 @@ JS_PUBLIC_API bool JS::IsArrayBufferViewShared(JSObject* obj) { } return view->isSharedMemory(); } - -JS_FRIEND_API bool JS::IsLargeArrayBufferView(JSObject* obj) { -#ifdef JS_64BIT - obj = &obj->unwrapAs(); - BufferSize len = obj->is() - ? obj->as().byteLength() - : obj->as().byteLength(); - return len.get() > ArrayBufferObject::MaxByteLengthForSmallBuffer; -#else - // Large ArrayBuffers are not supported on 32-bit. - MOZ_ASSERT(ArrayBufferObject::maxBufferByteLength() == - ArrayBufferObject::MaxByteLengthForSmallBuffer); - return false; -#endif -} diff --git a/js/xpconnect/src/XPCJSContext.cpp b/js/xpconnect/src/XPCJSContext.cpp index 1b1a5121cdd9..af2d57405baa 100644 --- a/js/xpconnect/src/XPCJSContext.cpp +++ b/js/xpconnect/src/XPCJSContext.cpp @@ -38,7 +38,6 @@ #include "nsCycleCollectionNoteRootCallback.h" #include "nsCycleCollector.h" #include "jsapi.h" -#include "js/ArrayBuffer.h" #include "js/ContextOptions.h" #include "js/MemoryMetrics.h" #include "js/OffThreadScriptCompilation.h" @@ -942,9 +941,6 @@ static void LoadStartupJSPrefs(XPCJSContext* xpccx) { } JS::SetUseOffThreadParseGlobal(useOffThreadParseGlobal); - - JS::SetLargeArrayBuffersEnabled( - StaticPrefs::javascript_options_large_arraybuffers()); } static void ReloadPrefsCallback(const char* pref, void* aXpccx) { diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index 2f978f26178e..4fa946f6929a 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -5341,11 +5341,6 @@ mirror: always #endif -- name: javascript.options.large_arraybuffers - type: RelaxedAtomicBool - value: false - mirror: always - #--------------------------------------------------------------------------- # Prefs starting with "layers." #---------------------------------------------------------------------------