| 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 593 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   604  |   604  | 
|   605   void ResetOutput(Node* node, MachineRepresentation representation, |   605   void ResetOutput(Node* node, MachineRepresentation representation, | 
|   606                    TypeCheckKind type_check = TypeCheckKind::kNone) { |   606                    TypeCheckKind type_check = TypeCheckKind::kNone) { | 
|   607     NodeInfo* info = GetInfo(node); |   607     NodeInfo* info = GetInfo(node); | 
|   608     info->set_output(representation); |   608     info->set_output(representation); | 
|   609     info->set_type_check(type_check); |   609     info->set_type_check(type_check); | 
|   610   } |   610   } | 
|   611  |   611  | 
|   612   Type* GetUpperBound(Node* node) { return NodeProperties::GetType(node); } |   612   Type* GetUpperBound(Node* node) { return NodeProperties::GetType(node); } | 
|   613  |   613  | 
 |   614   bool InputIs(Node* node, Type* type) { | 
 |   615     DCHECK_EQ(1, node->InputCount()); | 
 |   616     return GetUpperBound(node->InputAt(0))->Is(type); | 
 |   617   } | 
 |   618  | 
|   614   bool BothInputsAreSigned32(Node* node) { |   619   bool BothInputsAreSigned32(Node* node) { | 
|   615     DCHECK_EQ(2, node->InputCount()); |   620     return BothInputsAre(node, Type::Signed32()); | 
|   616     return GetUpperBound(node->InputAt(0))->Is(Type::Signed32()) && |  | 
|   617            GetUpperBound(node->InputAt(1))->Is(Type::Signed32()); |  | 
|   618   } |   621   } | 
|   619  |   622  | 
|   620   bool BothInputsAreUnsigned32(Node* node) { |   623   bool BothInputsAreUnsigned32(Node* node) { | 
|   621     DCHECK_EQ(2, node->InputCount()); |   624     return BothInputsAre(node, Type::Unsigned32()); | 
|   622     return GetUpperBound(node->InputAt(0))->Is(Type::Unsigned32()) && |  | 
|   623            GetUpperBound(node->InputAt(1))->Is(Type::Unsigned32()); |  | 
|   624   } |   625   } | 
|   625  |   626  | 
|   626   bool BothInputsAre(Node* node, Type* type) { |   627   bool BothInputsAre(Node* node, Type* type) { | 
|   627     DCHECK_EQ(2, node->op()->ValueInputCount()); |   628     DCHECK_EQ(2, node->op()->ValueInputCount()); | 
|   628     return GetUpperBound(node->InputAt(0))->Is(type) && |   629     return GetUpperBound(node->InputAt(0))->Is(type) && | 
|   629            GetUpperBound(node->InputAt(1))->Is(type); |   630            GetUpperBound(node->InputAt(1))->Is(type); | 
|   630   } |   631   } | 
|   631  |   632  | 
|   632   void ConvertInput(Node* node, int index, UseInfo use) { |   633   void ConvertInput(Node* node, int index, UseInfo use) { | 
|   633     Node* input = node->InputAt(index); |   634     Node* input = node->InputAt(index); | 
| (...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1386                   MachineRepresentation::kFloat64); |  1387                   MachineRepresentation::kFloat64); | 
|  1387         if (lower()) DeferReplacement(node, lowering->Float64Ceil(node)); |  1388         if (lower()) DeferReplacement(node, lowering->Float64Ceil(node)); | 
|  1388         return; |  1389         return; | 
|  1389       } |  1390       } | 
|  1390       case IrOpcode::kNumberFloor: { |  1391       case IrOpcode::kNumberFloor: { | 
|  1391         VisitUnop(node, UseInfo::TruncatingFloat64(), |  1392         VisitUnop(node, UseInfo::TruncatingFloat64(), | 
|  1392                   MachineRepresentation::kFloat64); |  1393                   MachineRepresentation::kFloat64); | 
|  1393         if (lower()) DeferReplacement(node, lowering->Float64Floor(node)); |  1394         if (lower()) DeferReplacement(node, lowering->Float64Floor(node)); | 
|  1394         return; |  1395         return; | 
|  1395       } |  1396       } | 
 |  1397       case IrOpcode::kNumberFround: { | 
 |  1398         VisitUnop(node, UseInfo::TruncatingFloat64(), | 
 |  1399                   MachineRepresentation::kFloat32); | 
 |  1400         if (lower()) NodeProperties::ChangeOp(node, Float64Op(node)); | 
 |  1401         return; | 
 |  1402       } | 
|  1396       case IrOpcode::kNumberAtan2: { |  1403       case IrOpcode::kNumberAtan2: { | 
|  1397         VisitBinop(node, UseInfo::TruncatingFloat64(), |  1404         VisitBinop(node, UseInfo::TruncatingFloat64(), | 
|  1398                    MachineRepresentation::kFloat64); |  1405                    MachineRepresentation::kFloat64); | 
|  1399         if (lower()) NodeProperties::ChangeOp(node, Float64Op(node)); |  1406         if (lower()) NodeProperties::ChangeOp(node, Float64Op(node)); | 
|  1400         return; |  1407         return; | 
|  1401       } |  1408       } | 
|  1402       case IrOpcode::kNumberAtan: |  1409       case IrOpcode::kNumberAtan: | 
|  1403       case IrOpcode::kNumberLog: |  1410       case IrOpcode::kNumberLog: | 
|  1404       case IrOpcode::kNumberLog1p: { |  1411       case IrOpcode::kNumberLog1p: { | 
|  1405         VisitUnop(node, UseInfo::TruncatingFloat64(), |  1412         VisitUnop(node, UseInfo::TruncatingFloat64(), | 
|  1406                   MachineRepresentation::kFloat64); |  1413                   MachineRepresentation::kFloat64); | 
|  1407         if (lower()) NodeProperties::ChangeOp(node, Float64Op(node)); |  1414         if (lower()) NodeProperties::ChangeOp(node, Float64Op(node)); | 
|  1408         return; |  1415         return; | 
|  1409       } |  1416       } | 
|  1410       case IrOpcode::kNumberRound: { |  1417       case IrOpcode::kNumberRound: { | 
|  1411         VisitUnop(node, UseInfo::TruncatingFloat64(), |  1418         VisitUnop(node, UseInfo::TruncatingFloat64(), | 
|  1412                   MachineRepresentation::kFloat64); |  1419                   MachineRepresentation::kFloat64); | 
|  1413         if (lower()) DeferReplacement(node, lowering->Float64Round(node)); |  1420         if (lower()) DeferReplacement(node, lowering->Float64Round(node)); | 
|  1414         return; |  1421         return; | 
|  1415       } |  1422       } | 
 |  1423       case IrOpcode::kNumberSqrt: { | 
 |  1424         VisitUnop(node, UseInfo::TruncatingFloat64(), | 
 |  1425                   MachineRepresentation::kFloat64); | 
 |  1426         if (lower()) NodeProperties::ChangeOp(node, Float64Op(node)); | 
 |  1427         return; | 
 |  1428       } | 
|  1416       case IrOpcode::kNumberTrunc: { |  1429       case IrOpcode::kNumberTrunc: { | 
|  1417         VisitUnop(node, UseInfo::TruncatingFloat64(), |  1430         VisitUnop(node, UseInfo::TruncatingFloat64(), | 
|  1418                   MachineRepresentation::kFloat64); |  1431                   MachineRepresentation::kFloat64); | 
|  1419         if (lower()) DeferReplacement(node, lowering->Float64Trunc(node)); |  1432         if (lower()) DeferReplacement(node, lowering->Float64Trunc(node)); | 
|  1420         return; |  1433         return; | 
|  1421       } |  1434       } | 
|  1422       case IrOpcode::kNumberToInt32: { |  1435       case IrOpcode::kNumberToInt32: { | 
|  1423         // Just change representation if necessary. |  1436         // Just change representation if necessary. | 
|  1424         VisitUnop(node, UseInfo::TruncatingWord32(), |  1437         VisitUnop(node, UseInfo::TruncatingWord32(), | 
|  1425                   MachineRepresentation::kWord32); |  1438                   MachineRepresentation::kWord32); | 
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1676               access.type, node->InputAt(2)); |  1689               access.type, node->InputAt(2)); | 
|  1677           if (write_barrier_kind < access.write_barrier_kind) { |  1690           if (write_barrier_kind < access.write_barrier_kind) { | 
|  1678             access.write_barrier_kind = write_barrier_kind; |  1691             access.write_barrier_kind = write_barrier_kind; | 
|  1679             NodeProperties::ChangeOp( |  1692             NodeProperties::ChangeOp( | 
|  1680                 node, jsgraph_->simplified()->StoreElement(access)); |  1693                 node, jsgraph_->simplified()->StoreElement(access)); | 
|  1681           } |  1694           } | 
|  1682         } |  1695         } | 
|  1683         return; |  1696         return; | 
|  1684       } |  1697       } | 
|  1685       case IrOpcode::kPlainPrimitiveToNumber: |  1698       case IrOpcode::kPlainPrimitiveToNumber: | 
|  1686         ProcessInput(node, 0, UseInfo::AnyTagged()); |  | 
|  1687         if (truncation.TruncatesToWord32()) { |  1699         if (truncation.TruncatesToWord32()) { | 
|  1688           SetOutput(node, MachineRepresentation::kWord32); |  1700           // TODO(jarin): Extend this to Number \/ Oddball | 
|  1689           if (lower()) { |  1701           if (InputIs(node, Type::NumberOrUndefined())) { | 
|  1690             NodeProperties::ChangeOp(node, |  1702             VisitUnop(node, UseInfo::TruncatingWord32(), | 
|  1691                                      simplified()->PlainPrimitiveToWord32()); |  1703                       MachineRepresentation::kWord32); | 
 |  1704             if (lower()) DeferReplacement(node, node->InputAt(0)); | 
 |  1705           } else { | 
 |  1706             VisitUnop(node, UseInfo::AnyTagged(), | 
 |  1707                       MachineRepresentation::kWord32); | 
 |  1708             if (lower()) { | 
 |  1709               NodeProperties::ChangeOp(node, | 
 |  1710                                        simplified()->PlainPrimitiveToWord32()); | 
 |  1711             } | 
|  1692           } |  1712           } | 
|  1693         } else if (truncation.TruncatesToFloat64()) { |  1713         } else if (truncation.TruncatesToFloat64()) { | 
|  1694           SetOutput(node, MachineRepresentation::kFloat64); |  1714           // TODO(jarin): Extend this to Number \/ Oddball | 
|  1695           if (lower()) { |  1715           if (InputIs(node, Type::NumberOrUndefined())) { | 
|  1696             NodeProperties::ChangeOp(node, |  1716             VisitUnop(node, UseInfo::TruncatingFloat64(), | 
|  1697                                      simplified()->PlainPrimitiveToFloat64()); |  1717                       MachineRepresentation::kFloat64); | 
 |  1718             if (lower()) DeferReplacement(node, node->InputAt(0)); | 
 |  1719           } else { | 
 |  1720             VisitUnop(node, UseInfo::AnyTagged(), | 
 |  1721                       MachineRepresentation::kFloat64); | 
 |  1722             if (lower()) { | 
 |  1723               NodeProperties::ChangeOp(node, | 
 |  1724                                        simplified()->PlainPrimitiveToFloat64()); | 
 |  1725             } | 
|  1698           } |  1726           } | 
|  1699         } else { |  1727         } else { | 
|  1700           SetOutput(node, MachineRepresentation::kTagged); |  1728           VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kTagged); | 
|  1701         } |  1729         } | 
|  1702         return; |  1730         return; | 
|  1703       case IrOpcode::kObjectIsCallable: |  1731       case IrOpcode::kObjectIsCallable: | 
|  1704       case IrOpcode::kObjectIsNumber: |  1732       case IrOpcode::kObjectIsNumber: | 
|  1705       case IrOpcode::kObjectIsReceiver: |  1733       case IrOpcode::kObjectIsReceiver: | 
|  1706       case IrOpcode::kObjectIsSmi: |  1734       case IrOpcode::kObjectIsSmi: | 
|  1707       case IrOpcode::kObjectIsString: |  1735       case IrOpcode::kObjectIsString: | 
|  1708       case IrOpcode::kObjectIsUndetectable: { |  1736       case IrOpcode::kObjectIsUndetectable: { | 
|  1709         ProcessInput(node, 0, UseInfo::AnyTagged()); |  1737         ProcessInput(node, 0, UseInfo::AnyTagged()); | 
|  1710         SetOutput(node, MachineRepresentation::kBit); |  1738         SetOutput(node, MachineRepresentation::kBit); | 
| (...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2890         isolate(), graph()->zone(), callable.descriptor(), 0, flags, |  2918         isolate(), graph()->zone(), callable.descriptor(), 0, flags, | 
|  2891         Operator::kNoProperties); |  2919         Operator::kNoProperties); | 
|  2892     to_number_operator_.set(common()->Call(desc)); |  2920     to_number_operator_.set(common()->Call(desc)); | 
|  2893   } |  2921   } | 
|  2894   return to_number_operator_.get(); |  2922   return to_number_operator_.get(); | 
|  2895 } |  2923 } | 
|  2896  |  2924  | 
|  2897 }  // namespace compiler |  2925 }  // namespace compiler | 
|  2898 }  // namespace internal |  2926 }  // namespace internal | 
|  2899 }  // namespace v8 |  2927 }  // namespace v8 | 
| OLD | NEW |