OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 testMemorySizeZero() { | 10 (function testMemorySizeZero() { |
11 print("testMemorySizeZero()"); | 11 print("testMemorySizeZero()"); |
12 var builder = new WasmModuleBuilder(); | 12 var builder = new WasmModuleBuilder(); |
| 13 builder.addMemory(0, 0, false); |
13 builder.addFunction("memory_size", kSig_i_v) | 14 builder.addFunction("memory_size", kSig_i_v) |
14 .addBody([kExprMemorySize, kMemoryZero]) | 15 .addBody([kExprMemorySize, kMemoryZero]) |
15 .exportFunc(); | 16 .exportFunc(); |
16 var module = builder.instantiate(); | 17 var module = builder.instantiate(); |
17 assertEquals(0, module.exports.memory_size()); | 18 assertEquals(0, module.exports.memory_size()); |
18 })(); | 19 })(); |
19 | 20 |
20 (function testMemorySizeNonZero() { | 21 (function testMemorySizeNonZero() { |
21 print("testMemorySizeNonZero()"); | 22 print("testMemorySizeNonZero()"); |
22 var builder = new WasmModuleBuilder(); | 23 var builder = new WasmModuleBuilder(); |
23 var size = 11; | 24 var size = 11; |
24 builder.addMemory(size, size, false); | 25 builder.addMemory(size, size, false); |
25 builder.addFunction("memory_size", kSig_i_v) | 26 builder.addFunction("memory_size", kSig_i_v) |
26 .addBody([kExprMemorySize, kMemoryZero]) | 27 .addBody([kExprMemorySize, kMemoryZero]) |
27 .exportFunc(); | 28 .exportFunc(); |
28 var module = builder.instantiate(); | 29 var module = builder.instantiate(); |
29 assertEquals(size, module.exports.memory_size()); | 30 assertEquals(size, module.exports.memory_size()); |
30 })(); | 31 })(); |
OLD | NEW |