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 | 8 |
9 var kMemSize = 4096; | 9 var kMemSize = 4096; |
10 | 10 |
(...skipping 27 matching lines...) Expand all Loading... |
38 kExprI32LoadMem,0,kExprGetLocal,0, | 38 kExprI32LoadMem,0,kExprGetLocal,0, |
39 kExprBr,2, kExprI8Const, 255, | 39 kExprBr,2, kExprI8Const, 255, |
40 kExprSetLocal,0, | 40 kExprSetLocal,0, |
41 kExprI32Sub,kExprGetLocal,0,kExprI8Const,4, | 41 kExprI32Sub,kExprGetLocal,0,kExprI8Const,4, |
42 kExprI8Const,0, | 42 kExprI8Const,0, |
43 // names | 43 // names |
44 kDeclEnd, | 44 kDeclEnd, |
45 'm', 'a', 'i', 'n', 0 // -- | 45 'm', 'a', 'i', 'n', 0 // -- |
46 ); | 46 ); |
47 | 47 |
48 return WASM.instantiateModule(data, null, memory); | 48 return _WASMEXP_.instantiateModule(data, null, memory); |
49 } | 49 } |
50 | 50 |
51 function testPokeMemory() { | 51 function testPokeMemory() { |
52 var module = genModule(null); | 52 var module = genModule(null); |
53 var buffer = module.memory; | 53 var buffer = module.memory; |
54 assertEquals(kMemSize, buffer.byteLength); | 54 assertEquals(kMemSize, buffer.byteLength); |
55 | 55 |
56 var array = new Int8Array(buffer); | 56 var array = new Int8Array(buffer); |
57 assertEquals(kMemSize, array.length); | 57 assertEquals(kMemSize, array.length); |
58 | 58 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 0, 0, // local float64 count | 152 0, 0, // local float64 count |
153 kBodySize, 0, // code size | 153 kBodySize, 0, // code size |
154 // geti: return mem[a] = mem[b] | 154 // geti: return mem[a] = mem[b] |
155 kExprI32StoreMem, 0, kExprGetLocal, 0, kExprI32LoadMem, 0, kExprGetLocal, 1, | 155 kExprI32StoreMem, 0, kExprGetLocal, 0, kExprI32LoadMem, 0, kExprGetLocal, 1, |
156 // names | 156 // names |
157 kDeclEnd, | 157 kDeclEnd, |
158 'g','e','t','i', 0 // -- | 158 'g','e','t','i', 0 // -- |
159 ); | 159 ); |
160 | 160 |
161 var memory = null; | 161 var memory = null; |
162 var module = WASM.instantiateModule(data, null, memory); | 162 var module = _WASMEXP_.instantiateModule(data, null, memory); |
163 | 163 |
164 var offset; | 164 var offset; |
165 | 165 |
166 function read() { return module.geti(0, offset); } | 166 function read() { return module.geti(0, offset); } |
167 function write() { return module.geti(offset, 0); } | 167 function write() { return module.geti(offset, 0); } |
168 | 168 |
169 for (offset = 0; offset < 4092; offset++) { | 169 for (offset = 0; offset < 4092; offset++) { |
170 assertEquals(0, read()); | 170 assertEquals(0, read()); |
171 assertEquals(0, write()); | 171 assertEquals(0, write()); |
172 } | 172 } |
173 | 173 |
174 | 174 |
175 for (offset = 4093; offset < 4124; offset++) { | 175 for (offset = 4093; offset < 4124; offset++) { |
176 assertTraps(kTrapMemOutOfBounds, read); | 176 assertTraps(kTrapMemOutOfBounds, read); |
177 assertTraps(kTrapMemOutOfBounds, write); | 177 assertTraps(kTrapMemOutOfBounds, write); |
178 } | 178 } |
179 } | 179 } |
180 | 180 |
181 testOOBThrows(); | 181 testOOBThrows(); |
OLD | NEW |