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

Side by Side Diff: test/mjsunit/wasm/calls.js

Issue 1830663002: [wasm] Binary 11: AST changes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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 | « test/mjsunit/wasm/asm-wasm-switch.js ('k') | test/mjsunit/wasm/divrem-trap.js » ('j') | no next file with comments »
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 function assertModule(module, memsize) { 10 function assertModule(module, memsize) {
(...skipping 19 matching lines...) Expand all
30 } 30 }
31 31
32 function assertFunction(module, func) { 32 function assertFunction(module, func) {
33 assertEquals("object", typeof module.exports); 33 assertEquals("object", typeof module.exports);
34 34
35 var exp = module.exports[func]; 35 var exp = module.exports[func];
36 assertFalse(exp === undefined); 36 assertFalse(exp === undefined);
37 assertFalse(exp === null); 37 assertFalse(exp === null);
38 assertFalse(exp === 0); 38 assertFalse(exp === 0);
39 assertEquals("function", typeof exp); 39 assertEquals("function", typeof exp);
40
41 return exp; 40 return exp;
42 } 41 }
43 42
44 (function I64SubTest() { 43 (function I64SubTest() {
45 44
46 var builder = new WasmModuleBuilder(); 45 var builder = new WasmModuleBuilder();
47 46
48 builder.addMemory(1, 1, true); 47 builder.addMemory(1, 1, true);
49 builder.addFunction("sub", [kAstI64, kAstI64, kAstI64]) 48 builder.addFunction("sub", [kAstI64, kAstI64, kAstI64])
50 .addBody([ 49 .addBody([ // --
51 kExprI64Sub, // -- 50 kExprGetLocal, 0, // --
52 kExprGetLocal, 0, // -- 51 kExprGetLocal, 1, // --
53 kExprGetLocal, 1]) // -- 52 kExprI64Sub]) // --
54 .exportFunc() 53 .exportFunc()
55 54
56 var module = builder.instantiate(); 55 var module = builder.instantiate();
57 assertModule(module, kPageSize); 56 assertModule(module, kPageSize);
58 57
59 // Check the properties of the sub function. 58 // Check the properties of the sub function.
60 var sub = assertFunction(module, "sub"); 59 var sub = assertFunction(module, "sub");
61 assertEquals(-55, sub(33, 88)); 60 assertEquals(-55, sub(33, 88));
62 assertEquals(-55555, sub(33333, 88888)); 61 assertEquals(-55555, sub(33333, 88888));
63 assertEquals(-5555555, sub(3333333, 8888888)); 62 assertEquals(-5555555, sub(3333333, 8888888));
64 })(); 63 })();
65 64
66 (function SubTest() { 65 (function SubTest() {
67 66
68 var builder = new WasmModuleBuilder(); 67 var builder = new WasmModuleBuilder();
69 68
70 builder.addMemory(1, 1, true); 69 builder.addMemory(1, 1, true);
71 builder.addFunction("sub", [kAstI32, kAstI32, kAstI32]) 70 builder.addFunction("sub", [kAstI32, kAstI32, kAstI32])
72 .addBody([ 71 .addBody([
72 kExprGetLocal, 0, // --
73 kExprGetLocal, 1, // --
73 kExprI32Sub, // -- 74 kExprI32Sub, // --
74 kExprGetLocal, 0, // -- 75 ])
75 kExprGetLocal, 1]) // --
76 .exportFunc() 76 .exportFunc()
77 77
78 var module = builder.instantiate(); 78 var module = builder.instantiate();
79 assertModule(module, kPageSize); 79 assertModule(module, kPageSize);
80 80
81 // Check the properties of the sub function. 81 // Check the properties of the sub function.
82 var sub = assertFunction(module, "sub"); 82 var sub = assertFunction(module, "sub");
83 assertEquals(-55, sub(33, 88)); 83 assertEquals(-55, sub(33, 88));
84 assertEquals(-55555, sub(33333, 88888)); 84 assertEquals(-55555, sub(33333, 88888));
85 assertEquals(-5555555, sub(3333333, 8888888)); 85 assertEquals(-5555555, sub(3333333, 8888888));
(...skipping 18 matching lines...) Expand all
104 })(); 104 })();
105 105
106 106
107 (function testLt() { 107 (function testLt() {
108 var builder = new WasmModuleBuilder(); 108 var builder = new WasmModuleBuilder();
109 109
110 var kPages = 3; 110 var kPages = 3;
111 builder.addMemory(kPages, kPages, true); 111 builder.addMemory(kPages, kPages, true);
112 builder.addFunction("flt", [kAstI32, kAstF64, kAstF64]) 112 builder.addFunction("flt", [kAstI32, kAstF64, kAstF64])
113 .addBody([ 113 .addBody([
114 kExprF64Lt, // --
115 kExprGetLocal, 0, // -- 114 kExprGetLocal, 0, // --
116 kExprGetLocal, 1]) // -- 115 kExprGetLocal, 1, // --
116 kExprF64Lt // --
117 ]) // --
117 .exportFunc(); 118 .exportFunc();
118 119
119 var module = builder.instantiate(); 120 var module = builder.instantiate();
120 assertModule(module, kPageSize * kPages); 121 assertModule(module, kPageSize * kPages);
121 122
122 var flt = assertFunction(module, "flt"); 123 var flt = assertFunction(module, "flt");
123 assertEquals(1, flt(-2, -1)); 124 assertEquals(1, flt(-2, -1));
124 assertEquals(0, flt(7.3, 7.1)); 125 assertEquals(0, flt(7.3, 7.1));
125 assertEquals(1, flt(7.1, 7.3)); 126 assertEquals(1, flt(7.1, 7.3));
126 })(); 127 })();
OLDNEW
« no previous file with comments | « test/mjsunit/wasm/asm-wasm-switch.js ('k') | test/mjsunit/wasm/divrem-trap.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698