OLD | NEW |
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 | 8 |
9 function testCallFFI(ffi) { | 9 function testCallFFI(ffi) { |
10 var kBodySize = 6; | 10 var kBodySize = 6; |
11 var kNameAddOffset = 28 + kBodySize + 1; | 11 var kNameAddOffset = kHeaderSize + 28 + kBodySize + 1; |
12 var kNameMainOffset = kNameAddOffset + 4; | 12 var kNameMainOffset = kNameAddOffset + 4; |
13 | 13 |
14 var data = bytes( | 14 var data = bytesWithHeader( |
15 kDeclMemory, | 15 kDeclMemory, |
16 12, 12, 1, // memory | 16 12, 12, 1, // memory |
17 // -- signatures | 17 // -- signatures |
18 kDeclSignatures, 1, | 18 kDeclSignatures, 1, |
19 2, kAstI32, kAstF64, kAstF64, // (f64,f64)->int | 19 2, kAstI32, kAstF64, kAstF64, // (f64,f64)->int |
20 // -- foreign function | 20 // -- foreign function |
21 kDeclFunctions, 2, | 21 kDeclFunctions, 2, |
22 kDeclFunctionName | kDeclFunctionImport, | 22 kDeclFunctionName | kDeclFunctionImport, |
23 0, 0, // signature index | 23 0, 0, // signature index |
24 kNameAddOffset, 0, 0, 0, // name offset | 24 kNameAddOffset, 0, 0, 0, // name offset |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 testCallFFI(ffi); | 70 testCallFFI(ffi); |
71 }); | 71 }); |
72 | 72 |
73 | 73 |
74 // "fun" should be a JS function. | 74 // "fun" should be a JS function. |
75 assertThrows(function() { | 75 assertThrows(function() { |
76 var ffi = new Object(); | 76 var ffi = new Object(); |
77 ffi.fun = 0; | 77 ffi.fun = 0; |
78 testCallFFI(ffi); | 78 testCallFFI(ffi); |
79 }); | 79 }); |
OLD | NEW |