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

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, 9 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 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 SubTest() { 43 (function SubTest() {
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", [kAstI32, kAstI32, kAstI32]) 48 builder.addFunction("sub", [kAstI32, kAstI32, kAstI32])
50 .addBody([ 49 .addBody([
50 kExprGetLocal, 0, // --
51 kExprGetLocal, 1, // --
51 kExprI32Sub, // -- 52 kExprI32Sub, // --
52 kExprGetLocal, 0, // -- 53 ])
53 kExprGetLocal, 1]) // --
54 .exportFunc() 54 .exportFunc()
55 55
56 var module = builder.instantiate(); 56 var module = builder.instantiate();
57 assertModule(module, kPageSize); 57 assertModule(module, kPageSize);
58 58
59 // Check the properties of the sub function. 59 // Check the properties of the sub function.
60 var sub = assertFunction(module, "sub"); 60 var sub = assertFunction(module, "sub");
61 assertEquals(-55, sub(33, 88)); 61 assertEquals(-55, sub(33, 88));
62 assertEquals(-55555, sub(33333, 88888)); 62 assertEquals(-55555, sub(33333, 88888));
63 assertEquals(-5555555, sub(3333333, 8888888)); 63 assertEquals(-5555555, sub(3333333, 8888888));
(...skipping 18 matching lines...) Expand all
82 })(); 82 })();
83 83
84 84
85 (function testLt() { 85 (function testLt() {
86 var builder = new WasmModuleBuilder(); 86 var builder = new WasmModuleBuilder();
87 87
88 var kPages = 3; 88 var kPages = 3;
89 builder.addMemory(kPages, kPages, true); 89 builder.addMemory(kPages, kPages, true);
90 builder.addFunction("flt", [kAstI32, kAstF64, kAstF64]) 90 builder.addFunction("flt", [kAstI32, kAstF64, kAstF64])
91 .addBody([ 91 .addBody([
92 kExprF64Lt, // --
93 kExprGetLocal, 0, // -- 92 kExprGetLocal, 0, // --
94 kExprGetLocal, 1]) // -- 93 kExprGetLocal, 1, // --
94 kExprF64Lt // --
95 ]) // --
95 .exportFunc(); 96 .exportFunc();
96 97
97 var module = builder.instantiate(); 98 var module = builder.instantiate();
98 assertModule(module, kPageSize * kPages); 99 assertModule(module, kPageSize * kPages);
99 100
100 var flt = assertFunction(module, "flt"); 101 var flt = assertFunction(module, "flt");
101 assertEquals(1, flt(-2, -1)); 102 assertEquals(1, flt(-2, -1));
102 assertEquals(0, flt(7.3, 7.1)); 103 assertEquals(0, flt(7.3, 7.1));
103 assertEquals(1, flt(7.1, 7.3)); 104 assertEquals(1, flt(7.1, 7.3));
104 })(); 105 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698