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/bootstrapper.h" | 5 #include "src/bootstrapper.h" |
6 #include "src/compiler/graph-inl.h" | 6 #include "src/compiler/graph-inl.h" |
7 #include "src/compiler/graph-reducer.h" | 7 #include "src/compiler/graph-reducer.h" |
8 #include "src/compiler/js-operator.h" | 8 #include "src/compiler/js-operator.h" |
9 #include "src/compiler/node.h" | 9 #include "src/compiler/node.h" |
10 #include "src/compiler/node-properties-inl.h" | 10 #include "src/compiler/node-properties-inl.h" |
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
881 | 881 |
882 Type* Typer::Visitor::JSBitwiseXorTyper(Type* lhs, Type* rhs, Typer* t) { | 882 Type* Typer::Visitor::JSBitwiseXorTyper(Type* lhs, Type* rhs, Typer* t) { |
883 lhs = NumberToInt32(ToNumber(lhs, t), t); | 883 lhs = NumberToInt32(ToNumber(lhs, t), t); |
884 rhs = NumberToInt32(ToNumber(rhs, t), t); | 884 rhs = NumberToInt32(ToNumber(rhs, t), t); |
885 double lmin = lhs->Min(); | 885 double lmin = lhs->Min(); |
886 double rmin = rhs->Min(); | 886 double rmin = rhs->Min(); |
887 double lmax = lhs->Max(); | 887 double lmax = lhs->Max(); |
888 double rmax = rhs->Max(); | 888 double rmax = rhs->Max(); |
889 if ((lmin >= 0 && rmin >= 0) || (lmax < 0 && rmax < 0)) { | 889 if ((lmin >= 0 && rmin >= 0) || (lmax < 0 && rmax < 0)) { |
890 // Xor-ing negative or non-negative values results in a non-negative value. | 890 // Xor-ing negative or non-negative values results in a non-negative value. |
891 return Type::NonNegativeSigned32(); | 891 return Type::Unsigned31(); |
892 } | 892 } |
893 if ((lmax < 0 && rmin >= 0) || (lmin >= 0 && rmax < 0)) { | 893 if ((lmax < 0 && rmin >= 0) || (lmin >= 0 && rmax < 0)) { |
894 // Xor-ing a negative and a non-negative value results in a negative value. | 894 // Xor-ing a negative and a non-negative value results in a negative value. |
895 // TODO(jarin) Use a range here. | 895 // TODO(jarin) Use a range here. |
896 return Type::NegativeSigned32(); | 896 return Type::Negative32(); |
897 } | 897 } |
898 return Type::Signed32(); | 898 return Type::Signed32(); |
899 } | 899 } |
900 | 900 |
901 | 901 |
902 Type* Typer::Visitor::JSShiftLeftTyper(Type* lhs, Type* rhs, Typer* t) { | 902 Type* Typer::Visitor::JSShiftLeftTyper(Type* lhs, Type* rhs, Typer* t) { |
903 return Type::Signed32(); | 903 return Type::Signed32(); |
904 } | 904 } |
905 | 905 |
906 | 906 |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1251 return Bounds::Unbounded(zone()); | 1251 return Bounds::Unbounded(zone()); |
1252 } | 1252 } |
1253 | 1253 |
1254 | 1254 |
1255 // Returns a somewhat larger range if we previously assigned | 1255 // Returns a somewhat larger range if we previously assigned |
1256 // a (smaller) range to this node. This is used to speed up | 1256 // a (smaller) range to this node. This is used to speed up |
1257 // the fixpoint calculation in case there appears to be a loop | 1257 // the fixpoint calculation in case there appears to be a loop |
1258 // in the graph. In the current implementation, we are | 1258 // in the graph. In the current implementation, we are |
1259 // increasing the limits to the closest power of two. | 1259 // increasing the limits to the closest power of two. |
1260 Type* Typer::Visitor::Weaken(Type* current_type, Type* previous_type) { | 1260 Type* Typer::Visitor::Weaken(Type* current_type, Type* previous_type) { |
1261 Type::RangeType* previous = previous_type->GetRange(); | 1261 // If the types have nothing to do with integers, return the types. |
1262 Type::RangeType* current = current_type->GetRange(); | 1262 if (!current_type->Maybe(typer_->integer) || |
1263 if (previous != NULL && current != NULL) { | 1263 !previous_type->Maybe(typer_->integer)) { |
1264 double current_min = current->Min()->Number(); | 1264 return current_type; |
1265 Handle<Object> new_min = current->Min(); | 1265 } |
1266 | 1266 |
1267 // Find the closest lower entry in the list of allowed | 1267 Type* previous_number = |
1268 // minima (or negative infinity if there is no such entry). | 1268 Type::Intersect(previous_type, typer_->integer, zone()); |
1269 if (current_min != previous->Min()->Number()) { | 1269 Type* current_number = Type::Intersect(current_type, typer_->integer, zone()); |
1270 new_min = typer_->integer->AsRange()->Min(); | 1270 if (!current_number->IsRange() || !previous_number->IsRange()) { |
1271 for (const auto val : typer_->weaken_min_limits_) { | 1271 return current_type; |
1272 if (val->Number() <= current_min) { | 1272 } |
1273 new_min = val; | 1273 |
1274 break; | 1274 Type::RangeType* previous = previous_number->AsRange(); |
1275 } | 1275 Type::RangeType* current = current_number->AsRange(); |
| 1276 |
| 1277 double current_min = current->Min()->Number(); |
| 1278 Handle<Object> new_min = current->Min(); |
| 1279 |
| 1280 // Find the closest lower entry in the list of allowed |
| 1281 // minima (or negative infinity if there is no such entry). |
| 1282 if (current_min != previous->Min()->Number()) { |
| 1283 new_min = typer_->integer->AsRange()->Min(); |
| 1284 for (const auto val : typer_->weaken_min_limits_) { |
| 1285 if (val->Number() <= current_min) { |
| 1286 new_min = val; |
| 1287 break; |
1276 } | 1288 } |
1277 } | 1289 } |
| 1290 } |
1278 | 1291 |
1279 double current_max = current->Max()->Number(); | 1292 double current_max = current->Max()->Number(); |
1280 Handle<Object> new_max = current->Max(); | 1293 Handle<Object> new_max = current->Max(); |
1281 // Find the closest greater entry in the list of allowed | 1294 // Find the closest greater entry in the list of allowed |
1282 // maxima (or infinity if there is no such entry). | 1295 // maxima (or infinity if there is no such entry). |
1283 if (current_max != previous->Max()->Number()) { | 1296 if (current_max != previous->Max()->Number()) { |
1284 new_max = typer_->integer->AsRange()->Max(); | 1297 new_max = typer_->integer->AsRange()->Max(); |
1285 for (const auto val : typer_->weaken_max_limits_) { | 1298 for (const auto val : typer_->weaken_max_limits_) { |
1286 if (val->Number() >= current_max) { | 1299 if (val->Number() >= current_max) { |
1287 new_max = val; | 1300 new_max = val; |
1288 break; | 1301 break; |
1289 } | |
1290 } | 1302 } |
1291 } | 1303 } |
| 1304 } |
1292 | 1305 |
1293 return Type::Union(current_type, | 1306 return Type::Union(current_type, |
1294 Type::Range(new_min, new_max, typer_->zone()), | 1307 Type::Range(new_min, new_max, typer_->zone()), |
1295 typer_->zone()); | 1308 typer_->zone()); |
1296 } | |
1297 return current_type; | |
1298 } | 1309 } |
1299 | 1310 |
1300 | 1311 |
1301 Bounds Typer::Visitor::TypeJSStoreProperty(Node* node) { | 1312 Bounds Typer::Visitor::TypeJSStoreProperty(Node* node) { |
1302 UNREACHABLE(); | 1313 UNREACHABLE(); |
1303 return Bounds(); | 1314 return Bounds(); |
1304 } | 1315 } |
1305 | 1316 |
1306 | 1317 |
1307 Bounds Typer::Visitor::TypeJSStoreNamed(Node* node) { | 1318 Bounds Typer::Visitor::TypeJSStoreNamed(Node* node) { |
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2114 TYPED_ARRAYS(TYPED_ARRAY_CASE) | 2125 TYPED_ARRAYS(TYPED_ARRAY_CASE) |
2115 #undef TYPED_ARRAY_CASE | 2126 #undef TYPED_ARRAY_CASE |
2116 } | 2127 } |
2117 } | 2128 } |
2118 return Type::Constant(value, zone()); | 2129 return Type::Constant(value, zone()); |
2119 } | 2130 } |
2120 | 2131 |
2121 } // namespace compiler | 2132 } // namespace compiler |
2122 } // namespace internal | 2133 } // namespace internal |
2123 } // namespace v8 | 2134 } // namespace v8 |
OLD | NEW |