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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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::kObjectIsReceiver: | 52 case IrOpcode::kObjectIsReceiver: |
53 return ObjectIsReceiver(node); | 53 return ObjectIsReceiver(node); |
54 case IrOpcode::kObjectIsSmi: | 54 case IrOpcode::kObjectIsSmi: |
55 return ObjectIsSmi(node); | 55 return ObjectIsSmi(node); |
56 case IrOpcode::kObjectIsNumber: | 56 case IrOpcode::kObjectIsNumber: |
57 return ObjectIsNumber(node); | 57 return ObjectIsNumber(node); |
58 case IrOpcode::kObjectIsUndetectable: | |
59 return ObjectIsUndetectable(node); | |
60 default: | 58 default: |
61 return NoChange(); | 59 return NoChange(); |
62 } | 60 } |
63 UNREACHABLE(); | 61 UNREACHABLE(); |
64 return NoChange(); | 62 return NoChange(); |
65 } | 63 } |
66 | 64 |
67 | 65 |
68 Node* ChangeLowering::HeapNumberValueIndexConstant() { | 66 Node* ChangeLowering::HeapNumberValueIndexConstant() { |
69 return jsgraph()->IntPtrConstant(HeapNumber::kValueOffset - kHeapObjectTag); | 67 return jsgraph()->IntPtrConstant(HeapNumber::kValueOffset - kHeapObjectTag); |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 jsgraph()->IntPtrConstant(kSmiTag)); | 596 jsgraph()->IntPtrConstant(kSmiTag)); |
599 } | 597 } |
600 | 598 |
601 Node* ChangeLowering::LoadHeapObjectMap(Node* object, Node* control) { | 599 Node* ChangeLowering::LoadHeapObjectMap(Node* object, Node* control) { |
602 return graph()->NewNode( | 600 return graph()->NewNode( |
603 machine()->Load(MachineType::AnyTagged()), object, | 601 machine()->Load(MachineType::AnyTagged()), object, |
604 jsgraph()->IntPtrConstant(HeapObject::kMapOffset - kHeapObjectTag), | 602 jsgraph()->IntPtrConstant(HeapObject::kMapOffset - kHeapObjectTag), |
605 graph()->start(), control); | 603 graph()->start(), control); |
606 } | 604 } |
607 | 605 |
608 Node* ChangeLowering::LoadMapBitField(Node* map) { | |
609 return graph()->NewNode( | |
610 machine()->Load(MachineType::Uint8()), map, | |
611 jsgraph()->IntPtrConstant(Map::kBitFieldOffset - kHeapObjectTag), | |
612 graph()->start(), graph()->start()); | |
613 } | |
614 | |
615 Node* ChangeLowering::LoadMapInstanceType(Node* map) { | 606 Node* ChangeLowering::LoadMapInstanceType(Node* map) { |
616 return graph()->NewNode( | 607 return graph()->NewNode( |
617 machine()->Load(MachineType::Uint8()), map, | 608 machine()->Load(MachineType::Uint8()), map, |
618 jsgraph()->IntPtrConstant(Map::kInstanceTypeOffset - kHeapObjectTag), | 609 jsgraph()->IntPtrConstant(Map::kInstanceTypeOffset - kHeapObjectTag), |
619 graph()->start(), graph()->start()); | 610 graph()->start(), graph()->start()); |
620 } | 611 } |
621 | 612 |
622 Reduction ChangeLowering::ObjectIsNumber(Node* node) { | 613 Reduction ChangeLowering::ObjectIsNumber(Node* node) { |
623 Node* input = NodeProperties::GetValueInput(node, 0); | 614 Node* input = NodeProperties::GetValueInput(node, 0); |
624 // TODO(bmeurer): Optimize somewhat based on input type. | 615 // TODO(bmeurer): Optimize somewhat based on input type. |
(...skipping 27 matching lines...) Expand all Loading... |
652 jsgraph()->Uint32Constant(FIRST_JS_RECEIVER_TYPE), | 643 jsgraph()->Uint32Constant(FIRST_JS_RECEIVER_TYPE), |
653 LoadMapInstanceType(LoadHeapObjectMap(input, if_false))); | 644 LoadMapInstanceType(LoadHeapObjectMap(input, if_false))); |
654 Node* control = graph()->NewNode(common()->Merge(2), if_true, if_false); | 645 Node* control = graph()->NewNode(common()->Merge(2), if_true, if_false); |
655 node->ReplaceInput(0, vtrue); | 646 node->ReplaceInput(0, vtrue); |
656 node->AppendInput(graph()->zone(), vfalse); | 647 node->AppendInput(graph()->zone(), vfalse); |
657 node->AppendInput(graph()->zone(), control); | 648 node->AppendInput(graph()->zone(), control); |
658 NodeProperties::ChangeOp(node, common()->Phi(MachineRepresentation::kBit, 2)); | 649 NodeProperties::ChangeOp(node, common()->Phi(MachineRepresentation::kBit, 2)); |
659 return Changed(node); | 650 return Changed(node); |
660 } | 651 } |
661 | 652 |
662 Reduction ChangeLowering::ObjectIsUndetectable(Node* node) { | |
663 Node* input = NodeProperties::GetValueInput(node, 0); | |
664 // TODO(bmeurer): Optimize somewhat based on input type. | |
665 Node* check = IsSmi(input); | |
666 Node* branch = graph()->NewNode(common()->Branch(), check, graph()->start()); | |
667 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); | |
668 Node* vtrue = jsgraph()->Int32Constant(0); | |
669 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); | |
670 Node* vfalse = graph()->NewNode( | |
671 machine()->Word32Equal(), | |
672 graph()->NewNode( | |
673 machine()->Word32Equal(), | |
674 graph()->NewNode(machine()->Word32And(), | |
675 jsgraph()->Uint32Constant(1 << Map::kIsUndetectable), | |
676 LoadMapBitField(LoadHeapObjectMap(input, if_false))), | |
677 jsgraph()->Int32Constant(0)), | |
678 jsgraph()->Int32Constant(0)); | |
679 Node* control = graph()->NewNode(common()->Merge(2), if_true, if_false); | |
680 node->ReplaceInput(0, vtrue); | |
681 node->AppendInput(graph()->zone(), vfalse); | |
682 node->AppendInput(graph()->zone(), control); | |
683 NodeProperties::ChangeOp(node, common()->Phi(MachineRepresentation::kBit, 2)); | |
684 return Changed(node); | |
685 } | |
686 | |
687 Reduction ChangeLowering::ObjectIsSmi(Node* node) { | 653 Reduction ChangeLowering::ObjectIsSmi(Node* node) { |
688 node->ReplaceInput(0, | 654 node->ReplaceInput(0, |
689 graph()->NewNode(machine()->WordAnd(), node->InputAt(0), | 655 graph()->NewNode(machine()->WordAnd(), node->InputAt(0), |
690 jsgraph()->IntPtrConstant(kSmiTagMask))); | 656 jsgraph()->IntPtrConstant(kSmiTagMask))); |
691 node->AppendInput(graph()->zone(), jsgraph()->IntPtrConstant(kSmiTag)); | 657 node->AppendInput(graph()->zone(), jsgraph()->IntPtrConstant(kSmiTag)); |
692 NodeProperties::ChangeOp(node, machine()->WordEqual()); | 658 NodeProperties::ChangeOp(node, machine()->WordEqual()); |
693 return Changed(node); | 659 return Changed(node); |
694 } | 660 } |
695 | 661 |
696 Isolate* ChangeLowering::isolate() const { return jsgraph()->isolate(); } | 662 Isolate* ChangeLowering::isolate() const { return jsgraph()->isolate(); } |
697 | 663 |
698 | 664 |
699 Graph* ChangeLowering::graph() const { return jsgraph()->graph(); } | 665 Graph* ChangeLowering::graph() const { return jsgraph()->graph(); } |
700 | 666 |
701 | 667 |
702 CommonOperatorBuilder* ChangeLowering::common() const { | 668 CommonOperatorBuilder* ChangeLowering::common() const { |
703 return jsgraph()->common(); | 669 return jsgraph()->common(); |
704 } | 670 } |
705 | 671 |
706 | 672 |
707 MachineOperatorBuilder* ChangeLowering::machine() const { | 673 MachineOperatorBuilder* ChangeLowering::machine() const { |
708 return jsgraph()->machine(); | 674 return jsgraph()->machine(); |
709 } | 675 } |
710 | 676 |
711 } // namespace compiler | 677 } // namespace compiler |
712 } // namespace internal | 678 } // namespace internal |
713 } // namespace v8 | 679 } // namespace v8 |
OLD | NEW |