v8/test/mjsunit/wasm/huge-memory.js
Clemens Backes 421fd3929d [wasm] Rename {Get,Set,Tee}Local to Local{Get,Set,Tee}
This brings our constants back in line with the changed spec text. We
already use kExprTableGet and kExprTableSet, but for locals and globals
we still use the old wording.

This renaming is mostly mechanical.

PS1 was created using:
ag -l 'kExpr(Get|Set|Tee)Local' src test | \
  xargs -L1 sed -E 's/kExpr(Get|Set|Tee)Local\b/kExprLocal\1/g' -i

PS2 contains manual fixes.

R=mstarzinger@chromium.org

Bug: v8:9810
Change-Id: I1617f1b2a100685a3bf56218e76845a9481959c5
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1847354
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64161}
2019-10-08 14:14:40 +00:00

83 lines
2.1 KiB
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: --wasm-max-mem-pages=49152
// This test makes sure things don't break once we support >2GB wasm memories.
load("test/mjsunit/wasm/wasm-module-builder.js");
(function testHugeMemory() {
print(arguments.callee.name);
var builder = new WasmModuleBuilder();
const num_pages = 49152; // 3GB
builder.addMemory(num_pages, num_pages, true);
builder.addFunction("geti", kSig_i_ii)
.addBody([
kExprLocalGet, 0,
kExprLocalGet, 1,
kExprI32Mul,
kExprI32LoadMem, 0, 0,
])
.exportFunc();
var module = builder.instantiate();
const geti = module.exports.geti;
print("In bounds");
assertEquals(0, geti(2500, 1 << 20));
print("Out of bounds");
assertTraps(kTrapMemOutOfBounds, () => geti(3500, 1 << 20));
})();
(function testHugeMemoryConstInBounds() {
print(arguments.callee.name);
var builder = new WasmModuleBuilder();
const num_pages = 49152; // 3GB
builder.addMemory(num_pages, num_pages, true);
builder.addFunction("geti", kSig_i_v)
.addBody([
kExprI32Const, 0x80, 0x80, 0x80, 0x80, 0x7A, // 0xA0000000, 2.5GB
kExprI32LoadMem, 0, 0,
])
.exportFunc();
var module = builder.instantiate();
const geti = module.exports.geti;
print("In bounds");
assertEquals(0, geti());
})();
(function testHugeMemoryConstOutOfBounds() {
print(arguments.callee.name);
var builder = new WasmModuleBuilder();
const num_pages = 49152; // 3GB
builder.addMemory(num_pages, num_pages, true);
builder.addFunction("geti", kSig_i_v)
.addBody([
kExprI32Const, 0x80, 0x80, 0x80, 0x80, 0x7E, // 0xE0000000, 3.5GB
kExprI32LoadMem, 0, 0,
])
.exportFunc();
var module = builder.instantiate();
const geti = module.exports.geti;
print("Out of bounds");
assertTraps(kTrapMemOutOfBounds, geti);
})();
(function testGrowHugeMemory() {
print(arguments.callee.name);
let mem = new WebAssembly.Memory({initial: 1});
mem.grow(49151);
})();