v8/test/mjsunit/wasm/graceful_shutdown.js
Andreas Haas c7d68161bd [d8] Add no-wait-for-wasm flag
The flag lets d8 wait for async compilation of WebAssembly to finish
before d8 shuts down.

R=clemensh@chromium.org
CC=​kimanh@google.com

Change-Id: I4cf59a1f35cc5a0ecaf769d2745df5e2e14eb509
Reviewed-on: https://chromium-review.googlesource.com/966031
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51999}
2018-03-16 15:35:27 +00:00

31 lines
994 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: --expose-wasm --wasm-async-compilation --no-wait-for-wasm
load("test/mjsunit/wasm/wasm-constants.js");
load("test/mjsunit/wasm/wasm-module-builder.js");
(function CompileFunctionsTest() {
// Create a big module.
var builder = new WasmModuleBuilder();
builder.addMemory(1, 1, true);
for (i = 0; i < 100; i++) {
builder.addFunction("sub" + i, kSig_i_i)
.addBody([ // --
kExprGetLocal, 0, // --
kExprI32Const, i % 61, // --
kExprI32Sub]) // --
.exportFunc()
}
var buffer = builder.toBuffer();
// Start the compilation but do not wait for the promise to resolve
// with assertPromiseResult. This should not cause a crash.
WebAssembly.compile(buffer).then(
() => { print("success")},
() => { print("failed"); });
})();