[rab/gsab,api] Add v8::BackingStore::MaxByteLength
I originally thought MaxByteLength would only be needed for v8::ArrayBuffer and v8::SharedArrayBuffer, but it is also needed on v8::BackingStore. In particular, blink uses Mojo to serialize ArrayBuffers' contents via v8::BackingStore when doing cross-process postMessage. Bug: chromium:1396361, v8:11111 Change-Id: I86d44829175ad760fb43294d386483a16044fc3b Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4090708 Commit-Queue: Shu-yu Guo <syg@chromium.org> Reviewed-by: Adam Klein <adamk@chromium.org> Cr-Commit-Position: refs/heads/main@{#84767}
This commit is contained in:
parent
2dcb0a1a1e
commit
08e95d81d5
@ -53,6 +53,15 @@ class V8_EXPORT BackingStore : public v8::internal::BackingStoreBase {
|
||||
*/
|
||||
size_t ByteLength() const;
|
||||
|
||||
/**
|
||||
* The maximum length (in bytes) that this backing store may grow to.
|
||||
*
|
||||
* If this backing store was created for a resizable ArrayBuffer or a growable
|
||||
* SharedArrayBuffer, it is >= ByteLength(). Otherwise it is ==
|
||||
* ByteLength().
|
||||
*/
|
||||
size_t MaxByteLength() const;
|
||||
|
||||
/**
|
||||
* Indicates whether the backing store was created for an ArrayBuffer or
|
||||
* a SharedArrayBuffer.
|
||||
|
@ -4191,6 +4191,10 @@ size_t v8::BackingStore::ByteLength() const {
|
||||
return reinterpret_cast<const i::BackingStore*>(this)->byte_length();
|
||||
}
|
||||
|
||||
size_t v8::BackingStore::MaxByteLength() const {
|
||||
return reinterpret_cast<const i::BackingStore*>(this)->max_byte_length();
|
||||
}
|
||||
|
||||
bool v8::BackingStore::IsShared() const {
|
||||
return reinterpret_cast<const i::BackingStore*>(this)->is_shared();
|
||||
}
|
||||
|
@ -833,6 +833,7 @@ TEST(ArrayBuffer_Resizable) {
|
||||
CHECK(gsab->GetBackingStore()->IsResizableByUserJavaScript());
|
||||
CHECK_EQ(32, gsab->ByteLength());
|
||||
CHECK_EQ(1024, gsab->MaxByteLength());
|
||||
CHECK_EQ(gsab->MaxByteLength(), gsab->GetBackingStore()->MaxByteLength());
|
||||
}
|
||||
|
||||
TEST(ArrayBuffer_FixedLength) {
|
||||
@ -848,9 +849,11 @@ TEST(ArrayBuffer_FixedLength) {
|
||||
CHECK(!ab->GetBackingStore()->IsResizableByUserJavaScript());
|
||||
CHECK_EQ(32, ab->ByteLength());
|
||||
CHECK_EQ(32, ab->MaxByteLength());
|
||||
CHECK_EQ(ab->MaxByteLength(), ab->GetBackingStore()->MaxByteLength());
|
||||
v8::Local<v8::SharedArrayBuffer> sab =
|
||||
CompileRun("new SharedArrayBuffer(32);").As<v8::SharedArrayBuffer>();
|
||||
CHECK(!sab->GetBackingStore()->IsResizableByUserJavaScript());
|
||||
CHECK_EQ(32, sab->ByteLength());
|
||||
CHECK_EQ(32, sab->MaxByteLength());
|
||||
CHECK_EQ(sab->MaxByteLength(), sab->GetBackingStore()->MaxByteLength());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user