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