632
633
634 #ifdef ASSERT
635 class AssertValues: public ValueVisitor {
636 void visit(Value* x) { assert((*x) != NULL, "value must exist"); }
637 };
638 #define ASSERT_VALUES { AssertValues assert_value; values_do(&assert_value); }
639 #else
640 #define ASSERT_VALUES
641 #endif // ASSERT
642
643
644 // A Phi is a phi function in the sense of SSA form. It stands for
645 // the value of a local variable at the beginning of a join block.
646 // A Phi consists of n operands, one for every incoming branch.
647
648 LEAF(Phi, Instruction)
649 private:
650 int _pf_flags; // the flags of the phi function
651 int _index; // to value on operand stack (index < 0) or to local
652 public:
653 // creation
654 Phi(ValueType* type, BlockBegin* b, int index)
655 : Instruction(type->base())
656 , _pf_flags(0)
657 , _index(index)
658 {
659 _block = b;
660 NOT_PRODUCT(set_printable_bci(Value(b)->printable_bci()));
661 if (type->is_illegal()) {
662 make_illegal();
663 }
664 }
665
666 // flags
667 enum Flag {
668 no_flag = 0,
669 visited = 1 << 0,
670 cannot_simplify = 1 << 1
671 };
672
673 // accessors
674 bool is_local() const { return _index >= 0; }
675 bool is_on_stack() const { return !is_local(); }
676 int local_index() const { assert(is_local(), ""); return _index; }
677 int stack_index() const { assert(is_on_stack(), ""); return -(_index+1); }
678
679 Value operand_at(int i) const;
680 int operand_count() const;
681
682 void set(Flag f) { _pf_flags |= f; }
683 void clear(Flag f) { _pf_flags &= ~f; }
|
632
633
634 #ifdef ASSERT
635 class AssertValues: public ValueVisitor {
636 void visit(Value* x) { assert((*x) != NULL, "value must exist"); }
637 };
638 #define ASSERT_VALUES { AssertValues assert_value; values_do(&assert_value); }
639 #else
640 #define ASSERT_VALUES
641 #endif // ASSERT
642
643
644 // A Phi is a phi function in the sense of SSA form. It stands for
645 // the value of a local variable at the beginning of a join block.
646 // A Phi consists of n operands, one for every incoming branch.
647
648 LEAF(Phi, Instruction)
649 private:
650 int _pf_flags; // the flags of the phi function
651 int _index; // to value on operand stack (index < 0) or to local
652 ciType* _exact_type; // preserve type information for flattened arrays.
653 public:
654 // creation
655 Phi(ValueType* type, BlockBegin* b, int index, ciType* exact_type)
656 : Instruction(type->base())
657 , _pf_flags(0)
658 , _index(index)
659 , _exact_type(exact_type)
660 {
661 _block = b;
662 NOT_PRODUCT(set_printable_bci(Value(b)->printable_bci()));
663 if (type->is_illegal()) {
664 make_illegal();
665 }
666 }
667
668 virtual ciType* exact_type() const {
669 return _exact_type;
670 }
671
672 virtual ciType* declared_type() const {
673 return _exact_type;
674 }
675
676 // flags
677 enum Flag {
678 no_flag = 0,
679 visited = 1 << 0,
680 cannot_simplify = 1 << 1
681 };
682
683 // accessors
684 bool is_local() const { return _index >= 0; }
685 bool is_on_stack() const { return !is_local(); }
686 int local_index() const { assert(is_local(), ""); return _index; }
687 int stack_index() const { assert(is_on_stack(), ""); return -(_index+1); }
688
689 Value operand_at(int i) const;
690 int operand_count() const;
691
692 void set(Flag f) { _pf_flags |= f; }
693 void clear(Flag f) { _pf_flags &= ~f; }
|