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 // TODO(jochen): Remove this after the setting is turned on globally. | 5 // TODO(jochen): Remove this after the setting is turned on globally. |
6 #define V8_IMMINENT_DEPRECATION_WARNINGS | 6 #define V8_IMMINENT_DEPRECATION_WARNINGS |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/ast.h" | 10 #include "src/ast.h" |
11 #include "src/ast-expression-visitor.h" | 11 #include "src/ast-expression-visitor.h" |
12 #include "src/parser.h" | 12 #include "src/parser.h" |
13 #include "src/rewriter.h" | 13 #include "src/rewriter.h" |
14 #include "src/scopes.h" | 14 #include "src/scopes.h" |
15 #include "src/type-cache.h" | 15 #include "src/type-cache.h" |
16 #include "src/typing-asm.h" | 16 #include "src/typing-asm.h" |
17 #include "test/cctest/cctest.h" | 17 #include "test/cctest/cctest.h" |
18 #include "test/cctest/expression-type-collector.h" | 18 #include "test/cctest/expression-type-collector.h" |
19 #include "test/cctest/expression-type-collector-macros.h" | 19 #include "test/cctest/expression-type-collector-macros.h" |
20 | 20 |
21 // Macros for function types. | 21 // Macros for function types. |
22 #define FUNC_V_TYPE Bounds(Type::Function(Type::Undefined(), zone)) | 22 #define FUNC_V_TYPE Bounds(Type::Function(Type::Undefined(), zone)) |
23 #define FUNC_I_TYPE Bounds(Type::Function(cache.kInt32, zone)) | 23 #define FUNC_I_TYPE Bounds(Type::Function(cache.kAsmSigned, zone)) |
24 #define FUNC_F_TYPE Bounds(Type::Function(cache.kFloat32, zone)) | 24 #define FUNC_F_TYPE Bounds(Type::Function(cache.kAsmFloat, zone)) |
25 #define FUNC_D_TYPE Bounds(Type::Function(cache.kFloat64, zone)) | 25 #define FUNC_D_TYPE Bounds(Type::Function(cache.kAsmDouble, zone)) |
26 #define FUNC_D2D_TYPE \ | 26 #define FUNC_D2D_TYPE \ |
27 Bounds(Type::Function(cache.kFloat64, cache.kFloat64, zone)) | 27 Bounds(Type::Function(cache.kAsmDouble, cache.kAsmDouble, zone)) |
28 #define FUNC_N2F_TYPE \ | 28 #define FUNC_N2F_TYPE \ |
29 Bounds(Type::Function(cache.kFloat32, Type::Number(), zone)) | 29 Bounds(Type::Function(cache.kAsmFloat, Type::Number(), zone)) |
30 #define FUNC_I2I_TYPE Bounds(Type::Function(cache.kInt32, cache.kInt32, zone)) | 30 #define FUNC_I2I_TYPE \ |
| 31 Bounds(Type::Function(cache.kAsmSigned, cache.kAsmInt, zone)) |
31 #define FUNC_II2D_TYPE \ | 32 #define FUNC_II2D_TYPE \ |
32 Bounds(Type::Function(cache.kFloat64, cache.kInt32, cache.kInt32, zone)) | 33 Bounds(Type::Function(cache.kAsmDouble, cache.kAsmInt, cache.kAsmInt, zone)) |
33 #define FUNC_II2I_TYPE \ | 34 #define FUNC_II2I_TYPE \ |
34 Bounds(Type::Function(cache.kInt32, cache.kInt32, cache.kInt32, zone)) | 35 Bounds(Type::Function(cache.kAsmSigned, cache.kAsmInt, cache.kAsmInt, zone)) |
35 #define FUNC_DD2D_TYPE \ | 36 #define FUNC_DD2D_TYPE \ |
36 Bounds(Type::Function(cache.kFloat64, cache.kFloat64, cache.kFloat64, zone)) | 37 Bounds(Type::Function(cache.kAsmDouble, cache.kAsmDouble, cache.kAsmDouble, \ |
| 38 zone)) |
37 #define FUNC_N2N_TYPE \ | 39 #define FUNC_N2N_TYPE \ |
38 Bounds(Type::Function(Type::Number(), Type::Number(), zone)) | 40 Bounds(Type::Function(Type::Number(), Type::Number(), zone)) |
39 | 41 |
40 // Macros for array types. | 42 // Macros for array types. |
41 #define FLOAT64_ARRAY_TYPE Bounds(Type::Array(cache.kFloat64, zone)) | 43 #define FLOAT64_ARRAY_TYPE Bounds(Type::Array(cache.kAsmDouble, zone)) |
42 #define FUNC_I2I_ARRAY_TYPE \ | 44 #define FUNC_I2I_ARRAY_TYPE \ |
43 Bounds(Type::Array(Type::Function(cache.kInt32, cache.kInt32, zone), zone)) | 45 Bounds(Type::Array(Type::Function(cache.kAsmSigned, cache.kAsmInt, zone), \ |
| 46 zone)) |
44 | 47 |
45 using namespace v8::internal; | 48 using namespace v8::internal; |
46 | 49 |
47 namespace { | 50 namespace { |
48 | 51 |
49 std::string Validate(Zone* zone, const char* source, | 52 std::string Validate(Zone* zone, const char* source, |
50 ZoneVector<ExpressionTypeEntry>* types) { | 53 ZoneVector<ExpressionTypeEntry>* types) { |
51 i::Isolate* isolate = CcTest::i_isolate(); | 54 i::Isolate* isolate = CcTest::i_isolate(); |
52 i::Factory* factory = isolate->factory(); | 55 i::Factory* factory = isolate->factory(); |
53 | 56 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 Zone* zone = handles.main_zone(); | 122 Zone* zone = handles.main_zone(); |
120 ZoneVector<ExpressionTypeEntry> types(zone); | 123 ZoneVector<ExpressionTypeEntry> types(zone); |
121 CHECK_EQ("", Validate(zone, test_function, &types)); | 124 CHECK_EQ("", Validate(zone, test_function, &types)); |
122 TypeCache cache; | 125 TypeCache cache; |
123 | 126 |
124 CHECK_TYPES_BEGIN { | 127 CHECK_TYPES_BEGIN { |
125 // Module. | 128 // Module. |
126 CHECK_EXPR(FunctionLiteral, Bounds::Unbounded()) { | 129 CHECK_EXPR(FunctionLiteral, Bounds::Unbounded()) { |
127 // function logSum | 130 // function logSum |
128 CHECK_EXPR(FunctionLiteral, FUNC_II2D_TYPE) { | 131 CHECK_EXPR(FunctionLiteral, FUNC_II2D_TYPE) { |
129 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { | 132 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
130 CHECK_VAR(start, Bounds(cache.kInt32)); | 133 CHECK_VAR(start, Bounds(cache.kAsmInt)); |
131 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 134 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
132 CHECK_VAR(start, Bounds(cache.kInt32)); | 135 CHECK_VAR(start, Bounds(cache.kAsmInt)); |
133 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 136 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
134 } | 137 } |
135 } | 138 } |
136 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { | 139 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
137 CHECK_VAR(end, Bounds(cache.kInt32)); | 140 CHECK_VAR(end, Bounds(cache.kAsmInt)); |
138 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 141 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
139 CHECK_VAR(end, Bounds(cache.kInt32)); | 142 CHECK_VAR(end, Bounds(cache.kAsmInt)); |
140 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 143 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
141 } | 144 } |
142 } | 145 } |
143 CHECK_EXPR(Assignment, Bounds(cache.kFloat64)) { | 146 CHECK_EXPR(Assignment, Bounds(cache.kAsmDouble)) { |
144 CHECK_VAR(sum, Bounds(cache.kFloat64)); | 147 CHECK_VAR(sum, Bounds(cache.kAsmDouble)); |
145 CHECK_EXPR(Literal, Bounds(cache.kFloat64)); | 148 CHECK_EXPR(Literal, Bounds(cache.kAsmDouble)); |
146 } | 149 } |
147 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { | 150 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
148 CHECK_VAR(p, Bounds(cache.kInt32)); | 151 CHECK_VAR(p, Bounds(cache.kAsmInt)); |
149 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 152 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
150 } | 153 } |
151 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { | 154 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
152 CHECK_VAR(q, Bounds(cache.kInt32)); | 155 CHECK_VAR(q, Bounds(cache.kAsmInt)); |
153 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 156 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
154 } | 157 } |
155 // for (p = start << 3, q = end << 3; | 158 // for (p = start << 3, q = end << 3; |
156 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 159 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmInt)) { |
157 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { | 160 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
158 CHECK_VAR(p, Bounds(cache.kInt32)); | 161 CHECK_VAR(p, Bounds(cache.kAsmInt)); |
159 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 162 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
160 CHECK_VAR(start, Bounds(cache.kInt32)); | 163 CHECK_VAR(start, Bounds(cache.kAsmInt)); |
161 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 164 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
162 } | 165 } |
163 } | 166 } |
164 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { | 167 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
165 CHECK_VAR(q, Bounds(cache.kInt32)); | 168 CHECK_VAR(q, Bounds(cache.kAsmInt)); |
166 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 169 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
167 CHECK_VAR(end, Bounds(cache.kInt32)); | 170 CHECK_VAR(end, Bounds(cache.kAsmInt)); |
168 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 171 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
169 } | 172 } |
170 } | 173 } |
171 } | 174 } |
172 // (p|0) < (q|0); | 175 // (p|0) < (q|0); |
173 CHECK_EXPR(CompareOperation, Bounds(cache.kInt32)) { | 176 CHECK_EXPR(CompareOperation, Bounds(cache.kAsmSigned)) { |
174 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 177 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
175 CHECK_VAR(p, Bounds(cache.kInt32)); | 178 CHECK_VAR(p, Bounds(cache.kAsmInt)); |
176 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 179 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
177 } | 180 } |
178 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 181 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
179 CHECK_VAR(q, Bounds(cache.kInt32)); | 182 CHECK_VAR(q, Bounds(cache.kAsmInt)); |
180 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 183 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
181 } | 184 } |
182 } | 185 } |
183 // p = (p + 8)|0) {\n" | 186 // p = (p + 8)|0) {\n" |
184 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { | 187 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
185 CHECK_VAR(p, Bounds(cache.kInt32)); | 188 CHECK_VAR(p, Bounds(cache.kAsmInt)); |
186 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 189 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
187 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 190 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmInt)) { |
188 CHECK_VAR(p, Bounds(cache.kInt32)); | 191 CHECK_VAR(p, Bounds(cache.kAsmInt)); |
189 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 192 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
190 } | 193 } |
191 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 194 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
192 } | 195 } |
193 } | 196 } |
194 // sum = sum + +log(values[p>>3]); | 197 // sum = sum + +log(values[p>>3]); |
195 CHECK_EXPR(Assignment, Bounds(cache.kFloat64)) { | 198 CHECK_EXPR(Assignment, Bounds(cache.kAsmDouble)) { |
196 CHECK_VAR(sum, Bounds(cache.kFloat64)); | 199 CHECK_VAR(sum, Bounds(cache.kAsmDouble)); |
197 CHECK_EXPR(BinaryOperation, Bounds(cache.kFloat64)) { | 200 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmDouble)) { |
198 CHECK_VAR(sum, Bounds(cache.kFloat64)); | 201 CHECK_VAR(sum, Bounds(cache.kAsmDouble)); |
199 CHECK_EXPR(BinaryOperation, Bounds(cache.kFloat64)) { | 202 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmDouble)) { |
200 CHECK_EXPR(Call, Bounds(cache.kFloat64)) { | 203 CHECK_EXPR(Call, Bounds(cache.kAsmDouble)) { |
201 CHECK_VAR(log, FUNC_D2D_TYPE); | 204 CHECK_VAR(log, FUNC_D2D_TYPE); |
202 CHECK_EXPR(Property, Bounds(cache.kFloat64)) { | 205 CHECK_EXPR(Property, Bounds(cache.kAsmDouble)) { |
203 CHECK_VAR(values, FLOAT64_ARRAY_TYPE); | 206 CHECK_VAR(values, FLOAT64_ARRAY_TYPE); |
204 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 207 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
205 CHECK_VAR(p, Bounds(cache.kInt32)); | 208 CHECK_VAR(p, Bounds(cache.kAsmSigned)); |
206 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 209 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
207 } | 210 } |
208 } | 211 } |
209 } | 212 } |
210 CHECK_EXPR(Literal, Bounds(cache.kFloat64)); | 213 CHECK_EXPR(Literal, Bounds(cache.kAsmDouble)); |
211 } | 214 } |
212 } | 215 } |
213 } | 216 } |
214 // return +sum; | 217 // return +sum; |
215 CHECK_EXPR(BinaryOperation, Bounds(cache.kFloat64)) { | 218 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmDouble)) { |
216 CHECK_VAR(sum, Bounds(cache.kFloat64)); | 219 CHECK_VAR(sum, Bounds(cache.kAsmDouble)); |
217 CHECK_EXPR(Literal, Bounds(cache.kFloat64)); | 220 CHECK_EXPR(Literal, Bounds(cache.kAsmDouble)); |
218 } | 221 } |
219 } | 222 } |
220 // function geometricMean | 223 // function geometricMean |
221 CHECK_EXPR(FunctionLiteral, FUNC_II2D_TYPE) { | 224 CHECK_EXPR(FunctionLiteral, FUNC_II2D_TYPE) { |
222 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { | 225 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
223 CHECK_VAR(start, Bounds(cache.kInt32)); | 226 CHECK_VAR(start, Bounds(cache.kAsmInt)); |
224 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 227 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
225 CHECK_VAR(start, Bounds(cache.kInt32)); | 228 CHECK_VAR(start, Bounds(cache.kAsmInt)); |
226 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 229 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
227 } | 230 } |
228 } | 231 } |
229 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { | 232 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
230 CHECK_VAR(end, Bounds(cache.kInt32)); | 233 CHECK_VAR(end, Bounds(cache.kAsmInt)); |
231 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 234 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
232 CHECK_VAR(end, Bounds(cache.kInt32)); | 235 CHECK_VAR(end, Bounds(cache.kAsmInt)); |
233 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 236 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
234 } | 237 } |
235 } | 238 } |
236 // return +exp(+logSum(start, end) / +((end - start)|0)); | 239 // return +exp(+logSum(start, end) / +((end - start)|0)); |
237 CHECK_EXPR(BinaryOperation, Bounds(cache.kFloat64)) { | 240 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmDouble)) { |
238 CHECK_EXPR(Call, Bounds(cache.kFloat64)) { | 241 CHECK_EXPR(Call, Bounds(cache.kAsmDouble)) { |
239 CHECK_VAR(exp, FUNC_D2D_TYPE); | 242 CHECK_VAR(exp, FUNC_D2D_TYPE); |
240 CHECK_EXPR(BinaryOperation, Bounds(cache.kFloat64)) { | 243 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmDouble)) { |
241 CHECK_EXPR(BinaryOperation, Bounds(cache.kFloat64)) { | 244 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmDouble)) { |
242 CHECK_EXPR(Call, Bounds(cache.kFloat64)) { | 245 CHECK_EXPR(Call, Bounds(cache.kAsmDouble)) { |
243 CHECK_VAR(logSum, FUNC_II2D_TYPE); | 246 CHECK_VAR(logSum, FUNC_II2D_TYPE); |
244 CHECK_VAR(start, Bounds(cache.kInt32)); | 247 CHECK_VAR(start, Bounds(cache.kAsmInt)); |
245 CHECK_VAR(end, Bounds(cache.kInt32)); | 248 CHECK_VAR(end, Bounds(cache.kAsmInt)); |
246 } | 249 } |
247 CHECK_EXPR(Literal, Bounds(cache.kFloat64)); | 250 CHECK_EXPR(Literal, Bounds(cache.kAsmDouble)); |
248 } | 251 } |
249 CHECK_EXPR(BinaryOperation, Bounds(cache.kFloat64)) { | 252 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmDouble)) { |
250 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 253 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
251 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 254 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmInt)) { |
252 CHECK_VAR(end, Bounds(cache.kInt32)); | 255 CHECK_VAR(end, Bounds(cache.kAsmInt)); |
253 CHECK_VAR(start, Bounds(cache.kInt32)); | 256 CHECK_VAR(start, Bounds(cache.kAsmInt)); |
254 } | 257 } |
255 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 258 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
256 } | 259 } |
257 CHECK_EXPR(Literal, Bounds(cache.kFloat64)); | 260 CHECK_EXPR(Literal, Bounds(cache.kAsmDouble)); |
258 } | 261 } |
259 } | 262 } |
260 } | 263 } |
261 CHECK_EXPR(Literal, Bounds(cache.kFloat64)); | 264 CHECK_EXPR(Literal, Bounds(cache.kAsmDouble)); |
262 } | 265 } |
263 } | 266 } |
264 // "use asm"; | 267 // "use asm"; |
265 CHECK_EXPR(Literal, Bounds(Type::String())); | 268 CHECK_EXPR(Literal, Bounds(Type::String())); |
266 // var exp = stdlib.Math.exp; | 269 // var exp = stdlib.Math.exp; |
267 CHECK_EXPR(Assignment, FUNC_D2D_TYPE) { | 270 CHECK_EXPR(Assignment, FUNC_D2D_TYPE) { |
268 CHECK_VAR(exp, FUNC_D2D_TYPE); | 271 CHECK_VAR(exp, FUNC_D2D_TYPE); |
269 CHECK_EXPR(Property, FUNC_D2D_TYPE) { | 272 CHECK_EXPR(Property, FUNC_D2D_TYPE) { |
270 CHECK_EXPR(Property, Bounds::Unbounded()) { | 273 CHECK_EXPR(Property, Bounds::Unbounded()) { |
271 CHECK_VAR(stdlib, Bounds::Unbounded()); | 274 CHECK_VAR(stdlib, Bounds::Unbounded()); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 CHECK_VAR(buffer, Bounds::Unbounded()); \ | 396 CHECK_VAR(buffer, Bounds::Unbounded()); \ |
394 } \ | 397 } \ |
395 } | 398 } |
396 | 399 |
397 | 400 |
398 namespace { | 401 namespace { |
399 | 402 |
400 void CheckStdlibShortcuts(Zone* zone, ZoneVector<ExpressionTypeEntry>& types, | 403 void CheckStdlibShortcuts(Zone* zone, ZoneVector<ExpressionTypeEntry>& types, |
401 size_t& index, int& depth, TypeCache& cache) { | 404 size_t& index, int& depth, TypeCache& cache) { |
402 // var exp = stdlib.*; (D * 12) | 405 // var exp = stdlib.*; (D * 12) |
403 CHECK_VAR_SHORTCUT(Infinity, Bounds(cache.kFloat64)); | 406 CHECK_VAR_SHORTCUT(Infinity, Bounds(cache.kAsmDouble)); |
404 CHECK_VAR_SHORTCUT(NaN, Bounds(cache.kFloat64)); | 407 CHECK_VAR_SHORTCUT(NaN, Bounds(cache.kAsmDouble)); |
405 // var x = stdlib.Math.x; D2D | 408 // var x = stdlib.Math.x; D2D |
406 CHECK_VAR_MATH_SHORTCUT(acos, FUNC_D2D_TYPE); | 409 CHECK_VAR_MATH_SHORTCUT(acos, FUNC_D2D_TYPE); |
407 CHECK_VAR_MATH_SHORTCUT(asin, FUNC_D2D_TYPE); | 410 CHECK_VAR_MATH_SHORTCUT(asin, FUNC_D2D_TYPE); |
408 CHECK_VAR_MATH_SHORTCUT(atan, FUNC_D2D_TYPE); | 411 CHECK_VAR_MATH_SHORTCUT(atan, FUNC_D2D_TYPE); |
409 CHECK_VAR_MATH_SHORTCUT(cos, FUNC_D2D_TYPE); | 412 CHECK_VAR_MATH_SHORTCUT(cos, FUNC_D2D_TYPE); |
410 CHECK_VAR_MATH_SHORTCUT(sin, FUNC_D2D_TYPE); | 413 CHECK_VAR_MATH_SHORTCUT(sin, FUNC_D2D_TYPE); |
411 CHECK_VAR_MATH_SHORTCUT(tan, FUNC_D2D_TYPE); | 414 CHECK_VAR_MATH_SHORTCUT(tan, FUNC_D2D_TYPE); |
412 CHECK_VAR_MATH_SHORTCUT(exp, FUNC_D2D_TYPE); | 415 CHECK_VAR_MATH_SHORTCUT(exp, FUNC_D2D_TYPE); |
413 CHECK_VAR_MATH_SHORTCUT(log, FUNC_D2D_TYPE); | 416 CHECK_VAR_MATH_SHORTCUT(log, FUNC_D2D_TYPE); |
414 CHECK_VAR_MATH_SHORTCUT(ceil, FUNC_D2D_TYPE); | 417 CHECK_VAR_MATH_SHORTCUT(ceil, FUNC_D2D_TYPE); |
415 CHECK_VAR_MATH_SHORTCUT(floor, FUNC_D2D_TYPE); | 418 CHECK_VAR_MATH_SHORTCUT(floor, FUNC_D2D_TYPE); |
416 CHECK_VAR_MATH_SHORTCUT(sqrt, FUNC_D2D_TYPE); | 419 CHECK_VAR_MATH_SHORTCUT(sqrt, FUNC_D2D_TYPE); |
417 // var exp = stdlib.Math.*; (DD2D * 12) | 420 // var exp = stdlib.Math.*; (DD2D * 12) |
418 CHECK_VAR_MATH_SHORTCUT(min, FUNC_DD2D_TYPE); | 421 CHECK_VAR_MATH_SHORTCUT(min, FUNC_DD2D_TYPE); |
419 CHECK_VAR_MATH_SHORTCUT(max, FUNC_DD2D_TYPE); | 422 CHECK_VAR_MATH_SHORTCUT(max, FUNC_DD2D_TYPE); |
420 CHECK_VAR_MATH_SHORTCUT(atan2, FUNC_DD2D_TYPE); | 423 CHECK_VAR_MATH_SHORTCUT(atan2, FUNC_DD2D_TYPE); |
421 CHECK_VAR_MATH_SHORTCUT(pow, FUNC_DD2D_TYPE); | 424 CHECK_VAR_MATH_SHORTCUT(pow, FUNC_DD2D_TYPE); |
422 // Special ones. | 425 // Special ones. |
423 CHECK_VAR_MATH_SHORTCUT(abs, FUNC_N2N_TYPE); | 426 CHECK_VAR_MATH_SHORTCUT(abs, FUNC_N2N_TYPE); |
424 CHECK_VAR_MATH_SHORTCUT(imul, FUNC_II2I_TYPE); | 427 CHECK_VAR_MATH_SHORTCUT(imul, FUNC_II2I_TYPE); |
425 CHECK_VAR_MATH_SHORTCUT(fround, FUNC_N2F_TYPE); | 428 CHECK_VAR_MATH_SHORTCUT(fround, FUNC_N2F_TYPE); |
426 // var exp = stdlib.Math.*; (D * 12) | 429 // var exp = stdlib.Math.*; (D * 12) |
427 CHECK_VAR_MATH_SHORTCUT(E, Bounds(cache.kFloat64)); | 430 CHECK_VAR_MATH_SHORTCUT(E, Bounds(cache.kAsmDouble)); |
428 CHECK_VAR_MATH_SHORTCUT(LN10, Bounds(cache.kFloat64)); | 431 CHECK_VAR_MATH_SHORTCUT(LN10, Bounds(cache.kAsmDouble)); |
429 CHECK_VAR_MATH_SHORTCUT(LN2, Bounds(cache.kFloat64)); | 432 CHECK_VAR_MATH_SHORTCUT(LN2, Bounds(cache.kAsmDouble)); |
430 CHECK_VAR_MATH_SHORTCUT(LOG2E, Bounds(cache.kFloat64)); | 433 CHECK_VAR_MATH_SHORTCUT(LOG2E, Bounds(cache.kAsmDouble)); |
431 CHECK_VAR_MATH_SHORTCUT(LOG10E, Bounds(cache.kFloat64)); | 434 CHECK_VAR_MATH_SHORTCUT(LOG10E, Bounds(cache.kAsmDouble)); |
432 CHECK_VAR_MATH_SHORTCUT(PI, Bounds(cache.kFloat64)); | 435 CHECK_VAR_MATH_SHORTCUT(PI, Bounds(cache.kAsmDouble)); |
433 CHECK_VAR_MATH_SHORTCUT(SQRT1_2, Bounds(cache.kFloat64)); | 436 CHECK_VAR_MATH_SHORTCUT(SQRT1_2, Bounds(cache.kAsmDouble)); |
434 CHECK_VAR_MATH_SHORTCUT(SQRT2, Bounds(cache.kFloat64)); | 437 CHECK_VAR_MATH_SHORTCUT(SQRT2, Bounds(cache.kAsmDouble)); |
435 // var values = new stdlib.*Array(buffer); | 438 // var values = new stdlib.*Array(buffer); |
436 CHECK_VAR_NEW_SHORTCUT(u8, Bounds(cache.kUint8Array)); | 439 CHECK_VAR_NEW_SHORTCUT(u8, Bounds(cache.kUint8Array)); |
437 CHECK_VAR_NEW_SHORTCUT(i8, Bounds(cache.kInt8Array)); | 440 CHECK_VAR_NEW_SHORTCUT(i8, Bounds(cache.kInt8Array)); |
438 CHECK_VAR_NEW_SHORTCUT(u16, Bounds(cache.kUint16Array)); | 441 CHECK_VAR_NEW_SHORTCUT(u16, Bounds(cache.kUint16Array)); |
439 CHECK_VAR_NEW_SHORTCUT(i16, Bounds(cache.kInt16Array)); | 442 CHECK_VAR_NEW_SHORTCUT(i16, Bounds(cache.kInt16Array)); |
440 CHECK_VAR_NEW_SHORTCUT(u32, Bounds(cache.kUint32Array)); | 443 CHECK_VAR_NEW_SHORTCUT(u32, Bounds(cache.kUint32Array)); |
441 CHECK_VAR_NEW_SHORTCUT(i32, Bounds(cache.kInt32Array)); | 444 CHECK_VAR_NEW_SHORTCUT(i32, Bounds(cache.kInt32Array)); |
442 CHECK_VAR_NEW_SHORTCUT(f32, Bounds(cache.kFloat32Array)); | 445 CHECK_VAR_NEW_SHORTCUT(f32, Bounds(cache.kFloat32Array)); |
443 CHECK_VAR_NEW_SHORTCUT(f64, Bounds(cache.kFloat64Array)); | 446 CHECK_VAR_NEW_SHORTCUT(f64, Bounds(cache.kFloat64Array)); |
444 } | 447 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 } | 535 } |
533 CHECK_FUNC_TYPES_END | 536 CHECK_FUNC_TYPES_END |
534 } | 537 } |
535 | 538 |
536 | 539 |
537 TEST(DoesNothing) { | 540 TEST(DoesNothing) { |
538 CHECK_FUNC_TYPES_BEGIN( | 541 CHECK_FUNC_TYPES_BEGIN( |
539 "function bar() { var x = 1.0; }\n" | 542 "function bar() { var x = 1.0; }\n" |
540 "function foo() { bar(); }") { | 543 "function foo() { bar(); }") { |
541 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { | 544 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { |
542 CHECK_EXPR(Assignment, Bounds(cache.kFloat64)) { | 545 CHECK_EXPR(Assignment, Bounds(cache.kAsmDouble)) { |
543 CHECK_VAR(x, Bounds(cache.kFloat64)); | 546 CHECK_VAR(x, Bounds(cache.kAsmDouble)); |
544 CHECK_EXPR(Literal, Bounds(cache.kFloat64)); | 547 CHECK_EXPR(Literal, Bounds(cache.kAsmDouble)); |
545 } | 548 } |
546 } | 549 } |
547 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { | 550 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { |
548 CHECK_EXPR(Call, Bounds(Type::Undefined())) { | 551 CHECK_EXPR(Call, Bounds(Type::Undefined())) { |
549 CHECK_VAR(bar, FUNC_V_TYPE); | 552 CHECK_VAR(bar, FUNC_V_TYPE); |
550 } | 553 } |
551 } | 554 } |
552 } | 555 } |
553 CHECK_FUNC_TYPES_END | 556 CHECK_FUNC_TYPES_END |
554 } | 557 } |
555 | 558 |
556 | 559 |
557 TEST(ReturnInt32Literal) { | 560 TEST(ReturnInt32Literal) { |
558 CHECK_FUNC_TYPES_BEGIN( | 561 CHECK_FUNC_TYPES_BEGIN( |
559 "function bar() { return 1; }\n" | 562 "function bar() { return 1; }\n" |
560 "function foo() { bar(); }") { | 563 "function foo() { bar(); }") { |
561 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { | 564 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { |
562 // return 1; | 565 // return 1; |
563 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 566 CHECK_EXPR(Literal, Bounds(cache.kAsmSigned)); |
564 } | 567 } |
565 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { | 568 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { |
566 CHECK_EXPR(Call, Bounds(cache.kInt32)) { CHECK_VAR(bar, FUNC_I_TYPE); } | 569 CHECK_EXPR(Call, Bounds(cache.kAsmSigned)) { |
| 570 CHECK_VAR(bar, FUNC_I_TYPE); |
| 571 } |
567 } | 572 } |
568 } | 573 } |
569 CHECK_FUNC_TYPES_END | 574 CHECK_FUNC_TYPES_END |
570 } | 575 } |
571 | 576 |
572 | 577 |
573 TEST(ReturnFloat64Literal) { | 578 TEST(ReturnFloat64Literal) { |
574 CHECK_FUNC_TYPES_BEGIN( | 579 CHECK_FUNC_TYPES_BEGIN( |
575 "function bar() { return 1.0; }\n" | 580 "function bar() { return 1.0; }\n" |
576 "function foo() { bar(); }") { | 581 "function foo() { bar(); }") { |
577 CHECK_EXPR(FunctionLiteral, FUNC_D_TYPE) { | 582 CHECK_EXPR(FunctionLiteral, FUNC_D_TYPE) { |
578 // return 1.0; | 583 // return 1.0; |
579 CHECK_EXPR(Literal, Bounds(cache.kFloat64)); | 584 CHECK_EXPR(Literal, Bounds(cache.kAsmDouble)); |
580 } | 585 } |
581 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { | 586 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { |
582 CHECK_EXPR(Call, Bounds(cache.kFloat64)) { CHECK_VAR(bar, FUNC_D_TYPE); } | 587 CHECK_EXPR(Call, Bounds(cache.kAsmDouble)) { |
| 588 CHECK_VAR(bar, FUNC_D_TYPE); |
| 589 } |
583 } | 590 } |
584 } | 591 } |
585 CHECK_FUNC_TYPES_END | 592 CHECK_FUNC_TYPES_END |
586 } | 593 } |
587 | 594 |
588 | 595 |
589 TEST(ReturnFloat32Literal) { | 596 TEST(ReturnFloat32Literal) { |
590 CHECK_FUNC_TYPES_BEGIN( | 597 CHECK_FUNC_TYPES_BEGIN( |
591 "function bar() { return fround(1.0); }\n" | 598 "function bar() { return fround(1.0); }\n" |
592 "function foo() { bar(); }") { | 599 "function foo() { bar(); }") { |
593 CHECK_EXPR(FunctionLiteral, FUNC_F_TYPE) { | 600 CHECK_EXPR(FunctionLiteral, FUNC_F_TYPE) { |
594 // return fround(1.0); | 601 // return fround(1.0); |
595 CHECK_EXPR(Call, Bounds(cache.kFloat32)) { | 602 CHECK_EXPR(Call, Bounds(cache.kAsmFloat)) { |
596 CHECK_VAR(fround, FUNC_N2F_TYPE); | 603 CHECK_VAR(fround, FUNC_N2F_TYPE); |
597 CHECK_EXPR(Literal, Bounds(cache.kFloat64)); | 604 CHECK_EXPR(Literal, Bounds(cache.kAsmDouble)); |
598 } | 605 } |
599 } | 606 } |
600 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { | 607 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { |
601 CHECK_EXPR(Call, Bounds(cache.kFloat32)) { CHECK_VAR(bar, FUNC_F_TYPE); } | 608 CHECK_EXPR(Call, Bounds(cache.kAsmFloat)) { CHECK_VAR(bar, FUNC_F_TYPE); } |
602 } | 609 } |
603 } | 610 } |
604 CHECK_FUNC_TYPES_END | 611 CHECK_FUNC_TYPES_END |
605 } | 612 } |
606 | 613 |
607 | 614 |
608 TEST(ReturnFloat64Var) { | 615 TEST(ReturnFloat64Var) { |
609 CHECK_FUNC_TYPES_BEGIN( | 616 CHECK_FUNC_TYPES_BEGIN( |
610 "function bar() { var x = 1.0; return +x; }\n" | 617 "function bar() { var x = 1.0; return +x; }\n" |
611 "function foo() { bar(); }") { | 618 "function foo() { bar(); }") { |
612 CHECK_EXPR(FunctionLiteral, FUNC_D_TYPE) { | 619 CHECK_EXPR(FunctionLiteral, FUNC_D_TYPE) { |
613 // return 1.0; | 620 // return 1.0; |
614 CHECK_EXPR(Assignment, Bounds(cache.kFloat64)) { | 621 CHECK_EXPR(Assignment, Bounds(cache.kAsmDouble)) { |
615 CHECK_VAR(x, Bounds(cache.kFloat64)); | 622 CHECK_VAR(x, Bounds(cache.kAsmDouble)); |
616 CHECK_EXPR(Literal, Bounds(cache.kFloat64)); | 623 CHECK_EXPR(Literal, Bounds(cache.kAsmDouble)); |
617 } | 624 } |
618 // return 1.0; | 625 // return 1.0; |
619 CHECK_EXPR(BinaryOperation, Bounds(cache.kFloat64)) { | 626 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmDouble)) { |
620 CHECK_VAR(x, Bounds(cache.kFloat64)); | 627 CHECK_VAR(x, Bounds(cache.kAsmDouble)); |
621 CHECK_EXPR(Literal, Bounds(cache.kFloat64)); | 628 CHECK_EXPR(Literal, Bounds(cache.kAsmDouble)); |
622 } | 629 } |
623 } | 630 } |
624 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { | 631 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { |
625 CHECK_EXPR(Call, Bounds(cache.kFloat64)) { CHECK_VAR(bar, FUNC_D_TYPE); } | 632 CHECK_EXPR(Call, Bounds(cache.kAsmDouble)) { |
| 633 CHECK_VAR(bar, FUNC_D_TYPE); |
| 634 } |
626 } | 635 } |
627 } | 636 } |
628 CHECK_FUNC_TYPES_END | 637 CHECK_FUNC_TYPES_END |
629 } | 638 } |
630 | 639 |
631 | 640 |
632 TEST(Addition2) { | 641 TEST(Addition2) { |
633 CHECK_FUNC_TYPES_BEGIN( | 642 CHECK_FUNC_TYPES_BEGIN( |
634 "function bar() { var x = 1; var y = 2; return (x+y)|0; }\n" | 643 "function bar() { var x = 1; var y = 2; return (x+y)|0; }\n" |
635 "function foo() { bar(); }") { | 644 "function foo() { bar(); }") { |
636 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { | 645 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { |
637 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { | 646 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
638 CHECK_VAR(x, Bounds(cache.kInt32)); | 647 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
639 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 648 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
640 } | 649 } |
641 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { | 650 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
642 CHECK_VAR(y, Bounds(cache.kInt32)); | 651 CHECK_VAR(y, Bounds(cache.kAsmInt)); |
643 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 652 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
644 } | 653 } |
645 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 654 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
646 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 655 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmInt)) { |
647 CHECK_VAR(x, Bounds(cache.kInt32)); | 656 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
648 CHECK_VAR(y, Bounds(cache.kInt32)); | 657 CHECK_VAR(y, Bounds(cache.kAsmInt)); |
649 } | 658 } |
650 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 659 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
651 } | 660 } |
652 } | 661 } |
653 CHECK_SKIP(); | 662 CHECK_SKIP(); |
654 } | 663 } |
655 CHECK_FUNC_TYPES_END | 664 CHECK_FUNC_TYPES_END |
656 } | 665 } |
657 | 666 |
658 | 667 |
659 #define TEST_COMPARE_OP(name, op) \ | 668 #define TEST_COMPARE_OP(name, op) \ |
660 TEST(name) { \ | 669 TEST(name) { \ |
661 CHECK_FUNC_TYPES_BEGIN("function bar() { return (0 " op \ | 670 CHECK_FUNC_TYPES_BEGIN("function bar() { return (0 " op \ |
662 " 0)|0; }\n" \ | 671 " 0)|0; }\n" \ |
663 "function foo() { bar(); }") { \ | 672 "function foo() { bar(); }") { \ |
664 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { \ | 673 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { \ |
665 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { \ | 674 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { \ |
666 CHECK_EXPR(CompareOperation, Bounds(cache.kInt32)) { \ | 675 CHECK_EXPR(CompareOperation, Bounds(cache.kAsmSigned)) { \ |
667 CHECK_EXPR(Literal, Bounds(cache.kInt32)); \ | 676 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); \ |
668 CHECK_EXPR(Literal, Bounds(cache.kInt32)); \ | 677 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); \ |
669 } \ | 678 } \ |
670 CHECK_EXPR(Literal, Bounds(cache.kInt32)); \ | 679 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); \ |
671 } \ | 680 } \ |
672 } \ | 681 } \ |
673 CHECK_SKIP(); \ | 682 CHECK_SKIP(); \ |
674 } \ | 683 } \ |
675 CHECK_FUNC_TYPES_END \ | 684 CHECK_FUNC_TYPES_END \ |
676 } | 685 } |
677 | 686 |
678 | 687 |
679 TEST_COMPARE_OP(EqOperator, "==") | 688 TEST_COMPARE_OP(EqOperator, "==") |
680 TEST_COMPARE_OP(LtOperator, "<") | 689 TEST_COMPARE_OP(LtOperator, "<") |
681 TEST_COMPARE_OP(LteOperator, "<=") | 690 TEST_COMPARE_OP(LteOperator, "<=") |
682 TEST_COMPARE_OP(GtOperator, ">") | 691 TEST_COMPARE_OP(GtOperator, ">") |
683 TEST_COMPARE_OP(GteOperator, ">=") | 692 TEST_COMPARE_OP(GteOperator, ">=") |
684 | 693 |
685 | 694 |
686 TEST(NeqOperator) { | 695 TEST(NeqOperator) { |
687 CHECK_FUNC_TYPES_BEGIN( | 696 CHECK_FUNC_TYPES_BEGIN( |
688 "function bar() { return (0 != 0)|0; }\n" | 697 "function bar() { return (0 != 0)|0; }\n" |
689 "function foo() { bar(); }") { | 698 "function foo() { bar(); }") { |
690 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { | 699 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { |
691 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 700 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
692 CHECK_EXPR(UnaryOperation, Bounds(cache.kInt32)) { | 701 CHECK_EXPR(UnaryOperation, Bounds(cache.kAsmSigned)) { |
693 CHECK_EXPR(CompareOperation, Bounds(cache.kInt32)) { | 702 CHECK_EXPR(CompareOperation, Bounds(cache.kAsmSigned)) { |
694 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 703 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
695 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 704 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
696 } | 705 } |
697 } | 706 } |
698 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 707 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
699 } | 708 } |
700 } | 709 } |
701 CHECK_SKIP(); | 710 CHECK_SKIP(); |
702 } | 711 } |
703 CHECK_FUNC_TYPES_END | 712 CHECK_FUNC_TYPES_END |
704 } | 713 } |
705 | 714 |
706 | 715 |
707 TEST(NotOperator) { | 716 TEST(NotOperator) { |
708 CHECK_FUNC_TYPES_BEGIN( | 717 CHECK_FUNC_TYPES_BEGIN( |
709 "function bar() { var x = 0; return (!x)|0; }\n" | 718 "function bar() { var x = 0; return (!x)|0; }\n" |
710 "function foo() { bar(); }") { | 719 "function foo() { bar(); }") { |
711 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { | 720 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { |
712 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { | 721 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
713 CHECK_VAR(x, Bounds(cache.kInt32)); | 722 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
714 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 723 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
715 } | 724 } |
716 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 725 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
717 CHECK_EXPR(UnaryOperation, Bounds(cache.kInt32)) { | 726 CHECK_EXPR(UnaryOperation, Bounds(cache.kAsmSigned)) { |
718 CHECK_VAR(x, Bounds(cache.kInt32)); | 727 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
719 } | 728 } |
720 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 729 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
721 } | 730 } |
722 } | 731 } |
723 CHECK_SKIP(); | 732 CHECK_SKIP(); |
724 } | 733 } |
725 CHECK_FUNC_TYPES_END | 734 CHECK_FUNC_TYPES_END |
726 } | 735 } |
727 | 736 |
728 | 737 |
729 TEST(InvertOperator) { | 738 TEST(InvertOperator) { |
730 CHECK_FUNC_TYPES_BEGIN( | 739 CHECK_FUNC_TYPES_BEGIN( |
731 "function bar() { var x = 0; return (~x)|0; }\n" | 740 "function bar() { var x = 0; return (~x)|0; }\n" |
732 "function foo() { bar(); }") { | 741 "function foo() { bar(); }") { |
733 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { | 742 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { |
734 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { | 743 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
735 CHECK_VAR(x, Bounds(cache.kInt32)); | 744 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
736 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 745 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
737 } | 746 } |
738 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 747 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
739 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 748 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
740 CHECK_VAR(x, Bounds(cache.kInt32)); | 749 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
741 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 750 CHECK_EXPR(Literal, Bounds(cache.kAsmSigned)); |
742 } | 751 } |
743 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 752 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
744 } | 753 } |
745 } | 754 } |
746 CHECK_SKIP(); | 755 CHECK_SKIP(); |
747 } | 756 } |
748 CHECK_FUNC_TYPES_END | 757 CHECK_FUNC_TYPES_END |
749 } | 758 } |
750 | 759 |
751 | 760 |
752 TEST(InvertConversion) { | 761 TEST(InvertConversion) { |
753 CHECK_FUNC_TYPES_BEGIN( | 762 CHECK_FUNC_TYPES_BEGIN( |
754 "function bar() { var x = 0.0; return (~~x)|0; }\n" | 763 "function bar() { var x = 0.0; return (~~x)|0; }\n" |
755 "function foo() { bar(); }") { | 764 "function foo() { bar(); }") { |
756 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { | 765 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { |
757 CHECK_EXPR(Assignment, Bounds(cache.kFloat64)) { | 766 CHECK_EXPR(Assignment, Bounds(cache.kAsmDouble)) { |
758 CHECK_VAR(x, Bounds(cache.kFloat64)); | 767 CHECK_VAR(x, Bounds(cache.kAsmDouble)); |
759 CHECK_EXPR(Literal, Bounds(cache.kFloat64)); | 768 CHECK_EXPR(Literal, Bounds(cache.kAsmDouble)); |
760 } | 769 } |
761 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 770 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
762 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 771 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
763 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 772 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
764 CHECK_VAR(x, Bounds(cache.kFloat64)); | 773 CHECK_VAR(x, Bounds(cache.kAsmDouble)); |
765 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 774 CHECK_EXPR(Literal, Bounds(cache.kAsmSigned)); |
766 } | 775 } |
767 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 776 CHECK_EXPR(Literal, Bounds(cache.kAsmSigned)); |
768 } | 777 } |
769 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 778 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
770 } | 779 } |
771 } | 780 } |
772 CHECK_SKIP(); | 781 CHECK_SKIP(); |
| 782 } |
| 783 CHECK_FUNC_TYPES_END |
| 784 } |
| 785 |
| 786 |
| 787 TEST(Ternary) { |
| 788 CHECK_FUNC_TYPES_BEGIN( |
| 789 "function bar() { var x = 1; var y = 1; return (x?y:5)|0; }\n" |
| 790 "function foo() { bar(); }") { |
| 791 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { |
| 792 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
| 793 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
| 794 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 795 } |
| 796 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
| 797 CHECK_VAR(y, Bounds(cache.kAsmInt)); |
| 798 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 799 } |
| 800 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
| 801 CHECK_EXPR(Conditional, Bounds(cache.kAsmInt)) { |
| 802 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
| 803 CHECK_VAR(y, Bounds(cache.kAsmInt)); |
| 804 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 805 } |
| 806 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 807 } |
| 808 } |
| 809 CHECK_SKIP(); |
773 } | 810 } |
774 CHECK_FUNC_TYPES_END | 811 CHECK_FUNC_TYPES_END |
775 } | 812 } |
776 | 813 |
777 | 814 |
778 #define TEST_INT_BIN_OP(name, op) \ | 815 #define TEST_INT_BIN_OP(name, op) \ |
779 TEST(name) { \ | 816 TEST(name) { \ |
780 CHECK_FUNC_TYPES_BEGIN("function bar() { var x = 0; return (x " op \ | 817 CHECK_FUNC_TYPES_BEGIN("function bar() { var x = 0; return (x " op \ |
781 " 123)|0; }\n" \ | 818 " 123)|0; }\n" \ |
782 "function foo() { bar(); }") { \ | 819 "function foo() { bar(); }") { \ |
783 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { \ | 820 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { \ |
784 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { \ | 821 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { \ |
785 CHECK_VAR(x, Bounds(cache.kInt32)); \ | 822 CHECK_VAR(x, Bounds(cache.kAsmInt)); \ |
786 CHECK_EXPR(Literal, Bounds(cache.kInt32)); \ | 823 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); \ |
787 } \ | 824 } \ |
788 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { \ | 825 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { \ |
789 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { \ | 826 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { \ |
790 CHECK_VAR(x, Bounds(cache.kInt32)); \ | 827 CHECK_VAR(x, Bounds(cache.kAsmInt)); \ |
791 CHECK_EXPR(Literal, Bounds(cache.kInt32)); \ | 828 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); \ |
792 } \ | 829 } \ |
793 CHECK_EXPR(Literal, Bounds(cache.kInt32)); \ | 830 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); \ |
794 } \ | 831 } \ |
795 } \ | 832 } \ |
796 CHECK_SKIP(); \ | 833 CHECK_SKIP(); \ |
797 } \ | 834 } \ |
798 CHECK_FUNC_TYPES_END \ | 835 CHECK_FUNC_TYPES_END \ |
799 } | 836 } |
800 | 837 |
801 | 838 |
802 TEST_INT_BIN_OP(AndOperator, "&") | 839 TEST_INT_BIN_OP(AndOperator, "&") |
803 TEST_INT_BIN_OP(OrOperator, "|") | 840 TEST_INT_BIN_OP(OrOperator, "|") |
804 TEST_INT_BIN_OP(XorOperator, "^") | 841 TEST_INT_BIN_OP(XorOperator, "^") |
805 | 842 |
806 | 843 |
807 TEST(UnsignedCompare) { | 844 TEST(UnsignedCompare) { |
808 CHECK_FUNC_TYPES_BEGIN( | 845 CHECK_FUNC_TYPES_BEGIN( |
809 "function bar() { var x = 1; var y = 1; return ((x>>>0) < (y>>>0))|0; }\n" | 846 "function bar() { var x = 1; var y = 1; return ((x>>>0) < (y>>>0))|0; }\n" |
810 "function foo() { bar(); }") { | 847 "function foo() { bar(); }") { |
811 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { | 848 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { |
812 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { | 849 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
813 CHECK_VAR(x, Bounds(cache.kInt32)); | 850 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
814 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 851 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
815 } | 852 } |
816 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { | 853 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
817 CHECK_VAR(y, Bounds(cache.kInt32)); | 854 CHECK_VAR(y, Bounds(cache.kAsmInt)); |
818 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 855 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
819 } | 856 } |
820 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 857 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
821 CHECK_EXPR(CompareOperation, Bounds(cache.kInt32)) { | 858 CHECK_EXPR(CompareOperation, Bounds(cache.kAsmSigned)) { |
822 CHECK_EXPR(BinaryOperation, Bounds(cache.kUint32)) { | 859 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmUnsigned)) { |
823 CHECK_VAR(x, Bounds(cache.kInt32)); | 860 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
824 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 861 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
825 } | 862 } |
826 CHECK_EXPR(BinaryOperation, Bounds(cache.kUint32)) { | 863 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmUnsigned)) { |
827 CHECK_VAR(y, Bounds(cache.kInt32)); | 864 CHECK_VAR(y, Bounds(cache.kAsmInt)); |
828 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 865 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
829 } | 866 } |
830 } | 867 } |
831 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 868 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
832 } | 869 } |
833 } | 870 } |
834 CHECK_SKIP(); | 871 CHECK_SKIP(); |
835 } | 872 } |
836 CHECK_FUNC_TYPES_END | 873 CHECK_FUNC_TYPES_END |
837 } | 874 } |
838 | 875 |
839 | 876 |
840 TEST(UnsignedDivide) { | 877 TEST(UnsignedDivide) { |
841 CHECK_FUNC_TYPES_BEGIN( | 878 CHECK_FUNC_TYPES_BEGIN( |
842 "function bar() { var x = 1; var y = 1; return ((x>>>0) / (y>>>0))|0; }\n" | 879 "function bar() { var x = 1; var y = 1; return ((x>>>0) / (y>>>0))|0; }\n" |
843 "function foo() { bar(); }") { | 880 "function foo() { bar(); }") { |
844 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { | 881 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { |
845 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { | 882 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
846 CHECK_VAR(x, Bounds(cache.kInt32)); | 883 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
847 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 884 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
848 } | 885 } |
849 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { | 886 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
850 CHECK_VAR(y, Bounds(cache.kInt32)); | 887 CHECK_VAR(y, Bounds(cache.kAsmInt)); |
851 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 888 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
852 } | 889 } |
853 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 890 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
854 CHECK_EXPR(BinaryOperation, Bounds(Type::None(), Type::Any())) { | 891 CHECK_EXPR(BinaryOperation, Bounds(Type::None(), Type::Any())) { |
855 CHECK_EXPR(BinaryOperation, Bounds(cache.kUint32)) { | 892 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmUnsigned)) { |
856 CHECK_VAR(x, Bounds(cache.kInt32)); | 893 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
857 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 894 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
858 } | 895 } |
859 CHECK_EXPR(BinaryOperation, Bounds(cache.kUint32)) { | 896 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmUnsigned)) { |
860 CHECK_VAR(y, Bounds(cache.kInt32)); | 897 CHECK_VAR(y, Bounds(cache.kAsmInt)); |
861 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 898 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
862 } | 899 } |
863 } | 900 } |
864 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 901 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
865 } | 902 } |
866 } | 903 } |
867 CHECK_SKIP(); | 904 CHECK_SKIP(); |
868 } | 905 } |
869 CHECK_FUNC_TYPES_END | 906 CHECK_FUNC_TYPES_END |
870 } | 907 } |
871 | 908 |
872 | 909 |
873 TEST(UnsignedFromFloat64) { | 910 TEST(UnsignedFromFloat64) { |
874 CHECK_FUNC_ERROR( | 911 CHECK_FUNC_ERROR( |
875 "function bar() { var x = 1.0; return (x>>>0)|0; }\n" | 912 "function bar() { var x = 1.0; return (x>>>0)|0; }\n" |
876 "function foo() { bar(); }", | 913 "function foo() { bar(); }", |
877 "asm: line 39: ill typed bitwise operation\n"); | 914 "asm: line 39: left bitwise operand expected to be an integer\n"); |
878 } | 915 } |
879 | 916 |
880 | 917 |
| 918 TEST(AndFloat64) { |
| 919 CHECK_FUNC_ERROR( |
| 920 "function bar() { var x = 1.0; return (x&0)|0; }\n" |
| 921 "function foo() { bar(); }", |
| 922 "asm: line 39: left bitwise operand expected to be an integer\n"); |
| 923 } |
| 924 |
| 925 |
881 TEST(TypeMismatchAddInt32Float64) { | 926 TEST(TypeMismatchAddInt32Float64) { |
882 CHECK_FUNC_ERROR( | 927 CHECK_FUNC_ERROR( |
883 "function bar() { var x = 1.0; var y = 0; return (x + y)|0; }\n" | 928 "function bar() { var x = 1.0; var y = 0; return (x + y)|0; }\n" |
884 "function foo() { bar(); }", | 929 "function foo() { bar(); }", |
885 "asm: line 39: ill-typed arithmetic operation\n"); | 930 "asm: line 39: ill-typed arithmetic operation\n"); |
886 } | 931 } |
887 | 932 |
888 | 933 |
889 TEST(TypeMismatchSubInt32Float64) { | 934 TEST(TypeMismatchSubInt32Float64) { |
890 CHECK_FUNC_ERROR( | 935 CHECK_FUNC_ERROR( |
(...skipping 24 matching lines...) Expand all Loading... |
915 "function bar() { var x = fround(1.0); return (x % x)|0; }\n" | 960 "function bar() { var x = fround(1.0); return (x % x)|0; }\n" |
916 "function foo() { bar(); }", | 961 "function foo() { bar(); }", |
917 "asm: line 39: ill-typed arithmetic operation\n"); | 962 "asm: line 39: ill-typed arithmetic operation\n"); |
918 } | 963 } |
919 | 964 |
920 | 965 |
921 TEST(TernaryMismatchInt32Float64) { | 966 TEST(TernaryMismatchInt32Float64) { |
922 CHECK_FUNC_ERROR( | 967 CHECK_FUNC_ERROR( |
923 "function bar() { var x = 1; var y = 0.0; return (1 ? x : y)|0; }\n" | 968 "function bar() { var x = 1; var y = 0.0; return (1 ? x : y)|0; }\n" |
924 "function foo() { bar(); }", | 969 "function foo() { bar(); }", |
925 "asm: line 39: ill-typed conditional\n"); | 970 "asm: line 39: then and else expressions in ? must have the same type\n"); |
926 } | 971 } |
927 | 972 |
928 | 973 |
| 974 TEST(TernaryMismatchIntish) { |
| 975 CHECK_FUNC_ERROR( |
| 976 "function bar() { var x = 1; var y = 0; return (1 ? x + x : y)|0; }\n" |
| 977 "function foo() { bar(); }", |
| 978 "asm: line 39: invalid type in ? then expression\n"); |
| 979 } |
| 980 |
| 981 |
| 982 TEST(TernaryMismatchInt32Float32) { |
| 983 CHECK_FUNC_ERROR( |
| 984 "function bar() { var x = 1; var y = 2; return (x?fround(y):x)|0; }\n" |
| 985 "function foo() { bar(); }", |
| 986 "asm: line 39: then and else expressions in ? must have the same type\n"); |
| 987 } |
| 988 |
| 989 |
| 990 TEST(TernaryBadCondition) { |
| 991 CHECK_FUNC_ERROR( |
| 992 "function bar() { var x = 1; var y = 2.0; return (y?x:1)|0; }\n" |
| 993 "function foo() { bar(); }", |
| 994 "asm: line 39: condition must be of type int\n"); |
| 995 } |
| 996 |
| 997 |
929 TEST(FroundFloat32) { | 998 TEST(FroundFloat32) { |
930 CHECK_FUNC_TYPES_BEGIN( | 999 CHECK_FUNC_TYPES_BEGIN( |
931 "function bar() { var x = 1; return fround(x); }\n" | 1000 "function bar() { var x = 1; return fround(x); }\n" |
932 "function foo() { bar(); }") { | 1001 "function foo() { bar(); }") { |
933 CHECK_EXPR(FunctionLiteral, FUNC_F_TYPE) { | 1002 CHECK_EXPR(FunctionLiteral, FUNC_F_TYPE) { |
934 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { | 1003 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
935 CHECK_VAR(x, Bounds(cache.kInt32)); | 1004 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
936 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 1005 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
937 } | 1006 } |
938 CHECK_EXPR(Call, Bounds(cache.kFloat32)) { | 1007 CHECK_EXPR(Call, Bounds(cache.kAsmFloat)) { |
939 CHECK_VAR(fround, FUNC_N2F_TYPE); | 1008 CHECK_VAR(fround, FUNC_N2F_TYPE); |
940 CHECK_VAR(x, Bounds(cache.kInt32)); | 1009 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
941 } | 1010 } |
942 } | 1011 } |
943 CHECK_SKIP(); | 1012 CHECK_SKIP(); |
944 } | 1013 } |
945 CHECK_FUNC_TYPES_END | 1014 CHECK_FUNC_TYPES_END |
946 } | 1015 } |
947 | 1016 |
948 | 1017 |
949 TEST(Addition4) { | 1018 TEST(Addition4) { |
950 CHECK_FUNC_TYPES_BEGIN( | 1019 CHECK_FUNC_TYPES_BEGIN( |
951 "function bar() { var x = 1; var y = 2; return (x+y+x+y)|0; }\n" | 1020 "function bar() { var x = 1; var y = 2; return (x+y+x+y)|0; }\n" |
952 "function foo() { bar(); }") { | 1021 "function foo() { bar(); }") { |
953 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { | 1022 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { |
954 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { | 1023 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
955 CHECK_VAR(x, Bounds(cache.kInt32)); | 1024 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
956 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 1025 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
957 } | 1026 } |
958 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { | 1027 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
959 CHECK_VAR(y, Bounds(cache.kInt32)); | 1028 CHECK_VAR(y, Bounds(cache.kAsmInt)); |
960 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 1029 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
961 } | 1030 } |
962 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 1031 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
963 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 1032 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmInt)) { |
964 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 1033 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmInt)) { |
965 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 1034 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmInt)) { |
966 CHECK_VAR(x, Bounds(cache.kInt32)); | 1035 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
967 CHECK_VAR(y, Bounds(cache.kInt32)); | 1036 CHECK_VAR(y, Bounds(cache.kAsmInt)); |
968 } | 1037 } |
969 CHECK_VAR(x, Bounds(cache.kInt32)); | 1038 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
970 } | 1039 } |
971 CHECK_VAR(y, Bounds(cache.kInt32)); | 1040 CHECK_VAR(y, Bounds(cache.kAsmInt)); |
972 } | 1041 } |
973 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 1042 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
974 } | 1043 } |
975 } | 1044 } |
976 CHECK_SKIP(); | 1045 CHECK_SKIP(); |
977 } | 1046 } |
978 CHECK_FUNC_TYPES_END | 1047 CHECK_FUNC_TYPES_END |
979 } | 1048 } |
980 | 1049 |
981 | 1050 |
982 TEST(Multiplication2) { | 1051 TEST(Multiplication2) { |
983 CHECK_FUNC_ERROR( | 1052 CHECK_FUNC_ERROR( |
984 "function bar() { var x = 1; var y = 2; return (x*y)|0; }\n" | 1053 "function bar() { var x = 1; var y = 2; return (x*y)|0; }\n" |
985 "function foo() { bar(); }", | 1054 "function foo() { bar(); }", |
986 "asm: line 39: direct integer multiply forbidden\n"); | 1055 "asm: line 39: direct integer multiply forbidden\n"); |
987 } | 1056 } |
988 | 1057 |
989 | 1058 |
990 TEST(Division4) { | 1059 TEST(Division4) { |
991 CHECK_FUNC_ERROR( | 1060 CHECK_FUNC_ERROR( |
992 "function bar() { var x = 1; var y = 2; return (x/y/x/y)|0; }\n" | 1061 "function bar() { var x = 1; var y = 2; return (x/y/x/y)|0; }\n" |
993 "function foo() { bar(); }", | 1062 "function foo() { bar(); }", |
994 "asm: line 39: too many consecutive multiplicative ops\n"); | 1063 "asm: line 39: too many consecutive multiplicative ops\n"); |
995 } | 1064 } |
996 | 1065 |
997 | 1066 |
| 1067 TEST(CompareToStringLeft) { |
| 1068 CHECK_FUNC_ERROR( |
| 1069 "function bar() { var x = 1; return ('hi' > x)|0; }\n" |
| 1070 "function foo() { bar(); }", |
| 1071 "asm: line 39: bad type on left side of comparison\n"); |
| 1072 } |
| 1073 |
| 1074 |
| 1075 TEST(CompareToStringRight) { |
| 1076 CHECK_FUNC_ERROR( |
| 1077 "function bar() { var x = 1; return (x < 'hi')|0; }\n" |
| 1078 "function foo() { bar(); }", |
| 1079 "asm: line 39: bad type on right side of comparison\n"); |
| 1080 } |
| 1081 |
| 1082 |
998 TEST(CompareMismatchInt32Float64) { | 1083 TEST(CompareMismatchInt32Float64) { |
999 CHECK_FUNC_ERROR( | 1084 CHECK_FUNC_ERROR( |
1000 "function bar() { var x = 1; var y = 2.0; return (x < y)|0; }\n" | 1085 "function bar() { var x = 1; var y = 2.0; return (x < y)|0; }\n" |
1001 "function foo() { bar(); }", | 1086 "function foo() { bar(); }", |
1002 "asm: line 39: ill-typed comparison operation\n"); | 1087 "asm: line 39: left and right side of comparison must match\n"); |
1003 } | 1088 } |
1004 | 1089 |
1005 | 1090 |
1006 TEST(CompareMismatchInt32Uint32) { | 1091 TEST(CompareMismatchInt32Uint32) { |
1007 CHECK_FUNC_ERROR( | 1092 CHECK_FUNC_ERROR( |
1008 "function bar() { var x = 1; var y = 2; return (x < (y>>>0))|0; }\n" | 1093 "function bar() { var x = 1; var y = 2; return ((x|0) < (y>>>0))|0; }\n" |
1009 "function foo() { bar(); }", | 1094 "function foo() { bar(); }", |
1010 "asm: line 39: ill-typed comparison operation\n"); | 1095 "asm: line 39: left and right side of comparison must match\n"); |
1011 } | 1096 } |
1012 | 1097 |
1013 | 1098 |
1014 TEST(CompareMismatchInt32Float32) { | 1099 TEST(CompareMismatchInt32Float32) { |
1015 CHECK_FUNC_ERROR( | 1100 CHECK_FUNC_ERROR( |
1016 "function bar() { var x = 1; var y = 2; return (x < fround(y))|0; }\n" | 1101 "function bar() { var x = 1; var y = 2; return (x < fround(y))|0; }\n" |
1017 "function foo() { bar(); }", | 1102 "function foo() { bar(); }", |
1018 "asm: line 39: ill-typed comparison operation\n"); | 1103 "asm: line 39: left and right side of comparison must match\n"); |
1019 } | 1104 } |
1020 | 1105 |
1021 | 1106 |
1022 TEST(Float64ToInt32) { | 1107 TEST(Float64ToInt32) { |
1023 CHECK_FUNC_TYPES_BEGIN( | 1108 CHECK_FUNC_TYPES_BEGIN( |
1024 "function bar() { var x = 1; var y = 0.0; x = ~~y; }\n" | 1109 "function bar() { var x = 1; var y = 0.0; x = ~~y; }\n" |
1025 "function foo() { bar(); }") { | 1110 "function foo() { bar(); }") { |
1026 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { | 1111 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { |
1027 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { | 1112 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
1028 CHECK_VAR(x, Bounds(cache.kInt32)); | 1113 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
1029 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 1114 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
1030 } | 1115 } |
1031 CHECK_EXPR(Assignment, Bounds(cache.kFloat64)) { | 1116 CHECK_EXPR(Assignment, Bounds(cache.kAsmDouble)) { |
1032 CHECK_VAR(y, Bounds(cache.kFloat64)); | 1117 CHECK_VAR(y, Bounds(cache.kAsmDouble)); |
1033 CHECK_EXPR(Literal, Bounds(cache.kFloat64)); | 1118 CHECK_EXPR(Literal, Bounds(cache.kAsmDouble)); |
1034 } | 1119 } |
1035 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { | 1120 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
1036 CHECK_VAR(x, Bounds(cache.kInt32)); | 1121 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
1037 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 1122 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
1038 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 1123 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
1039 CHECK_VAR(y, Bounds(cache.kFloat64)); | 1124 CHECK_VAR(y, Bounds(cache.kAsmDouble)); |
1040 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 1125 CHECK_EXPR(Literal, Bounds(cache.kAsmSigned)); |
1041 } | 1126 } |
1042 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 1127 CHECK_EXPR(Literal, Bounds(cache.kAsmSigned)); |
1043 } | 1128 } |
1044 } | 1129 } |
1045 } | 1130 } |
1046 CHECK_SKIP(); | 1131 CHECK_SKIP(); |
1047 } | 1132 } |
1048 CHECK_FUNC_TYPES_END | 1133 CHECK_FUNC_TYPES_END |
1049 } | 1134 } |
1050 | 1135 |
1051 | 1136 |
1052 TEST(Load1) { | 1137 TEST(Load1) { |
1053 CHECK_FUNC_TYPES_BEGIN( | 1138 CHECK_FUNC_TYPES_BEGIN( |
1054 "function bar() { var x = 1; var y = i8[x>>0]|0; }\n" | 1139 "function bar() { var x = 1; var y = i8[x>>0]|0; }\n" |
1055 "function foo() { bar(); }") { | 1140 "function foo() { bar(); }") { |
1056 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { | 1141 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { |
1057 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { | 1142 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
1058 CHECK_VAR(x, Bounds(cache.kInt32)); | 1143 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
1059 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 1144 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
1060 } | 1145 } |
1061 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { | 1146 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
1062 CHECK_VAR(y, Bounds(cache.kInt32)); | 1147 CHECK_VAR(y, Bounds(cache.kAsmInt)); |
1063 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 1148 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
1064 CHECK_EXPR(Property, Bounds(cache.kInt8)) { | 1149 CHECK_EXPR(Property, Bounds(cache.kInt8)) { |
1065 CHECK_VAR(i8, Bounds(cache.kInt8Array)); | 1150 CHECK_VAR(i8, Bounds(cache.kInt8Array)); |
1066 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 1151 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
1067 CHECK_VAR(x, Bounds(cache.kInt32)); | 1152 CHECK_VAR(x, Bounds(cache.kAsmSigned)); |
1068 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 1153 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
1069 } | 1154 } |
1070 } | 1155 } |
1071 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 1156 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
1072 } | 1157 } |
1073 } | 1158 } |
1074 } | 1159 } |
1075 CHECK_SKIP(); | 1160 CHECK_SKIP(); |
1076 } | 1161 } |
1077 CHECK_FUNC_TYPES_END | 1162 CHECK_FUNC_TYPES_END |
1078 } | 1163 } |
1079 | 1164 |
1080 | 1165 |
1081 TEST(Load1Constant) { | 1166 TEST(Load1Constant) { |
1082 CHECK_FUNC_TYPES_BEGIN( | 1167 CHECK_FUNC_TYPES_BEGIN( |
1083 "function bar() { var x = 1; var y = i8[5]|0; }\n" | 1168 "function bar() { var x = 1; var y = i8[5]|0; }\n" |
1084 "function foo() { bar(); }") { | 1169 "function foo() { bar(); }") { |
1085 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { | 1170 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { |
1086 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { | 1171 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
1087 CHECK_VAR(x, Bounds(cache.kInt32)); | 1172 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
1088 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 1173 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
1089 } | 1174 } |
1090 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { | 1175 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
1091 CHECK_VAR(y, Bounds(cache.kInt32)); | 1176 CHECK_VAR(y, Bounds(cache.kAsmInt)); |
1092 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 1177 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
1093 CHECK_EXPR(Property, Bounds(cache.kInt8)) { | 1178 CHECK_EXPR(Property, Bounds(cache.kInt8)) { |
1094 CHECK_VAR(i8, Bounds(cache.kInt8Array)); | 1179 CHECK_VAR(i8, Bounds(cache.kInt8Array)); |
1095 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 1180 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
1096 } | 1181 } |
1097 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 1182 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
1098 } | 1183 } |
1099 } | 1184 } |
1100 } | 1185 } |
1101 CHECK_SKIP(); | 1186 CHECK_SKIP(); |
1102 } | 1187 } |
1103 CHECK_FUNC_TYPES_END | 1188 CHECK_FUNC_TYPES_END |
1104 } | 1189 } |
1105 | 1190 |
1106 | 1191 |
1107 TEST(FunctionTables) { | 1192 TEST(FunctionTables) { |
1108 CHECK_FUNC_TYPES_BEGIN( | 1193 CHECK_FUNC_TYPES_BEGIN( |
1109 "function func1(x) { x = x | 0; return (x * 5) | 0; }\n" | 1194 "function func1(x) { x = x | 0; return (x * 5) | 0; }\n" |
1110 "function func2(x) { x = x | 0; return (x * 25) | 0; }\n" | 1195 "function func2(x) { x = x | 0; return (x * 25) | 0; }\n" |
1111 "var table1 = [func1, func2];\n" | 1196 "var table1 = [func1, func2];\n" |
1112 "function bar(x, y) { x = x | 0; y = y | 0;\n" | 1197 "function bar(x, y) { x = x | 0; y = y | 0;\n" |
1113 " return table1[x & 1](y)|0; }\n" | 1198 " return table1[x & 1](y)|0; }\n" |
1114 "function foo() { bar(1, 2); }") { | 1199 "function foo() { bar(1, 2); }") { |
1115 CHECK_EXPR(FunctionLiteral, FUNC_I2I_TYPE) { | 1200 CHECK_EXPR(FunctionLiteral, FUNC_I2I_TYPE) { |
1116 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { | 1201 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
1117 CHECK_VAR(x, Bounds(cache.kInt32)); | 1202 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
1118 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 1203 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
1119 CHECK_VAR(x, Bounds(cache.kInt32)); | 1204 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
1120 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 1205 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
1121 } | 1206 } |
1122 } | 1207 } |
1123 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 1208 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
1124 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 1209 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmInt)) { |
1125 CHECK_VAR(x, Bounds(cache.kInt32)); | 1210 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
1126 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 1211 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
1127 } | 1212 } |
1128 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 1213 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
1129 } | 1214 } |
1130 } | 1215 } |
1131 CHECK_EXPR(FunctionLiteral, FUNC_I2I_TYPE) { | 1216 CHECK_EXPR(FunctionLiteral, FUNC_I2I_TYPE) { |
1132 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { | 1217 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
1133 CHECK_VAR(x, Bounds(cache.kInt32)); | 1218 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
1134 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 1219 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
1135 CHECK_VAR(x, Bounds(cache.kInt32)); | 1220 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
1136 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 1221 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
1137 } | 1222 } |
1138 } | 1223 } |
1139 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 1224 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
1140 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 1225 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmInt)) { |
1141 CHECK_VAR(x, Bounds(cache.kInt32)); | 1226 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
1142 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 1227 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
1143 } | 1228 } |
1144 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 1229 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
1145 } | 1230 } |
1146 } | 1231 } |
1147 CHECK_EXPR(FunctionLiteral, FUNC_II2I_TYPE) { | 1232 CHECK_EXPR(FunctionLiteral, FUNC_II2I_TYPE) { |
1148 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { | 1233 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
1149 CHECK_VAR(x, Bounds(cache.kInt32)); | 1234 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
1150 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 1235 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
1151 CHECK_VAR(x, Bounds(cache.kInt32)); | 1236 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
1152 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 1237 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
1153 } | 1238 } |
1154 } | 1239 } |
1155 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { | 1240 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
1156 CHECK_VAR(y, Bounds(cache.kInt32)); | 1241 CHECK_VAR(y, Bounds(cache.kAsmInt)); |
1157 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 1242 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
1158 CHECK_VAR(y, Bounds(cache.kInt32)); | 1243 CHECK_VAR(y, Bounds(cache.kAsmInt)); |
1159 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 1244 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
1160 } | 1245 } |
1161 } | 1246 } |
1162 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 1247 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
1163 CHECK_EXPR(Call, Bounds(cache.kInt32)) { | 1248 CHECK_EXPR(Call, Bounds(cache.kAsmSigned)) { |
1164 CHECK_EXPR(Property, FUNC_I2I_TYPE) { | 1249 CHECK_EXPR(Property, FUNC_I2I_TYPE) { |
1165 CHECK_VAR(table1, FUNC_I2I_ARRAY_TYPE); | 1250 CHECK_VAR(table1, FUNC_I2I_ARRAY_TYPE); |
1166 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 1251 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
1167 CHECK_VAR(x, Bounds(cache.kInt32)); | 1252 CHECK_VAR(x, Bounds(cache.kAsmSigned)); |
1168 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 1253 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
1169 } | 1254 } |
1170 } | 1255 } |
1171 CHECK_VAR(y, Bounds(cache.kInt32)); | 1256 CHECK_VAR(y, Bounds(cache.kAsmInt)); |
1172 } | 1257 } |
1173 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 1258 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
1174 } | 1259 } |
1175 } | 1260 } |
1176 CHECK_SKIP(); | 1261 CHECK_SKIP(); |
1177 } | 1262 } |
1178 CHECK_FUNC_TYPES_END_1(); | 1263 CHECK_FUNC_TYPES_END_1(); |
1179 CHECK_EXPR(Assignment, FUNC_I2I_ARRAY_TYPE) { | 1264 CHECK_EXPR(Assignment, FUNC_I2I_ARRAY_TYPE) { |
1180 CHECK_VAR(table1, FUNC_I2I_ARRAY_TYPE); | 1265 CHECK_VAR(table1, FUNC_I2I_ARRAY_TYPE); |
1181 CHECK_EXPR(ArrayLiteral, FUNC_I2I_ARRAY_TYPE) { | 1266 CHECK_EXPR(ArrayLiteral, FUNC_I2I_ARRAY_TYPE) { |
1182 CHECK_VAR(func1, FUNC_I2I_TYPE); | 1267 CHECK_VAR(func1, FUNC_I2I_TYPE); |
1183 CHECK_VAR(func2, FUNC_I2I_TYPE); | 1268 CHECK_VAR(func2, FUNC_I2I_TYPE); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1333 "asm: line 39: illegal literal\n"); | 1418 "asm: line 39: illegal literal\n"); |
1334 } | 1419 } |
1335 | 1420 |
1336 | 1421 |
1337 TEST(ForeignFunction) { | 1422 TEST(ForeignFunction) { |
1338 CHECK_FUNC_TYPES_BEGIN( | 1423 CHECK_FUNC_TYPES_BEGIN( |
1339 "var baz = foreign.baz;\n" | 1424 "var baz = foreign.baz;\n" |
1340 "function bar() { return baz(1, 2)|0; }\n" | 1425 "function bar() { return baz(1, 2)|0; }\n" |
1341 "function foo() { bar(); }") { | 1426 "function foo() { bar(); }") { |
1342 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { | 1427 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { |
1343 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 1428 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
1344 CHECK_EXPR(Call, Bounds(Type::Number(zone))) { | 1429 CHECK_EXPR(Call, Bounds(Type::Number(zone))) { |
1345 CHECK_VAR(baz, Bounds(Type::Any())); | 1430 CHECK_VAR(baz, Bounds(Type::Any())); |
1346 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 1431 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
1347 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 1432 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
1348 } | 1433 } |
1349 CHECK_EXPR(Literal, Bounds(cache.kInt32)); | 1434 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
1350 } | 1435 } |
1351 } | 1436 } |
1352 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { | 1437 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { |
1353 CHECK_EXPR(Call, Bounds(cache.kInt32)) { CHECK_VAR(bar, FUNC_I_TYPE); } | 1438 CHECK_EXPR(Call, Bounds(cache.kAsmSigned)) { |
| 1439 CHECK_VAR(bar, FUNC_I_TYPE); |
| 1440 } |
1354 } | 1441 } |
1355 } | 1442 } |
1356 CHECK_FUNC_TYPES_END_1() | 1443 CHECK_FUNC_TYPES_END_1() |
1357 CHECK_EXPR(Assignment, Bounds(Type::Any())) { | 1444 CHECK_EXPR(Assignment, Bounds(Type::Any())) { |
1358 CHECK_VAR(baz, Bounds(Type::Any())); | 1445 CHECK_VAR(baz, Bounds(Type::Any())); |
1359 CHECK_EXPR(Property, Bounds(Type::Any())) { | 1446 CHECK_EXPR(Property, Bounds(Type::Any())) { |
1360 CHECK_VAR(foreign, Bounds::Unbounded()); | 1447 CHECK_VAR(foreign, Bounds::Unbounded()); |
1361 CHECK_EXPR(Literal, Bounds::Unbounded()); | 1448 CHECK_EXPR(Literal, Bounds::Unbounded()); |
1362 } | 1449 } |
1363 } | 1450 } |
1364 CHECK_FUNC_TYPES_END_2() | 1451 CHECK_FUNC_TYPES_END_2() |
1365 } | 1452 } |
1366 | 1453 |
1367 | 1454 |
1368 TEST(BadExports) { | 1455 TEST(BadExports) { |
1369 HARNESS_PREAMBLE() | 1456 HARNESS_PREAMBLE() |
1370 "function foo() {};\n" | 1457 "function foo() {};\n" |
1371 "return {foo: foo, bar: 1};" | 1458 "return {foo: foo, bar: 1};" |
1372 "}\n"; | 1459 "}\n"; |
1373 | 1460 |
1374 v8::V8::Initialize(); | 1461 v8::V8::Initialize(); |
1375 HandleAndZoneScope handles; | 1462 HandleAndZoneScope handles; |
1376 Zone* zone = handles.main_zone(); | 1463 Zone* zone = handles.main_zone(); |
1377 ZoneVector<ExpressionTypeEntry> types(zone); | 1464 ZoneVector<ExpressionTypeEntry> types(zone); |
1378 CHECK_EQ("asm: line 40: non-function in function table\n", | 1465 CHECK_EQ("asm: line 40: non-function in function table\n", |
1379 Validate(zone, test_function, &types)); | 1466 Validate(zone, test_function, &types)); |
1380 } | 1467 } |
| 1468 |
| 1469 |
| 1470 TEST(TypeConsistency) { |
| 1471 v8::V8::Initialize(); |
| 1472 // HandleAndZoneScope handles; |
| 1473 // Zone* zone = handles.main_zone(); |
| 1474 TypeCache cache; |
| 1475 |
| 1476 |
| 1477 CHECK(!cache.kAsmSigned->Is(cache.kAsmDouble)); |
| 1478 CHECK(!cache.kAsmSigned->Is(cache.kAsmFloat)); |
| 1479 CHECK(!cache.kAsmSigned->Is(cache.kAsmUnsigned)); |
| 1480 CHECK(!cache.kAsmDouble->Is(cache.kAsmSigned)); |
| 1481 CHECK(cache.kAsmSigned->Is(cache.kAsmInt)); |
| 1482 CHECK(!cache.kAsmSigned->Is(cache.kAsmDouble)); |
| 1483 } |
OLD | NEW |