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

Side by Side Diff: test/mjsunit/wasm/parallel_compilation.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 --wasm-num-compilation-tasks=10 5 // Flags: --expose-wasm --wasm-num-compilation-tasks=10
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 assertModule(module, memsize) { 10 function assertModule(module, memsize) {
11 // Check the module exists. 11 // Check the module exists.
12 assertFalse(module === undefined); 12 assertFalse(module === undefined);
13 assertFalse(module === null); 13 assertFalse(module === null);
14 assertFalse(module === 0); 14 assertFalse(module === 0);
15 assertEquals("object", typeof module); 15 assertEquals("object", typeof module);
16 16
17 // Check the memory is an ArrayBuffer. 17 // Check the memory is an ArrayBuffer.
18 var mem = module.exports.memory; 18 var mem = module.exports.memory;
19 assertFalse(mem === undefined); 19 assertFalse(mem === undefined);
20 assertFalse(mem === null); 20 assertFalse(mem === null);
21 assertFalse(mem === 0); 21 assertFalse(mem === 0);
22 assertEquals("object", typeof mem); 22 assertEquals("object", typeof mem);
23 assertTrue(mem instanceof ArrayBuffer); 23 assertTrue(mem instanceof WebAssembly.Memory);
24 var buf = mem.buffer;
25 assertTrue(buf instanceof ArrayBuffer);
26 assertEquals(memsize, buf.byteLength);
24 for (var i = 0; i < 4; i++) { 27 for (var i = 0; i < 4; i++) {
25 module.exports.memory = 0; // should be ignored 28 module.exports.memory = 0; // should be ignored
26 assertEquals(mem, module.exports.memory); 29 mem.buffer = 0; // should be ignored
30 assertSame(mem, module.exports.memory);
31 assertSame(buf, mem.buffer);
27 } 32 }
28
29 assertEquals(memsize, module.exports.memory.byteLength);
30 } 33 }
31 34
32 function assertFunction(module, func) { 35 function assertFunction(module, func) {
33 assertEquals("object", typeof module.exports); 36 assertEquals("object", typeof module.exports);
34 37
35 var exp = module.exports[func]; 38 var exp = module.exports[func];
36 assertFalse(exp === undefined); 39 assertFalse(exp === undefined);
37 assertFalse(exp === null); 40 assertFalse(exp === null);
38 assertFalse(exp === 0); 41 assertFalse(exp === 0);
39 assertEquals("function", typeof exp); 42 assertEquals("function", typeof exp);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 kExprI32Add, // -- 80 kExprI32Add, // --
78 ]) 81 ])
79 .exportFunc() 82 .exportFunc()
80 83
81 builder.addMemory(1, 1, true); 84 builder.addMemory(1, 1, true);
82 for (i = 1; i < 256; i++) { 85 for (i = 1; i < 256; i++) {
83 f[i] = builder.addFunction("add" + i, kSig_i_ii) 86 f[i] = builder.addFunction("add" + i, kSig_i_ii)
84 .addBody([ // -- 87 .addBody([ // --
85 kExprGetLocal, 0, // -- 88 kExprGetLocal, 0, // --
86 kExprGetLocal, 1, // -- 89 kExprGetLocal, 1, // --
87 kExprCallFunction, kArity2, f[i >>> 1].index]) // -- 90 kExprCallFunction, f[i >>> 1].index]) // --
88 .exportFunc() 91 .exportFunc()
89 } 92 }
90 var module = builder.instantiate(); 93 var module = builder.instantiate();
91 assertModule(module, kPageSize); 94 assertModule(module, kPageSize);
92 95
93 // Check the properties of the functions. 96 // Check the properties of the functions.
94 for (i = 0; i < 256; i++) { 97 for (i = 0; i < 256; i++) {
95 var add = assertFunction(module, "add" + i); 98 var add = assertFunction(module, "add" + i);
96 assertEquals(88, add(33, 55)); 99 assertEquals(88, add(33, 55));
97 assertEquals(88888, add(33333, 55555)); 100 assertEquals(88888, add(33333, 55555));
98 assertEquals(8888888, add(3333333, 5555555)); 101 assertEquals(8888888, add(3333333, 5555555));
99 } 102 }
100 })(); 103 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698