diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /js/src/vm/ArrayBufferObject.cpp | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip |
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/vm/ArrayBufferObject.cpp')
-rw-r--r-- | js/src/vm/ArrayBufferObject.cpp | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/js/src/vm/ArrayBufferObject.cpp b/js/src/vm/ArrayBufferObject.cpp index 72c9ebeb18..2fe4f01f8d 100644 --- a/js/src/vm/ArrayBufferObject.cpp +++ b/js/src/vm/ArrayBufferObject.cpp @@ -536,12 +536,7 @@ bool ArrayBufferObject::maxByteLengthGetterImpl(JSContext* cx, auto* buffer = &args.thisv().toObject().as<ArrayBufferObject>(); // Steps 4-6. - size_t maxByteLength; - if (buffer->isResizable()) { - maxByteLength = buffer->as<ResizableArrayBufferObject>().maxByteLength(); - } else { - maxByteLength = buffer->byteLength(); - } + size_t maxByteLength = buffer->maxByteLength(); MOZ_ASSERT_IF(buffer->isDetached(), maxByteLength == 0); // Step 7. @@ -914,8 +909,6 @@ void ArrayBufferObject::detach(JSContext* cx, // Update all views of the buffer to account for the buffer having been // detached, and clear the buffer's data and list of views. - // - // Typed object buffers are not exposed and cannot be detached. auto& innerViews = ObjectRealm::get(buffer).innerViews.get(); if (InnerViewTable::ViewVector* views = @@ -962,6 +955,20 @@ void ResizableArrayBufferObject::resize(size_t newByteLength) { } setByteLength(newByteLength); + + // Update all views of the buffer to account for the buffer having been + // resized. + + auto& innerViews = ObjectRealm::get(this).innerViews.get(); + if (InnerViewTable::ViewVector* views = + innerViews.maybeViewsUnbarriered(this)) { + for (auto& view : *views) { + view->notifyBufferResized(); + } + } + if (auto* view = firstView()) { + view->as<ArrayBufferViewObject>().notifyBufferResized(); + } } /* clang-format off */ @@ -1490,10 +1497,7 @@ size_t ArrayBufferObject::byteLength() const { inline size_t ArrayBufferObject::associatedBytes() const { if (isMalloced()) { - if (isResizable()) { - return as<ResizableArrayBufferObject>().maxByteLength(); - } - return byteLength(); + return maxByteLength(); } if (isMapped()) { return RoundUp(byteLength(), js::gc::SystemPageSize()); @@ -2472,7 +2476,7 @@ bool ArrayBufferObject::ensureNonInline(JSContext* cx, return true; } - size_t nbytes = buffer->byteLength(); + size_t nbytes = buffer->maxByteLength(); ArrayBufferContents copy = NewCopiedBufferContents(cx, buffer); if (!copy) { return false; |