| 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 860 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 871 | 871 | 
| 872 Type* Typer::Visitor::JSBitwiseXorTyper(Type* lhs, Type* rhs, Typer* t) { | 872 Type* Typer::Visitor::JSBitwiseXorTyper(Type* lhs, Type* rhs, Typer* t) { | 
| 873   lhs = NumberToInt32(ToNumber(lhs, t), t); | 873   lhs = NumberToInt32(ToNumber(lhs, t), t); | 
| 874   rhs = NumberToInt32(ToNumber(rhs, t), t); | 874   rhs = NumberToInt32(ToNumber(rhs, t), t); | 
| 875   double lmin = lhs->Min(); | 875   double lmin = lhs->Min(); | 
| 876   double rmin = rhs->Min(); | 876   double rmin = rhs->Min(); | 
| 877   double lmax = lhs->Max(); | 877   double lmax = lhs->Max(); | 
| 878   double rmax = rhs->Max(); | 878   double rmax = rhs->Max(); | 
| 879   if ((lmin >= 0 && rmin >= 0) || (lmax < 0 && rmax < 0)) { | 879   if ((lmin >= 0 && rmin >= 0) || (lmax < 0 && rmax < 0)) { | 
| 880     // Xor-ing negative or non-negative values results in a non-negative value. | 880     // Xor-ing negative or non-negative values results in a non-negative value. | 
| 881     return Type::NonNegativeSigned32(); | 881     return Type::Unsigned31(); | 
| 882   } | 882   } | 
| 883   if ((lmax < 0 && rmin >= 0) || (lmin >= 0 && rmax < 0)) { | 883   if ((lmax < 0 && rmin >= 0) || (lmin >= 0 && rmax < 0)) { | 
| 884     // Xor-ing a negative and a non-negative value results in a negative value. | 884     // Xor-ing a negative and a non-negative value results in a negative value. | 
| 885     // TODO(jarin) Use a range here. | 885     // TODO(jarin) Use a range here. | 
| 886     return Type::NegativeSigned32(); | 886     return Type::Negative32(); | 
| 887   } | 887   } | 
| 888   return Type::Signed32(); | 888   return Type::Signed32(); | 
| 889 } | 889 } | 
| 890 | 890 | 
| 891 | 891 | 
| 892 Type* Typer::Visitor::JSShiftLeftTyper(Type* lhs, Type* rhs, Typer* t) { | 892 Type* Typer::Visitor::JSShiftLeftTyper(Type* lhs, Type* rhs, Typer* t) { | 
| 893   return Type::Signed32(); | 893   return Type::Signed32(); | 
| 894 } | 894 } | 
| 895 | 895 | 
| 896 | 896 | 
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1241   return Bounds::Unbounded(zone()); | 1241   return Bounds::Unbounded(zone()); | 
| 1242 } | 1242 } | 
| 1243 | 1243 | 
| 1244 | 1244 | 
| 1245 // Returns a somewhat larger range if we previously assigned | 1245 // Returns a somewhat larger range if we previously assigned | 
| 1246 // a (smaller) range to this node. This is used  to speed up | 1246 // a (smaller) range to this node. This is used  to speed up | 
| 1247 // the fixpoint calculation in case there appears to be a loop | 1247 // the fixpoint calculation in case there appears to be a loop | 
| 1248 // in the graph. In the current implementation, we are | 1248 // in the graph. In the current implementation, we are | 
| 1249 // increasing the limits to the closest power of two. | 1249 // increasing the limits to the closest power of two. | 
| 1250 Type* Typer::Visitor::Weaken(Type* current_type, Type* previous_type) { | 1250 Type* Typer::Visitor::Weaken(Type* current_type, Type* previous_type) { | 
| 1251   Type::RangeType* previous = previous_type->GetRange(); | 1251   // If the types have nothing to do with integers, return the types. | 
| 1252   Type::RangeType* current = current_type->GetRange(); | 1252   if (!current_type->Maybe(typer_->integer) || | 
| 1253   if (previous != NULL && current != NULL) { | 1253       !previous_type->Maybe(typer_->integer)) { | 
| 1254     double current_min = current->Min()->Number(); | 1254     return current_type; | 
| 1255     Handle<Object> new_min = current->Min(); | 1255   } | 
| 1256 | 1256 | 
| 1257     // Find the closest lower entry in the list of allowed | 1257   Type* previous_number = | 
| 1258     // minima (or negative infinity if there is no such entry). | 1258       Type::Intersect(previous_type, typer_->integer, zone()); | 
| 1259     if (current_min != previous->Min()->Number()) { | 1259   Type* current_number = Type::Intersect(current_type, typer_->integer, zone()); | 
| 1260       new_min = typer_->integer->AsRange()->Min(); | 1260   if (!current_number->IsRange() || !previous_number->IsRange()) { | 
| 1261       for (const auto val : typer_->weaken_min_limits_) { | 1261     return current_type; | 
| 1262         if (val->Number() <= current_min) { | 1262   } | 
| 1263           new_min = val; | 1263 | 
| 1264           break; | 1264   Type::RangeType* previous = previous_number->AsRange(); | 
| 1265         } | 1265   Type::RangeType* current = current_number->AsRange(); | 
|  | 1266 | 
|  | 1267   double current_min = current->Min()->Number(); | 
|  | 1268   Handle<Object> new_min = current->Min(); | 
|  | 1269 | 
|  | 1270   // Find the closest lower entry in the list of allowed | 
|  | 1271   // minima (or negative infinity if there is no such entry). | 
|  | 1272   if (current_min != previous->Min()->Number()) { | 
|  | 1273     new_min = typer_->integer->AsRange()->Min(); | 
|  | 1274     for (const auto val : typer_->weaken_min_limits_) { | 
|  | 1275       if (val->Number() <= current_min) { | 
|  | 1276         new_min = val; | 
|  | 1277         break; | 
| 1266       } | 1278       } | 
| 1267     } | 1279     } | 
|  | 1280   } | 
| 1268 | 1281 | 
| 1269     double current_max = current->Max()->Number(); | 1282   double current_max = current->Max()->Number(); | 
| 1270     Handle<Object> new_max = current->Max(); | 1283   Handle<Object> new_max = current->Max(); | 
| 1271     // Find the closest greater entry in the list of allowed | 1284   // Find the closest greater entry in the list of allowed | 
| 1272     // maxima (or infinity if there is no such entry). | 1285   // maxima (or infinity if there is no such entry). | 
| 1273     if (current_max != previous->Max()->Number()) { | 1286   if (current_max != previous->Max()->Number()) { | 
| 1274       new_max = typer_->integer->AsRange()->Max(); | 1287     new_max = typer_->integer->AsRange()->Max(); | 
| 1275       for (const auto val : typer_->weaken_max_limits_) { | 1288     for (const auto val : typer_->weaken_max_limits_) { | 
| 1276         if (val->Number() >= current_max) { | 1289       if (val->Number() >= current_max) { | 
| 1277           new_max = val; | 1290         new_max = val; | 
| 1278           break; | 1291         break; | 
| 1279         } |  | 
| 1280       } | 1292       } | 
| 1281     } | 1293     } | 
|  | 1294   } | 
| 1282 | 1295 | 
| 1283     return Type::Union(current_type, | 1296   return Type::Union(current_type, | 
| 1284                        Type::Range(new_min, new_max, typer_->zone()), | 1297                      Type::Range(new_min, new_max, typer_->zone()), | 
| 1285                        typer_->zone()); | 1298                      typer_->zone()); | 
| 1286   } |  | 
| 1287   return current_type; |  | 
| 1288 } | 1299 } | 
| 1289 | 1300 | 
| 1290 | 1301 | 
| 1291 Bounds Typer::Visitor::TypeJSStoreProperty(Node* node) { | 1302 Bounds Typer::Visitor::TypeJSStoreProperty(Node* node) { | 
| 1292   UNREACHABLE(); | 1303   UNREACHABLE(); | 
| 1293   return Bounds(); | 1304   return Bounds(); | 
| 1294 } | 1305 } | 
| 1295 | 1306 | 
| 1296 | 1307 | 
| 1297 Bounds Typer::Visitor::TypeJSStoreNamed(Node* node) { | 1308 Bounds Typer::Visitor::TypeJSStoreNamed(Node* node) { | 
| (...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2100       TYPED_ARRAYS(TYPED_ARRAY_CASE) | 2111       TYPED_ARRAYS(TYPED_ARRAY_CASE) | 
| 2101 #undef TYPED_ARRAY_CASE | 2112 #undef TYPED_ARRAY_CASE | 
| 2102     } | 2113     } | 
| 2103   } | 2114   } | 
| 2104   return Type::Constant(value, zone()); | 2115   return Type::Constant(value, zone()); | 
| 2105 } | 2116 } | 
| 2106 | 2117 | 
| 2107 }  // namespace compiler | 2118 }  // namespace compiler | 
| 2108 }  // namespace internal | 2119 }  // namespace internal | 
| 2109 }  // namespace v8 | 2120 }  // namespace v8 | 
| OLD | NEW | 
|---|