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

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

Issue 2410763002: [wasm] GrowMemory should use maximum size declared in WebAssembly.Memory (Closed)
Patch Set: Separate refactoring, add 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
« src/wasm/wasm-module.cc ('K') | « 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 73
74 for (var i = 0; i < 1e11; i = i * 3 + 5) { 74 for (var i = 0; i < 1e11; i = i * 3 + 5) {
75 for (var j = 0; j < 10; j++) { 75 for (var j = 0; j < 10; j++) {
76 var val = i + 99077 + j; 76 var val = i + 99077 + j;
77 i32[j] = val; 77 i32[j] = val;
78 assertEquals(val | 0, i1.exports.foo(j * 4)); 78 assertEquals(val | 0, i1.exports.foo(j * 4));
79 assertEquals(val | 0, i2.exports.bar(j * 4)); 79 assertEquals(val | 0, i2.exports.bar(j * 4));
80 } 80 }
81 } 81 }
82 })(); 82 })();
83
84 (function TestGrowMemMaxDesc() {
85 print("Maximum descriptor");
86 let memory = new WebAssembly.Memory({initial: 1, maximum: 5});
87 assertEquals(kPageSize, memory.buffer.byteLength);
88 let i32 = new Int32Array(memory.buffer);
89 let builder = new WasmModuleBuilder();
90 builder.addImportedMemory("mine");
91 builder.addFunction("main", kSig_i_v)
92 .addBody([
93 kExprI32Const, 0,
94 kExprI32LoadMem, 0, 0])
95 .exportAs("main");
96
97 let main = builder.instantiate({mine: memory}).exports.main;
98 assertEquals(0, main());
99 i32[0] = 993377;
100 assertEquals(993377, main());
101
102 for (var i = 1; i < 4; i++) {
103 assertEquals(i, memory.grow(1));
104 assertEquals(993377, main());
105 }
106 try {
107 memory.grow(1);
108 } catch (e) {
109 assertEquals("object", typeof e);
110 }
111 })();
OLDNEW
« src/wasm/wasm-module.cc ('K') | « src/wasm/wasm-module.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698