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

Side by Side Diff: test/mjsunit/wasm/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/adapter-frame.js ('k') | test/mjsunit/wasm/divrem-trap.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 function assertModule(module, memsize) { 10 function assertModule(module, memsize) {
(...skipping 27 matching lines...) Expand all
38 assertFalse(exp === 0); 38 assertFalse(exp === 0);
39 assertEquals("function", typeof exp); 39 assertEquals("function", typeof exp);
40 return exp; 40 return exp;
41 } 41 }
42 42
43 (function I64SubTest() { 43 (function I64SubTest() {
44 44
45 var builder = new WasmModuleBuilder(); 45 var builder = new WasmModuleBuilder();
46 46
47 builder.addMemory(1, 1, true); 47 builder.addMemory(1, 1, true);
48 builder.addFunction("sub", [kAstI64, kAstI64, kAstI64]) 48 builder.addFunction("sub", kSig_l_ll)
49 .addBody([ // -- 49 .addBody([ // --
50 kExprGetLocal, 0, // -- 50 kExprGetLocal, 0, // --
51 kExprGetLocal, 1, // -- 51 kExprGetLocal, 1, // --
52 kExprI64Sub]) // -- 52 kExprI64Sub]) // --
53 .exportFunc() 53 .exportFunc()
54 54
55 var module = builder.instantiate(); 55 var module = builder.instantiate();
56 assertModule(module, kPageSize); 56 assertModule(module, kPageSize);
57 57
58 // Check the properties of the sub function. 58 // Check the properties of the sub function.
59 var sub = assertFunction(module, "sub"); 59 var sub = assertFunction(module, "sub");
60 assertEquals(-55, sub(33, 88)); 60 assertEquals(-55, sub(33, 88));
61 assertEquals(-55555, sub(33333, 88888)); 61 assertEquals(-55555, sub(33333, 88888));
62 assertEquals(-5555555, sub(3333333, 8888888)); 62 assertEquals(-5555555, sub(3333333, 8888888));
63 })(); 63 })();
64 64
65 (function SubTest() { 65 (function SubTest() {
66 66
67 var builder = new WasmModuleBuilder(); 67 var builder = new WasmModuleBuilder();
68 68
69 builder.addMemory(1, 1, true); 69 builder.addMemory(1, 1, true);
70 builder.addFunction("sub", [kAstI32, kAstI32, kAstI32]) 70 builder.addFunction("sub", kSig_i_ii)
71 .addBody([ 71 .addBody([
72 kExprGetLocal, 0, // -- 72 kExprGetLocal, 0, // --
73 kExprGetLocal, 1, // -- 73 kExprGetLocal, 1, // --
74 kExprI32Sub, // -- 74 kExprI32Sub, // --
75 ]) 75 ])
76 .exportFunc() 76 .exportFunc()
77 77
78 var module = builder.instantiate(); 78 var module = builder.instantiate();
79 assertModule(module, kPageSize); 79 assertModule(module, kPageSize);
80 80
81 // Check the properties of the sub function. 81 // Check the properties of the sub function.
82 var sub = assertFunction(module, "sub"); 82 var sub = assertFunction(module, "sub");
83 assertEquals(-55, sub(33, 88)); 83 assertEquals(-55, sub(33, 88));
84 assertEquals(-55555, sub(33333, 88888)); 84 assertEquals(-55555, sub(33333, 88888));
85 assertEquals(-5555555, sub(3333333, 8888888)); 85 assertEquals(-5555555, sub(3333333, 8888888));
86 })(); 86 })();
87 87
88 88
89 (function NopTest() { 89 (function NopTest() {
90 90
91 var builder = new WasmModuleBuilder(); 91 var builder = new WasmModuleBuilder();
92 92
93 var kPages = 2; 93 var kPages = 2;
94 builder.addMemory(kPages, kPages, true); 94 builder.addMemory(kPages, kPages, true);
95 builder.addFunction("nop", [kAstStmt]) 95 builder.addFunction("nop", kSig_v_v)
96 .addBody([kExprNop]) 96 .addBody([kExprNop])
97 .exportFunc(); 97 .exportFunc();
98 98
99 var module = builder.instantiate(); 99 var module = builder.instantiate();
100 assertModule(module, kPageSize * kPages); 100 assertModule(module, kPageSize * kPages);
101 101
102 var nop = assertFunction(module, "nop"); 102 var nop = assertFunction(module, "nop");
103 assertEquals(undefined, nop()); 103 assertEquals(undefined, nop());
104 })(); 104 })();
105 105
106 106
107 (function testLt() { 107 (function testLt() {
108 var builder = new WasmModuleBuilder(); 108 var builder = new WasmModuleBuilder();
109 109
110 var kPages = 3; 110 var kPages = 3;
111 builder.addMemory(kPages, kPages, true); 111 builder.addMemory(kPages, kPages, true);
112 builder.addFunction("flt", [kAstI32, kAstF64, kAstF64]) 112 builder.addFunction("flt", kSig_i_dd)
113 .addBody([ 113 .addBody([
114 kExprGetLocal, 0, // -- 114 kExprGetLocal, 0, // --
115 kExprGetLocal, 1, // -- 115 kExprGetLocal, 1, // --
116 kExprF64Lt // -- 116 kExprF64Lt // --
117 ]) // -- 117 ]) // --
118 .exportFunc(); 118 .exportFunc();
119 119
120 var module = builder.instantiate(); 120 var module = builder.instantiate();
121 assertModule(module, kPageSize * kPages); 121 assertModule(module, kPageSize * kPages);
122 122
123 var flt = assertFunction(module, "flt"); 123 var flt = assertFunction(module, "flt");
124 assertEquals(1, flt(-2, -1)); 124 assertEquals(1, flt(-2, -1));
125 assertEquals(0, flt(7.3, 7.1)); 125 assertEquals(0, flt(7.3, 7.1));
126 assertEquals(1, flt(7.1, 7.3)); 126 assertEquals(1, flt(7.1, 7.3));
127 })(); 127 })();
OLDNEW
« no previous file with comments | « test/mjsunit/wasm/adapter-frame.js ('k') | test/mjsunit/wasm/divrem-trap.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698