v8/test/mjsunit/regress/regress-crbug-759327.js
Michael Starzinger 89f839e5d0 [asm.js] Correctly set minimum memory size to zero.
This makes sure the minimum memory size for WebAssembly modules derived
from asm.js is set to zero. It allows instatiation without allocating an
underlying memory, when such memory is unused. It also fixes a bug in
patching of embedded memory sizes for asm.js modules.

R=ahaas@chromium.org
TEST=mjsunit/regress/regress-crbug-759327
BUG=chromium:759327

Change-Id: If5a965b96a03cbb5ba15bc41fbaf359f74961f41
Reviewed-on: https://chromium-review.googlesource.com/637912
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47646}
2017-08-28 15:01:30 +00:00

24 lines
568 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: --allow-natives-syntax --expose-gc
function Module(stdlib, env, heap) {
"use asm";
var MEM = new stdlib.Int32Array(heap);
function f() {
MEM[0] = 0;
}
return { f: f };
}
function instantiate() {
var buffer = new ArrayBuffer(0);
Module(this, {}, buffer).f();
try {} finally {}
gc();
Module(this, {}, buffer).f();
}
instantiate();
assertTrue(%IsAsmWasmCode(Module));