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

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

Issue 2474333003: [wasm] Exported memory should set maximum property when maximum is defined. (Closed)
Patch Set: Remove large allocation, fails on mac Created 4 years, 1 month 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') | no next file » | 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 .exportFunc(); 192 .exportFunc();
193 builder.addImportedMemory("mine"); 193 builder.addImportedMemory("mine");
194 let instance = builder.instantiate({mine: memory}); 194 let instance = builder.instantiate({mine: memory});
195 function grow(pages) { return instance.exports.grow(pages); } 195 function grow(pages) { return instance.exports.grow(pages); }
196 assertEquals(2, grow(3)); 196 assertEquals(2, grow(3));
197 assertEquals(5*kPageSize, memory.buffer.byteLength); 197 assertEquals(5*kPageSize, memory.buffer.byteLength);
198 assertEquals(5, grow(5)); 198 assertEquals(5, grow(5));
199 assertEquals(10*kPageSize, memory.buffer.byteLength); 199 assertEquals(10*kPageSize, memory.buffer.byteLength);
200 assertThrows(() => memory.grow(1)); 200 assertThrows(() => memory.grow(1));
201 })(); 201 })();
202
203 (function TestGrowMemoryExportedMaximum() {
204 print("TestGrowMemoryExportedMaximum");
205 let initial_size = 1, maximum_size = 10;
206 var exp_instance;
207 {
208 let builder = new WasmModuleBuilder();
209 builder.addMemory(initial_size, maximum_size, true);
210 builder.exportMemoryAs("exported_mem");
211 exp_instance = builder.instantiate();
212 }
213 var instance;
214 {
215 var builder = new WasmModuleBuilder();
216 builder.addImportedMemory("imported_mem");
217 builder.addFunction("mem_size", kSig_i_v)
218 .addBody([kExprMemorySize, kMemoryZero])
219 .exportFunc();
220 builder.addFunction("grow", kSig_i_i)
221 .addBody([kExprGetLocal, 0, kExprGrowMemory, kMemoryZero])
222 .exportFunc();
223 instance = builder.instantiate({
224 imported_mem: exp_instance.exports.exported_mem});
225 }
226 for (var i = initial_size; i < maximum_size; i++) {
227 assertEquals(i, instance.exports.grow(1));
228 assertEquals((i+1), instance.exports.mem_size());
229 }
230 assertEquals(-1, instance.exports.grow(1));
231 })();
OLDNEW
« no previous file with comments | « test/mjsunit/wasm/grow-memory.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698