Chromium Code Reviews| 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 --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 kMemSize = 65536; | 10 var kMemSize = 65536; |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 /* */ kExprEnd, // -- | 35 /* */ kExprEnd, // -- |
| 36 /**/ kExprI8Const, 0 // -- | 36 /**/ kExprI8Const, 0 // -- |
| 37 ]) | 37 ]) |
| 38 .exportFunc(); | 38 .exportFunc(); |
| 39 var module = builder.instantiate(null, memory); | 39 var module = builder.instantiate(null, memory); |
| 40 assertTrue(module.exports.memory instanceof WebAssembly.Memory); | 40 assertTrue(module.exports.memory instanceof WebAssembly.Memory); |
| 41 if (memory != null) assertEquals(memory, module.exports.memory.buffer); | 41 if (memory != null) assertEquals(memory, module.exports.memory.buffer); |
| 42 return module; | 42 return module; |
| 43 } | 43 } |
| 44 | 44 |
| 45 | |
| 46 function testSmallMemory() { | |
| 47 var buffer = new ArrayBuffer(1); | |
|
gdeepti
2016/10/07 02:50:52
Following up from offline discussions, this test s
| |
| 48 var module = genModule(buffer); | |
| 49 var main = module.exports.main; | |
| 50 assertEquals(1, buffer.byteLength); | |
| 51 assertEquals(0, main(0)); | |
| 52 } | |
| 53 | |
| 54 testSmallMemory(); | |
| 55 | |
| 56 | |
| 45 function testPokeMemory() { | 57 function testPokeMemory() { |
| 46 var module = genModule(null); | 58 var module = genModule(null); |
| 47 var buffer = module.exports.memory.buffer; | 59 var buffer = module.exports.memory.buffer; |
| 48 var main = module.exports.main; | 60 var main = module.exports.main; |
| 49 assertEquals(kMemSize, buffer.byteLength); | 61 assertEquals(kMemSize, buffer.byteLength); |
| 50 | 62 |
| 51 var array = new Int8Array(buffer); | 63 var array = new Int8Array(buffer); |
| 52 assertEquals(kMemSize, array.length); | 64 assertEquals(kMemSize, array.length); |
| 53 | 65 |
| 54 for (var i = 0; i < kMemSize; i++) { | 66 for (var i = 0; i < kMemSize; i++) { |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 } | 170 } |
| 159 | 171 |
| 160 | 172 |
| 161 for (offset = 65534; offset < 66536; offset++) { | 173 for (offset = 65534; offset < 66536; offset++) { |
| 162 assertTraps(kTrapMemOutOfBounds, read); | 174 assertTraps(kTrapMemOutOfBounds, read); |
| 163 assertTraps(kTrapMemOutOfBounds, write); | 175 assertTraps(kTrapMemOutOfBounds, write); |
| 164 } | 176 } |
| 165 } | 177 } |
| 166 | 178 |
| 167 testOOBThrows(); | 179 testOOBThrows(); |
| OLD | NEW |