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 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
863 | 863 |
864 Type* Typer::Visitor::JSBitwiseXorTyper(Type* lhs, Type* rhs, Typer* t) { | 864 Type* Typer::Visitor::JSBitwiseXorTyper(Type* lhs, Type* rhs, Typer* t) { |
865 lhs = NumberToInt32(ToNumber(lhs, t), t); | 865 lhs = NumberToInt32(ToNumber(lhs, t), t); |
866 rhs = NumberToInt32(ToNumber(rhs, t), t); | 866 rhs = NumberToInt32(ToNumber(rhs, t), t); |
867 double lmin = lhs->Min(); | 867 double lmin = lhs->Min(); |
868 double rmin = rhs->Min(); | 868 double rmin = rhs->Min(); |
869 double lmax = lhs->Max(); | 869 double lmax = lhs->Max(); |
870 double rmax = rhs->Max(); | 870 double rmax = rhs->Max(); |
871 if ((lmin >= 0 && rmin >= 0) || (lmax < 0 && rmax < 0)) { | 871 if ((lmin >= 0 && rmin >= 0) || (lmax < 0 && rmax < 0)) { |
872 // Xor-ing negative or non-negative values results in a non-negative value. | 872 // Xor-ing negative or non-negative values results in a non-negative value. |
873 return Type::NonNegativeSigned32(); | 873 return Type::Unsigned31(); |
rossberg
2014/12/12 13:57:50
Similarly here.
Jarin
2015/01/08 14:30:27
This is Unsigned31, so there is no Small* alternat
rossberg
2015/01/15 15:15:11
Ah, right. I would prefer the name NonNegative32 f
Jarin
2015/01/16 16:28:39
That's how it was and I changed it because you tho
rossberg
2015/01/19 11:43:56
Then I was wrong. :)
| |
874 } | 874 } |
875 if ((lmax < 0 && rmin >= 0) || (lmin >= 0 && rmax < 0)) { | 875 if ((lmax < 0 && rmin >= 0) || (lmin >= 0 && rmax < 0)) { |
876 // Xor-ing a negative and a non-negative value results in a negative value. | 876 // Xor-ing a negative and a non-negative value results in a negative value. |
877 // TODO(jarin) Use a range here. | 877 // TODO(jarin) Use a range here. |
878 return Type::NegativeSigned32(); | 878 return Type::Negative32(); |
879 } | 879 } |
880 return Type::Signed32(); | 880 return Type::Signed32(); |
881 } | 881 } |
882 | 882 |
883 | 883 |
884 Type* Typer::Visitor::JSShiftLeftTyper(Type* lhs, Type* rhs, Typer* t) { | 884 Type* Typer::Visitor::JSShiftLeftTyper(Type* lhs, Type* rhs, Typer* t) { |
885 return Type::Signed32(); | 885 return Type::Signed32(); |
886 } | 886 } |
887 | 887 |
888 | 888 |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1233 return Bounds::Unbounded(zone()); | 1233 return Bounds::Unbounded(zone()); |
1234 } | 1234 } |
1235 | 1235 |
1236 | 1236 |
1237 // Returns a somewhat larger range if we previously assigned | 1237 // Returns a somewhat larger range if we previously assigned |
1238 // a (smaller) range to this node. This is used to speed up | 1238 // a (smaller) range to this node. This is used to speed up |
1239 // the fixpoint calculation in case there appears to be a loop | 1239 // the fixpoint calculation in case there appears to be a loop |
1240 // in the graph. In the current implementation, we are | 1240 // in the graph. In the current implementation, we are |
1241 // increasing the limits to the closest power of two. | 1241 // increasing the limits to the closest power of two. |
1242 Type* Typer::Visitor::Weaken(Type* current_type, Type* previous_type) { | 1242 Type* Typer::Visitor::Weaken(Type* current_type, Type* previous_type) { |
1243 Type::RangeType* previous = previous_type->GetRange(); | 1243 // If the types have nothing to do with integers, return the types. |
1244 Type::RangeType* current = current_type->GetRange(); | 1244 if (!current_type->Maybe(typer_->integer) || |
1245 if (previous != NULL && current != NULL) { | 1245 !previous_type->Maybe(typer_->integer)) { |
1246 double current_min = current->Min()->Number(); | 1246 return current_type; |
1247 Handle<Object> new_min = current->Min(); | 1247 } |
1248 | 1248 |
1249 // Find the closest lower entry in the list of allowed | 1249 Type* previous_number = |
1250 // minima (or negative infinity if there is no such entry). | 1250 Type::Intersect(previous_type, typer_->integer, zone()); |
1251 if (current_min != previous->Min()->Number()) { | 1251 Type* current_number = Type::Intersect(current_type, typer_->integer, zone()); |
1252 new_min = typer_->integer->AsRange()->Min(); | 1252 if (!current_number->IsRange() || !previous_number->IsRange()) { |
rossberg
2014/12/12 13:57:50
Hm, I wish we could avoid IsRange as well. It's on
Jarin
2015/01/08 14:30:27
As discussed online, I will try to express this us
| |
1253 for (const auto val : typer_->weaken_min_limits_) { | 1253 return current_type; |
1254 if (val->Number() <= current_min) { | 1254 } |
1255 new_min = val; | 1255 |
1256 break; | 1256 Type::RangeType* previous = previous_number->AsRange(); |
1257 } | 1257 Type::RangeType* current = current_number->AsRange(); |
1258 | |
1259 double current_min = current->Min()->Number(); | |
1260 Handle<Object> new_min = current->Min(); | |
1261 | |
1262 // Find the closest lower entry in the list of allowed | |
1263 // minima (or negative infinity if there is no such entry). | |
1264 if (current_min != previous->Min()->Number()) { | |
1265 new_min = typer_->integer->AsRange()->Min(); | |
1266 for (const auto val : typer_->weaken_min_limits_) { | |
1267 if (val->Number() <= current_min) { | |
1268 new_min = val; | |
1269 break; | |
1258 } | 1270 } |
1259 } | 1271 } |
1272 } | |
1260 | 1273 |
1261 double current_max = current->Max()->Number(); | 1274 double current_max = current->Max()->Number(); |
1262 Handle<Object> new_max = current->Max(); | 1275 Handle<Object> new_max = current->Max(); |
1263 // Find the closest greater entry in the list of allowed | 1276 // Find the closest greater entry in the list of allowed |
1264 // maxima (or infinity if there is no such entry). | 1277 // maxima (or infinity if there is no such entry). |
1265 if (current_max != previous->Max()->Number()) { | 1278 if (current_max != previous->Max()->Number()) { |
1266 new_max = typer_->integer->AsRange()->Max(); | 1279 new_max = typer_->integer->AsRange()->Max(); |
1267 for (const auto val : typer_->weaken_max_limits_) { | 1280 for (const auto val : typer_->weaken_max_limits_) { |
1268 if (val->Number() >= current_max) { | 1281 if (val->Number() >= current_max) { |
1269 new_max = val; | 1282 new_max = val; |
1270 break; | 1283 break; |
1271 } | |
1272 } | 1284 } |
1273 } | 1285 } |
1286 } | |
1274 | 1287 |
1275 return Type::Union(current_type, | 1288 return Type::Union(current_type, |
1276 Type::Range(new_min, new_max, typer_->zone()), | 1289 Type::Range(new_min, new_max, typer_->zone()), |
1277 typer_->zone()); | 1290 typer_->zone()); |
1278 } | |
1279 return current_type; | |
1280 } | 1291 } |
1281 | 1292 |
1282 | 1293 |
1283 Bounds Typer::Visitor::TypeJSStoreProperty(Node* node) { | 1294 Bounds Typer::Visitor::TypeJSStoreProperty(Node* node) { |
1284 UNREACHABLE(); | 1295 UNREACHABLE(); |
1285 return Bounds(); | 1296 return Bounds(); |
1286 } | 1297 } |
1287 | 1298 |
1288 | 1299 |
1289 Bounds Typer::Visitor::TypeJSStoreNamed(Node* node) { | 1300 Bounds Typer::Visitor::TypeJSStoreNamed(Node* node) { |
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2092 // TODO(rossberg): Do we want some ClampedArray type to express this? | 2103 // TODO(rossberg): Do we want some ClampedArray type to express this? |
2093 break; | 2104 break; |
2094 } | 2105 } |
2095 } | 2106 } |
2096 return Type::Constant(value, zone()); | 2107 return Type::Constant(value, zone()); |
2097 } | 2108 } |
2098 | 2109 |
2099 } // namespace compiler | 2110 } // namespace compiler |
2100 } // namespace internal | 2111 } // namespace internal |
2101 } // namespace v8 | 2112 } // namespace v8 |
OLD | NEW |