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

Side by Side Diff: test/mjsunit/wasm/ffi.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/export-table.js ('k') | test/mjsunit/wasm/ffi-error.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 testCallFFI(func, check) { 10 function testCallFFI(func, check) {
11 var builder = new WasmModuleBuilder(); 11 var builder = new WasmModuleBuilder();
12 12
13 var sig_index = builder.addSignature([kAstI32, kAstF64, kAstF64]); 13 var sig_index = builder.addSignature(kSig_i_dd);
14 builder.addImport("func", sig_index); 14 builder.addImport("func", sig_index);
15 builder.addFunction("main", sig_index) 15 builder.addFunction("main", sig_index)
16 .addBody([ 16 .addBody([
17 kExprGetLocal, 0, // -- 17 kExprGetLocal, 0, // --
18 kExprGetLocal, 1, // -- 18 kExprGetLocal, 1, // --
19 kExprCallImport, kArity2, 0 // -- 19 kExprCallImport, kArity2, 0 // --
20 ]) // -- 20 ]) // --
21 .exportFunc(); 21 .exportFunc();
22 22
23 var main = builder.instantiate({func: func}).exports.main; 23 var main = builder.instantiate({func: func}).exports.main;
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 ffi = {func: function(a, b) { 178 ffi = {func: function(a, b) {
179 passed_length = arguments.length; 179 passed_length = arguments.length;
180 passed_a = a; 180 passed_a = a;
181 passed_b = b; 181 passed_b = b;
182 args_a = arguments[0]; 182 args_a = arguments[0];
183 args_b = arguments[1]; 183 args_b = arguments[1];
184 }}; 184 }};
185 185
186 var builder = new WasmModuleBuilder(); 186 var builder = new WasmModuleBuilder();
187 187
188 builder.addImport("func", [kAstStmt, type, type]); 188 builder.addImport("func", makeSig_v_xx(type));
189 builder.addFunction("main", [kAstI32, type, type]) 189 builder.addFunction("main", makeSig_r_xx(kAstI32, type))
190 .addBody([ 190 .addBody([
191 kExprGetLocal, 0, // -- 191 kExprGetLocal, 0, // --
192 kExprGetLocal, 1, // -- 192 kExprGetLocal, 1, // --
193 kExprCallImport, kArity2, 0, // -- 193 kExprCallImport, kArity2, 0, // --
194 kExprI8Const, 99 // -- 194 kExprI8Const, 99 // --
195 ]) // -- 195 ]) // --
196 .exportFunc() 196 .exportFunc()
197 197
198 var main = builder.instantiate(ffi).exports.main; 198 var main = builder.instantiate(ffi).exports.main;
199 199
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 testCallBinopVoid(kAstI32); 234 testCallBinopVoid(kAstI32);
235 // TODO testCallBinopVoid(kAstI64); 235 // TODO testCallBinopVoid(kAstI64);
236 testCallBinopVoid(kAstF32); 236 testCallBinopVoid(kAstF32);
237 testCallBinopVoid(kAstF64); 237 testCallBinopVoid(kAstF64);
238 238
239 239
240 240
241 function testCallPrint() { 241 function testCallPrint() {
242 var builder = new WasmModuleBuilder(); 242 var builder = new WasmModuleBuilder();
243 243
244 builder.addImport("print", [kAstStmt, kAstI32]); 244 builder.addImport("print", makeSig_v_x(kAstI32));
245 builder.addImport("print", [kAstStmt, kAstF64]); 245 builder.addImport("print", makeSig_v_x(kAstF64));
246 builder.addFunction("main", [kAstStmt, kAstF64]) 246 builder.addFunction("main", makeSig_v_x(kAstF64))
247 .addBody([ 247 .addBody([
248 kExprI8Const, 97, // -- 248 kExprI8Const, 97, // --
249 kExprCallImport, kArity1, 0, // -- 249 kExprCallImport, kArity1, 0, // --
250 kExprGetLocal, 0, // -- 250 kExprGetLocal, 0, // --
251 kExprCallImport, kArity1, 1 // -- 251 kExprCallImport, kArity1, 1 // --
252 ]) // -- 252 ]) // --
253 .exportFunc() 253 .exportFunc()
254 254
255 var main = builder.instantiate({print: print}).exports.main; 255 var main = builder.instantiate({print: print}).exports.main;
256 for (var i = -9; i < 900; i += 6.125) main(i); 256 for (var i = -9; i < 900; i += 6.125) main(i);
257 } 257 }
258 258
259 testCallPrint(); 259 testCallPrint();
260 testCallPrint(); 260 testCallPrint();
OLDNEW
« no previous file with comments | « test/mjsunit/wasm/export-table.js ('k') | test/mjsunit/wasm/ffi-error.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698