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

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

Issue 2802113003: [turbofan] Introduce a SpeculativeToNumber operator. (Closed)
Patch Set: Paint it green! Created 3 years, 8 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 | « src/compiler/operation-typer.h ('k') | src/compiler/simplified-lowering.cc » ('j') | 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 950 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 return type; 961 return type;
962 } 962 }
963 963
964 Type* OperationTyper::NumberPow(Type* lhs, Type* rhs) { 964 Type* OperationTyper::NumberPow(Type* lhs, Type* rhs) {
965 DCHECK(lhs->Is(Type::Number())); 965 DCHECK(lhs->Is(Type::Number()));
966 DCHECK(rhs->Is(Type::Number())); 966 DCHECK(rhs->Is(Type::Number()));
967 // TODO(turbofan): We should be able to do better here. 967 // TODO(turbofan): We should be able to do better here.
968 return Type::Number(); 968 return Type::Number();
969 } 969 }
970 970
971 #define SPECULATIVE_NUMBER_BINOP(Name) \ 971 #define SPECULATIVE_NUMBER_BINOP(Name) \
972 Type* OperationTyper::Speculative##Name(Type* lhs, Type* rhs) { \ 972 Type* OperationTyper::Speculative##Name(Type* lhs, Type* rhs) { \
973 lhs = ToNumber(Type::Intersect(lhs, Type::NumberOrOddball(), zone())); \ 973 lhs = SpeculativeToNumber(lhs); \
974 rhs = ToNumber(Type::Intersect(rhs, Type::NumberOrOddball(), zone())); \ 974 rhs = SpeculativeToNumber(rhs); \
975 return Name(lhs, rhs); \ 975 return Name(lhs, rhs); \
976 } 976 }
977 SPECULATIVE_NUMBER_BINOP(NumberAdd) 977 SPECULATIVE_NUMBER_BINOP(NumberAdd)
978 SPECULATIVE_NUMBER_BINOP(NumberSubtract) 978 SPECULATIVE_NUMBER_BINOP(NumberSubtract)
979 SPECULATIVE_NUMBER_BINOP(NumberMultiply) 979 SPECULATIVE_NUMBER_BINOP(NumberMultiply)
980 SPECULATIVE_NUMBER_BINOP(NumberDivide) 980 SPECULATIVE_NUMBER_BINOP(NumberDivide)
981 SPECULATIVE_NUMBER_BINOP(NumberModulus) 981 SPECULATIVE_NUMBER_BINOP(NumberModulus)
982 SPECULATIVE_NUMBER_BINOP(NumberBitwiseOr) 982 SPECULATIVE_NUMBER_BINOP(NumberBitwiseOr)
983 SPECULATIVE_NUMBER_BINOP(NumberBitwiseAnd) 983 SPECULATIVE_NUMBER_BINOP(NumberBitwiseAnd)
984 SPECULATIVE_NUMBER_BINOP(NumberBitwiseXor) 984 SPECULATIVE_NUMBER_BINOP(NumberBitwiseXor)
985 SPECULATIVE_NUMBER_BINOP(NumberShiftLeft) 985 SPECULATIVE_NUMBER_BINOP(NumberShiftLeft)
986 SPECULATIVE_NUMBER_BINOP(NumberShiftRight) 986 SPECULATIVE_NUMBER_BINOP(NumberShiftRight)
987 SPECULATIVE_NUMBER_BINOP(NumberShiftRightLogical) 987 SPECULATIVE_NUMBER_BINOP(NumberShiftRightLogical)
988 #undef SPECULATIVE_NUMBER_BINOP 988 #undef SPECULATIVE_NUMBER_BINOP
989 989
990 Type* OperationTyper::SpeculativeToNumber(Type* type) {
991 return ToNumber(Type::Intersect(type, Type::NumberOrOddball(), zone()));
992 }
993
990 Type* OperationTyper::ToPrimitive(Type* type) { 994 Type* OperationTyper::ToPrimitive(Type* type) {
991 if (type->Is(Type::Primitive()) && !type->Maybe(Type::Receiver())) { 995 if (type->Is(Type::Primitive()) && !type->Maybe(Type::Receiver())) {
992 return type; 996 return type;
993 } 997 }
994 return Type::Primitive(); 998 return Type::Primitive();
995 } 999 }
996 1000
997 Type* OperationTyper::Invert(Type* type) { 1001 Type* OperationTyper::Invert(Type* type) {
998 DCHECK(type->Is(Type::Boolean())); 1002 DCHECK(type->Is(Type::Boolean()));
999 DCHECK(type->IsInhabited()); 1003 DCHECK(type->IsInhabited());
(...skipping 22 matching lines...) Expand all
1022 return singleton_true(); 1026 return singleton_true();
1023 } 1027 }
1024 1028
1025 Type* OperationTyper::TypeTypeGuard(const Operator* sigma_op, Type* input) { 1029 Type* OperationTyper::TypeTypeGuard(const Operator* sigma_op, Type* input) {
1026 return Type::Intersect(input, TypeGuardTypeOf(sigma_op), zone()); 1030 return Type::Intersect(input, TypeGuardTypeOf(sigma_op), zone());
1027 } 1031 }
1028 1032
1029 } // namespace compiler 1033 } // namespace compiler
1030 } // namespace internal 1034 } // namespace internal
1031 } // namespace v8 1035 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/operation-typer.h ('k') | src/compiler/simplified-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698