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 --expose-gc --stress-compaction | 5 // Flags: --expose-wasm --expose-gc --stress-compaction |
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 var kPageSize = 0x10000; | 10 var kPageSize = 0x10000; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 function testGrowMemoryTrapsWithNonSmiInput() { | 121 function testGrowMemoryTrapsWithNonSmiInput() { |
122 var builder = genGrowMemoryBuilder(); | 122 var builder = genGrowMemoryBuilder(); |
123 var module = builder.instantiate(); | 123 var module = builder.instantiate(); |
124 function growMem(pages) { return module.exports.grow_memory(pages); } | 124 function growMem(pages) { return module.exports.grow_memory(pages); } |
125 // The parameter of grow_memory is unsigned. Therefore -1 stands for | 125 // The parameter of grow_memory is unsigned. Therefore -1 stands for |
126 // UINT32_MIN, which cannot be represented as SMI. | 126 // UINT32_MIN, which cannot be represented as SMI. |
127 assertEquals(-1, growMem(-1)); | 127 assertEquals(-1, growMem(-1)); |
128 }; | 128 }; |
129 | 129 |
130 testGrowMemoryTrapsWithNonSmiInput(); | 130 testGrowMemoryTrapsWithNonSmiInput(); |
| 131 |
| 132 function testGrowMemoryCurrentMemory() { |
| 133 var builder = genGrowMemoryBuilder(); |
| 134 builder.addMemory(1, 1, false); |
| 135 builder.addFunction("memory_size", kSig_i_v) |
| 136 .addBody([kExprMemorySize]) |
| 137 .exportFunc(); |
| 138 var module = builder.instantiate(); |
| 139 function growMem(pages) { return module.exports.grow_memory(pages); } |
| 140 function MemSize() { return module.exports.memory_size(); } |
| 141 assertEquals(65536, MemSize()); |
| 142 assertEquals(1, growMem(1)); |
| 143 assertEquals(131072, MemSize()); |
| 144 } |
| 145 |
| 146 testGrowMemoryCurrentMemory(); |
OLD | NEW |