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

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: Last comments update 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, kExp rGetLocal, 1])
Mircea Trofin 2016/09/19 16:16:26 80 char limit (below, too)
22 .exportFunc(); 22 .exportFunc();
23 builder.addFunction("load16", kSig_i_i) 23 builder.addFunction("load16", kSig_i_i)
24 .addBody([kExprGetLocal, 0, kExprI32LoadMem16U, 0, 0]) 24 .addBody([kExprGetLocal, 0, kExprI32LoadMem16U, 0, 0])
25 .exportFunc(); 25 .exportFunc();
26 builder.addFunction("store16", kSig_i_ii) 26 builder.addFunction("store16", kSig_i_ii)
27 .addBody([kExprGetLocal, 0, kExprGetLocal, 1, kExprI32StoreMem16, 0, 0]) 27 .addBody([kExprGetLocal, 0, kExprGetLocal, 1, kExprI32StoreMem16, 0, 0, kE xprGetLocal, 1])
28 .exportFunc(); 28 .exportFunc();
29 builder.addFunction("load8", kSig_i_i) 29 builder.addFunction("load8", kSig_i_i)
30 .addBody([kExprGetLocal, 0, kExprI32LoadMem8U, 0, 0]) 30 .addBody([kExprGetLocal, 0, kExprI32LoadMem8U, 0, 0])
31 .exportFunc(); 31 .exportFunc();
32 builder.addFunction("store8", kSig_i_ii) 32 builder.addFunction("store8", kSig_i_ii)
33 .addBody([kExprGetLocal, 0, kExprGetLocal, 1, kExprI32StoreMem8, 0, 0]) 33 .addBody([kExprGetLocal, 0, kExprGetLocal, 1, kExprI32StoreMem8, 0, 0, kEx prGetLocal, 1])
34 .exportFunc(); 34 .exportFunc();
35 return builder; 35 return builder;
36 } 36 }
37 37
38 function testGrowMemoryReadWrite32() { 38 function testGrowMemoryReadWrite32() {
39 var builder = genGrowMemoryBuilder(); 39 var builder = genGrowMemoryBuilder();
40 builder.addMemory(1, 1, false); 40 builder.addMemory(1, 1, false);
41 var module = builder.instantiate(); 41 var module = builder.instantiate();
42 var offset; 42 var offset;
43 function peek() { return module.exports.load(offset); } 43 function peek() { return module.exports.load(offset); }
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 316
317 val = 0; 317 val = 0;
318 318
319 for(offset = 0; offset <= (kPageSize - 1); offset++, val++) { 319 for(offset = 0; offset <= (kPageSize - 1); offset++, val++) {
320 assertEquals(val, peek()); 320 assertEquals(val, peek());
321 if (val == 255) val = 0; 321 if (val == 255) val = 0;
322 } 322 }
323 } 323 }
324 324
325 testGrowMemoryPreservesDataMemOp8(); 325 testGrowMemoryPreservesDataMemOp8();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698