OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #include "src/compiler/typer.h" | 5 #include "src/compiler/typer.h" |
6 | 6 |
7 #include "src/base/flags.h" | 7 #include "src/base/flags.h" |
8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
9 #include "src/compilation-dependencies.h" | 9 #include "src/compilation-dependencies.h" |
10 #include "src/compiler/common-operator.h" | 10 #include "src/compiler/common-operator.h" |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 } | 414 } |
415 return Type::Boolean(); | 415 return Type::Boolean(); |
416 } | 416 } |
417 | 417 |
418 | 418 |
419 // static | 419 // static |
420 Type* Typer::Visitor::ToInteger(Type* type, Typer* t) { | 420 Type* Typer::Visitor::ToInteger(Type* type, Typer* t) { |
421 // ES6 section 7.1.4 ToInteger ( argument ) | 421 // ES6 section 7.1.4 ToInteger ( argument ) |
422 type = ToNumber(type, t); | 422 type = ToNumber(type, t); |
423 if (type->Is(t->cache_.kIntegerOrMinusZero)) return type; | 423 if (type->Is(t->cache_.kIntegerOrMinusZero)) return type; |
| 424 if (type->Is(t->cache_.kIntegerOrMinusZeroOrNaN)) { |
| 425 return Type::Union( |
| 426 Type::Intersect(type, t->cache_.kIntegerOrMinusZero, t->zone()), |
| 427 t->cache_.kSingletonZero, t->zone()); |
| 428 } |
424 return t->cache_.kIntegerOrMinusZero; | 429 return t->cache_.kIntegerOrMinusZero; |
425 } | 430 } |
426 | 431 |
427 | 432 |
428 // static | 433 // static |
429 Type* Typer::Visitor::ToLength(Type* type, Typer* t) { | 434 Type* Typer::Visitor::ToLength(Type* type, Typer* t) { |
430 // ES6 section 7.1.15 ToLength ( argument ) | 435 // ES6 section 7.1.15 ToLength ( argument ) |
431 type = ToInteger(type, t); | 436 type = ToInteger(type, t); |
432 double min = type->Min(); | 437 double min = type->Min(); |
433 double max = type->Max(); | 438 double max = type->Max(); |
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1238 } | 1243 } |
1239 | 1244 |
1240 | 1245 |
1241 // JS conversion operators. | 1246 // JS conversion operators. |
1242 | 1247 |
1243 | 1248 |
1244 Type* Typer::Visitor::TypeJSToBoolean(Node* node) { | 1249 Type* Typer::Visitor::TypeJSToBoolean(Node* node) { |
1245 return TypeUnaryOp(node, ToBoolean); | 1250 return TypeUnaryOp(node, ToBoolean); |
1246 } | 1251 } |
1247 | 1252 |
| 1253 Type* Typer::Visitor::TypeJSToInteger(Node* node) { |
| 1254 return TypeUnaryOp(node, ToInteger); |
| 1255 } |
| 1256 |
| 1257 Type* Typer::Visitor::TypeJSToLength(Node* node) { |
| 1258 return TypeUnaryOp(node, ToLength); |
| 1259 } |
| 1260 |
| 1261 Type* Typer::Visitor::TypeJSToName(Node* node) { |
| 1262 return TypeUnaryOp(node, ToName); |
| 1263 } |
1248 | 1264 |
1249 Type* Typer::Visitor::TypeJSToNumber(Node* node) { | 1265 Type* Typer::Visitor::TypeJSToNumber(Node* node) { |
1250 return TypeUnaryOp(node, ToNumber); | 1266 return TypeUnaryOp(node, ToNumber); |
1251 } | 1267 } |
1252 | 1268 |
| 1269 Type* Typer::Visitor::TypeJSToObject(Node* node) { |
| 1270 return TypeUnaryOp(node, ToObject); |
| 1271 } |
1253 | 1272 |
1254 Type* Typer::Visitor::TypeJSToString(Node* node) { | 1273 Type* Typer::Visitor::TypeJSToString(Node* node) { |
1255 return TypeUnaryOp(node, ToString); | 1274 return TypeUnaryOp(node, ToString); |
1256 } | 1275 } |
1257 | 1276 |
1258 | |
1259 Type* Typer::Visitor::TypeJSToName(Node* node) { | |
1260 return TypeUnaryOp(node, ToName); | |
1261 } | |
1262 | |
1263 | |
1264 Type* Typer::Visitor::TypeJSToObject(Node* node) { | |
1265 return TypeUnaryOp(node, ToObject); | |
1266 } | |
1267 | |
1268 | |
1269 // JS object operators. | 1277 // JS object operators. |
1270 | 1278 |
1271 | 1279 |
1272 Type* Typer::Visitor::TypeJSCreate(Node* node) { return Type::Object(); } | 1280 Type* Typer::Visitor::TypeJSCreate(Node* node) { return Type::Object(); } |
1273 | 1281 |
1274 | 1282 |
1275 Type* Typer::Visitor::TypeJSCreateArguments(Node* node) { | 1283 Type* Typer::Visitor::TypeJSCreateArguments(Node* node) { |
1276 return Type::OtherObject(); | 1284 return Type::OtherObject(); |
1277 } | 1285 } |
1278 | 1286 |
(...skipping 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2524 } | 2532 } |
2525 if (Type::IsInteger(*value)) { | 2533 if (Type::IsInteger(*value)) { |
2526 return Type::Range(value->Number(), value->Number(), zone()); | 2534 return Type::Range(value->Number(), value->Number(), zone()); |
2527 } | 2535 } |
2528 return Type::Constant(value, zone()); | 2536 return Type::Constant(value, zone()); |
2529 } | 2537 } |
2530 | 2538 |
2531 } // namespace compiler | 2539 } // namespace compiler |
2532 } // namespace internal | 2540 } // namespace internal |
2533 } // namespace v8 | 2541 } // namespace v8 |
OLD | NEW |