Commit f47706a7 authored by Deepti Gandluri's avatar Deepti Gandluri Committed by Commit Bot

[wasm] Add tests for SIMD JS-API errors

Change-Id: I7fc2eb95f9a2d1ea45bc84543a05c84e32bb6d31
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1838924Reviewed-by: 's avatarZhi An Ng <zhin@chromium.org>
Commit-Queue: Deepti Gandluri <gdeepti@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64098}
parent c42a7fe5
// Copyright 2019 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: --experimental-wasm-simd
load("test/mjsunit/wasm/wasm-module-builder.js");
(function S128InSignatureThrows() {
print(arguments.callee.name);
let builder = new WasmModuleBuilder();
builder.addMemory(1, 1, true);
builder.addFunction('foo', kSig_s_i)
.addBody([
kExprGetLocal, 0,
kSimdPrefix,
kExprI32x4Splat])
.exportFunc()
const instance = builder.instantiate();
assertThrows(() => instance.exports.foo(33), TypeError);
})();
(function S128ParamInSignatureThrows() {
print(arguments.callee.name);
let builder = new WasmModuleBuilder();
builder.addMemory(1, 1, true);
builder.addFunction('foo', kSig_i_s)
.addBody([
kExprGetLocal, 0,
kSimdPrefix,
kExprI32x4ExtractLane, 1])
.exportFunc();
const instance = builder.instantiate();
assertThrows(() => instance.exports.invalid_foo(10), TypeError);
})();
(function ImportS128Return() {
print(arguments.callee.name);
let builder = new WasmModuleBuilder();
builder.addImport('', 'f', makeSig([], [kWasmS128]));
builder.addFunction('foo', kSig_v_v)
.addBody([kExprCallFunction, 0, kExprDrop])
.exportFunc();
const instance = builder.instantiate({'': {f: _ => 1}});
assertThrows(() => instance.exports.foo(), TypeError);
})();
(function S128ImportThrows() {
print(arguments.callee.name);
let builder = new WasmModuleBuilder();
let sig_index = builder.addType(kSig_i_i);
let sig_s128_index = builder.addType(kSig_i_s);
let index = builder.addImport('', 'func', sig_s128_index);
builder.addFunction('foo', sig_index)
.addBody([
kExprGetLocal, 0,
kSimdPrefix,
kExprI32x4Splat,
kExprCallFunction, index])
.exportFunc();
const instance = builder.instantiate({'': {func: _ => {}}});
assertThrows(() => instance.exports.foo(14), TypeError);
})();
(function TestS128GlobalConstructor() {
assertThrows(() => new WebAssembly.Global({value: 'i128'}), TypeError);
})();
......@@ -162,6 +162,8 @@ let kSig_r_v = makeSig([], [kWasmAnyRef]);
let kSig_a_v = makeSig([], [kWasmAnyFunc]);
let kSig_a_i = makeSig([kWasmI32], [kWasmAnyFunc]);
let kSig_e_v = makeSig([], [kWasmExnRef]);
let kSig_s_i = makeSig([kWasmI32], [kWasmS128]);
let kSig_i_s = makeSig([kWasmS128], [kWasmI32]);
function makeSig(params, results) {
return {params: params, results: results};
......@@ -466,6 +468,8 @@ let kExprI64AtomicCompareExchange32U = 0x4e;
// Simd opcodes.
let kExprF32x4Min = 0x9e;
let kExprI32x4Splat = 0x0c
let kExprI32x4ExtractLane = 0x0d;
// Compilation hint constants.
let kCompilationHintStrategyDefault = 0x00;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment