Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(538)

Unified Diff: test/mjsunit/wasm/exceptions.js

Issue 2339053003: [V8][Wasm] Wasm throws. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addresses comments. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/wasm/ast-decoder.cc ('k') | test/mjsunit/wasm/wasm-constants.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/wasm/exceptions.js
diff --git a/test/mjsunit/wasm/exceptions.js b/test/mjsunit/wasm/exceptions.js
new file mode 100644
index 0000000000000000000000000000000000000000..07b0bf4e0e18c3f2690ac59b05ec0ef87d781682
--- /dev/null
+++ b/test/mjsunit/wasm/exceptions.js
@@ -0,0 +1,67 @@
+// Copyright 2015 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-eh-prototype
+
+load("test/mjsunit/wasm/wasm-constants.js");
+load("test/mjsunit/wasm/wasm-module-builder.js");
+
+var module = (function () {
+ var builder = new WasmModuleBuilder();
+
+ builder.addFunction("throw_param_if_not_zero", kSig_i_i)
+ .addBody([
+ kExprGetLocal, 0,
+ kExprI32Const, 0,
+ kExprI32Ne,
+ kExprIf,
+ kExprGetLocal, 0,
+ kExprThrow,
+ kExprEnd,
+ kExprI32Const, 1
+ ])
+ .exportFunc()
+
+ builder.addFunction("throw_20", kSig_v_v)
+ .addBody([
+ kExprI32Const, 20,
+ kExprThrow
+ ])
+ .exportFunc()
+
+ builder.addFunction("throw_expr_with_params", kSig_v_ddi)
+ .addBody([
+ // p2 * (p0 + min(p0, p1))|0 - 20
+ kExprGetLocal, 2,
+ kExprGetLocal, 0,
+ kExprGetLocal, 0,
+ kExprGetLocal, 1,
+ kExprF64Min,
+ kExprF64Add,
+ kExprI32SConvertF64,
+ kExprI32Mul,
+ kExprI32Const, 20,
+ kExprI32Sub,
+ kExprThrow
+ ])
+ .exportFunc()
+
+ return builder.instantiate();
+})();
+
+// Check the module exists.
+assertFalse(module === undefined);
+assertFalse(module === null);
+assertFalse(module === 0);
+assertEquals("object", typeof module.exports);
+assertEquals("function", typeof module.exports.throw_param_if_not_zero);
+
+assertEquals(1, module.exports.throw_param_if_not_zero(0));
+assertWasmThrows(10, function() { module.exports.throw_param_if_not_zero(10) });
+assertWasmThrows(-1, function() { module.exports.throw_param_if_not_zero(-1) });
+assertWasmThrows(20, module.exports.throw_20);
+assertWasmThrows(
+ -8, function() { module.exports.throw_expr_with_params(1.5, 2.5, 4); });
+assertWasmThrows(
+ 12, function() { module.exports.throw_expr_with_params(5.7, 2.5, 4); });
« no previous file with comments | « src/wasm/ast-decoder.cc ('k') | test/mjsunit/wasm/wasm-constants.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698