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

Side by Side Diff: test/mjsunit/wasm/ffi-error.js

Issue 1770913002: [wasm] Use the JavaScript WasmModuleBuilder utility in JS tests. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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/ffi.js ('k') | test/mjsunit/wasm/import-table.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 9
9 function testCallFFI(ffi) { 10 function testCallFFI(ffi) {
10 var kBodySize = 6; 11 var builder = new WasmModuleBuilder();
11 var kNameAddOffset = kHeaderSize + 28 + kBodySize + 1;
12 var kNameMainOffset = kNameAddOffset + 4;
13 12
14 var data = bytesWithHeader( 13 var sig_index = [kAstI32, kAstF64, kAstF64];
15 kDeclMemory, 14 builder.addImport("fun", sig_index);
16 1, 1, 1, // memory 15 builder.addFunction("main", sig_index)
17 // -- signatures 16 .addBody([
18 kDeclSignatures, 1, 17 kExprCallImport, 0, // --
19 2, kAstI32, kAstF64, kAstF64, // (f64,f64)->int 18 kExprGetLocal, 0, // --
20 // -- foreign function 19 kExprGetLocal, 1]) // --
21 kDeclFunctions, 2, 20 .exportFunc();
22 kDeclFunctionName | kDeclFunctionImport,
23 0, 0, // signature index
24 kNameAddOffset, 0, 0, 0, // name offset
25 // -- main function
26 kDeclFunctionName | kDeclFunctionExport,
27 0, 0, // signature index
28 kNameMainOffset, 0, 0, 0, // name offset
29 kBodySize, 0,
30 // main body
31 kExprCallFunction, 0, // --
32 kExprGetLocal, 0, // --
33 kExprGetLocal, 1, // --
34 // names
35 kDeclEnd,
36 'f', 'u', 'n', 0, // --
37 'm', 'a', 'i', 'n', 0 // --
38 );
39 21
40 print("instantiate FFI"); 22 var module = builder.instantiate(ffi);
41 var module = _WASMEXP_.instantiateModule(data, ffi);
42 } 23 }
43 24
44 // everything is good. 25 // everything is good.
45 (function() { 26 (function() {
46 var ffi = new Object(); 27 var ffi = new Object();
47 ffi.fun = function(a, b) { print(a, b); } 28 ffi.fun = function(a, b) { print(a, b); }
48 testCallFFI(ffi); 29 testCallFFI(ffi);
49 })(); 30 })();
50 31
51 32
(...skipping 18 matching lines...) Expand all
70 testCallFFI(ffi); 51 testCallFFI(ffi);
71 }); 52 });
72 53
73 54
74 // "fun" should be a JS function. 55 // "fun" should be a JS function.
75 assertThrows(function() { 56 assertThrows(function() {
76 var ffi = new Object(); 57 var ffi = new Object();
77 ffi.fun = 0; 58 ffi.fun = 0;
78 testCallFFI(ffi); 59 testCallFFI(ffi);
79 }); 60 });
OLDNEW
« no previous file with comments | « test/mjsunit/wasm/ffi.js ('k') | test/mjsunit/wasm/import-table.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698