1e7e3e9b8a
It has been superseeded by SetModifyCodeGenerationFromStringsCallback. The new method has been introduced in M77 [1], in current form since M80 [2], default-used by Blink since M80 [3]. [1] https://crrev.com/b9342b7b5ff2e5588eceb503dd52bb1e3fbfb21c [2] https://crrev.com/6c0825aaa73ca3163f089ca161c1f6e15633f306 [3] https://crrev.com/bfd0621af3f09557e9713d5c76108c7dddaa49a6 Bug: v8:10096 Change-Id: If5475aaff9cfee29b42529cd158372b191d34f32 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1987252 Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org> Reviewed-by: Clemens Backes <clemensb@chromium.org> Reviewed-by: Ulan Degenbaev <ulan@chromium.org> Reviewed-by: Daniel Vogelheim <vogelheim@chromium.org> Cr-Commit-Position: refs/heads/master@{#65717}
146 lines
4.0 KiB
JavaScript
146 lines
4.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: --expose-wasm --allow-natives-syntax
|
|
|
|
load("test/mjsunit/wasm/wasm-module-builder.js");
|
|
|
|
let kReturnValue = 19;
|
|
|
|
let buffer = (function CreateBuffer() {
|
|
let builder = new WasmModuleBuilder();
|
|
builder.addMemory(1, 1, true);
|
|
builder.addFunction('main', kSig_i_v)
|
|
.addBody([kExprI32Const, kReturnValue])
|
|
.exportFunc();
|
|
|
|
return builder.toBuffer();
|
|
})();
|
|
|
|
%DisallowWasmCodegen(true);
|
|
|
|
function SyncTestOk() {
|
|
print('sync module compile (ok)...');
|
|
%DisallowWasmCodegen(false);
|
|
let module = new WebAssembly.Module(buffer);
|
|
assertInstanceof(module, WebAssembly.Module);
|
|
}
|
|
|
|
function SyncTestWasmFail() {
|
|
print('sync wasm module compile (fail)...');
|
|
%DisallowWasmCodegen(true);
|
|
try {
|
|
let module = new WebAssembly.Module(buffer);
|
|
assertUnreachable();
|
|
} catch (e) {
|
|
print(" " + e);
|
|
assertInstanceof(e, WebAssembly.CompileError);
|
|
}
|
|
}
|
|
|
|
async function AsyncTestOk() {
|
|
print('async module compile (ok)...');
|
|
%DisallowWasmCodegen(false);
|
|
let promise = WebAssembly.compile(buffer);
|
|
assertPromiseResult(
|
|
promise, module => assertInstanceof(module, WebAssembly.Module));
|
|
}
|
|
|
|
async function AsyncTestWithInstantiateOk() {
|
|
print('async module instantiate (ok)...');
|
|
%DisallowWasmCodegen(false);
|
|
let promise = WebAssembly.instantiate(buffer);
|
|
assertPromiseResult(
|
|
promise,
|
|
module => assertInstanceof(module.instance, WebAssembly.Instance));
|
|
}
|
|
|
|
async function AsyncTestWasmFail() {
|
|
print('async wasm module compile (fail)...');
|
|
%DisallowWasmCodegen(true);
|
|
try {
|
|
let m = await WebAssembly.compile(buffer);
|
|
assertUnreachable();
|
|
} catch (e) {
|
|
print(" " + e);
|
|
assertInstanceof(e, WebAssembly.CompileError);
|
|
}
|
|
}
|
|
|
|
async function AsyncTestWasmWithInstantiateFail() {
|
|
print('async wasm module instantiate (fail)...');
|
|
%DisallowWasmCodegen(true);
|
|
try {
|
|
let m = await WebAssembly.instantiate(buffer);
|
|
assertUnreachable();
|
|
} catch (e) {
|
|
print(" " + e);
|
|
assertInstanceof(e, WebAssembly.CompileError);
|
|
}
|
|
}
|
|
|
|
async function StreamingTestOk() {
|
|
print('streaming module compile (ok)...');
|
|
// TODO(titzer): compileStreaming must be supplied by embedder.
|
|
// (and it takes a response, not a buffer)
|
|
%DisallowWasmCodegen(false);
|
|
if ("Function" != typeof WebAssembly.compileStreaming) {
|
|
print(" no embedder for streaming compilation");
|
|
return;
|
|
}
|
|
let promise = WebAssembly.compileStreaming(buffer);
|
|
await assertPromiseResult(
|
|
promise, module => assertInstanceof(module, WebAssembly.Module));
|
|
}
|
|
|
|
async function StreamingTestFail() {
|
|
print('streaming module compile (fail)...');
|
|
%DisallowWasmCodegen(false);
|
|
// TODO(titzer): compileStreaming must be supplied by embedder.
|
|
// (and it takes a response, not a buffer)
|
|
if ("Function" != typeof WebAssembly.compileStreaming) {
|
|
print(" no embedder for streaming compilation");
|
|
return;
|
|
}
|
|
try {
|
|
let m = await WebAssembly.compileStreaming(buffer);
|
|
assertUnreachable();
|
|
} catch (e) {
|
|
print(" " + e);
|
|
assertInstanceof(e, WebAssembly.CompileError);
|
|
}
|
|
}
|
|
|
|
|
|
async function StreamingTestWasmFail() {
|
|
print('streaming wasm module compile (fail)...');
|
|
%DisallowWasmCodegen(true);
|
|
// TODO(titzer): compileStreaming must be supplied by embedder.
|
|
// (and it takes a response, not a buffer)
|
|
if ("Function" != typeof WebAssembly.compileStreaming) {
|
|
print(" no embedder for streaming compilation");
|
|
return;
|
|
}
|
|
try {
|
|
let m = await WebAssembly.compileStreaming(buffer);
|
|
assertUnreachable();
|
|
} catch (e) {
|
|
print(" " + e);
|
|
assertInstanceof(e, WebAssembly.CompileError);
|
|
}
|
|
}
|
|
|
|
async function RunAll() {
|
|
SyncTestOk();
|
|
AsyncTestOk();
|
|
await StreamingTestOk();
|
|
await StreamingTestFail();
|
|
SyncTestWasmFail();
|
|
await AsyncTestWasmFail();
|
|
await AsyncTestWasmWithInstantiateFail();
|
|
await StreamingTestWasmFail()
|
|
}
|
|
|
|
assertPromiseResult(RunAll());
|