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

Side by Side Diff: test/mjsunit/wasm/indirect-calls.js

Issue 1896863003: [wasm] Binary 11: Module changes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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 | « test/mjsunit/wasm/import-table.js ('k') | test/mjsunit/wasm/instantiate-module-basic.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Flags: --expose-wasm 5 // Flags: --expose-wasm
6 6
7 load("test/mjsunit/wasm/wasm-constants.js"); 7 load("test/mjsunit/wasm/wasm-constants.js");
8 load("test/mjsunit/wasm/wasm-module-builder.js"); 8 load("test/mjsunit/wasm/wasm-module-builder.js");
9 9
10 var module = (function () { 10 var module = (function () {
11 var builder = new WasmModuleBuilder(); 11 var builder = new WasmModuleBuilder();
12 12
13 var sig_index = builder.addSignature([kAstI32, kAstI32, kAstI32]); 13 var sig_index = builder.addSignature(kSig_i_ii);
14 builder.addImport("add", sig_index); 14 builder.addImport("add", sig_index);
15 builder.addFunction("add", sig_index) 15 builder.addFunction("add", sig_index)
16 .addBody([ 16 .addBody([
17 kExprGetLocal, 0, kExprGetLocal, 1, kExprCallImport, kArity2, 0 17 kExprGetLocal, 0, kExprGetLocal, 1, kExprCallImport, kArity2, 0
18 ]); 18 ]);
19 builder.addFunction("sub", sig_index) 19 builder.addFunction("sub", sig_index)
20 .addBody([ 20 .addBody([
21 kExprGetLocal, 0, // -- 21 kExprGetLocal, 0, // --
22 kExprGetLocal, 1, // -- 22 kExprGetLocal, 1, // --
23 kExprI32Sub, // -- 23 kExprI32Sub, // --
24 ]); 24 ]);
25 builder.addFunction("main", [kAstI32, kAstI32, kAstI32, kAstI32]) 25 builder.addFunction("main", kSig_i_iii)
26 .addBody([ 26 .addBody([
27 kExprGetLocal, 0, 27 kExprGetLocal, 0,
28 kExprGetLocal, 1, 28 kExprGetLocal, 1,
29 kExprGetLocal, 2, 29 kExprGetLocal, 2,
30 kExprCallIndirect, kArity2, sig_index 30 kExprCallIndirect, kArity2, sig_index
31 ]) 31 ])
32 .exportFunc() 32 .exportFunc()
33 builder.appendToFunctionTable([0, 1, 2]); 33 builder.appendToFunctionTable([0, 1, 2]);
34 34
35 return builder.instantiate({add: function(a, b) { return a + b | 0; }}); 35 return builder.instantiate({add: function(a, b) { return a + b | 0; }});
36 })(); 36 })();
37 37
38 // Check the module exists. 38 // Check the module exists.
39 assertFalse(module === undefined); 39 assertFalse(module === undefined);
40 assertFalse(module === null); 40 assertFalse(module === null);
41 assertFalse(module === 0); 41 assertFalse(module === 0);
42 assertEquals("object", typeof module.exports); 42 assertEquals("object", typeof module.exports);
43 assertEquals("function", typeof module.exports.main); 43 assertEquals("function", typeof module.exports.main);
44 44
45 assertEquals(5, module.exports.main(1, 12, 7)); 45 assertEquals(5, module.exports.main(1, 12, 7));
46 assertEquals(19, module.exports.main(0, 12, 7)); 46 assertEquals(19, module.exports.main(0, 12, 7));
47 47
48 assertTraps(kTrapFuncSigMismatch, "module.exports.main(2, 12, 33)"); 48 assertTraps(kTrapFuncSigMismatch, "module.exports.main(2, 12, 33)");
49 assertTraps(kTrapFuncInvalid, "module.exports.main(3, 12, 33)"); 49 assertTraps(kTrapFuncInvalid, "module.exports.main(3, 12, 33)");
OLDNEW
« no previous file with comments | « test/mjsunit/wasm/import-table.js ('k') | test/mjsunit/wasm/instantiate-module-basic.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698