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

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

Issue 788313002: Reland of "Avoid number range holes in bitset types." (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 6 years 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 | « no previous file | 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 Type* unsigned32 = Type::Unsigned32(); 168 Type* unsigned32 = Type::Unsigned32();
169 Type* nan_or_minuszero = Type::Union(Type::NaN(), Type::MinusZero(), zone); 169 Type* nan_or_minuszero = Type::Union(Type::NaN(), Type::MinusZero(), zone);
170 Type* truncating_to_zero = 170 Type* truncating_to_zero =
171 Type::Union(Type::Union(Type::Constant(infinity, zone), 171 Type::Union(Type::Union(Type::Constant(infinity, zone),
172 Type::Constant(minusinfinity, zone), zone), 172 Type::Constant(minusinfinity, zone), zone),
173 nan_or_minuszero, zone); 173 nan_or_minuszero, zone);
174 174
175 boolean_or_number = Type::Union(Type::Boolean(), Type::Number(), zone); 175 boolean_or_number = Type::Union(Type::Boolean(), Type::Number(), zone);
176 undefined_or_null = Type::Union(Type::Undefined(), Type::Null(), zone); 176 undefined_or_null = Type::Union(Type::Undefined(), Type::Null(), zone);
177 undefined_or_number = Type::Union(Type::Undefined(), Type::Number(), zone); 177 undefined_or_number = Type::Union(Type::Undefined(), Type::Number(), zone);
178 negative_signed32 = Type::Union(
179 Type::SignedSmall(), Type::OtherSigned32(), zone);
180 non_negative_signed32 = Type::Union(
181 Type::UnsignedSmall(), Type::OtherUnsigned31(), zone);
182 singleton_false = Type::Constant(f->false_value(), zone); 178 singleton_false = Type::Constant(f->false_value(), zone);
183 singleton_true = Type::Constant(f->true_value(), zone); 179 singleton_true = Type::Constant(f->true_value(), zone);
184 singleton_zero = Type::Range(zero, zero, zone); 180 singleton_zero = Type::Range(zero, zero, zone);
185 singleton_one = Type::Range(one, one, zone); 181 singleton_one = Type::Range(one, one, zone);
186 zero_or_one = Type::Union(singleton_zero, singleton_one, zone); 182 zero_or_one = Type::Union(singleton_zero, singleton_one, zone);
187 zeroish = Type::Union(singleton_zero, nan_or_minuszero, zone); 183 zeroish = Type::Union(singleton_zero, nan_or_minuszero, zone);
188 signed32ish = Type::Union(signed32, truncating_to_zero, zone); 184 signed32ish = Type::Union(signed32, truncating_to_zero, zone);
189 unsigned32ish = Type::Union(unsigned32, truncating_to_zero, zone); 185 unsigned32ish = Type::Union(unsigned32, truncating_to_zero, zone);
190 falsish = Type::Union(Type::Undetectable(), 186 falsish = Type::Union(Type::Undetectable(),
191 Type::Union(zeroish, undefined_or_null, zone), zone); 187 Type::Union(zeroish, undefined_or_null, zone), zone);
192 integer = Type::Range(minusinfinity, infinity, zone); 188 integer = Type::Range(minusinfinity, infinity, zone);
193 weakint = Type::Union(integer, nan_or_minuszero, zone); 189 weakint = Type::Union(integer, nan_or_minuszero, zone);
194 190
195 number_fun0_ = Type::Function(number, zone); 191 number_fun0_ = Type::Function(number, zone);
196 number_fun1_ = Type::Function(number, number, zone); 192 number_fun1_ = Type::Function(number, number, zone);
197 number_fun2_ = Type::Function(number, number, number, zone); 193 number_fun2_ = Type::Function(number, number, number, zone);
198 194
199 weakint_fun1_ = Type::Function(weakint, number, zone); 195 weakint_fun1_ = Type::Function(weakint, number, zone);
200 random_fun_ = Type::Function(Type::Union( 196 random_fun_ = Type::Function(Type::OrderedNumber(), zone);
201 Type::UnsignedSmall(), Type::OtherNumber(), zone), zone);
202 197
203 const int limits_count = 20; 198 const int limits_count = 20;
204 199
205 weaken_min_limits_.reserve(limits_count + 1); 200 weaken_min_limits_.reserve(limits_count + 1);
206 weaken_max_limits_.reserve(limits_count + 1); 201 weaken_max_limits_.reserve(limits_count + 1);
207 202
208 double limit = 1 << 30; 203 double limit = 1 << 30;
209 weaken_min_limits_.push_back(f->NewNumber(0)); 204 weaken_min_limits_.push_back(f->NewNumber(0));
210 weaken_max_limits_.push_back(f->NewNumber(0)); 205 weaken_max_limits_.push_back(f->NewNumber(0));
211 for (int i = 0; i < limits_count; i++) { 206 for (int i = 0; i < limits_count; i++) {
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 863
869 Type* Typer::Visitor::JSBitwiseXorTyper(Type* lhs, Type* rhs, Typer* t) { 864 Type* Typer::Visitor::JSBitwiseXorTyper(Type* lhs, Type* rhs, Typer* t) {
870 lhs = NumberToInt32(ToNumber(lhs, t), t); 865 lhs = NumberToInt32(ToNumber(lhs, t), t);
871 rhs = NumberToInt32(ToNumber(rhs, t), t); 866 rhs = NumberToInt32(ToNumber(rhs, t), t);
872 double lmin = lhs->Min(); 867 double lmin = lhs->Min();
873 double rmin = rhs->Min(); 868 double rmin = rhs->Min();
874 double lmax = lhs->Max(); 869 double lmax = lhs->Max();
875 double rmax = rhs->Max(); 870 double rmax = rhs->Max();
876 if ((lmin >= 0 && rmin >= 0) || (lmax < 0 && rmax < 0)) { 871 if ((lmin >= 0 && rmin >= 0) || (lmax < 0 && rmax < 0)) {
877 // 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.
878 return t->non_negative_signed32; 873 return Type::NonNegativeSigned32();
879 } 874 }
880 if ((lmax < 0 && rmin >= 0) || (lmin >= 0 && rmax < 0)) { 875 if ((lmax < 0 && rmin >= 0) || (lmin >= 0 && rmax < 0)) {
881 // 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.
882 return t->negative_signed32; 877 // TODO(jarin) Use a range here.
878 return Type::NegativeSigned32();
883 } 879 }
884 return Type::Signed32(); 880 return Type::Signed32();
885 } 881 }
886 882
887 883
888 Type* Typer::Visitor::JSShiftLeftTyper(Type* lhs, Type* rhs, Typer* t) { 884 Type* Typer::Visitor::JSShiftLeftTyper(Type* lhs, Type* rhs, Typer* t) {
889 return Type::Signed32(); 885 return Type::Signed32();
890 } 886 }
891 887
892 888
(...skipping 1203 matching lines...) Expand 10 before | Expand all | Expand 10 after
2096 // TODO(rossberg): Do we want some ClampedArray type to express this? 2092 // TODO(rossberg): Do we want some ClampedArray type to express this?
2097 break; 2093 break;
2098 } 2094 }
2099 } 2095 }
2100 return Type::Constant(value, zone()); 2096 return Type::Constant(value, zone());
2101 } 2097 }
2102 2098
2103 } // namespace compiler 2099 } // namespace compiler
2104 } // namespace internal 2100 } // namespace internal
2105 } // namespace v8 2101 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698