Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(300)

Side by Side Diff: test/mjsunit/wasm/import-memory.js

Issue 2935243002: Revert of [wasm] Increase WebAssembly.Memory maximum size to ~2GB (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/mjsunit/wasm/grow-memory.js ('k') | test/mjsunit/wasm/large-offset.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 TestOne() { 10 (function TestOne() {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 assertEquals(offset * 2, load()); 142 assertEquals(offset * 2, load());
143 } 143 }
144 for (offset = 5 * kPageSize; offset < 5 * kPageSize + 4; offset++) { 144 for (offset = 5 * kPageSize; offset < 5 * kPageSize + 4; offset++) {
145 assertThrows(load); 145 assertThrows(load);
146 } 146 }
147 assertThrows(() => memory.grow(1)); 147 assertThrows(() => memory.grow(1));
148 })(); 148 })();
149 149
150 (function TestGrowMemoryZeroInitialMemory() { 150 (function TestGrowMemoryZeroInitialMemory() {
151 print("ZeroInitialMemory"); 151 print("ZeroInitialMemory");
152 let kV8MaxPages = 32767;
153 let memory = new WebAssembly.Memory({initial: 0}); 152 let memory = new WebAssembly.Memory({initial: 0});
154 assertEquals(0, memory.buffer.byteLength); 153 assertEquals(0, memory.buffer.byteLength);
155 let i32 = new Int32Array(memory.buffer); 154 let i32 = new Int32Array(memory.buffer);
156 let builder = new WasmModuleBuilder(); 155 let builder = new WasmModuleBuilder();
157 builder.addImportedMemory("mine", "fro"); 156 builder.addImportedMemory("mine", "fro");
158 builder.addFunction("load", kSig_i_i) 157 builder.addFunction("load", kSig_i_i)
159 .addBody([kExprGetLocal, 0, kExprI32LoadMem, 0, 0]) 158 .addBody([kExprGetLocal, 0, kExprI32LoadMem, 0, 0])
160 .exportFunc(); 159 .exportFunc();
161 builder.addFunction("store", kSig_i_ii) 160 builder.addFunction("store", kSig_i_ii)
162 .addBody([kExprGetLocal, 0, kExprGetLocal, 1, kExprI32StoreMem, 0, 0, 161 .addBody([kExprGetLocal, 0, kExprGetLocal, 1, kExprI32StoreMem, 0, 0,
163 kExprGetLocal, 1]) 162 kExprGetLocal, 1])
164 .exportFunc(); 163 .exportFunc();
165 var offset; 164 var offset;
166 let instance = builder.instantiate({mine: {fro: memory}}); 165 let instance = builder.instantiate({mine: {fro: memory}});
167 function load() { return instance.exports.load(offset); } 166 function load() { return instance.exports.load(offset); }
168 function store(value) { return instance.exports.store(offset, value); } 167 function store(value) { return instance.exports.store(offset, value); }
169 168
170 for (var i = 1; i < 5; i++) { 169 for (var i = 1; i < 5; i++) {
171 assertEquals(i - 1, memory.grow(1)); 170 assertEquals(i - 1, memory.grow(1));
172 assertEquals(i * kPageSize, memory.buffer.byteLength); 171 assertEquals(i * kPageSize, memory.buffer.byteLength);
173 for (offset = (i - 1) * kPageSize; offset < i * kPageSize - 3; offset++) { 172 for (offset = (i - 1) * kPageSize; offset < i * kPageSize - 3; offset++) {
174 store(offset * 2); 173 store(offset * 2);
175 } 174 }
176 } 175 }
177 for (offset = 5 * kPageSize; offset < 5 * kPageSize + 4; offset++) { 176 for (offset = 5 * kPageSize; offset < 5 * kPageSize + 4; offset++) {
178 assertThrows(load); 177 assertThrows(load);
179 } 178 }
180 assertThrows(() => memory.grow(kV8MaxPages - 3)); 179 assertThrows(() => memory.grow(16381));
181 })(); 180 })();
182 181
183 (function ImportedMemoryBufferLength() { 182 (function ImportedMemoryBufferLength() {
184 print("ImportedMemoryBufferLength"); 183 print("ImportedMemoryBufferLength");
185 let memory = new WebAssembly.Memory({initial: 2, maximum: 10}); 184 let memory = new WebAssembly.Memory({initial: 2, maximum: 10});
186 assertEquals(2*kPageSize, memory.buffer.byteLength); 185 assertEquals(2*kPageSize, memory.buffer.byteLength);
187 let builder = new WasmModuleBuilder(); 186 let builder = new WasmModuleBuilder();
188 builder.addFunction("grow", kSig_i_i) 187 builder.addFunction("grow", kSig_i_i)
189 .addBody([kExprGetLocal, 0, kExprGrowMemory, kMemoryZero]) 188 .addBody([kExprGetLocal, 0, kExprGrowMemory, kMemoryZero])
190 .exportFunc(); 189 .exportFunc();
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 var builder = new WasmModuleBuilder(); 404 var builder = new WasmModuleBuilder();
406 builder.addImportedMemory("m", "imported_mem"); 405 builder.addImportedMemory("m", "imported_mem");
407 let instance = builder.instantiate({m: {imported_mem: memory}}); 406 let instance = builder.instantiate({m: {imported_mem: memory}});
408 let buffer = memory.buffer; 407 let buffer = memory.buffer;
409 assertEquals(kPageSize, buffer.byteLength); 408 assertEquals(kPageSize, buffer.byteLength);
410 assertEquals(1, memory.grow(2)); 409 assertEquals(1, memory.grow(2));
411 assertTrue(buffer !== memory.buffer); 410 assertTrue(buffer !== memory.buffer);
412 assertEquals(0, buffer.byteLength); 411 assertEquals(0, buffer.byteLength);
413 assertEquals(3*kPageSize, memory.buffer.byteLength); 412 assertEquals(3*kPageSize, memory.buffer.byteLength);
414 })(); 413 })();
OLDNEW
« no previous file with comments | « test/mjsunit/wasm/grow-memory.js ('k') | test/mjsunit/wasm/large-offset.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698