Commit fe036121 authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[wasm] Brush up mjsunit/wasm/exceptions test.

R=clemensh@chromium.org
TEST=mjsunit/wasm/exceptions
BUG=v8:8091

Change-Id: I93227c29bb3591983f1901577afdf305637beb70
Reviewed-on: https://chromium-review.googlesource.com/1226803
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55954}
parent bb595303
...@@ -535,41 +535,57 @@ function assertWasmThrows(runtime_id, values, code) { ...@@ -535,41 +535,57 @@ function assertWasmThrows(runtime_id, values, code) {
]) ])
.exportFunc(); .exportFunc();
// Scenario 4: Catches an exception raised in JS. // Scenario 4: Does not catch an exception raised in JS, even if primitive
builder.addFunction("from_js", kSig_i_i) // values are being used as exceptions.
builder.addFunction("i_from_js", kSig_i_i)
.addBody([ .addBody([
kExprTry, kWasmI32, kExprTry, kWasmI32,
kExprGetLocal, 0, kExprGetLocal, 0,
kExprCallFunction, kJSThrowI, kExprCallFunction, kJSThrowI,
kExprUnreachable, kExprUnreachable,
kExprCatch, except, kExprCatch, except,
kExprUnreachable,
kExprEnd, kExprEnd,
]) ])
.exportFunc(); .exportFunc();
// Scenario 5: Does not catch an exception raised in JS if it is not a
// number.
builder.addFunction("string_from_js", kSig_v_v) builder.addFunction("string_from_js", kSig_v_v)
.addBody([ .addBody([
kExprCallFunction, kJSThrowString kExprTry, kWasmStmt,
kExprCallFunction, kJSThrowString,
kExprCatch, except,
kExprUnreachable,
kExprEnd,
]) ])
.exportFunc(); .exportFunc();
builder.addFunction("fp_from_js", kSig_v_v) builder.addFunction("fp_from_js", kSig_v_v)
.addBody([ .addBody([
kExprCallFunction, kJSThrowFP kExprTry, kWasmStmt,
kExprCallFunction, kJSThrowFP,
kExprCatch, except,
kExprUnreachable,
kExprEnd,
]) ])
.exportFunc(); .exportFunc();
builder.addFunction("large_from_js", kSig_v_v) builder.addFunction("large_from_js", kSig_v_v)
.addBody([ .addBody([
kExprCallFunction, kJSThrowLarge kExprTry, kWasmStmt,
kExprCallFunction, kJSThrowLarge,
kExprCatch, except,
kExprUnreachable,
kExprEnd,
]) ])
.exportFunc(); .exportFunc();
builder.addFunction("undefined_from_js", kSig_v_v) builder.addFunction("undefined_from_js", kSig_v_v)
.addBody([ .addBody([
kExprCallFunction, kJSThrowUndefined kExprTry, kWasmStmt,
kExprCallFunction, kJSThrowUndefined,
kExprCatch, except,
kExprUnreachable,
kExprEnd,
]) ])
.exportFunc(); .exportFunc();
...@@ -599,10 +615,9 @@ function assertWasmThrows(runtime_id, values, code) { ...@@ -599,10 +615,9 @@ function assertWasmThrows(runtime_id, values, code) {
assertEquals(0x7FFFFFFF, instance.exports.from_direct_callee(0x7FFFFFFF)); assertEquals(0x7FFFFFFF, instance.exports.from_direct_callee(0x7FFFFFFF));
assertEquals(10, instance.exports.from_indirect_callee(10, 0)); assertEquals(10, instance.exports.from_indirect_callee(10, 0));
assertEquals(77, instance.exports.from_indirect_callee(77, 1)); assertEquals(77, instance.exports.from_indirect_callee(77, 1));
// TODO(mstarzinger): Re-enable the following test cases.
/*assertEquals(10, instance.exports.from_js(10));
assertEquals(-10, instance.exports.from_js(-10));*/
assertThrowsEquals(() => instance.exports.i_from_js(10), 10);
assertThrowsEquals(() => instance.exports.i_from_js(-10), -10);
assertThrowsEquals(instance.exports.string_from_js, "use wasm"); assertThrowsEquals(instance.exports.string_from_js, "use wasm");
assertThrowsEquals(instance.exports.fp_from_js, 10.5); assertThrowsEquals(instance.exports.fp_from_js, 10.5);
assertThrowsEquals(instance.exports.large_from_js, 1e+28); assertThrowsEquals(instance.exports.large_from_js, 1e+28);
......
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