| 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 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 909 | 909 |
| 910 Type* Typer::Visitor::JSShiftRightTyper(Type* lhs, Type* rhs, Typer* t) { | 910 Type* Typer::Visitor::JSShiftRightTyper(Type* lhs, Type* rhs, Typer* t) { |
| 911 lhs = NumberToInt32(ToNumber(lhs, t), t); | 911 lhs = NumberToInt32(ToNumber(lhs, t), t); |
| 912 rhs = NumberToUint32(ToNumber(rhs, t), t); | 912 rhs = NumberToUint32(ToNumber(rhs, t), t); |
| 913 double min = kMinInt; | 913 double min = kMinInt; |
| 914 double max = kMaxInt; | 914 double max = kMaxInt; |
| 915 if (lhs->Min() >= 0) { | 915 if (lhs->Min() >= 0) { |
| 916 // Right-shifting a non-negative value cannot make it negative, nor larger. | 916 // Right-shifting a non-negative value cannot make it negative, nor larger. |
| 917 min = std::max(min, 0.0); | 917 min = std::max(min, 0.0); |
| 918 max = std::min(max, lhs->Max()); | 918 max = std::min(max, lhs->Max()); |
| 919 if (rhs->Min() > 0 && rhs->Max() <= 31) { |
| 920 max = static_cast<int>(max) >> static_cast<int>(rhs->Min()); |
| 921 } |
| 919 } | 922 } |
| 920 if (lhs->Max() < 0) { | 923 if (lhs->Max() < 0) { |
| 921 // Right-shifting a negative value cannot make it non-negative, nor smaller. | 924 // Right-shifting a negative value cannot make it non-negative, nor smaller. |
| 922 min = std::max(min, lhs->Min()); | 925 min = std::max(min, lhs->Min()); |
| 923 max = std::min(max, -1.0); | 926 max = std::min(max, -1.0); |
| 927 if (rhs->Min() > 0 && rhs->Max() <= 31) { |
| 928 min = static_cast<int>(min) >> static_cast<int>(rhs->Min()); |
| 929 } |
| 924 } | 930 } |
| 925 if (rhs->Min() > 0 && rhs->Max() <= 31) { | 931 if (rhs->Min() > 0 && rhs->Max() <= 31) { |
| 926 // Right-shifting by a positive value yields a small integer value. | 932 // Right-shifting by a positive value yields a small integer value. |
| 927 double shift_min = kMinInt >> static_cast<int>(rhs->Min()); | 933 double shift_min = kMinInt >> static_cast<int>(rhs->Min()); |
| 928 double shift_max = kMaxInt >> static_cast<int>(rhs->Min()); | 934 double shift_max = kMaxInt >> static_cast<int>(rhs->Min()); |
| 929 min = std::max(min, shift_min); | 935 min = std::max(min, shift_min); |
| 930 max = std::min(max, shift_max); | 936 max = std::min(max, shift_max); |
| 931 } | 937 } |
| 932 // TODO(jarin) Ideally, the following micro-optimization should be performed | 938 // TODO(jarin) Ideally, the following micro-optimization should be performed |
| 933 // by the type constructor. | 939 // by the type constructor. |
| (...skipping 1183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2117 TYPED_ARRAYS(TYPED_ARRAY_CASE) | 2123 TYPED_ARRAYS(TYPED_ARRAY_CASE) |
| 2118 #undef TYPED_ARRAY_CASE | 2124 #undef TYPED_ARRAY_CASE |
| 2119 } | 2125 } |
| 2120 } | 2126 } |
| 2121 return Type::Constant(value, zone()); | 2127 return Type::Constant(value, zone()); |
| 2122 } | 2128 } |
| 2123 | 2129 |
| 2124 } // namespace compiler | 2130 } // namespace compiler |
| 2125 } // namespace internal | 2131 } // namespace internal |
| 2126 } // namespace v8 | 2132 } // namespace v8 |
| OLD | NEW |