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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Flags: --expose-wasm --wasm-eh-prototype
6
7 load("test/mjsunit/wasm/wasm-constants.js");
8 load("test/mjsunit/wasm/wasm-module-builder.js");
9
10 var module = (function () {
11 var builder = new WasmModuleBuilder();
12
13 builder.addFunction("throw_param_if_not_zero", kSig_i_i)
14 .addBody([
15 kExprGetLocal, 0,
16 kExprI32Const, 0,
17 kExprI32Ne,
18 kExprIf,
19 kExprGetLocal, 0,
20 kExprThrow,
21 kExprEnd,
22 kExprI32Const, 1
23 ])
24 .exportFunc()
25
26 builder.addFunction("throw_20", kSig_v_v)
27 .addBody([
28 kExprI32Const, 20,
29 kExprThrow
30 ])
31 .exportFunc()
32
33 builder.addFunction("throw_expr_with_params", kSig_v_ddi)
34 .addBody([
35 // p2 * (p0 + min(p0, p1))|0 - 20
36 kExprGetLocal, 2,
37 kExprGetLocal, 0,
38 kExprGetLocal, 0,
39 kExprGetLocal, 1,
40 kExprF64Min,
41 kExprF64Add,
42 kExprI32SConvertF64,
43 kExprI32Mul,
44 kExprI32Const, 20,
45 kExprI32Sub,
46 kExprThrow
47 ])
48 .exportFunc()
49
50 return builder.instantiate();
51 })();
52
53 // Check the module exists.
54 assertFalse(module === undefined);
55 assertFalse(module === null);
56 assertFalse(module === 0);
57 assertEquals("object", typeof module.exports);
58 assertEquals("function", typeof module.exports.throw_param_if_not_zero);
59
60 assertEquals(1, module.exports.throw_param_if_not_zero(0));
61 assertWasmThrows(10, function() { module.exports.throw_param_if_not_zero(10) });
62 assertWasmThrows(-1, function() { module.exports.throw_param_if_not_zero(-1) });
63 assertWasmThrows(20, module.exports.throw_20);
64 assertWasmThrows(
65 -8, function() { module.exports.throw_expr_with_params(1.5, 2.5, 4); });
66 assertWasmThrows(
67 12, function() { module.exports.throw_expr_with_params(5.7, 2.5, 4); });
OLDNEW
« 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