2018-04-10 21:39:51 -04:00
|
|
|
// Copyright 2018 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-lazy-compilation
|
|
|
|
|
2021-08-29 14:20:49 +02:00
|
|
|
d8.file.execute('test/mjsunit/wasm/wasm-module-builder.js');
|
2018-04-10 21:39:51 -04:00
|
|
|
|
|
|
|
const builder = new WasmModuleBuilder();
|
|
|
|
builder.addMemory(16, 32);
|
|
|
|
builder.addFunction('grow', kSig_i_i).addBody([
|
2019-11-08 15:39:11 +01:00
|
|
|
kExprLocalGet, 0,
|
2019-03-12 09:01:49 +01:00
|
|
|
kExprMemoryGrow, 0,
|
2018-04-10 21:39:51 -04:00
|
|
|
]).exportFunc();
|
|
|
|
builder.addFunction('main', kSig_i_i).addBody([
|
|
|
|
...wasmI32Const(0x41),
|
2019-11-08 15:39:11 +01:00
|
|
|
kExprLocalSet, 0,
|
2018-04-10 21:39:51 -04:00
|
|
|
// Enter loop, such that values are spilled to the stack.
|
2021-06-08 14:04:59 +02:00
|
|
|
kExprLoop, kWasmVoid,
|
2018-04-10 21:39:51 -04:00
|
|
|
kExprEnd,
|
|
|
|
// Reload value. This must be loaded as 32 bit value.
|
2019-11-08 15:39:11 +01:00
|
|
|
kExprLocalGet, 0,
|
2018-04-10 21:39:51 -04:00
|
|
|
kExprI32LoadMem, 0, 0,
|
|
|
|
]).exportFunc();
|
|
|
|
const instance = builder.instantiate();
|
|
|
|
// Execute grow, such that the stack contains garbage data afterwards.
|
|
|
|
instance.exports.grow(1);
|
|
|
|
instance.exports.main();
|