[wasm-hints] Add Tests for Lazy Modules

Added test cases for entirely lazily compiled modules. They are treated
just like empty modules are.

Bug: v8:9003
Change-Id: Ic0fcae7de32e50a0aac271567c18159bf8154028
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1562130
Commit-Queue: Frederik Gossen <frgossen@google.com>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60846}
This commit is contained in:
Frederik Gossen 2019-04-15 15:03:55 +02:00 committed by Commit Bot
parent 71ed7f4b32
commit 87792715c9

View File

@ -71,3 +71,28 @@ load('test/mjsunit/wasm/wasm-module-builder.js');
assertUnreachable,
error => assertEquals("WebAssembly.compile(): call[1] expected type f32, found get_local of type i32 @+94", error.message)));
})();
(function testInstantiateStreamingEmptyModule() {
print(arguments.callee.name);
let builder = new WasmModuleBuilder();
builder.addImport('mod', 'pow', kSig_i_ii);
let bytes = builder.toBuffer();
assertPromiseResult(WebAssembly.instantiateStreaming(Promise.resolve(bytes), {mod: {pow: Math.pow}}));
})();
(function testInstantiateStreamingAllHintsLazy() {
print(arguments.callee.name);
let builder = new WasmModuleBuilder();
builder.addImport('mod', 'pow', kSig_i_ii);
builder.addFunction('upow', kSig_i_i)
.addBody([kExprGetLocal, 0,
kExprGetLocal, 0,
kExprCallFunction, 0])
.giveCompilationHint(kCompilationHintStrategyLazy,
kCompilationHintTierDefault,
kCompilationHintTierDefault)
.exportFunc();
let bytes = builder.toBuffer();
assertPromiseResult(WebAssembly.instantiateStreaming(Promise.resolve(bytes), {mod: {pow: Math.pow}}).then(
({module, instance}) => assertEquals(27, instance.exports.upow(3))));
})();