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

Side by Side Diff: test/mjsunit/wasm/adapter-frame.js

Issue 2081973003: Refactor module builder (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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 | « no previous file | test/mjsunit/wasm/ffi.js » ('j') | test/mjsunit/wasm/wasm-module-builder.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 const JS = false; // for testing the tests. 10 const JS = false; // for testing the tests.
11 const WRONG1 = 0x0DEDFACE; 11 const WRONG1 = 0x0DEDFACE;
12 const WRONG2 = 0x0DEDBABE; 12 const WRONG2 = 0x0DEDBABE;
13 const WRONG3 = 0x0DEDD011 13 const WRONG3 = 0x0DEDD011
14 14
15 function makeSelect(type, args, which) { 15 function makeSelect(type, args, which) {
16 if (JS) { 16 if (JS) {
17 // For testing the tests. 17 // For testing the tests.
18 return function() { 18 return function() {
19 var val = +arguments[which]; 19 var val = +arguments[which];
20 print(" " + val); 20 print(" " + val);
21 if (type == kAstI32) return val | 0; 21 if (type == kAstI32) return val | 0;
22 if (type == kAstF32) return Math.fround(val); 22 if (type == kAstF32) return Math.fround(val);
23 if (type == kAstF64) return val; 23 if (type == kAstF64) return val;
24 return undefined; 24 return undefined;
25 } 25 }
26 } 26 }
27 27
28 var builder = new WasmModuleBuilder(); 28 var builder = new WasmModuleBuilder();
29 var sig = new Array(); 29 var params = [];
30 sig.push(args); 30 for (var i = 0; i < args; i++) params.push(type);
31 for (var i = 0; i < args; i++) sig.push(type); 31 builder.addFunction("select", makeSig(params, [type]))
32 sig.push(1);
33 sig.push(type);
34 builder.addFunction("select", sig)
35 .addBody([kExprGetLocal, which]) 32 .addBody([kExprGetLocal, which])
36 .exportFunc(); 33 .exportFunc();
37 34
38 return builder.instantiate().exports.select; 35 return builder.instantiate().exports.select;
39 } 36 }
40 37
41 const inputs = [ 38 const inputs = [
42 -1, 0, 2.2, 3.3, 3000.11, Infinity, -Infinity, NaN 39 -1, 0, 2.2, 3.3, 3000.11, Infinity, -Infinity, NaN
43 ]; 40 ];
44 41
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 assertEquals(C(val), select(WRONG1, WRONG2, val)); 311 assertEquals(C(val), select(WRONG1, WRONG2, val));
315 312
316 // under args 313 // under args
317 assertEquals(C(undefined), select()); 314 assertEquals(C(undefined), select());
318 assertEquals(C(undefined), select(0xDEDFACE)); 315 assertEquals(C(undefined), select(0xDEDFACE));
319 assertEquals(C(undefined), select(WRONG1, WRONG2)); 316 assertEquals(C(undefined), select(WRONG1, WRONG2));
320 // over args 317 // over args
321 assertEquals(C(val), select(WRONG1, WRONG2, val, WRONG3)); 318 assertEquals(C(val), select(WRONG1, WRONG2, val, WRONG3));
322 } 319 }
323 })(); 320 })();
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/wasm/ffi.js » ('j') | test/mjsunit/wasm/wasm-module-builder.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698