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 18 matching lines...) Expand all Loading... |
29 /* */ kExprGetLocal, 0, // -- | 29 /* */ kExprGetLocal, 0, // -- |
30 /* */ kExprI32Const, 4, // -- | 30 /* */ kExprI32Const, 4, // -- |
31 /* */ kExprI32Sub, // -- | 31 /* */ kExprI32Sub, // -- |
32 /* */ kExprSetLocal, 0, // -- | 32 /* */ kExprSetLocal, 0, // -- |
33 /* */ kExprBr, 1, // -- | 33 /* */ kExprBr, 1, // -- |
34 /* */ kExprEnd, // -- | 34 /* */ kExprEnd, // -- |
35 /* */ kExprEnd, // -- | 35 /* */ kExprEnd, // -- |
36 /**/ kExprI32Const, 0 // -- | 36 /**/ kExprI32Const, 0 // -- |
37 ]) | 37 ]) |
38 .exportFunc(); | 38 .exportFunc(); |
39 var module = builder.instantiate(null, memory); | 39 var module = builder.instantiate(undefined, memory); |
40 assertTrue(module.exports.memory instanceof WebAssembly.Memory); | 40 assertTrue(module.exports.memory instanceof WebAssembly.Memory); |
41 if (memory != null) assertEquals(memory.buffer, module.exports.memory.buffer); | 41 if (memory != null) assertEquals(memory.buffer, module.exports.memory.buffer); |
42 return module; | 42 return module; |
43 } | 43 } |
44 | 44 |
45 function testPokeMemory() { | 45 function testPokeMemory() { |
46 print("testPokeMemory"); | 46 print("testPokeMemory"); |
47 var module = genModule(null); | 47 var module = genModule(undefined); |
48 var buffer = module.exports.memory.buffer; | 48 var buffer = module.exports.memory.buffer; |
49 var main = module.exports.main; | 49 var main = module.exports.main; |
50 assertEquals(kMemSize, buffer.byteLength); | 50 assertEquals(kMemSize, buffer.byteLength); |
51 | 51 |
52 var array = new Int8Array(buffer); | 52 var array = new Int8Array(buffer); |
53 assertEquals(kMemSize, array.length); | 53 assertEquals(kMemSize, array.length); |
54 | 54 |
55 for (var i = 0; i < kMemSize; i++) { | 55 for (var i = 0; i < kMemSize; i++) { |
56 assertEquals(0, array[i]); | 56 assertEquals(0, array[i]); |
57 } | 57 } |
(...skipping 10 matching lines...) Expand all Loading... |
68 } | 68 } |
69 } | 69 } |
70 | 70 |
71 testPokeMemory(); | 71 testPokeMemory(); |
72 | 72 |
73 function genAndGetMain(buffer) { | 73 function genAndGetMain(buffer) { |
74 return genModule(buffer).exports.main; // to prevent intermediates living | 74 return genModule(buffer).exports.main; // to prevent intermediates living |
75 } | 75 } |
76 | 76 |
77 function testSurvivalAcrossGc() { | 77 function testSurvivalAcrossGc() { |
78 var checker = genAndGetMain(null); | 78 var checker = genAndGetMain(undefined); |
79 for (var i = 0; i < 3; i++) { | 79 for (var i = 0; i < 3; i++) { |
80 print("gc run ", i); | 80 print("gc run ", i); |
81 assertEquals(0, checker(kMemSize - 4)); | 81 assertEquals(0, checker(kMemSize - 4)); |
82 gc(); | 82 gc(); |
83 } | 83 } |
84 } | 84 } |
85 | 85 |
86 testSurvivalAcrossGc(); | 86 testSurvivalAcrossGc(); |
87 testSurvivalAcrossGc(); | 87 testSurvivalAcrossGc(); |
88 testSurvivalAcrossGc(); | 88 testSurvivalAcrossGc(); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 } | 160 } |
161 | 161 |
162 | 162 |
163 for (offset = 65534; offset < 66536; offset++) { | 163 for (offset = 65534; offset < 66536; offset++) { |
164 assertTraps(kTrapMemOutOfBounds, read); | 164 assertTraps(kTrapMemOutOfBounds, read); |
165 assertTraps(kTrapMemOutOfBounds, write); | 165 assertTraps(kTrapMemOutOfBounds, write); |
166 } | 166 } |
167 } | 167 } |
168 | 168 |
169 testOOBThrows(); | 169 testOOBThrows(); |
OLD | NEW |