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

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

Issue 759013003: Avoid number range holes in bitset types. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Another 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 Type* unsigned32 = Type::Unsigned32(); 158 Type* unsigned32 = Type::Unsigned32();
159 Type* nan_or_minuszero = Type::Union(Type::NaN(), Type::MinusZero(), zone); 159 Type* nan_or_minuszero = Type::Union(Type::NaN(), Type::MinusZero(), zone);
160 Type* truncating_to_zero = 160 Type* truncating_to_zero =
161 Type::Union(Type::Union(Type::Constant(infinity, zone), 161 Type::Union(Type::Union(Type::Constant(infinity, zone),
162 Type::Constant(minusinfinity, zone), zone), 162 Type::Constant(minusinfinity, zone), zone),
163 nan_or_minuszero, zone); 163 nan_or_minuszero, zone);
164 164
165 boolean_or_number = Type::Union(Type::Boolean(), Type::Number(), zone); 165 boolean_or_number = Type::Union(Type::Boolean(), Type::Number(), zone);
166 undefined_or_null = Type::Union(Type::Undefined(), Type::Null(), zone); 166 undefined_or_null = Type::Union(Type::Undefined(), Type::Null(), zone);
167 undefined_or_number = Type::Union(Type::Undefined(), Type::Number(), zone); 167 undefined_or_number = Type::Union(Type::Undefined(), Type::Number(), zone);
168 negative_signed32 = Type::Union(
169 Type::SignedSmall(), Type::OtherSigned32(), zone);
170 non_negative_signed32 = Type::Union(
171 Type::UnsignedSmall(), Type::OtherUnsigned31(), zone);
172 singleton_false = Type::Constant(f->false_value(), zone); 168 singleton_false = Type::Constant(f->false_value(), zone);
173 singleton_true = Type::Constant(f->true_value(), zone); 169 singleton_true = Type::Constant(f->true_value(), zone);
174 singleton_zero = Type::Range(zero, zero, zone); 170 singleton_zero = Type::Range(zero, zero, zone);
175 singleton_one = Type::Range(one, one, zone); 171 singleton_one = Type::Range(one, one, zone);
176 zero_or_one = Type::Union(singleton_zero, singleton_one, zone); 172 zero_or_one = Type::Union(singleton_zero, singleton_one, zone);
177 zeroish = Type::Union(singleton_zero, nan_or_minuszero, zone); 173 zeroish = Type::Union(singleton_zero, nan_or_minuszero, zone);
178 signed32ish = Type::Union(signed32, truncating_to_zero, zone); 174 signed32ish = Type::Union(signed32, truncating_to_zero, zone);
179 unsigned32ish = Type::Union(unsigned32, truncating_to_zero, zone); 175 unsigned32ish = Type::Union(unsigned32, truncating_to_zero, zone);
180 falsish = Type::Union(Type::Undetectable(), 176 falsish = Type::Union(Type::Undetectable(),
181 Type::Union(zeroish, undefined_or_null, zone), zone); 177 Type::Union(zeroish, undefined_or_null, zone), zone);
182 integer = Type::Range(minusinfinity, infinity, zone); 178 integer = Type::Range(minusinfinity, infinity, zone);
183 weakint = Type::Union(integer, nan_or_minuszero, zone); 179 weakint = Type::Union(integer, nan_or_minuszero, zone);
184 180
185 signed8_ = Type::Range(f->NewNumber(kMinInt8), f->NewNumber(kMaxInt8), zone); 181 signed8_ = Type::Range(f->NewNumber(kMinInt8), f->NewNumber(kMaxInt8), zone);
186 unsigned8_ = Type::Range(zero, f->NewNumber(kMaxUInt8), zone); 182 unsigned8_ = Type::Range(zero, f->NewNumber(kMaxUInt8), zone);
187 signed16_ = 183 signed16_ =
188 Type::Range(f->NewNumber(kMinInt16), f->NewNumber(kMaxInt16), zone); 184 Type::Range(f->NewNumber(kMinInt16), f->NewNumber(kMaxInt16), zone);
189 unsigned16_ = Type::Range(zero, f->NewNumber(kMaxUInt16), zone); 185 unsigned16_ = Type::Range(zero, f->NewNumber(kMaxUInt16), zone);
190 186
191 number_fun0_ = Type::Function(number, zone); 187 number_fun0_ = Type::Function(number, zone);
192 number_fun1_ = Type::Function(number, number, zone); 188 number_fun1_ = Type::Function(number, number, zone);
193 number_fun2_ = Type::Function(number, number, number, zone); 189 number_fun2_ = Type::Function(number, number, number, zone);
194 190
195 weakint_fun1_ = Type::Function(weakint, number, zone); 191 weakint_fun1_ = Type::Function(weakint, number, zone);
196 random_fun_ = Type::Function(Type::Union( 192 random_fun_ = Type::Function(Type::OrderedNumber(), zone);
197 Type::UnsignedSmall(), Type::OtherNumber(), zone), zone);
198 193
199 const int limits_count = 20; 194 const int limits_count = 20;
200 195
201 weaken_min_limits_.reserve(limits_count + 1); 196 weaken_min_limits_.reserve(limits_count + 1);
202 weaken_max_limits_.reserve(limits_count + 1); 197 weaken_max_limits_.reserve(limits_count + 1);
203 198
204 double limit = 1 << 30; 199 double limit = 1 << 30;
205 weaken_min_limits_.push_back(f->NewNumber(0)); 200 weaken_min_limits_.push_back(f->NewNumber(0));
206 weaken_max_limits_.push_back(f->NewNumber(0)); 201 weaken_max_limits_.push_back(f->NewNumber(0));
207 for (int i = 0; i < limits_count; i++) { 202 for (int i = 0; i < limits_count; i++) {
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 858
864 Type* Typer::Visitor::JSBitwiseXorTyper(Type* lhs, Type* rhs, Typer* t) { 859 Type* Typer::Visitor::JSBitwiseXorTyper(Type* lhs, Type* rhs, Typer* t) {
865 lhs = NumberToInt32(ToNumber(lhs, t), t); 860 lhs = NumberToInt32(ToNumber(lhs, t), t);
866 rhs = NumberToInt32(ToNumber(rhs, t), t); 861 rhs = NumberToInt32(ToNumber(rhs, t), t);
867 double lmin = lhs->Min(); 862 double lmin = lhs->Min();
868 double rmin = rhs->Min(); 863 double rmin = rhs->Min();
869 double lmax = lhs->Max(); 864 double lmax = lhs->Max();
870 double rmax = rhs->Max(); 865 double rmax = rhs->Max();
871 if ((lmin >= 0 && rmin >= 0) || (lmax < 0 && rmax < 0)) { 866 if ((lmin >= 0 && rmin >= 0) || (lmax < 0 && rmax < 0)) {
872 // Xor-ing negative or non-negative values results in a non-negative value. 867 // Xor-ing negative or non-negative values results in a non-negative value.
873 return t->non_negative_signed32; 868 return Type::NonNegativeSigned32();
874 } 869 }
875 if ((lmax < 0 && rmin >= 0) || (lmin >= 0 && rmax < 0)) { 870 if ((lmax < 0 && rmin >= 0) || (lmin >= 0 && rmax < 0)) {
876 // Xor-ing a negative and a non-negative value results in a negative value. 871 // Xor-ing a negative and a non-negative value results in a negative value.
877 return t->negative_signed32; 872 // TODO(jarin) Use a range here.
873 return Type::NegativeSigned32();
878 } 874 }
879 return Type::Signed32(); 875 return Type::Signed32();
880 } 876 }
881 877
882 878
883 Type* Typer::Visitor::JSShiftLeftTyper(Type* lhs, Type* rhs, Typer* t) { 879 Type* Typer::Visitor::JSShiftLeftTyper(Type* lhs, Type* rhs, Typer* t) {
884 return Type::Signed32(); 880 return Type::Signed32();
885 } 881 }
886 882
887 883
(...skipping 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after
2088 return typer_->cache_->Get(kFloat64ArrayFunc); 2084 return typer_->cache_->Get(kFloat64ArrayFunc);
2089 } 2085 }
2090 } 2086 }
2091 } 2087 }
2092 return Type::Constant(value, zone()); 2088 return Type::Constant(value, zone());
2093 } 2089 }
2094 2090
2095 } // namespace compiler 2091 } // namespace compiler
2096 } // namespace internal 2092 } // namespace internal
2097 } // namespace v8 2093 } // 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