Commit c1c93e82 authored by Eric Holk's avatar Eric Holk Committed by Commit Bot

[wasm] add a test case for 3GB memory

Although we currently only support up to 1GB memory, we want to raise
this issue in the future. This test illustrates several issues we need
to be sure to fix first.

Bug: v8:6306
Change-Id: I362b7a9e51e8eb33a50e3b172a6f01d41995c3cb
Reviewed-on: https://chromium-review.googlesource.com/487047
Commit-Queue: Brad Nelson <bradnelson@chromium.org>
Reviewed-by: 's avatarBrad Nelson <bradnelson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44876}
parent 1de34725
...@@ -195,6 +195,9 @@ ...@@ -195,6 +195,9 @@
# BUG(v8:6113). # BUG(v8:6113).
'es6/array-iterator-turbo': [SKIP], 'es6/array-iterator-turbo': [SKIP],
# BUG(v8:6306).
'wasm/huge-memory': [SKIP],
}], # ALWAYS }], # ALWAYS
['novfp3 == True', { ['novfp3 == True', {
......
// 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-constants.js");
load("test/mjsunit/wasm/wasm-module-builder.js");
function testHugeMemory() {
var builder = new WasmModuleBuilder();
const num_pages = 49152; // 3GB
builder.addMemory(num_pages, num_pages, true);
builder.addFunction("geti", kSig_i_ii)
.addBody([
kExprGetLocal, 0,
kExprGetLocal, 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));
}
testHugeMemory();
function testHugeMemoryConstInBounds() {
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());
}
testHugeMemoryConstInBounds();
function testHugeMemoryConstOutOfBounds() {
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);
}
testHugeMemoryConstOutOfBounds();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment