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 var kReturnValue = 117; | 9 var kReturnValue = 117; |
10 | 10 |
11 var kBodySize = 2; | 11 var kBodySize = 3; |
12 var kNameOffset = kHeaderSize + 19 + kBodySize + 1; | 12 var kNameOffset = kHeaderSize + 19 + kBodySize + 1; |
13 | 13 |
14 var data = bytesWithHeader( | 14 var data = bytesWithHeader( |
15 // -- memory | 15 // -- memory |
16 kDeclMemory, | 16 kDeclMemory, |
17 10, 10, 1, | 17 10, 10, 1, |
18 // -- signatures | 18 // -- signatures |
19 kDeclSignatures, 1, | 19 kDeclSignatures, 1, |
20 0, kAstI32, // signature: void -> int | 20 0, kAstI32, // signature: void -> int |
21 // -- main function | 21 // -- main function |
22 kDeclFunctions, 1, | 22 kDeclFunctions, 1, |
23 kDeclFunctionName | kDeclFunctionExport, | 23 kDeclFunctionName | kDeclFunctionExport, |
24 0, 0, // signature index | 24 0, 0, // signature index |
25 kNameOffset, 0, 0, 0, // name offset | 25 kNameOffset, 0, 0, 0, // name offset |
26 kBodySize, 0, // body size | 26 kBodySize, 0, // body size |
27 // -- body | 27 // -- body |
| 28 kDeclNoLocals, // -- |
28 kExprI8Const, // -- | 29 kExprI8Const, // -- |
29 kReturnValue, // -- | 30 kReturnValue, // -- |
30 kDeclEnd, | 31 kDeclEnd, |
31 'm', 'a', 'i', 'n', 0 // name | 32 'm', 'a', 'i', 'n', 0 // name |
32 ); | 33 ); |
33 | 34 |
34 var module = _WASMEXP_.instantiateModule(data); | 35 var module = _WASMEXP_.instantiateModule(data); |
35 | 36 |
36 // Check the module exists. | 37 // Check the module exists. |
37 assertFalse(module === undefined); | 38 assertFalse(module === undefined); |
(...skipping 15 matching lines...) Expand all Loading... |
53 | 54 |
54 assertEquals(1024, module.memory.byteLength); | 55 assertEquals(1024, module.memory.byteLength); |
55 | 56 |
56 // Check the properties of the main function. | 57 // Check the properties of the main function. |
57 assertFalse(module.main === undefined); | 58 assertFalse(module.main === undefined); |
58 assertFalse(module.main === null); | 59 assertFalse(module.main === null); |
59 assertFalse(module.main === 0); | 60 assertFalse(module.main === 0); |
60 assertEquals("function", typeof module.main); | 61 assertEquals("function", typeof module.main); |
61 | 62 |
62 assertEquals(kReturnValue, module.main()); | 63 assertEquals(kReturnValue, module.main()); |
OLD | NEW |