summaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/regress/regress-319722-ArrayBuffer.js
diff options
context:
space:
mode:
authorMatheus Marchini <mmarchini@netflix.com>2020-03-05 10:49:19 -0800
committerMatheus Marchini <mmarchini@netflix.com>2020-03-18 16:23:22 -0700
commit2883c855e0105b51e5c8020d21458af109ffe3d4 (patch)
tree26777aad0a398e9f7755c8b65ac76827fe352a81 /deps/v8/test/mjsunit/regress/regress-319722-ArrayBuffer.js
parent5f0af2af2a67216e00fe07ccda11e889d14abfcd (diff)
downloadnode-new-2883c855e0105b51e5c8020d21458af109ffe3d4.tar.gz
deps: update V8 to 8.1.307.20
PR-URL: https://github.com/nodejs/node/pull/32116 Reviewed-By: Michaƫl Zasso <targos@protonmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'deps/v8/test/mjsunit/regress/regress-319722-ArrayBuffer.js')
-rw-r--r--deps/v8/test/mjsunit/regress/regress-319722-ArrayBuffer.js46
1 files changed, 25 insertions, 21 deletions
diff --git a/deps/v8/test/mjsunit/regress/regress-319722-ArrayBuffer.js b/deps/v8/test/mjsunit/regress/regress-319722-ArrayBuffer.js
index 4a48a61ab3..e9fb57eaa8 100644
--- a/deps/v8/test/mjsunit/regress/regress-319722-ArrayBuffer.js
+++ b/deps/v8/test/mjsunit/regress/regress-319722-ArrayBuffer.js
@@ -26,32 +26,36 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --nostress-opt --allow-natives-syntax --mock-arraybuffer-allocator
-var maxSize = %MaxSmi() + 1;
-var ab;
+
+let kArrayBufferByteLengthLimit = %ArrayBufferMaxByteLength() + 1;
+let kTypedArrayLengthLimit = %TypedArrayMaxLength() + 1;
// Allocate the largest ArrayBuffer we can on this architecture.
-for (k = 8; k >= 1 && ab == null; k = k/2) {
- try {
- ab = new ArrayBuffer(maxSize * k);
- } catch (e) {
- ab = null;
- }
-}
+let ab = new ArrayBuffer(kArrayBufferByteLengthLimit - 1);
-assertTrue(ab != null);
+function TestArray(constr, elementSize) {
+ assertEquals(kArrayBufferByteLengthLimit % elementSize, 0);
+ let bufferSizeLength = kArrayBufferByteLengthLimit / elementSize;
+
+ let minUnallocatableSize =
+ kTypedArrayLengthLimit < bufferSizeLength
+ ? kTypedArrayLengthLimit
+ : bufferSizeLength;
-function TestArray(constr) {
assertThrows(function() {
- new constr(ab, 0, maxSize);
+ new constr(ab, 0, minUnallocatableSize);
}, RangeError);
+
+ // This one must succeed.
+ new constr(ab, 0, minUnallocatableSize - 1);
}
-TestArray(Uint8Array);
-TestArray(Int8Array);
-TestArray(Uint16Array);
-TestArray(Int16Array);
-TestArray(Uint32Array);
-TestArray(Int32Array);
-TestArray(Float32Array);
-TestArray(Float64Array);
-TestArray(Uint8ClampedArray);
+TestArray(Uint8Array, 1);
+TestArray(Int8Array, 1);
+TestArray(Uint16Array, 2);
+TestArray(Int16Array, 2);
+TestArray(Uint32Array, 4);
+TestArray(Int32Array, 4);
+TestArray(Float32Array, 4);
+TestArray(Float64Array, 8);
+TestArray(Uint8ClampedArray, 1);