OLD | NEW |
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 | 8 |
9 function runSelect2(module, which, a, b) { | 9 function runSelect2(module, which, a, b) { |
10 assertEquals(which == 0 ? a : b, module.select(a, b)); | 10 assertEquals(which == 0 ? a : b, module.select(a, b)); |
11 } | 11 } |
12 | 12 |
13 function testSelect2(type) { | 13 function testSelect2(type) { |
14 var kBodySize = 2; | 14 var kBodySize = 2; |
15 var kNameOffset = kHeaderSize + 21 + kBodySize + 1; | 15 var kNameOffset = kHeaderSize + 21 + kBodySize + 1; |
16 | 16 |
17 for (var which = 0; which < 2; which++) { | 17 for (var which = 0; which < 2; which++) { |
18 print("type = " + type + ", which = " + which); | 18 print("type = " + type + ", which = " + which); |
19 | 19 |
20 var data = bytesWithHeader( | 20 var data = bytesWithHeader( |
21 // -- memory | 21 // -- memory |
22 kDeclMemory, | 22 kDeclMemory, |
23 12, 12, 1, // memory | 23 1, 1, 1, // memory |
24 // -- signatures | 24 // -- signatures |
25 kDeclSignatures, 1, | 25 kDeclSignatures, 1, |
26 2, type, type, type, // signature: (t,t)->t | 26 2, type, type, type, // signature: (t,t)->t |
27 // -- select | 27 // -- select |
28 kDeclFunctions, 1, | 28 kDeclFunctions, 1, |
29 kDeclFunctionName | kDeclFunctionExport, | 29 kDeclFunctionName | kDeclFunctionExport, |
30 0, 0, | 30 0, 0, |
31 kNameOffset, 0, 0, 0, // name offset | 31 kNameOffset, 0, 0, 0, // name offset |
32 kBodySize, 0, // body size | 32 kBodySize, 0, // body size |
33 kExprGetLocal, which, // -- | 33 kExprGetLocal, which, // -- |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 function testSelect10(type) { | 89 function testSelect10(type) { |
90 var kBodySize = 2; | 90 var kBodySize = 2; |
91 var kNameOffset = kHeaderSize + 29 + kBodySize + 1; | 91 var kNameOffset = kHeaderSize + 29 + kBodySize + 1; |
92 | 92 |
93 for (var which = 0; which < 10; which++) { | 93 for (var which = 0; which < 10; which++) { |
94 print("type = " + type + ", which = " + which); | 94 print("type = " + type + ", which = " + which); |
95 | 95 |
96 var t = type; | 96 var t = type; |
97 var data = bytesWithHeader( | 97 var data = bytesWithHeader( |
98 kDeclMemory, | 98 kDeclMemory, |
99 12, 12, 1, // memory | 99 1, 1, 1, // memory |
100 // signatures | 100 // signatures |
101 kDeclSignatures, 1, | 101 kDeclSignatures, 1, |
102 10, t,t,t,t,t,t,t,t,t,t,t, // (tx10)->t | 102 10, t,t,t,t,t,t,t,t,t,t,t, // (tx10)->t |
103 // main function | 103 // main function |
104 kDeclFunctions, 1, | 104 kDeclFunctions, 1, |
105 kDeclFunctionName | kDeclFunctionExport, | 105 kDeclFunctionName | kDeclFunctionExport, |
106 0, 0, | 106 0, 0, |
107 kNameOffset, 0, 0, 0, // name offset | 107 kNameOffset, 0, 0, 0, // name offset |
108 kBodySize, 0, // body size | 108 kBodySize, 0, // body size |
109 kExprGetLocal, which, // -- | 109 kExprGetLocal, which, // -- |
(...skipping 20 matching lines...) Expand all Loading... |
130 runSelect10(module, which, -1.25, 5.25); | 130 runSelect10(module, which, -1.25, 5.25); |
131 runSelect10(module, which, Infinity, -Infinity); | 131 runSelect10(module, which, Infinity, -Infinity); |
132 } | 132 } |
133 } | 133 } |
134 } | 134 } |
135 | 135 |
136 | 136 |
137 testSelect10(kAstI32); | 137 testSelect10(kAstI32); |
138 testSelect10(kAstF32); | 138 testSelect10(kAstF32); |
139 testSelect10(kAstF64); | 139 testSelect10(kAstF64); |
OLD | NEW |