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

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

Issue 2706763003: [compiler] Refine typing of NumberShiftRightLogical. (Closed)
Patch Set: Created 3 years, 10 months 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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/compiler/operation-typer.h" 5 #include "src/compiler/operation-typer.h"
6 6
7 #include "src/compiler/common-operator.h" 7 #include "src/compiler/common-operator.h"
8 #include "src/compiler/type-cache.h" 8 #include "src/compiler/type-cache.h"
9 #include "src/compiler/types.h" 9 #include "src/compiler/types.h"
10 #include "src/factory.h" 10 #include "src/factory.h"
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 double max = std::max(max_lhs >> min_rhs, max_lhs >> max_rhs); 857 double max = std::max(max_lhs >> min_rhs, max_lhs >> max_rhs);
858 858
859 if (max == kMaxInt && min == kMinInt) return Type::Signed32(); 859 if (max == kMaxInt && min == kMinInt) return Type::Signed32();
860 return Type::Range(min, max, zone()); 860 return Type::Range(min, max, zone());
861 } 861 }
862 862
863 Type* OperationTyper::NumberShiftRightLogical(Type* lhs, Type* rhs) { 863 Type* OperationTyper::NumberShiftRightLogical(Type* lhs, Type* rhs) {
864 DCHECK(lhs->Is(Type::Number())); 864 DCHECK(lhs->Is(Type::Number()));
865 DCHECK(rhs->Is(Type::Number())); 865 DCHECK(rhs->Is(Type::Number()));
866 866
867 if (!lhs->IsInhabited()) return Type::None(); 867 if (!lhs->IsInhabited() || !rhs->IsInhabited()) return Type::None();
868 868
869 lhs = NumberToUint32(lhs); 869 lhs = NumberToUint32(lhs);
870 rhs = NumberToUint32(rhs);
870 871
871 // Logical right-shifting any value cannot make it larger. 872 uint32_t min_lhs = lhs->Min();
872 return Type::Range(0.0, lhs->Max(), zone()); 873 uint32_t max_lhs = lhs->Max();
874 uint32_t min_rhs = rhs->Min();
875 uint32_t max_rhs = rhs->Max();
876 if (max_rhs > 31) {
877 // rhs can be larger than the bitmask
878 max_rhs = 31;
879 min_rhs = 0;
880 }
881
882 double min = min_lhs >> max_rhs;
883 double max = max_lhs >> min_rhs;
884 DCHECK_LE(0, min);
885 DCHECK_LE(max, kMaxUInt32);
886
887 if (min == 0 && max == kMaxInt) return Type::Unsigned31();
888 if (min == 0 && max == kMaxUInt32) return Type::Unsigned32();
889 return Type::Range(min, max, zone());
873 } 890 }
874 891
875 Type* OperationTyper::NumberAtan2(Type* lhs, Type* rhs) { 892 Type* OperationTyper::NumberAtan2(Type* lhs, Type* rhs) {
876 DCHECK(lhs->Is(Type::Number())); 893 DCHECK(lhs->Is(Type::Number()));
877 DCHECK(rhs->Is(Type::Number())); 894 DCHECK(rhs->Is(Type::Number()));
878 return Type::Number(); 895 return Type::Number();
879 } 896 }
880 897
881 Type* OperationTyper::NumberImul(Type* lhs, Type* rhs) { 898 Type* OperationTyper::NumberImul(Type* lhs, Type* rhs) {
882 DCHECK(lhs->Is(Type::Number())); 899 DCHECK(lhs->Is(Type::Number()));
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 return singleton_true(); 1009 return singleton_true();
993 } 1010 }
994 1011
995 Type* OperationTyper::TypeTypeGuard(const Operator* sigma_op, Type* input) { 1012 Type* OperationTyper::TypeTypeGuard(const Operator* sigma_op, Type* input) {
996 return Type::Intersect(input, TypeGuardTypeOf(sigma_op), zone()); 1013 return Type::Intersect(input, TypeGuardTypeOf(sigma_op), zone());
997 } 1014 }
998 1015
999 } // namespace compiler 1016 } // namespace compiler
1000 } // namespace internal 1017 } // namespace internal
1001 } // namespace v8 1018 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698