| 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/js-operator.h" | 7 #include "src/compiler/js-operator.h" |
| 8 #include "src/compiler/node.h" | 8 #include "src/compiler/node.h" |
| 9 #include "src/compiler/node-properties-inl.h" | 9 #include "src/compiler/node-properties-inl.h" |
| 10 #include "src/compiler/node-properties.h" | 10 #include "src/compiler/node-properties.h" |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 Type* Typer::Visitor::ToString(Type* type, Typer* t) { | 460 Type* Typer::Visitor::ToString(Type* type, Typer* t) { |
| 461 if (type->Is(Type::String())) return type; | 461 if (type->Is(Type::String())) return type; |
| 462 return Type::String(); | 462 return Type::String(); |
| 463 } | 463 } |
| 464 | 464 |
| 465 | 465 |
| 466 Type* Typer::Visitor::NumberToInt32(Type* type, Typer* t) { | 466 Type* Typer::Visitor::NumberToInt32(Type* type, Typer* t) { |
| 467 // TODO(neis): DCHECK(type->Is(Type::Number())); | 467 // TODO(neis): DCHECK(type->Is(Type::Number())); |
| 468 if (type->Is(Type::Signed32())) return type; | 468 if (type->Is(Type::Signed32())) return type; |
| 469 if (type->Is(t->zeroish)) return t->singleton_zero; | 469 if (type->Is(t->zeroish)) return t->singleton_zero; |
| 470 Type* intish = Type::Union(Type::Signed32(), t->zeroish, t->zone()); |
| 471 if (type->Is(intish)) { |
| 472 return Type::Intersect(Type::Signed32(), type, t->zone()); |
| 473 } |
| 470 return Type::Signed32(); | 474 return Type::Signed32(); |
| 471 } | 475 } |
| 472 | 476 |
| 473 | 477 |
| 474 Type* Typer::Visitor::NumberToUint32(Type* type, Typer* t) { | 478 Type* Typer::Visitor::NumberToUint32(Type* type, Typer* t) { |
| 475 // TODO(neis): DCHECK(type->Is(Type::Number())); | 479 // TODO(neis): DCHECK(type->Is(Type::Number())); |
| 476 if (type->Is(Type::Unsigned32())) return type; | 480 if (type->Is(Type::Unsigned32())) return type; |
| 477 if (type->Is(t->zeroish)) return t->singleton_zero; | 481 if (type->Is(t->zeroish)) return t->singleton_zero; |
| 478 return Type::Unsigned32(); | 482 return Type::Unsigned32(); |
| 479 } | 483 } |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 // Or-ing any two values results in a value no smaller than their minimum. | 722 // Or-ing any two values results in a value no smaller than their minimum. |
| 719 // Even no smaller than their maximum if both values are non-negative. | 723 // Even no smaller than their maximum if both values are non-negative. |
| 720 Handle<Object> min = f->NewNumber( | 724 Handle<Object> min = f->NewNumber( |
| 721 lmin >= 0 && rmin >= 0 ? std::max(lmin, rmin) : std::min(lmin, rmin)); | 725 lmin >= 0 && rmin >= 0 ? std::max(lmin, rmin) : std::min(lmin, rmin)); |
| 722 if (lmax < 0 || rmax < 0) { | 726 if (lmax < 0 || rmax < 0) { |
| 723 // Or-ing two values of which at least one is negative results in a negative | 727 // Or-ing two values of which at least one is negative results in a negative |
| 724 // value. | 728 // value. |
| 725 Handle<Object> max = f->NewNumber(-1); | 729 Handle<Object> max = f->NewNumber(-1); |
| 726 return Type::Range(min, max, t->zone()); | 730 return Type::Range(min, max, t->zone()); |
| 727 } | 731 } |
| 732 if (rmax == 0 && rmin == 0) { |
| 733 Handle<Object> max = f->NewNumber(lmax); |
| 734 return Type::Range(min, max, t->zone()); |
| 735 } |
| 728 Handle<Object> max = f->NewNumber(Type::Signed32()->Max()); | 736 Handle<Object> max = f->NewNumber(Type::Signed32()->Max()); |
| 729 return Type::Range(min, max, t->zone()); | 737 return Type::Range(min, max, t->zone()); |
| 730 // TODO(neis): Be precise for singleton inputs, here and elsewhere. | 738 // TODO(neis): Be precise for singleton inputs, here and elsewhere. |
| 731 } | 739 } |
| 732 | 740 |
| 733 | 741 |
| 734 Type* Typer::Visitor::JSBitwiseAndTyper(Type* lhs, Type* rhs, Typer* t) { | 742 Type* Typer::Visitor::JSBitwiseAndTyper(Type* lhs, Type* rhs, Typer* t) { |
| 735 Factory* f = t->isolate()->factory(); | 743 Factory* f = t->isolate()->factory(); |
| 736 lhs = NumberToInt32(ToNumber(lhs, t), t); | 744 lhs = NumberToInt32(ToNumber(lhs, t), t); |
| 737 rhs = NumberToInt32(ToNumber(rhs, t), t); | 745 rhs = NumberToInt32(ToNumber(rhs, t), t); |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1026 | 1034 |
| 1027 if (lhs->Maybe(Type::NaN()) || rhs->Maybe(t->zeroish) || | 1035 if (lhs->Maybe(Type::NaN()) || rhs->Maybe(t->zeroish) || |
| 1028 lhs->Min() == -V8_INFINITY || lhs->Max() == +V8_INFINITY) { | 1036 lhs->Min() == -V8_INFINITY || lhs->Max() == +V8_INFINITY) { |
| 1029 // Result maybe NaN. | 1037 // Result maybe NaN. |
| 1030 return Type::Number(); | 1038 return Type::Number(); |
| 1031 } | 1039 } |
| 1032 | 1040 |
| 1033 lhs = Rangify(lhs, t); | 1041 lhs = Rangify(lhs, t); |
| 1034 rhs = Rangify(rhs, t); | 1042 rhs = Rangify(rhs, t); |
| 1035 if (lhs->IsRange() && rhs->IsRange()) { | 1043 if (lhs->IsRange() && rhs->IsRange()) { |
| 1036 // TODO(titzer): fix me. | 1044 return JSModulusRanger(lhs->AsRange(), rhs->AsRange(), t); |
| 1037 // return JSModulusRanger(lhs->AsRange(), rhs->AsRange(), t); | |
| 1038 } | 1045 } |
| 1039 return Type::OrderedNumber(); | 1046 return Type::OrderedNumber(); |
| 1040 } | 1047 } |
| 1041 | 1048 |
| 1042 | 1049 |
| 1043 // JS unary operators. | 1050 // JS unary operators. |
| 1044 | 1051 |
| 1045 | 1052 |
| 1046 Type* Typer::Visitor::JSUnaryNotTyper(Type* type, Typer* t) { | 1053 Type* Typer::Visitor::JSUnaryNotTyper(Type* type, Typer* t) { |
| 1047 return Invert(ToBoolean(type, t), t); | 1054 return Invert(ToBoolean(type, t), t); |
| (...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1933 return typer_->float64_array_fun_; | 1940 return typer_->float64_array_fun_; |
| 1934 } | 1941 } |
| 1935 } | 1942 } |
| 1936 } | 1943 } |
| 1937 return Type::Constant(value, zone()); | 1944 return Type::Constant(value, zone()); |
| 1938 } | 1945 } |
| 1939 | 1946 |
| 1940 } | 1947 } |
| 1941 } | 1948 } |
| 1942 } // namespace v8::internal::compiler | 1949 } // namespace v8::internal::compiler |
| OLD | NEW |