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

Side by Side Diff: test/mjsunit/wasm/default-func-call2.js

Issue 2049513003: [wasm] Support undefined indirect table entries, behind a flag. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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
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 // Flags: --wasm-jit-prototype
6 7
7 load("test/mjsunit/wasm/wasm-constants.js"); 8 load("test/mjsunit/wasm/wasm-constants.js");
8 load("test/mjsunit/wasm/wasm-module-builder.js"); 9 load("test/mjsunit/wasm/wasm-module-builder.js");
9 10
10 var module = (function () { 11 var module = (function () {
11 var builder = new WasmModuleBuilder(); 12 var builder = new WasmModuleBuilder();
12 13
13 var sig_index = builder.addSignature(kSig_i_ii); 14 var sig_index = builder.addSignature(kSig_i_ii);
14 builder.addImport("add", sig_index); 15 builder.addImport("add", sig_index);
15 builder.addFunction("add", sig_index) 16 builder.addFunction("add", sig_index)
16 .addBody([ 17 .addBody([
17 kExprGetLocal, 0, kExprGetLocal, 1, kExprCallImport, kArity2, 0 18 kExprGetLocal, 0, kExprGetLocal, 1, kExprCallImport, kArity2, 0
18 ]); 19 ]);
19 builder.addFunction("sub", sig_index) 20 builder.addFunction("sub", sig_index)
20 .addBody([ 21 .addBody([
21 kExprGetLocal, 0, // -- 22 kExprGetLocal, 0, // --
22 kExprGetLocal, 1, // -- 23 kExprGetLocal, 1, // --
23 kExprI32Sub, // -- 24 kExprI32Sub, // --
24 ]); 25 ]);
26 builder.appendToFunctionTable([0, 1]);
27 var i;
28 for(i = 0; i < 2000; i++){
29 builder.addFunction("sub".concat(i.toString()), sig_index)
30 .addBody([
31 kExprGetLocal, 0, // --
32 kExprGetLocal, 1, // --
33 kExprI32Sub, // --
34 ]);
35 builder.appendToFunctionTable([i + 2]);
36 }
25 builder.addFunction("main", kSig_i_iii) 37 builder.addFunction("main", kSig_i_iii)
26 .addBody([ 38 .addBody([
27 kExprGetLocal, 0, 39 kExprGetLocal, 0,
28 kExprGetLocal, 1, 40 kExprGetLocal, 1,
29 kExprGetLocal, 2, 41 kExprGetLocal, 2,
30 kExprCallIndirect, kArity2, sig_index 42 kExprCallIndirect, kArity2, sig_index
31 ]) 43 ])
32 .exportFunc() 44 .exportFunc()
33 builder.appendToFunctionTable([0, 1, 2]); 45 builder.appendToFunctionTable([2002]);
46
34 47
35 return builder.instantiate({add: function(a, b) { return a + b | 0; }}); 48 return builder.instantiate({add: function(a, b) { return a + b | 0; }});
36 })(); 49 })();
37 50
38 // Check the module exists. 51 // Check the module exists.
39 assertFalse(module === undefined); 52 assertFalse(module === undefined);
40 assertFalse(module === null); 53 assertFalse(module === null);
41 assertFalse(module === 0); 54 assertFalse(module === 0);
42 assertEquals("object", typeof module.exports); 55 assertEquals("object", typeof module.exports);
43 assertEquals("function", typeof module.exports.main); 56 assertEquals("function", typeof module.exports.main);
44 57
45 assertEquals(5, module.exports.main(1, 12, 7)); 58 // Check that the appropriate trap is generated
46 assertEquals(19, module.exports.main(0, 12, 7)); 59 assertTraps(kTrapFuncInvalid, "module.exports.main(-1,15,16)");
47 60 assertTraps(kTrapFuncInvalid, "module.exports.main(100000,15,16)");
48 assertTraps(kTrapFuncSigMismatch, "module.exports.main(2, 12, 33)"); 61 assertTraps(kTrapFuncInvalid, "module.exports.main(4006,15,16)");
49 assertTraps(kTrapFuncInvalid, "module.exports.main(3, 12, 33)"); 62 assertTraps(kTrapFuncInvalid, "module.exports.main(4007,15,16)");
63 assertTraps(kTrapDefaultFuncCall, "module.exports.main(4005,15,16)");
64 assertTraps(kTrapDefaultFuncCall, "module.exports.main(2003,15,16)");
65 assertTraps(kTrapDefaultFuncCall, "module.exports.main(3000,15,16)");
66 assertTraps(kTrapFuncSigMismatch, "module.exports.main(2002,15,16)");
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698