diff --git a/js/src/builtin/DataViewObject.cpp b/js/src/builtin/DataViewObject.cpp index c9e00fbc17b1..8838b15d81b4 100644 --- a/js/src/builtin/DataViewObject.cpp +++ b/js/src/builtin/DataViewObject.cpp @@ -247,7 +247,7 @@ bool DataViewObject::getAndCheckConstructorArgs( JSMSG_OFFSET_OUT_OF_BUFFER); return false; } - MOZ_ASSERT(offset <= ArrayBufferObject::MaxByteLength); + MOZ_ASSERT(offset <= ArrayBufferObject::ByteLengthLimit); uint64_t viewByteLength = 0; bool autoLength = false; @@ -275,7 +275,7 @@ bool DataViewObject::getAndCheckConstructorArgs( return false; } } - MOZ_ASSERT(viewByteLength <= ArrayBufferObject::MaxByteLength); + MOZ_ASSERT(viewByteLength <= ArrayBufferObject::ByteLengthLimit); *byteOffsetPtr = offset; *byteLengthPtr = viewByteLength; diff --git a/js/src/builtin/TestingFunctions.cpp b/js/src/builtin/TestingFunctions.cpp index 43ced5e4f9a9..60fe8144b276 100644 --- a/js/src/builtin/TestingFunctions.cpp +++ b/js/src/builtin/TestingFunctions.cpp @@ -2216,8 +2216,8 @@ static bool WasmGcArrayLength(JSContext* cx, unsigned argc, Value* vp) { static bool LargeArrayBufferSupported(JSContext* cx, unsigned argc, Value* vp) { CallArgs args = CallArgsFromVp(argc, vp); - args.rval().setBoolean(ArrayBufferObject::MaxByteLength > - ArrayBufferObject::MaxByteLengthForSmallBuffer); + args.rval().setBoolean(ArrayBufferObject::ByteLengthLimit > + ArrayBufferObject::ByteLengthLimitForSmallBuffer); return true; } diff --git a/js/src/ctypes/CTypes.cpp b/js/src/ctypes/CTypes.cpp index d002be016aec..1296e6cbb926 100644 --- a/js/src/ctypes/CTypes.cpp +++ b/js/src/ctypes/CTypes.cpp @@ -8011,7 +8011,7 @@ static bool ReadTypedArrayCommon(JSContext* cx, unsigned argc, Value* vp, CheckedInt size = *length; size *= CType::GetSize(baseType); - if (!size.isValid() || size.value() > ArrayBufferObject::MaxByteLength) { + if (!size.isValid() || size.value() > ArrayBufferObject::ByteLengthLimit) { return SizeOverflow(cx, "data", "typed array"); } diff --git a/js/src/jit/RangeAnalysis.cpp b/js/src/jit/RangeAnalysis.cpp index f8dc2b74ccfd..686ce1d1bb93 100644 --- a/js/src/jit/RangeAnalysis.cpp +++ b/js/src/jit/RangeAnalysis.cpp @@ -1791,13 +1791,13 @@ void MInitializedLength::computeRange(TempAllocator& alloc) { } void MArrayBufferViewLength::computeRange(TempAllocator& alloc) { - if constexpr (ArrayBufferObject::MaxByteLength <= INT32_MAX) { + if constexpr (ArrayBufferObject::ByteLengthLimit <= INT32_MAX) { setRange(Range::NewUInt32Range(alloc, 0, INT32_MAX)); } } void MArrayBufferViewByteOffset::computeRange(TempAllocator& alloc) { - if constexpr (ArrayBufferObject::MaxByteLength <= INT32_MAX) { + if constexpr (ArrayBufferObject::ByteLengthLimit <= INT32_MAX) { setRange(Range::NewUInt32Range(alloc, 0, INT32_MAX)); } } diff --git a/js/src/jit/VMFunctions.cpp b/js/src/jit/VMFunctions.cpp index 07d55388331e..55892338efc4 100644 --- a/js/src/jit/VMFunctions.cpp +++ b/js/src/jit/VMFunctions.cpp @@ -2353,8 +2353,8 @@ void AllocateAndInitTypedArrayBuffer(JSContext* cx, TypedArrayObject* obj, // Negative numbers or zero will bail out to the slow path, which in turn will // raise an invalid argument exception or create a correct object with zero // elements. - constexpr size_t maxByteLength = TypedArrayObject::MaxByteLength; - if (count <= 0 || size_t(count) > maxByteLength / obj->bytesPerElement()) { + constexpr size_t byteLengthLimit = TypedArrayObject::ByteLengthLimit; + if (count <= 0 || size_t(count) > byteLengthLimit / obj->bytesPerElement()) { obj->setFixedSlot(TypedArrayObject::LENGTH_SLOT, PrivateValue(size_t(0))); return; } @@ -2362,7 +2362,7 @@ void AllocateAndInitTypedArrayBuffer(JSContext* cx, TypedArrayObject* obj, obj->setFixedSlot(TypedArrayObject::LENGTH_SLOT, PrivateValue(count)); size_t nbytes = size_t(count) * obj->bytesPerElement(); - MOZ_ASSERT(nbytes <= maxByteLength); + MOZ_ASSERT(nbytes <= byteLengthLimit); nbytes = RoundUp(nbytes, sizeof(Value)); MOZ_ASSERT(!obj->isTenured()); diff --git a/js/src/shell/OSObject.cpp b/js/src/shell/OSObject.cpp index 89277315fa84..0c1ca437778f 100644 --- a/js/src/shell/OSObject.cpp +++ b/js/src/shell/OSObject.cpp @@ -320,7 +320,7 @@ JSObject* FileAsTypedArray(JSContext* cx, JS::HandleString pathnameStr) { return nullptr; } - if (len > ArrayBufferObject::MaxByteLength) { + if (len > ArrayBufferObject::ByteLengthLimit) { JS_ReportErrorUTF8(cx, "file %s is too large for a Uint8Array", pathname.get()); return nullptr; diff --git a/js/src/vm/ArrayBufferObject.cpp b/js/src/vm/ArrayBufferObject.cpp index 5732daee75d8..c54ff88a2b31 100644 --- a/js/src/vm/ArrayBufferObject.cpp +++ b/js/src/vm/ArrayBufferObject.cpp @@ -162,7 +162,7 @@ uint64_t js::WasmReservedBytes() { return wasmReservedBytes; } [[nodiscard]] static bool CheckArrayBufferTooLarge(JSContext* cx, uint64_t nbytes) { // Refuse to allocate too large buffers. - if (MOZ_UNLIKELY(nbytes > ArrayBufferObject::MaxByteLength)) { + if (MOZ_UNLIKELY(nbytes > ArrayBufferObject::ByteLengthLimit)) { JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_BAD_ARRAY_LENGTH); return false; @@ -1488,7 +1488,7 @@ inline size_t ArrayBufferObject::associatedBytes() const { } void ArrayBufferObject::setByteLength(size_t length) { - MOZ_ASSERT(length <= ArrayBufferObject::MaxByteLength); + MOZ_ASSERT(length <= ArrayBufferObject::ByteLengthLimit); setFixedSlot(BYTE_LENGTH_SLOT, PrivateValue(length)); } @@ -1594,7 +1594,7 @@ ArrayBufferObject* ArrayBufferObject::wasmGrowToPagesInPlace( return nullptr; } MOZ_ASSERT(newPages <= wasm::MaxMemoryPages(t) && - newPages.byteLength() <= ArrayBufferObject::MaxByteLength); + newPages.byteLength() <= ArrayBufferObject::ByteLengthLimit); // We have checked against the clamped maximum and so we know we can convert // to byte lengths now. @@ -1652,7 +1652,7 @@ ArrayBufferObject* ArrayBufferObject::wasmMovingGrowToPages( return nullptr; } MOZ_ASSERT(newPages <= wasm::MaxMemoryPages(t) && - newPages.byteLength() < ArrayBufferObject::MaxByteLength); + newPages.byteLength() < ArrayBufferObject::ByteLengthLimit); // We have checked against the clamped maximum and so we know we can convert // to byte lengths now. @@ -1847,7 +1847,7 @@ template ArrayBufferObject::createUninitializedBufferAndData( JSContext* cx, size_t nbytes, AutoSetNewObjectMetadata&, JS::Handle proto) { - MOZ_ASSERT(nbytes <= ArrayBufferObject::MaxByteLength, + MOZ_ASSERT(nbytes <= ArrayBufferObject::ByteLengthLimit, "caller must validate the byte count it passes"); static_assert(std::is_same_v || @@ -1898,7 +1898,7 @@ template ArrayBufferObject::createBufferAndData( JSContext* cx, size_t nbytes, AutoSetNewObjectMetadata& metadata, JS::Handle proto /* = nullptr */) { - MOZ_ASSERT(nbytes <= ArrayBufferObject::MaxByteLength, + MOZ_ASSERT(nbytes <= ArrayBufferObject::ByteLengthLimit, "caller must validate the byte count it passes"); auto [buffer, data] = @@ -1925,7 +1925,7 @@ ResizableArrayBufferObject::createBufferAndData( JSContext* cx, size_t byteLength, size_t maxByteLength, AutoSetNewObjectMetadata& metadata, Handle proto) { MOZ_ASSERT(byteLength <= maxByteLength); - MOZ_ASSERT(maxByteLength <= ArrayBufferObject::MaxByteLength, + MOZ_ASSERT(maxByteLength <= ArrayBufferObject::ByteLengthLimit, "caller must validate the byte count it passes"); // NOTE: The spec proposal for resizable ArrayBuffers suggests to use a @@ -1958,7 +1958,7 @@ ResizableArrayBufferObject::createBufferAndData( JSContext* cx, size_t newByteLength, JS::Handle source) { MOZ_ASSERT(!source->isDetached()); - MOZ_ASSERT(newByteLength <= ArrayBufferObject::MaxByteLength, + MOZ_ASSERT(newByteLength <= ArrayBufferObject::ByteLengthLimit, "caller must validate the byte count it passes"); size_t sourceByteLength = source->byteLength(); @@ -2037,7 +2037,7 @@ ResizableArrayBufferObject::createBufferAndData( JSContext* cx, size_t newByteLength, JS::Handle source) { MOZ_ASSERT(!source->isDetached()); - MOZ_ASSERT(newByteLength <= ArrayBufferObject::MaxByteLength, + MOZ_ASSERT(newByteLength <= ArrayBufferObject::ByteLengthLimit, "caller must validate the byte count it passes"); if (newByteLength > FixedLengthArrayBufferObject::MaxInlineBytes && @@ -2103,7 +2103,7 @@ ResizableArrayBufferObject::createBufferAndData( MOZ_ASSERT(source->bufferKind() == MALLOCED_ARRAYBUFFER_CONTENTS_ARENA); MOZ_ASSERT(newByteLength > FixedLengthArrayBufferObject::MaxInlineBytes, "prefer copying small buffers"); - MOZ_ASSERT(newByteLength <= ArrayBufferObject::MaxByteLength, + MOZ_ASSERT(newByteLength <= ArrayBufferObject::ByteLengthLimit, "caller must validate the byte count it passes"); size_t oldByteLength = source->associatedBytes(); diff --git a/js/src/vm/ArrayBufferObject.h b/js/src/vm/ArrayBufferObject.h index 1b33c0135533..c3d578e0bd1c 100644 --- a/js/src/vm/ArrayBufferObject.h +++ b/js/src/vm/ArrayBufferObject.h @@ -207,12 +207,12 @@ class ArrayBufferObject : public ArrayBufferObjectMaybeShared { // The length of an ArrayBuffer or SharedArrayBuffer can be at most INT32_MAX // on 32-bit platforms. Allow a larger limit on 64-bit platforms. - static constexpr size_t MaxByteLengthForSmallBuffer = INT32_MAX; + static constexpr size_t ByteLengthLimitForSmallBuffer = INT32_MAX; #ifdef JS_64BIT - static constexpr size_t MaxByteLength = + static constexpr size_t ByteLengthLimit = size_t(8) * 1024 * 1024 * 1024; // 8 GB. #else - static constexpr size_t MaxByteLength = MaxByteLengthForSmallBuffer; + static constexpr size_t ByteLengthLimit = ByteLengthLimitForSmallBuffer; #endif public: @@ -649,7 +649,7 @@ class ResizableArrayBufferObject : public ArrayBufferObject { bool hasInlineData() const { return dataPointer() == inlineDataPointer(); } void setMaxByteLength(size_t length) { - MOZ_ASSERT(length <= ArrayBufferObject::MaxByteLength); + MOZ_ASSERT(length <= ArrayBufferObject::ByteLengthLimit); setFixedSlot(MAX_BYTE_LENGTH_SLOT, PrivateValue(length)); } diff --git a/js/src/vm/ArrayBufferObjectMaybeShared.cpp b/js/src/vm/ArrayBufferObjectMaybeShared.cpp index c67662afe296..3412ba781939 100644 --- a/js/src/vm/ArrayBufferObjectMaybeShared.cpp +++ b/js/src/vm/ArrayBufferObjectMaybeShared.cpp @@ -66,11 +66,11 @@ JS_PUBLIC_API bool JS::IsLargeArrayBufferMaybeShared(JSObject* obj) { size_t len = obj->is() ? obj->as().byteLength() : obj->as().byteLength(); - return len > ArrayBufferObject::MaxByteLengthForSmallBuffer; + return len > ArrayBufferObject::ByteLengthLimitForSmallBuffer; #else // Large ArrayBuffers are not supported on 32-bit. - static_assert(ArrayBufferObject::MaxByteLength == - ArrayBufferObject::MaxByteLengthForSmallBuffer); + static_assert(ArrayBufferObject::ByteLengthLimit == + ArrayBufferObject::ByteLengthLimitForSmallBuffer); return false; #endif } diff --git a/js/src/vm/ArrayBufferViewObject.cpp b/js/src/vm/ArrayBufferViewObject.cpp index f1f2344e296b..160aba850ffd 100644 --- a/js/src/vm/ArrayBufferViewObject.cpp +++ b/js/src/vm/ArrayBufferViewObject.cpp @@ -114,12 +114,12 @@ bool ArrayBufferViewObject::init(JSContext* cx, MOZ_ASSERT_IF(!buffer, byteOffset == 0); MOZ_ASSERT_IF(buffer, !buffer->isDetached()); - MOZ_ASSERT(byteOffset <= ArrayBufferObject::MaxByteLength); - MOZ_ASSERT(length <= ArrayBufferObject::MaxByteLength); - MOZ_ASSERT(byteOffset + length <= ArrayBufferObject::MaxByteLength); + MOZ_ASSERT(byteOffset <= ArrayBufferObject::ByteLengthLimit); + MOZ_ASSERT(length <= ArrayBufferObject::ByteLengthLimit); + MOZ_ASSERT(byteOffset + length <= ArrayBufferObject::ByteLengthLimit); MOZ_ASSERT_IF(is(), - length <= TypedArrayObject::MaxByteLength / bytesPerElement); + length <= TypedArrayObject::ByteLengthLimit / bytesPerElement); // The isSharedMemory property is invariant. Self-hosting code that // sets BUFFER_SLOT or the private slot (if it does) must maintain it by @@ -359,11 +359,11 @@ JS_PUBLIC_API bool JS::IsLargeArrayBufferView(JSObject* obj) { size_t len = obj->is() ? obj->as().byteLength().valueOr(0) : obj->as().byteLength().valueOr(0); - return len > ArrayBufferObject::MaxByteLengthForSmallBuffer; + return len > ArrayBufferObject::ByteLengthLimitForSmallBuffer; #else // Large ArrayBuffers are not supported on 32-bit. - static_assert(ArrayBufferObject::MaxByteLength == - ArrayBufferObject::MaxByteLengthForSmallBuffer); + static_assert(ArrayBufferObject::ByteLengthLimit == + ArrayBufferObject::ByteLengthLimitForSmallBuffer); return false; #endif } diff --git a/js/src/vm/SharedArrayObject.cpp b/js/src/vm/SharedArrayObject.cpp index 6cf11ae543f6..73cf73400635 100644 --- a/js/src/vm/SharedArrayObject.cpp +++ b/js/src/vm/SharedArrayObject.cpp @@ -40,7 +40,7 @@ static size_t WasmSharedArrayAccessibleSize(size_t length) { } static size_t NonWasmSharedArrayAllocSize(size_t length) { - MOZ_ASSERT(length <= ArrayBufferObject::MaxByteLength); + MOZ_ASSERT(length <= ArrayBufferObject::ByteLengthLimit); return sizeof(SharedArrayRawBuffer) + length; } @@ -60,8 +60,8 @@ static size_t SharedArrayMappedSize(bool isWasm, size_t length) { SharedArrayRawBuffer* SharedArrayRawBuffer::Allocate(bool isGrowable, size_t length, size_t maxLength) { - MOZ_RELEASE_ASSERT(length <= ArrayBufferObject::MaxByteLength); - MOZ_RELEASE_ASSERT(maxLength <= ArrayBufferObject::MaxByteLength); + MOZ_RELEASE_ASSERT(length <= ArrayBufferObject::ByteLengthLimit); + MOZ_RELEASE_ASSERT(maxLength <= ArrayBufferObject::ByteLengthLimit); MOZ_ASSERT_IF(!isGrowable, length == maxLength); MOZ_ASSERT_IF(isGrowable, length <= maxLength); @@ -84,7 +84,7 @@ WasmSharedArrayRawBuffer* WasmSharedArrayRawBuffer::AllocateWasm( MOZ_ASSERT(initialPages.hasByteLength()); size_t length = initialPages.byteLength(); - MOZ_RELEASE_ASSERT(length <= ArrayBufferObject::MaxByteLength); + MOZ_RELEASE_ASSERT(length <= ArrayBufferObject::ByteLengthLimit); size_t accessibleSize = WasmSharedArrayAccessibleSize(length); if (accessibleSize < length) { @@ -144,7 +144,7 @@ bool WasmSharedArrayRawBuffer::wasmGrowToPagesInPlace(const Lock&, return false; } MOZ_ASSERT(newPages <= wasm::MaxMemoryPages(t) && - newPages.byteLength() <= ArrayBufferObject::MaxByteLength); + newPages.byteLength() <= ArrayBufferObject::ByteLengthLimit); // We have checked against the clamped maximum and so we know we can convert // to byte lengths now. @@ -471,7 +471,7 @@ bool SharedArrayBufferObject::class_constructor(JSContext* cx, unsigned argc, // 24.2.1.1, step 3 (Inlined 6.2.7.2 CreateSharedByteDataBlock, step 2). // Refuse to allocate too large buffers. - if (byteLength > ArrayBufferObject::MaxByteLength) { + if (byteLength > ArrayBufferObject::ByteLengthLimit) { JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_SHARED_ARRAY_BAD_LENGTH); return false; @@ -796,7 +796,7 @@ JS_PUBLIC_API void JS::GetSharedArrayBufferLengthAndData(JSObject* obj, JS_PUBLIC_API JSObject* JS::NewSharedArrayBuffer(JSContext* cx, size_t nbytes) { MOZ_ASSERT(cx->realm()->creationOptions().getSharedMemoryAndAtomicsEnabled()); - if (nbytes > ArrayBufferObject::MaxByteLength) { + if (nbytes > ArrayBufferObject::ByteLengthLimit) { JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_SHARED_ARRAY_BAD_LENGTH); return nullptr; diff --git a/js/src/vm/StructuredClone.cpp b/js/src/vm/StructuredClone.cpp index f2f8da05fb87..7d54c70df0ca 100644 --- a/js/src/vm/StructuredClone.cpp +++ b/js/src/vm/StructuredClone.cpp @@ -2621,8 +2621,8 @@ bool JSStructuredCloneReader::readTypedArray(uint32_t arrayType, } // Ensure invalid 64-bit values won't be truncated below. - if (nelems > ArrayBufferObject::MaxByteLength || - byteOffset > ArrayBufferObject::MaxByteLength) { + if (nelems > ArrayBufferObject::ByteLengthLimit || + byteOffset > ArrayBufferObject::ByteLengthLimit) { JS_ReportErrorNumberASCII(context(), GetErrorMessage, nullptr, JSMSG_SC_BAD_SERIALIZED_DATA, "invalid typed array length or offset"); @@ -2703,8 +2703,8 @@ bool JSStructuredCloneReader::readDataView(uint64_t byteLength, } // Ensure invalid 64-bit values won't be truncated below. - if (byteLength > ArrayBufferObject::MaxByteLength || - byteOffset > ArrayBufferObject::MaxByteLength) { + if (byteLength > ArrayBufferObject::ByteLengthLimit || + byteOffset > ArrayBufferObject::ByteLengthLimit) { JS_ReportErrorNumberASCII(context(), GetErrorMessage, nullptr, JSMSG_SC_BAD_SERIALIZED_DATA, "invalid DataView length or offset"); @@ -2753,8 +2753,8 @@ bool JSStructuredCloneReader::readArrayBuffer(StructuredDataType type, // The maximum ArrayBuffer size depends on the platform, and we cast to size_t // below, so we have to check this here. - if (nbytes > ArrayBufferObject::MaxByteLength || - maxbytes > ArrayBufferObject::MaxByteLength) { + if (nbytes > ArrayBufferObject::ByteLengthLimit || + maxbytes > ArrayBufferObject::ByteLengthLimit) { JS_ReportErrorNumberASCII(context(), GetErrorMessage, nullptr, JSMSG_BAD_ARRAY_LENGTH); return false; @@ -2799,7 +2799,7 @@ bool JSStructuredCloneReader::readSharedArrayBuffer(StructuredDataType type, // The maximum ArrayBuffer size depends on the platform, and we cast to size_t // below, so we have to check this here. - if (byteLength > ArrayBufferObject::MaxByteLength) { + if (byteLength > ArrayBufferObject::ByteLengthLimit) { JS_ReportErrorNumberASCII(context(), GetErrorMessage, nullptr, JSMSG_BAD_ARRAY_LENGTH); return false; @@ -3395,7 +3395,7 @@ bool JSStructuredCloneReader::readTransferMap() { return false; } - MOZ_RELEASE_ASSERT(extraData <= ArrayBufferObject::MaxByteLength); + MOZ_RELEASE_ASSERT(extraData <= ArrayBufferObject::ByteLengthLimit); size_t nbytes = extraData; MOZ_ASSERT(data == JS::SCTAG_TMO_ALLOC_DATA || diff --git a/js/src/vm/TypedArrayObject.cpp b/js/src/vm/TypedArrayObject.cpp index 90a63a9ba0d8..ea0a88760729 100644 --- a/js/src/vm/TypedArrayObject.cpp +++ b/js/src/vm/TypedArrayObject.cpp @@ -374,7 +374,7 @@ class TypedArrayObjectTemplate { using FixedLengthTypedArray = FixedLengthTypedArrayObjectTemplate; using ResizableTypedArray = ResizableTypedArrayObjectTemplate; - static constexpr auto MaxByteLength = TypedArrayObject::MaxByteLength; + static constexpr auto ByteLengthLimit = TypedArrayObject::ByteLengthLimit; static constexpr auto INLINE_BUFFER_LIMIT = FixedLengthTypedArrayObject::INLINE_BUFFER_LIMIT; @@ -580,7 +580,7 @@ class TypedArrayObjectTemplate { // Step 6. size_t bufferByteLength = bufferMaybeUnwrapped->byteLength(); - MOZ_ASSERT(bufferByteLength <= MaxByteLength); + MOZ_ASSERT(bufferByteLength <= ByteLengthLimit); size_t len; if (lengthIndex == UINT64_MAX) { @@ -631,7 +631,7 @@ class TypedArrayObjectTemplate { len = size_t(lengthIndex); } - MOZ_ASSERT(len <= MaxByteLength / BYTES_PER_ELEMENT); + MOZ_ASSERT(len <= ByteLengthLimit / BYTES_PER_ELEMENT); *length = len; *autoLength = false; return true; @@ -760,14 +760,14 @@ class TypedArrayObjectTemplate { static bool maybeCreateArrayBuffer(JSContext* cx, uint64_t count, MutableHandle buffer) { - if (count > MaxByteLength / BYTES_PER_ELEMENT) { + if (count > ByteLengthLimit / BYTES_PER_ELEMENT) { JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_BAD_ARRAY_LENGTH); return false; } size_t byteLength = count * BYTES_PER_ELEMENT; - MOZ_ASSERT(byteLength <= MaxByteLength); + MOZ_ASSERT(byteLength <= ByteLengthLimit); static_assert(INLINE_BUFFER_LIMIT % BYTES_PER_ELEMENT == 0, "ArrayBuffer inline storage shouldn't waste any space"); @@ -869,7 +869,7 @@ class FixedLengthTypedArrayObjectTemplate JSContext* cx, Handle buffer, size_t byteOffset, size_t len, HandleObject proto, gc::Heap heap = gc::Heap::Default) { - MOZ_ASSERT(len <= MaxByteLength / BYTES_PER_ELEMENT); + MOZ_ASSERT(len <= ByteLengthLimit / BYTES_PER_ELEMENT); gc::AllocKind allocKind = buffer ? gc::GetGCObjectKind(instanceClass()) @@ -952,14 +952,14 @@ class FixedLengthTypedArrayObjectTemplate static FixedLengthTypedArrayObject* makeTypedArrayWithTemplate( JSContext* cx, TypedArrayObject* templateObj, int32_t len) { - if (len < 0 || size_t(len) > MaxByteLength / BYTES_PER_ELEMENT) { + if (len < 0 || size_t(len) > ByteLengthLimit / BYTES_PER_ELEMENT) { JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_BAD_ARRAY_LENGTH); return nullptr; } size_t nbytes = size_t(len) * BYTES_PER_ELEMENT; - MOZ_ASSERT(nbytes <= MaxByteLength); + MOZ_ASSERT(nbytes <= ByteLengthLimit); bool fitsInline = nbytes <= INLINE_BUFFER_LIMIT; @@ -1041,7 +1041,7 @@ class ResizableTypedArrayObjectTemplate MOZ_ASSERT(!buffer->isDetached()); MOZ_ASSERT(!autoLength || len == 0, "length is zero for 'auto' length views"); - MOZ_ASSERT(len <= MaxByteLength / BYTES_PER_ELEMENT); + MOZ_ASSERT(len <= ByteLengthLimit / BYTES_PER_ELEMENT); gc::AllocKind allocKind = gc::GetGCObjectKind(instanceClass()); @@ -1436,7 +1436,7 @@ template return nullptr; } - MOZ_ASSERT(len <= MaxByteLength / BYTES_PER_ELEMENT); + MOZ_ASSERT(len <= ByteLengthLimit / BYTES_PER_ELEMENT); // Steps 6.b.i. Rooted obj( @@ -1481,7 +1481,7 @@ static bool GetTemplateObjectForNative(JSContext* cx, size_t nbytes; if (!js::CalculateAllocSize(len, &nbytes) || - nbytes > TypedArrayObject::MaxByteLength) { + nbytes > TypedArrayObject::ByteLengthLimit) { return true; } diff --git a/js/src/vm/TypedArrayObject.h b/js/src/vm/TypedArrayObject.h index 737257d1972c..9aea98058ec3 100644 --- a/js/src/vm/TypedArrayObject.h +++ b/js/src/vm/TypedArrayObject.h @@ -109,7 +109,7 @@ class TypedArrayObject : public ArrayBufferViewObject { MutableHandleObject res); // Maximum allowed byte length for any typed array. - static constexpr size_t MaxByteLength = ArrayBufferObject::MaxByteLength; + static constexpr size_t ByteLengthLimit = ArrayBufferObject::ByteLengthLimit; static bool isOriginalLengthGetter(Native native); diff --git a/js/src/wasm/WasmMemory.cpp b/js/src/wasm/WasmMemory.cpp index ebedb835e8fd..01ef36e8a36c 100644 --- a/js/src/wasm/WasmMemory.cpp +++ b/js/src/wasm/WasmMemory.cpp @@ -250,7 +250,7 @@ static_assert(MaxInlineMemoryFillLength < MinOffsetGuardLimit, "precondition"); wasm::Pages wasm::MaxMemoryPages(IndexType t) { MOZ_ASSERT_IF(t == IndexType::I64, !IsHugeMemoryEnabled(t)); size_t desired = MaxMemoryLimitField(t); - constexpr size_t actual = ArrayBufferObject::MaxByteLength / PageSize; + constexpr size_t actual = ArrayBufferObject::ByteLengthLimit / PageSize; return wasm::Pages(std::min(desired, actual)); } @@ -263,7 +263,7 @@ size_t wasm::MaxMemoryBoundsCheckLimit(IndexType t) { // range of an int32_t, which means the maximum heap size as observed by wasm // code is one wasm page less than 2GB. wasm::Pages wasm::MaxMemoryPages(IndexType t) { - static_assert(ArrayBufferObject::MaxByteLength >= INT32_MAX / PageSize); + static_assert(ArrayBufferObject::ByteLengthLimit >= INT32_MAX / PageSize); return wasm::Pages(INT32_MAX / PageSize); }