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) | |
Benedikt Meurer
2015/01/26 07:23:47
Nit: please add { and }.
| |
920 max = static_cast<int>(max) >> static_cast<int>(rhs->Min()); | |
919 } | 921 } |
920 if (lhs->Max() < 0) { | 922 if (lhs->Max() < 0) { |
921 // Right-shifting a negative value cannot make it non-negative, nor smaller. | 923 // Right-shifting a negative value cannot make it non-negative, nor smaller. |
922 min = std::max(min, lhs->Min()); | 924 min = std::max(min, lhs->Min()); |
923 max = std::min(max, -1.0); | 925 max = std::min(max, -1.0); |
926 if (rhs->Min() > 0 && rhs->Max() <= 31) | |
Benedikt Meurer
2015/01/26 07:23:47
Nit: please add { and }.
| |
927 min = static_cast<int>(min) >> static_cast<int>(rhs->Min()); | |
924 } | 928 } |
925 if (rhs->Min() > 0 && rhs->Max() <= 31) { | 929 if (rhs->Min() > 0 && rhs->Max() <= 31) { |
926 // Right-shifting by a positive value yields a small integer value. | 930 // Right-shifting by a positive value yields a small integer value. |
927 double shift_min = kMinInt >> static_cast<int>(rhs->Min()); | 931 double shift_min = kMinInt >> static_cast<int>(rhs->Min()); |
928 double shift_max = kMaxInt >> static_cast<int>(rhs->Min()); | 932 double shift_max = kMaxInt >> static_cast<int>(rhs->Min()); |
929 min = std::max(min, shift_min); | 933 min = std::max(min, shift_min); |
930 max = std::min(max, shift_max); | 934 max = std::min(max, shift_max); |
931 } | 935 } |
932 // TODO(jarin) Ideally, the following micro-optimization should be performed | 936 // TODO(jarin) Ideally, the following micro-optimization should be performed |
933 // by the type constructor. | 937 // by the type constructor. |
(...skipping 1183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2117 TYPED_ARRAYS(TYPED_ARRAY_CASE) | 2121 TYPED_ARRAYS(TYPED_ARRAY_CASE) |
2118 #undef TYPED_ARRAY_CASE | 2122 #undef TYPED_ARRAY_CASE |
2119 } | 2123 } |
2120 } | 2124 } |
2121 return Type::Constant(value, zone()); | 2125 return Type::Constant(value, zone()); |
2122 } | 2126 } |
2123 | 2127 |
2124 } // namespace compiler | 2128 } // namespace compiler |
2125 } // namespace internal | 2129 } // namespace internal |
2126 } // namespace v8 | 2130 } // namespace v8 |
OLD | NEW |