| 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/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 // only float64 uses. | 324 // only float64 uses. |
| 325 return kRepFloat64; | 325 return kRepFloat64; |
| 326 } else if ((use & kRepMask) == kRepTagged) { | 326 } else if ((use & kRepMask) == kRepTagged) { |
| 327 // only tagged uses. | 327 // only tagged uses. |
| 328 return kRepTagged; | 328 return kRepTagged; |
| 329 } else if (upper->Is(Type::Integral32())) { | 329 } else if (upper->Is(Type::Integral32())) { |
| 330 // Integer within [-2^31, 2^32[ range. | 330 // Integer within [-2^31, 2^32[ range. |
| 331 if (upper->Is(Type::Signed32()) || upper->Is(Type::Unsigned32())) { | 331 if (upper->Is(Type::Signed32()) || upper->Is(Type::Unsigned32())) { |
| 332 // multiple uses, but we are within 32 bits range => pick kRepWord32. | 332 // multiple uses, but we are within 32 bits range => pick kRepWord32. |
| 333 return kRepWord32; | 333 return kRepWord32; |
| 334 } else if (((use & kRepMask) == kRepWord32 && | 334 } else if ((use & kTypeMask) == kTypeInt32 || |
| 335 !CanObserveNonWord32(use)) || | |
| 336 (use & kTypeMask) == kTypeInt32 || | |
| 337 (use & kTypeMask) == kTypeUint32) { | 335 (use & kTypeMask) == kTypeUint32) { |
| 338 // We only use 32 bits or we use the result consistently. | 336 // We only use 32 bits or we use the result consistently. |
| 339 return kRepWord32; | 337 return kRepWord32; |
| 340 } else { | 338 } else { |
| 341 return kRepFloat64; | 339 return kRepFloat64; |
| 342 } | 340 } |
| 343 } else if (upper->Is(Type::Boolean())) { | 341 } else if (upper->Is(Type::Boolean())) { |
| 344 // multiple uses => pick kRepBit. | 342 // multiple uses => pick kRepBit. |
| 345 return kRepBit; | 343 return kRepBit; |
| 346 } else if (upper->Is(Type::Number())) { | 344 } else if (upper->Is(Type::Number())) { |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 bool CanLowerToUint32Binop(Node* node, MachineTypeUnion use) { | 484 bool CanLowerToUint32Binop(Node* node, MachineTypeUnion use) { |
| 487 return BothInputsAre(node, Type::Unsigned32()) && | 485 return BothInputsAre(node, Type::Unsigned32()) && |
| 488 (!CanObserveNonWord32(use) || | 486 (!CanObserveNonWord32(use) || |
| 489 NodeProperties::GetType(node)->Is(Type::Unsigned32())); | 487 NodeProperties::GetType(node)->Is(Type::Unsigned32())); |
| 490 } | 488 } |
| 491 | 489 |
| 492 bool CanObserveNonWord32(MachineTypeUnion use) { | 490 bool CanObserveNonWord32(MachineTypeUnion use) { |
| 493 return (use & kTypeMask & ~(kTypeInt32 | kTypeUint32)) != 0; | 491 return (use & kTypeMask & ~(kTypeInt32 | kTypeUint32)) != 0; |
| 494 } | 492 } |
| 495 | 493 |
| 496 bool CanObserveMinusZero(MachineTypeUnion use) { | |
| 497 // TODO(turbofan): technically Uint32 cannot observe minus zero either. | |
| 498 return (use & (kTypeUint32 | kTypeNumber | kTypeAny)) != 0; | |
| 499 } | |
| 500 | |
| 501 bool CanObserveNaN(MachineTypeUnion use) { | 494 bool CanObserveNaN(MachineTypeUnion use) { |
| 502 return (use & (kTypeNumber | kTypeAny)) != 0; | 495 return (use & (kTypeNumber | kTypeAny)) != 0; |
| 503 } | 496 } |
| 504 | 497 |
| 505 // Dispatching routine for visiting the node {node} with the usage {use}. | 498 // Dispatching routine for visiting the node {node} with the usage {use}. |
| 506 // Depending on the operator, propagate new usage info to the inputs. | 499 // Depending on the operator, propagate new usage info to the inputs. |
| 507 void VisitNode(Node* node, MachineTypeUnion use, | 500 void VisitNode(Node* node, MachineTypeUnion use, |
| 508 SimplifiedLowering* lowering) { | 501 SimplifiedLowering* lowering) { |
| 509 switch (node->opcode()) { | 502 switch (node->opcode()) { |
| 510 //------------------------------------------------------------------ | 503 //------------------------------------------------------------------ |
| (...skipping 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1681 ReplaceEffectUses(node, comparison); | 1674 ReplaceEffectUses(node, comparison); |
| 1682 node->ReplaceInput(0, comparison); | 1675 node->ReplaceInput(0, comparison); |
| 1683 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); | 1676 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); |
| 1684 node->TrimInputCount(2); | 1677 node->TrimInputCount(2); |
| 1685 NodeProperties::ChangeOp(node, machine()->IntLessThanOrEqual()); | 1678 NodeProperties::ChangeOp(node, machine()->IntLessThanOrEqual()); |
| 1686 } | 1679 } |
| 1687 | 1680 |
| 1688 } // namespace compiler | 1681 } // namespace compiler |
| 1689 } // namespace internal | 1682 } // namespace internal |
| 1690 } // namespace v8 | 1683 } // namespace v8 |
| OLD | NEW |