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