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 = 2; |
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 1, 1, 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 |
(...skipping 16 matching lines...) Expand all Loading... |
44 assertFalse(mem === undefined); | 44 assertFalse(mem === undefined); |
45 assertFalse(mem === null); | 45 assertFalse(mem === null); |
46 assertFalse(mem === 0); | 46 assertFalse(mem === 0); |
47 assertEquals("object", typeof mem); | 47 assertEquals("object", typeof mem); |
48 assertTrue(mem instanceof ArrayBuffer); | 48 assertTrue(mem instanceof ArrayBuffer); |
49 for (var i = 0; i < 4; i++) { | 49 for (var i = 0; i < 4; i++) { |
50 module.memory = 0; // should be ignored | 50 module.memory = 0; // should be ignored |
51 assertEquals(mem, module.memory); | 51 assertEquals(mem, module.memory); |
52 } | 52 } |
53 | 53 |
54 assertEquals(1024, module.memory.byteLength); | 54 assertEquals(65536, module.memory.byteLength); |
55 | 55 |
56 // Check the properties of the main function. | 56 // Check the properties of the main function. |
57 assertFalse(module.main === undefined); | 57 assertFalse(module.main === undefined); |
58 assertFalse(module.main === null); | 58 assertFalse(module.main === null); |
59 assertFalse(module.main === 0); | 59 assertFalse(module.main === 0); |
60 assertEquals("function", typeof module.main); | 60 assertEquals("function", typeof module.main); |
61 | 61 |
62 assertEquals(kReturnValue, module.main()); | 62 assertEquals(kReturnValue, module.main()); |
OLD | NEW |