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/change-lowering.h" | 5 #include "src/compiler/change-lowering.h" |
6 | 6 |
7 #include "src/address-map.h" | 7 #include "src/address-map.h" |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 case IrOpcode::kLoadField: | 42 case IrOpcode::kLoadField: |
43 return LoadField(node); | 43 return LoadField(node); |
44 case IrOpcode::kStoreField: | 44 case IrOpcode::kStoreField: |
45 return StoreField(node); | 45 return StoreField(node); |
46 case IrOpcode::kLoadElement: | 46 case IrOpcode::kLoadElement: |
47 return LoadElement(node); | 47 return LoadElement(node); |
48 case IrOpcode::kStoreElement: | 48 case IrOpcode::kStoreElement: |
49 return StoreElement(node); | 49 return StoreElement(node); |
50 case IrOpcode::kAllocate: | 50 case IrOpcode::kAllocate: |
51 return Allocate(node); | 51 return Allocate(node); |
| 52 case IrOpcode::kObjectIsNumber: |
| 53 return ObjectIsNumber(node); |
52 case IrOpcode::kObjectIsReceiver: | 54 case IrOpcode::kObjectIsReceiver: |
53 return ObjectIsReceiver(node); | 55 return ObjectIsReceiver(node); |
54 case IrOpcode::kObjectIsSmi: | 56 case IrOpcode::kObjectIsSmi: |
55 return ObjectIsSmi(node); | 57 return ObjectIsSmi(node); |
56 case IrOpcode::kObjectIsNumber: | 58 case IrOpcode::kObjectIsString: |
57 return ObjectIsNumber(node); | 59 return ObjectIsString(node); |
58 case IrOpcode::kObjectIsUndetectable: | 60 case IrOpcode::kObjectIsUndetectable: |
59 return ObjectIsUndetectable(node); | 61 return ObjectIsUndetectable(node); |
60 default: | 62 default: |
61 return NoChange(); | 63 return NoChange(); |
62 } | 64 } |
63 UNREACHABLE(); | 65 UNREACHABLE(); |
64 return NoChange(); | 66 return NoChange(); |
65 } | 67 } |
66 | 68 |
67 | 69 |
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 | 751 |
750 Reduction ChangeLowering::ObjectIsSmi(Node* node) { | 752 Reduction ChangeLowering::ObjectIsSmi(Node* node) { |
751 node->ReplaceInput(0, | 753 node->ReplaceInput(0, |
752 graph()->NewNode(machine()->WordAnd(), node->InputAt(0), | 754 graph()->NewNode(machine()->WordAnd(), node->InputAt(0), |
753 jsgraph()->IntPtrConstant(kSmiTagMask))); | 755 jsgraph()->IntPtrConstant(kSmiTagMask))); |
754 node->AppendInput(graph()->zone(), jsgraph()->IntPtrConstant(kSmiTag)); | 756 node->AppendInput(graph()->zone(), jsgraph()->IntPtrConstant(kSmiTag)); |
755 NodeProperties::ChangeOp(node, machine()->WordEqual()); | 757 NodeProperties::ChangeOp(node, machine()->WordEqual()); |
756 return Changed(node); | 758 return Changed(node); |
757 } | 759 } |
758 | 760 |
| 761 Reduction ChangeLowering::ObjectIsString(Node* node) { |
| 762 Node* input = NodeProperties::GetValueInput(node, 0); |
| 763 Node* check = IsSmi(input); |
| 764 Node* branch = graph()->NewNode(common()->Branch(), check, graph()->start()); |
| 765 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); |
| 766 Node* vtrue = jsgraph()->Int32Constant(0); |
| 767 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
| 768 Node* vfalse = |
| 769 graph()->NewNode(machine()->Uint32LessThan(), |
| 770 LoadMapInstanceType(LoadHeapObjectMap(input, if_false)), |
| 771 jsgraph()->Uint32Constant(FIRST_NONSTRING_TYPE)); |
| 772 Node* control = graph()->NewNode(common()->Merge(2), if_true, if_false); |
| 773 node->ReplaceInput(0, vtrue); |
| 774 node->AppendInput(graph()->zone(), vfalse); |
| 775 node->AppendInput(graph()->zone(), control); |
| 776 NodeProperties::ChangeOp(node, common()->Phi(MachineRepresentation::kBit, 2)); |
| 777 return Changed(node); |
| 778 } |
| 779 |
759 Isolate* ChangeLowering::isolate() const { return jsgraph()->isolate(); } | 780 Isolate* ChangeLowering::isolate() const { return jsgraph()->isolate(); } |
760 | 781 |
761 | 782 |
762 Graph* ChangeLowering::graph() const { return jsgraph()->graph(); } | 783 Graph* ChangeLowering::graph() const { return jsgraph()->graph(); } |
763 | 784 |
764 | 785 |
765 CommonOperatorBuilder* ChangeLowering::common() const { | 786 CommonOperatorBuilder* ChangeLowering::common() const { |
766 return jsgraph()->common(); | 787 return jsgraph()->common(); |
767 } | 788 } |
768 | 789 |
769 | 790 |
770 MachineOperatorBuilder* ChangeLowering::machine() const { | 791 MachineOperatorBuilder* ChangeLowering::machine() const { |
771 return jsgraph()->machine(); | 792 return jsgraph()->machine(); |
772 } | 793 } |
773 | 794 |
774 } // namespace compiler | 795 } // namespace compiler |
775 } // namespace internal | 796 } // namespace internal |
776 } // namespace v8 | 797 } // namespace v8 |
OLD | NEW |