60 class CodeBuffer;
61 class ConstraintCastNode;
62 class ConNode;
63 class CountedLoopNode;
64 class CountedLoopEndNode;
65 class DecodeNNode;
66 class EncodePNode;
67 class FastLockNode;
68 class FastUnlockNode;
69 class IfNode;
70 class IfFalseNode;
71 class IfTrueNode;
72 class InitializeNode;
73 class JVMState;
74 class JumpNode;
75 class JumpProjNode;
76 class LoadNode;
77 class LoadStoreNode;
78 class LockNode;
79 class LoopNode;
80 class MachCallDynamicJavaNode;
81 class MachCallJavaNode;
82 class MachCallLeafNode;
83 class MachCallNode;
84 class MachCallRuntimeNode;
85 class MachCallStaticJavaNode;
86 class MachConstantBaseNode;
87 class MachConstantNode;
88 class MachGotoNode;
89 class MachIfNode;
90 class MachNode;
91 class MachNullCheckNode;
92 class MachProjNode;
93 class MachReturnNode;
94 class MachSafePointNode;
95 class MachSpillCopyNode;
96 class MachTempNode;
97 class Matcher;
98 class MemBarNode;
99 class MemNode;
555 DEFINE_CLASS_ID(MultiBranch, Multi, 1)
556 DEFINE_CLASS_ID(PCTable, MultiBranch, 0)
557 DEFINE_CLASS_ID(Catch, PCTable, 0)
558 DEFINE_CLASS_ID(Jump, PCTable, 1)
559 DEFINE_CLASS_ID(If, MultiBranch, 1)
560 DEFINE_CLASS_ID(CountedLoopEnd, If, 0)
561 DEFINE_CLASS_ID(NeverBranch, MultiBranch, 2)
562 DEFINE_CLASS_ID(Start, Multi, 2)
563 DEFINE_CLASS_ID(MemBar, Multi, 3)
564 DEFINE_CLASS_ID(Initialize, MemBar, 0)
565
566 DEFINE_CLASS_ID(Mach, Node, 1)
567 DEFINE_CLASS_ID(MachReturn, Mach, 0)
568 DEFINE_CLASS_ID(MachSafePoint, MachReturn, 0)
569 DEFINE_CLASS_ID(MachCall, MachSafePoint, 0)
570 DEFINE_CLASS_ID(MachCallJava, MachCall, 0)
571 DEFINE_CLASS_ID(MachCallStaticJava, MachCallJava, 0)
572 DEFINE_CLASS_ID(MachCallDynamicJava, MachCallJava, 1)
573 DEFINE_CLASS_ID(MachCallRuntime, MachCall, 1)
574 DEFINE_CLASS_ID(MachCallLeaf, MachCallRuntime, 0)
575 DEFINE_CLASS_ID(MachSpillCopy, Mach, 1)
576 DEFINE_CLASS_ID(MachNullCheck, Mach, 2)
577 DEFINE_CLASS_ID(MachIf, Mach, 3)
578 DEFINE_CLASS_ID(MachTemp, Mach, 4)
579 DEFINE_CLASS_ID(MachConstantBase, Mach, 5)
580 DEFINE_CLASS_ID(MachConstant, Mach, 6)
581 DEFINE_CLASS_ID(MachGoto, Mach, 7)
582
583 DEFINE_CLASS_ID(Type, Node, 2)
584 DEFINE_CLASS_ID(Phi, Type, 0)
585 DEFINE_CLASS_ID(ConstraintCast, Type, 1)
586 DEFINE_CLASS_ID(CheckCastPP, Type, 2)
587 DEFINE_CLASS_ID(CMove, Type, 3)
588 DEFINE_CLASS_ID(SafePointScalarObject, Type, 4)
589 DEFINE_CLASS_ID(DecodeN, Type, 5)
590 DEFINE_CLASS_ID(EncodeP, Type, 6)
591
592 DEFINE_CLASS_ID(Proj, Node, 3)
593 DEFINE_CLASS_ID(CatchProj, Proj, 0)
594 DEFINE_CLASS_ID(JumpProj, Proj, 1)
595 DEFINE_CLASS_ID(IfTrue, Proj, 2)
596 DEFINE_CLASS_ID(IfFalse, Proj, 3)
597 DEFINE_CLASS_ID(Parm, Proj, 4)
598 DEFINE_CLASS_ID(MachProj, Proj, 5)
599
600 DEFINE_CLASS_ID(Mem, Node, 4)
601 DEFINE_CLASS_ID(Load, Mem, 0)
617 DEFINE_CLASS_ID(MergeMem, Node, 7)
618 DEFINE_CLASS_ID(Bool, Node, 8)
619 DEFINE_CLASS_ID(AddP, Node, 9)
620 DEFINE_CLASS_ID(BoxLock, Node, 10)
621 DEFINE_CLASS_ID(Add, Node, 11)
622 DEFINE_CLASS_ID(Vector, Node, 12)
623 DEFINE_CLASS_ID(ClearArray, Node, 13)
624
625 _max_classes = ClassMask_ClearArray
626 };
627 #undef DEFINE_CLASS_ID
628
629 // Flags are sorted by usage frequency.
630 enum NodeFlags {
631 Flag_is_Copy = 0x01, // should be first bit to avoid shift
632 Flag_rematerialize = Flag_is_Copy << 1,
633 Flag_needs_anti_dependence_check = Flag_rematerialize << 1,
634 Flag_is_macro = Flag_needs_anti_dependence_check << 1,
635 Flag_is_Con = Flag_is_macro << 1,
636 Flag_is_cisc_alternate = Flag_is_Con << 1,
637 Flag_is_Branch = Flag_is_cisc_alternate << 1,
638 Flag_is_dead_loop_safe = Flag_is_Branch << 1,
639 Flag_may_be_short_branch = Flag_is_dead_loop_safe << 1,
640 Flag_avoid_back_to_back = Flag_may_be_short_branch << 1,
641 _max_flags = (Flag_avoid_back_to_back << 1) - 1 // allow flags combination
642 };
643
644 private:
645 jushort _class_id;
646 jushort _flags;
647
648 protected:
649 // These methods should be called from constructors only.
650 void init_class_id(jushort c) {
651 assert(c <= _max_classes, "invalid node class");
652 _class_id = c; // cast out const
653 }
654 void init_flags(jushort fl) {
655 assert(fl <= _max_flags, "invalid node flag");
656 _flags |= fl;
657 }
658 void clear_flag(jushort fl) {
704 DEFINE_CLASS_QUERY(ClearArray)
705 DEFINE_CLASS_QUERY(CMove)
706 DEFINE_CLASS_QUERY(Cmp)
707 DEFINE_CLASS_QUERY(CountedLoop)
708 DEFINE_CLASS_QUERY(CountedLoopEnd)
709 DEFINE_CLASS_QUERY(DecodeN)
710 DEFINE_CLASS_QUERY(EncodeP)
711 DEFINE_CLASS_QUERY(FastLock)
712 DEFINE_CLASS_QUERY(FastUnlock)
713 DEFINE_CLASS_QUERY(If)
714 DEFINE_CLASS_QUERY(IfFalse)
715 DEFINE_CLASS_QUERY(IfTrue)
716 DEFINE_CLASS_QUERY(Initialize)
717 DEFINE_CLASS_QUERY(Jump)
718 DEFINE_CLASS_QUERY(JumpProj)
719 DEFINE_CLASS_QUERY(Load)
720 DEFINE_CLASS_QUERY(LoadStore)
721 DEFINE_CLASS_QUERY(Lock)
722 DEFINE_CLASS_QUERY(Loop)
723 DEFINE_CLASS_QUERY(Mach)
724 DEFINE_CLASS_QUERY(MachCall)
725 DEFINE_CLASS_QUERY(MachCallDynamicJava)
726 DEFINE_CLASS_QUERY(MachCallJava)
727 DEFINE_CLASS_QUERY(MachCallLeaf)
728 DEFINE_CLASS_QUERY(MachCallRuntime)
729 DEFINE_CLASS_QUERY(MachCallStaticJava)
730 DEFINE_CLASS_QUERY(MachConstantBase)
731 DEFINE_CLASS_QUERY(MachConstant)
732 DEFINE_CLASS_QUERY(MachGoto)
733 DEFINE_CLASS_QUERY(MachIf)
734 DEFINE_CLASS_QUERY(MachNullCheck)
735 DEFINE_CLASS_QUERY(MachProj)
736 DEFINE_CLASS_QUERY(MachReturn)
737 DEFINE_CLASS_QUERY(MachSafePoint)
738 DEFINE_CLASS_QUERY(MachSpillCopy)
739 DEFINE_CLASS_QUERY(MachTemp)
740 DEFINE_CLASS_QUERY(Mem)
741 DEFINE_CLASS_QUERY(MemBar)
742 DEFINE_CLASS_QUERY(MergeMem)
743 DEFINE_CLASS_QUERY(Multi)
770 // The data node which is safe to leave in dead loop during IGVN optimization.
771 bool is_dead_loop_safe() const {
772 return is_Phi() || (is_Proj() && in(0) == NULL) ||
773 ((_flags & (Flag_is_dead_loop_safe | Flag_is_Con)) != 0 &&
774 (!is_Proj() || !in(0)->is_Allocate()));
775 }
776
777 // is_Copy() returns copied edge index (0 or 1)
778 uint is_Copy() const { return (_flags & Flag_is_Copy); }
779
780 virtual bool is_CFG() const { return false; }
781
782 // If this node is control-dependent on a test, can it be
783 // rerouted to a dominating equivalent test? This is usually
784 // true of non-CFG nodes, but can be false for operations which
785 // depend for their correct sequencing on more than one test.
786 // (In that case, hoisting to a dominating test may silently
787 // skip some other important test.)
788 virtual bool depends_only_on_test() const { assert(!is_CFG(), ""); return true; };
789
790 // defined for MachNodes that match 'If' | 'Goto' | 'CountedLoopEnd' | 'Jump'
791 bool is_Branch() const { return (_flags & Flag_is_Branch) != 0; }
792
793 // When building basic blocks, I need to have a notion of block beginning
794 // Nodes, next block selector Nodes (block enders), and next block
795 // projections. These calls need to work on their machine equivalents. The
796 // Ideal beginning Nodes are RootNode, RegionNode and StartNode.
797 bool is_block_start() const {
798 if ( is_Region() )
799 return this == (const Node*)in(0);
800 else
801 return is_Start();
802 }
803
804 // The Ideal control projection Nodes are IfTrue/IfFalse, JumpProjNode, Root,
805 // Goto and Return. This call also returns the block ending Node.
806 virtual const Node *is_block_proj() const;
807
808 // The node is a "macro" node which needs to be expanded before matching
809 bool is_macro() const { return (_flags & Flag_is_macro) != 0; }
810
811 //----------------- Optimization
812
|
60 class CodeBuffer;
61 class ConstraintCastNode;
62 class ConNode;
63 class CountedLoopNode;
64 class CountedLoopEndNode;
65 class DecodeNNode;
66 class EncodePNode;
67 class FastLockNode;
68 class FastUnlockNode;
69 class IfNode;
70 class IfFalseNode;
71 class IfTrueNode;
72 class InitializeNode;
73 class JVMState;
74 class JumpNode;
75 class JumpProjNode;
76 class LoadNode;
77 class LoadStoreNode;
78 class LockNode;
79 class LoopNode;
80 class MachBranchNode;
81 class MachCallDynamicJavaNode;
82 class MachCallJavaNode;
83 class MachCallLeafNode;
84 class MachCallNode;
85 class MachCallRuntimeNode;
86 class MachCallStaticJavaNode;
87 class MachConstantBaseNode;
88 class MachConstantNode;
89 class MachGotoNode;
90 class MachIfNode;
91 class MachNode;
92 class MachNullCheckNode;
93 class MachProjNode;
94 class MachReturnNode;
95 class MachSafePointNode;
96 class MachSpillCopyNode;
97 class MachTempNode;
98 class Matcher;
99 class MemBarNode;
100 class MemNode;
556 DEFINE_CLASS_ID(MultiBranch, Multi, 1)
557 DEFINE_CLASS_ID(PCTable, MultiBranch, 0)
558 DEFINE_CLASS_ID(Catch, PCTable, 0)
559 DEFINE_CLASS_ID(Jump, PCTable, 1)
560 DEFINE_CLASS_ID(If, MultiBranch, 1)
561 DEFINE_CLASS_ID(CountedLoopEnd, If, 0)
562 DEFINE_CLASS_ID(NeverBranch, MultiBranch, 2)
563 DEFINE_CLASS_ID(Start, Multi, 2)
564 DEFINE_CLASS_ID(MemBar, Multi, 3)
565 DEFINE_CLASS_ID(Initialize, MemBar, 0)
566
567 DEFINE_CLASS_ID(Mach, Node, 1)
568 DEFINE_CLASS_ID(MachReturn, Mach, 0)
569 DEFINE_CLASS_ID(MachSafePoint, MachReturn, 0)
570 DEFINE_CLASS_ID(MachCall, MachSafePoint, 0)
571 DEFINE_CLASS_ID(MachCallJava, MachCall, 0)
572 DEFINE_CLASS_ID(MachCallStaticJava, MachCallJava, 0)
573 DEFINE_CLASS_ID(MachCallDynamicJava, MachCallJava, 1)
574 DEFINE_CLASS_ID(MachCallRuntime, MachCall, 1)
575 DEFINE_CLASS_ID(MachCallLeaf, MachCallRuntime, 0)
576 DEFINE_CLASS_ID(MachBranch, Mach, 1)
577 DEFINE_CLASS_ID(MachIf, MachBranch, 0)
578 DEFINE_CLASS_ID(MachGoto, MachBranch, 1)
579 DEFINE_CLASS_ID(MachNullCheck, MachBranch, 2)
580 DEFINE_CLASS_ID(MachSpillCopy, Mach, 2)
581 DEFINE_CLASS_ID(MachTemp, Mach, 3)
582 DEFINE_CLASS_ID(MachConstantBase, Mach, 4)
583 DEFINE_CLASS_ID(MachConstant, Mach, 5)
584
585 DEFINE_CLASS_ID(Type, Node, 2)
586 DEFINE_CLASS_ID(Phi, Type, 0)
587 DEFINE_CLASS_ID(ConstraintCast, Type, 1)
588 DEFINE_CLASS_ID(CheckCastPP, Type, 2)
589 DEFINE_CLASS_ID(CMove, Type, 3)
590 DEFINE_CLASS_ID(SafePointScalarObject, Type, 4)
591 DEFINE_CLASS_ID(DecodeN, Type, 5)
592 DEFINE_CLASS_ID(EncodeP, Type, 6)
593
594 DEFINE_CLASS_ID(Proj, Node, 3)
595 DEFINE_CLASS_ID(CatchProj, Proj, 0)
596 DEFINE_CLASS_ID(JumpProj, Proj, 1)
597 DEFINE_CLASS_ID(IfTrue, Proj, 2)
598 DEFINE_CLASS_ID(IfFalse, Proj, 3)
599 DEFINE_CLASS_ID(Parm, Proj, 4)
600 DEFINE_CLASS_ID(MachProj, Proj, 5)
601
602 DEFINE_CLASS_ID(Mem, Node, 4)
603 DEFINE_CLASS_ID(Load, Mem, 0)
619 DEFINE_CLASS_ID(MergeMem, Node, 7)
620 DEFINE_CLASS_ID(Bool, Node, 8)
621 DEFINE_CLASS_ID(AddP, Node, 9)
622 DEFINE_CLASS_ID(BoxLock, Node, 10)
623 DEFINE_CLASS_ID(Add, Node, 11)
624 DEFINE_CLASS_ID(Vector, Node, 12)
625 DEFINE_CLASS_ID(ClearArray, Node, 13)
626
627 _max_classes = ClassMask_ClearArray
628 };
629 #undef DEFINE_CLASS_ID
630
631 // Flags are sorted by usage frequency.
632 enum NodeFlags {
633 Flag_is_Copy = 0x01, // should be first bit to avoid shift
634 Flag_rematerialize = Flag_is_Copy << 1,
635 Flag_needs_anti_dependence_check = Flag_rematerialize << 1,
636 Flag_is_macro = Flag_needs_anti_dependence_check << 1,
637 Flag_is_Con = Flag_is_macro << 1,
638 Flag_is_cisc_alternate = Flag_is_Con << 1,
639 Flag_is_dead_loop_safe = Flag_is_cisc_alternate << 1,
640 Flag_may_be_short_branch = Flag_is_dead_loop_safe << 1,
641 Flag_avoid_back_to_back = Flag_may_be_short_branch << 1,
642 _max_flags = (Flag_avoid_back_to_back << 1) - 1 // allow flags combination
643 };
644
645 private:
646 jushort _class_id;
647 jushort _flags;
648
649 protected:
650 // These methods should be called from constructors only.
651 void init_class_id(jushort c) {
652 assert(c <= _max_classes, "invalid node class");
653 _class_id = c; // cast out const
654 }
655 void init_flags(jushort fl) {
656 assert(fl <= _max_flags, "invalid node flag");
657 _flags |= fl;
658 }
659 void clear_flag(jushort fl) {
705 DEFINE_CLASS_QUERY(ClearArray)
706 DEFINE_CLASS_QUERY(CMove)
707 DEFINE_CLASS_QUERY(Cmp)
708 DEFINE_CLASS_QUERY(CountedLoop)
709 DEFINE_CLASS_QUERY(CountedLoopEnd)
710 DEFINE_CLASS_QUERY(DecodeN)
711 DEFINE_CLASS_QUERY(EncodeP)
712 DEFINE_CLASS_QUERY(FastLock)
713 DEFINE_CLASS_QUERY(FastUnlock)
714 DEFINE_CLASS_QUERY(If)
715 DEFINE_CLASS_QUERY(IfFalse)
716 DEFINE_CLASS_QUERY(IfTrue)
717 DEFINE_CLASS_QUERY(Initialize)
718 DEFINE_CLASS_QUERY(Jump)
719 DEFINE_CLASS_QUERY(JumpProj)
720 DEFINE_CLASS_QUERY(Load)
721 DEFINE_CLASS_QUERY(LoadStore)
722 DEFINE_CLASS_QUERY(Lock)
723 DEFINE_CLASS_QUERY(Loop)
724 DEFINE_CLASS_QUERY(Mach)
725 DEFINE_CLASS_QUERY(MachBranch)
726 DEFINE_CLASS_QUERY(MachCall)
727 DEFINE_CLASS_QUERY(MachCallDynamicJava)
728 DEFINE_CLASS_QUERY(MachCallJava)
729 DEFINE_CLASS_QUERY(MachCallLeaf)
730 DEFINE_CLASS_QUERY(MachCallRuntime)
731 DEFINE_CLASS_QUERY(MachCallStaticJava)
732 DEFINE_CLASS_QUERY(MachConstantBase)
733 DEFINE_CLASS_QUERY(MachConstant)
734 DEFINE_CLASS_QUERY(MachGoto)
735 DEFINE_CLASS_QUERY(MachIf)
736 DEFINE_CLASS_QUERY(MachNullCheck)
737 DEFINE_CLASS_QUERY(MachProj)
738 DEFINE_CLASS_QUERY(MachReturn)
739 DEFINE_CLASS_QUERY(MachSafePoint)
740 DEFINE_CLASS_QUERY(MachSpillCopy)
741 DEFINE_CLASS_QUERY(MachTemp)
742 DEFINE_CLASS_QUERY(Mem)
743 DEFINE_CLASS_QUERY(MemBar)
744 DEFINE_CLASS_QUERY(MergeMem)
745 DEFINE_CLASS_QUERY(Multi)
772 // The data node which is safe to leave in dead loop during IGVN optimization.
773 bool is_dead_loop_safe() const {
774 return is_Phi() || (is_Proj() && in(0) == NULL) ||
775 ((_flags & (Flag_is_dead_loop_safe | Flag_is_Con)) != 0 &&
776 (!is_Proj() || !in(0)->is_Allocate()));
777 }
778
779 // is_Copy() returns copied edge index (0 or 1)
780 uint is_Copy() const { return (_flags & Flag_is_Copy); }
781
782 virtual bool is_CFG() const { return false; }
783
784 // If this node is control-dependent on a test, can it be
785 // rerouted to a dominating equivalent test? This is usually
786 // true of non-CFG nodes, but can be false for operations which
787 // depend for their correct sequencing on more than one test.
788 // (In that case, hoisting to a dominating test may silently
789 // skip some other important test.)
790 virtual bool depends_only_on_test() const { assert(!is_CFG(), ""); return true; };
791
792 // When building basic blocks, I need to have a notion of block beginning
793 // Nodes, next block selector Nodes (block enders), and next block
794 // projections. These calls need to work on their machine equivalents. The
795 // Ideal beginning Nodes are RootNode, RegionNode and StartNode.
796 bool is_block_start() const {
797 if ( is_Region() )
798 return this == (const Node*)in(0);
799 else
800 return is_Start();
801 }
802
803 // The Ideal control projection Nodes are IfTrue/IfFalse, JumpProjNode, Root,
804 // Goto and Return. This call also returns the block ending Node.
805 virtual const Node *is_block_proj() const;
806
807 // The node is a "macro" node which needs to be expanded before matching
808 bool is_macro() const { return (_flags & Flag_is_macro) != 0; }
809
810 //----------------- Optimization
811
|