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/compiler/simplified-lowering.h" | 5 #include "src/compiler/simplified-lowering.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "src/address-map.h" | 9 #include "src/address-map.h" |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 1968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1979 return; | 1979 return; |
1980 } | 1980 } |
1981 case IrOpcode::kSpeculativeNumberShiftRightLogical: { | 1981 case IrOpcode::kSpeculativeNumberShiftRightLogical: { |
1982 // ToNumber(x) can throw if x is either a Receiver or a Symbol, so we | 1982 // ToNumber(x) can throw if x is either a Receiver or a Symbol, so we |
1983 // can only eliminate an unused speculative number operation if we know | 1983 // can only eliminate an unused speculative number operation if we know |
1984 // that the inputs are PlainPrimitive, which excludes everything that's | 1984 // that the inputs are PlainPrimitive, which excludes everything that's |
1985 // might have side effects or throws during a ToNumber conversion. | 1985 // might have side effects or throws during a ToNumber conversion. |
1986 if (BothInputsAre(node, Type::PlainPrimitive())) { | 1986 if (BothInputsAre(node, Type::PlainPrimitive())) { |
1987 if (truncation.IsUnused()) return VisitUnused(node); | 1987 if (truncation.IsUnused()) return VisitUnused(node); |
1988 } | 1988 } |
| 1989 NumberOperationHint hint = NumberOperationHintOf(node->op()); |
| 1990 Type* rhs_type = GetUpperBound(node->InputAt(1)); |
| 1991 if (rhs_type->Is(type_cache_.kZeroish) && |
| 1992 (hint == NumberOperationHint::kSignedSmall || |
| 1993 hint == NumberOperationHint::kSigned32) && |
| 1994 !truncation.IsUsedAsWord32()) { |
| 1995 // The SignedSmall or Signed32 feedback means that the results that we |
| 1996 // have seen so far were of type Unsigned31. We speculate that this |
| 1997 // will continue to hold. Moreover, since the RHS is 0, the result |
| 1998 // will just be the (converted) LHS. |
| 1999 VisitBinop(node, CheckedUseInfoAsWord32FromHint(hint), |
| 2000 MachineRepresentation::kWord32, Type::Unsigned31()); |
| 2001 if (lower()) { |
| 2002 node->RemoveInput(1); |
| 2003 NodeProperties::ChangeOp(node, |
| 2004 simplified()->CheckedUint32ToInt32()); |
| 2005 } |
| 2006 return; |
| 2007 } |
1989 if (BothInputsAre(node, Type::NumberOrOddball())) { | 2008 if (BothInputsAre(node, Type::NumberOrOddball())) { |
1990 Type* rhs_type = GetUpperBound(node->InputAt(1)); | |
1991 VisitBinop(node, UseInfo::TruncatingWord32(), | 2009 VisitBinop(node, UseInfo::TruncatingWord32(), |
1992 UseInfo::TruncatingWord32(), | 2010 UseInfo::TruncatingWord32(), |
1993 MachineRepresentation::kWord32); | 2011 MachineRepresentation::kWord32); |
1994 if (lower()) { | 2012 if (lower()) { |
1995 lowering->DoShift(node, lowering->machine()->Word32Shr(), rhs_type); | 2013 lowering->DoShift(node, lowering->machine()->Word32Shr(), rhs_type); |
1996 } | 2014 } |
1997 return; | 2015 return; |
1998 } | 2016 } |
1999 NumberOperationHint hint = NumberOperationHintOf(node->op()); | |
2000 Type* rhs_type = GetUpperBound(node->InputAt(1)); | |
2001 VisitBinop(node, CheckedUseInfoAsWord32FromHint(hint), | 2017 VisitBinop(node, CheckedUseInfoAsWord32FromHint(hint), |
2002 MachineRepresentation::kWord32, Type::Unsigned32()); | 2018 MachineRepresentation::kWord32, Type::Unsigned32()); |
2003 if (lower()) { | 2019 if (lower()) { |
2004 lowering->DoShift(node, lowering->machine()->Word32Shr(), rhs_type); | 2020 lowering->DoShift(node, lowering->machine()->Word32Shr(), rhs_type); |
2005 } | 2021 } |
2006 return; | 2022 return; |
2007 } | 2023 } |
2008 case IrOpcode::kNumberAbs: { | 2024 case IrOpcode::kNumberAbs: { |
2009 if (TypeOf(node->InputAt(0))->Is(Type::Unsigned32())) { | 2025 if (TypeOf(node->InputAt(0))->Is(Type::Unsigned32())) { |
2010 VisitUnop(node, UseInfo::TruncatingWord32(), | 2026 VisitUnop(node, UseInfo::TruncatingWord32(), |
(...skipping 1505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3516 isolate(), graph()->zone(), callable.descriptor(), 0, flags, | 3532 isolate(), graph()->zone(), callable.descriptor(), 0, flags, |
3517 Operator::kNoProperties); | 3533 Operator::kNoProperties); |
3518 to_number_operator_.set(common()->Call(desc)); | 3534 to_number_operator_.set(common()->Call(desc)); |
3519 } | 3535 } |
3520 return to_number_operator_.get(); | 3536 return to_number_operator_.get(); |
3521 } | 3537 } |
3522 | 3538 |
3523 } // namespace compiler | 3539 } // namespace compiler |
3524 } // namespace internal | 3540 } // namespace internal |
3525 } // namespace v8 | 3541 } // namespace v8 |
OLD | NEW |