55193800cf
This reverts commitee3729d26e
. Reason for revert: The initial commit required https://chromium-review.googlesource.com/c/510021/ also land on the Blink side. I mistakenly thought it did. Original change's description: > Revert "[wasm] Remove override-ability from async compile and instantiate." > > This reverts commit2869dd55f3
. > > Reason for revert: Breaks: > https://build.chromium.org/p/client.v8.fyi/builders/V8-Blink%20Linux%2064/builds/15850 > > See also: > https://github.com/v8/v8/wiki/Blink-layout-tests > > Original change's description: > > [wasm] Remove override-ability from async compile and instantiate. > > > > We're now using explicit APIs. > > > > Bug: > > Change-Id: I4a4248e44543f6e7dfcbdc66456e610fb98ff5ee > > Reviewed-on: https://chromium-review.googlesource.com/513406 > > Commit-Queue: Brad Nelson <bradnelson@chromium.org> > > Reviewed-by: Brad Nelson <bradnelson@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#45500} > > TBR=bradnelson@chromium.org,mtrofin@chromium.org > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > > Bug: > Change-Id: Ie7c2db40279bd07c535c20afaa1cea51b680fe65 > Reviewed-on: https://chromium-review.googlesource.com/513862 > Reviewed-by: Michael Achenbach <machenbach@chromium.org> > Commit-Queue: Michael Achenbach <machenbach@chromium.org> > Cr-Commit-Position: refs/heads/master@{#45502} TBR=bradnelson@chromium.org,machenbach@chromium.org,mtrofin@chromium.org,v8-reviews@googlegroups.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Bug: Change-Id: Ib826b590b5d362d005460fcebdc6800c8d6c5f63 Reviewed-on: https://chromium-review.googlesource.com/513496 Reviewed-by: Mircea Trofin <mtrofin@chromium.org> Commit-Queue: Mircea Trofin <mtrofin@chromium.org> Cr-Commit-Position: refs/heads/master@{#45519}
75 lines
2.0 KiB
JavaScript
75 lines
2.0 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: --allow-natives-syntax
|
|
|
|
load("test/mjsunit/wasm/wasm-constants.js");
|
|
load("test/mjsunit/wasm/wasm-module-builder.js");
|
|
|
|
%SetWasmCompileControls(100000, true);
|
|
%SetWasmCompileControls(100000, false);
|
|
|
|
let buffer = (() => {
|
|
let builder = new WasmModuleBuilder();
|
|
builder.addFunction("f", kSig_i_v)
|
|
.addBody([kExprI32Const, 42])
|
|
.exportAs("f");
|
|
return builder.toBuffer();
|
|
})();
|
|
|
|
let ok_module = new WebAssembly.Module(buffer);
|
|
assertTrue(ok_module instanceof WebAssembly.Module);
|
|
assertEquals(42, new WebAssembly.Instance(ok_module).exports.f());
|
|
|
|
failWithMessage = msg => %AbortJS(msg);
|
|
|
|
async function SuccessfulTest() {
|
|
print("SuccessfulTest...");
|
|
%SetWasmCompileControls(buffer.byteLength, true);
|
|
%SetWasmInstantiateControls();
|
|
let m = new WebAssembly.Module(buffer);
|
|
let i = new WebAssembly.Instance(m);
|
|
assertEquals(i.exports.f(), 42);
|
|
}
|
|
|
|
async function FailSyncCompile() {
|
|
print("FailSyncCompile...");
|
|
%SetWasmCompileControls(buffer.byteLength - 1, true);
|
|
assertThrows(() => new WebAssembly.Module(buffer), RangeError);
|
|
|
|
print(" wait");
|
|
try {
|
|
let m = await WebAssembly.compile(buffer);
|
|
print(" cont");
|
|
assertTrue(m instanceof WebAssembly.Module);
|
|
} catch (e) {
|
|
print(" catch");
|
|
assertUnreachable();
|
|
}
|
|
}
|
|
|
|
async function FailSyncInstantiate() {
|
|
print("FailSyncInstantiate...");
|
|
%SetWasmCompileControls(buffer.byteLength - 1, true);
|
|
assertThrows(() => new WebAssembly.Instance(ok_module), RangeError);
|
|
|
|
print(" wait");
|
|
try {
|
|
let i = await WebAssembly.instantiate(ok_module);
|
|
print(" cont");
|
|
assertTrue(i instanceof WebAssembly.Instance);
|
|
} catch (e) {
|
|
print(" catch: " + e);
|
|
assertUnreachable();
|
|
}
|
|
}
|
|
|
|
async function TestAll() {
|
|
await SuccessfulTest();
|
|
await FailSyncCompile();
|
|
await FailSyncInstantiate();
|
|
}
|
|
|
|
assertPromiseResult(TestAll());
|