Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: src/compiler/typer.cc

Issue 868583002: Revert of Steps towards unification of number bitset and range types. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/change-lowering.cc ('k') | src/types.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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::Unsigned31(); 891 return Type::NonNegativeSigned32();
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::Negative32(); 896 return Type::NegativeSigned32();
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
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 // If the types have nothing to do with integers, return the types. 1261 Type::RangeType* previous = previous_type->GetRange();
1262 if (!current_type->Maybe(typer_->integer) || 1262 Type::RangeType* current = current_type->GetRange();
1263 !previous_type->Maybe(typer_->integer)) { 1263 if (previous != NULL && current != NULL) {
1264 return current_type; 1264 double current_min = current->Min()->Number();
1265 } 1265 Handle<Object> new_min = current->Min();
1266 1266
1267 Type* previous_number = 1267 // Find the closest lower entry in the list of allowed
1268 Type::Intersect(previous_type, typer_->integer, zone()); 1268 // minima (or negative infinity if there is no such entry).
1269 Type* current_number = Type::Intersect(current_type, typer_->integer, zone()); 1269 if (current_min != previous->Min()->Number()) {
1270 if (!current_number->IsRange() || !previous_number->IsRange()) { 1270 new_min = typer_->integer->AsRange()->Min();
1271 return current_type; 1271 for (const auto val : typer_->weaken_min_limits_) {
1272 } 1272 if (val->Number() <= current_min) {
1273 1273 new_min = val;
1274 Type::RangeType* previous = previous_number->AsRange(); 1274 break;
1275 Type::RangeType* current = current_number->AsRange(); 1275 }
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;
1288 } 1276 }
1289 } 1277 }
1290 }
1291 1278
1292 double current_max = current->Max()->Number(); 1279 double current_max = current->Max()->Number();
1293 Handle<Object> new_max = current->Max(); 1280 Handle<Object> new_max = current->Max();
1294 // Find the closest greater entry in the list of allowed 1281 // Find the closest greater entry in the list of allowed
1295 // maxima (or infinity if there is no such entry). 1282 // maxima (or infinity if there is no such entry).
1296 if (current_max != previous->Max()->Number()) { 1283 if (current_max != previous->Max()->Number()) {
1297 new_max = typer_->integer->AsRange()->Max(); 1284 new_max = typer_->integer->AsRange()->Max();
1298 for (const auto val : typer_->weaken_max_limits_) { 1285 for (const auto val : typer_->weaken_max_limits_) {
1299 if (val->Number() >= current_max) { 1286 if (val->Number() >= current_max) {
1300 new_max = val; 1287 new_max = val;
1301 break; 1288 break;
1289 }
1302 } 1290 }
1303 } 1291 }
1292
1293 return Type::Union(current_type,
1294 Type::Range(new_min, new_max, typer_->zone()),
1295 typer_->zone());
1304 } 1296 }
1305 1297 return current_type;
1306 return Type::Union(current_type,
1307 Type::Range(new_min, new_max, typer_->zone()),
1308 typer_->zone());
1309 } 1298 }
1310 1299
1311 1300
1312 Bounds Typer::Visitor::TypeJSStoreProperty(Node* node) { 1301 Bounds Typer::Visitor::TypeJSStoreProperty(Node* node) {
1313 UNREACHABLE(); 1302 UNREACHABLE();
1314 return Bounds(); 1303 return Bounds();
1315 } 1304 }
1316 1305
1317 1306
1318 Bounds Typer::Visitor::TypeJSStoreNamed(Node* node) { 1307 Bounds Typer::Visitor::TypeJSStoreNamed(Node* node) {
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after
2125 TYPED_ARRAYS(TYPED_ARRAY_CASE) 2114 TYPED_ARRAYS(TYPED_ARRAY_CASE)
2126 #undef TYPED_ARRAY_CASE 2115 #undef TYPED_ARRAY_CASE
2127 } 2116 }
2128 } 2117 }
2129 return Type::Constant(value, zone()); 2118 return Type::Constant(value, zone());
2130 } 2119 }
2131 2120
2132 } // namespace compiler 2121 } // namespace compiler
2133 } // namespace internal 2122 } // namespace internal
2134 } // namespace v8 2123 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/change-lowering.cc ('k') | src/types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698