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

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

Issue 2345593003: [wasm] Master CL for Binary 0xC changes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: [wasm] Master CL for Binary 0xC changes. Created 4 years, 3 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
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 --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 kPageSize = 0x10000; 10 var kPageSize = 0x10000;
11 11
12 function genGrowMemoryBuilder() { 12 function genGrowMemoryBuilder() {
13 var builder = new WasmModuleBuilder(); 13 var builder = new WasmModuleBuilder();
14 builder.addFunction("grow_memory", kSig_i_i) 14 builder.addFunction("grow_memory", kSig_i_i)
15 .addBody([kExprGetLocal, 0, kExprGrowMemory]) 15 .addBody([kExprGetLocal, 0, kExprGrowMemory])
16 .exportFunc(); 16 .exportFunc();
17 builder.addFunction("load", kSig_i_i) 17 builder.addFunction("load", kSig_i_i)
18 .addBody([kExprGetLocal, 0, kExprI32LoadMem, 0, 0]) 18 .addBody([kExprGetLocal, 0, kExprI32LoadMem, 0, 0])
19 .exportFunc(); 19 .exportFunc();
20 builder.addFunction("store", kSig_i_ii) 20 builder.addFunction("store", kSig_i_ii)
21 .addBody([kExprGetLocal, 0, kExprGetLocal, 1, kExprI32StoreMem, 0, 0]) 21 .addBody([kExprGetLocal, 0, kExprGetLocal, 1, kExprI32StoreMem, 0, 0,
22 kExprGetLocal, 1])
22 .exportFunc(); 23 .exportFunc();
23 builder.addFunction("load16", kSig_i_i) 24 builder.addFunction("load16", kSig_i_i)
24 .addBody([kExprGetLocal, 0, kExprI32LoadMem16U, 0, 0]) 25 .addBody([kExprGetLocal, 0, kExprI32LoadMem16U, 0, 0])
25 .exportFunc(); 26 .exportFunc();
26 builder.addFunction("store16", kSig_i_ii) 27 builder.addFunction("store16", kSig_i_ii)
27 .addBody([kExprGetLocal, 0, kExprGetLocal, 1, kExprI32StoreMem16, 0, 0]) 28 .addBody([kExprGetLocal, 0, kExprGetLocal, 1, kExprI32StoreMem16, 0, 0,
29 kExprGetLocal, 1])
28 .exportFunc(); 30 .exportFunc();
29 builder.addFunction("load8", kSig_i_i) 31 builder.addFunction("load8", kSig_i_i)
30 .addBody([kExprGetLocal, 0, kExprI32LoadMem8U, 0, 0]) 32 .addBody([kExprGetLocal, 0, kExprI32LoadMem8U, 0, 0])
31 .exportFunc(); 33 .exportFunc();
32 builder.addFunction("store8", kSig_i_ii) 34 builder.addFunction("store8", kSig_i_ii)
33 .addBody([kExprGetLocal, 0, kExprGetLocal, 1, kExprI32StoreMem8, 0, 0]) 35 .addBody([kExprGetLocal, 0, kExprGetLocal, 1, kExprI32StoreMem8, 0, 0,
36 kExprGetLocal, 1])
34 .exportFunc(); 37 .exportFunc();
35 return builder; 38 return builder;
36 } 39 }
37 40
38 function testGrowMemoryReadWrite32() { 41 function testGrowMemoryReadWrite32() {
39 var builder = genGrowMemoryBuilder(); 42 var builder = genGrowMemoryBuilder();
40 builder.addMemory(1, 1, false); 43 builder.addMemory(1, 1, false);
41 var module = builder.instantiate(); 44 var module = builder.instantiate();
42 var offset; 45 var offset;
43 function peek() { return module.exports.load(offset); } 46 function peek() { return module.exports.load(offset); }
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 240
238 function testGrowMemoryCurrentMemory() { 241 function testGrowMemoryCurrentMemory() {
239 var builder = genGrowMemoryBuilder(); 242 var builder = genGrowMemoryBuilder();
240 builder.addMemory(1, 1, false); 243 builder.addMemory(1, 1, false);
241 builder.addFunction("memory_size", kSig_i_v) 244 builder.addFunction("memory_size", kSig_i_v)
242 .addBody([kExprMemorySize]) 245 .addBody([kExprMemorySize])
243 .exportFunc(); 246 .exportFunc();
244 var module = builder.instantiate(); 247 var module = builder.instantiate();
245 function growMem(pages) { return module.exports.grow_memory(pages); } 248 function growMem(pages) { return module.exports.grow_memory(pages); }
246 function MemSize() { return module.exports.memory_size(); } 249 function MemSize() { return module.exports.memory_size(); }
247 assertEquals(65536, MemSize()); 250 assertEquals(1, MemSize());
248 assertEquals(1, growMem(1)); 251 assertEquals(1, growMem(1));
249 assertEquals(131072, MemSize()); 252 assertEquals(2, MemSize());
250 } 253 }
251 254
252 testGrowMemoryCurrentMemory(); 255 testGrowMemoryCurrentMemory();
253 256
254 function testGrowMemoryPreservesDataMemOp32() { 257 function testGrowMemoryPreservesDataMemOp32() {
255 var builder = genGrowMemoryBuilder(); 258 var builder = genGrowMemoryBuilder();
256 builder.addMemory(1, 1, false); 259 builder.addMemory(1, 1, false);
257 var module = builder.instantiate(); 260 var module = builder.instantiate();
258 var offset, val; 261 var offset, val;
259 function peek() { return module.exports.load(offset); } 262 function peek() { return module.exports.load(offset); }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 319
317 val = 0; 320 val = 0;
318 321
319 for(offset = 0; offset <= (kPageSize - 1); offset++, val++) { 322 for(offset = 0; offset <= (kPageSize - 1); offset++, val++) {
320 assertEquals(val, peek()); 323 assertEquals(val, peek());
321 if (val == 255) val = 0; 324 if (val == 255) val = 0;
322 } 325 }
323 } 326 }
324 327
325 testGrowMemoryPreservesDataMemOp8(); 328 testGrowMemoryPreservesDataMemOp8();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698