v8/test/mjsunit/regress/regress-crbug-754175.js
Jakob Kummerow 3bff8fa5ea [64bit] Bump TypedArray max length to 2**32-1 elements
The actual allocatable size still depends on the allocator;
in particular Blink's ArrayBufferAllocator is currently limited
to 2GB.
WebAssembly memories are not affected by this change (i.e. still
capped at 2GB as well).

For 32-bit platforms, the limit remains at 2**30-1 (=max smi) elements.

Bug: v8:4153
Change-Id: If0d6047dd4061028688d85a3dc0a2684dcca8693
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2007495
Reviewed-by: Adam Klein <adamk@chromium.org>
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65924}
2020-01-22 17:42:26 +00:00

21 lines
724 B
JavaScript

// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --mock-arraybuffer-allocator --allow-natives-syntax
function Module(stdlib, foreign, buffer) {
"use asm";
var heap = new stdlib.Int8Array(buffer);
function foo() { return heap[23] | 0 }
return { foo:foo };
}
const kLength = Math.max(0x100000000, %TypedArrayMaxLength() + 1);
function instantiate() {
// On 32-bit architectures buffer allocation will throw.
var buffer = new ArrayBuffer(kLength);
// On 64-bit architectures instantiation will throw.
var module = Module(this, {}, buffer);
}
assertThrows(instantiate, RangeError);