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

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

Issue 2438673006: [wasm] GrowMemory should update imported memory objects. (Closed)
Patch Set: Improve test Created 4 years, 2 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 | « src/wasm/wasm-module.cc ('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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 assertEquals(i * kPageSize, memory.buffer.byteLength); 174 assertEquals(i * kPageSize, memory.buffer.byteLength);
175 for (offset = (i - 1) * kPageSize; offset < i * kPageSize - 3; offset++) { 175 for (offset = (i - 1) * kPageSize; offset < i * kPageSize - 3; offset++) {
176 store(offset * 2); 176 store(offset * 2);
177 } 177 }
178 } 178 }
179 for (offset = 5 * kPageSize; offset < 5 * kPageSize + 4; offset++) { 179 for (offset = 5 * kPageSize; offset < 5 * kPageSize + 4; offset++) {
180 assertThrows(load); 180 assertThrows(load);
181 } 181 }
182 assertThrows(() => memory.grow(16381)); 182 assertThrows(() => memory.grow(16381));
183 })(); 183 })();
184
185 (function ImportedMemoryBufferLength() {
186 print("ImportedMemoryBufferLength");
187 let memory = new WebAssembly.Memory({initial: 2, maximum: 10});
188 assertEquals(2*kPageSize, memory.buffer.byteLength);
189 let builder = new WasmModuleBuilder();
190 builder.addFunction("grow", kSig_i_i)
191 .addBody([kExprGetLocal, 0, kExprGrowMemory])
192 .exportFunc();
193 builder.addImportedMemory("mine");
194 let instance = builder.instantiate({mine: memory});
195 function grow(pages) { return instance.exports.grow(pages); }
196 assertEquals(2, grow(3));
197 assertEquals(5*kPageSize, memory.buffer.byteLength);
198 assertEquals(5, grow(5));
199 assertEquals(10*kPageSize, memory.buffer.byteLength);
200 assertThrows(() => memory.grow(1));
201 })();
OLDNEW
« no previous file with comments | « src/wasm/wasm-module.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698