23 */
24
25 #include "precompiled.hpp"
26 #include "compiler/compileLog.hpp"
27 #include "ci/bcEscapeAnalyzer.hpp"
28 #include "compiler/oopMap.hpp"
29 #include "opto/callGenerator.hpp"
30 #include "opto/callnode.hpp"
31 #include "opto/castnode.hpp"
32 #include "opto/convertnode.hpp"
33 #include "opto/escape.hpp"
34 #include "opto/locknode.hpp"
35 #include "opto/machnode.hpp"
36 #include "opto/matcher.hpp"
37 #include "opto/parse.hpp"
38 #include "opto/regalloc.hpp"
39 #include "opto/regmask.hpp"
40 #include "opto/rootnode.hpp"
41 #include "opto/runtime.hpp"
42 #include "opto/valuetypenode.hpp"
43
44 // Portions of code courtesy of Clifford Click
45
46 // Optimization - Graph Style
47
48 //=============================================================================
49 uint StartNode::size_of() const { return sizeof(*this); }
50 uint StartNode::cmp( const Node &n ) const
51 { return _domain == ((StartNode&)n)._domain; }
52 const Type *StartNode::bottom_type() const { return _domain; }
53 const Type* StartNode::Value(PhaseGVN* phase) const { return _domain; }
54 #ifndef PRODUCT
55 void StartNode::dump_spec(outputStream *st) const { st->print(" #"); _domain->dump_on(st);}
56 void StartNode::dump_compact_spec(outputStream *st) const { /* empty */ }
57 #endif
58
59 //------------------------------Ideal------------------------------------------
60 Node *StartNode::Ideal(PhaseGVN *phase, bool can_reshape){
61 return remove_dead_region(phase, can_reshape) ? this : NULL;
62 }
63
64 //------------------------------calling_convention-----------------------------
65 void StartNode::calling_convention( BasicType* sig_bt, VMRegPair *parm_regs, uint argcnt ) const {
66 Matcher::calling_convention( sig_bt, parm_regs, argcnt, false );
67 }
68
69 //------------------------------Registers--------------------------------------
70 const RegMask &StartNode::in_RegMask(uint) const {
71 return RegMask::Empty;
72 }
73
74 //------------------------------match------------------------------------------
75 // Construct projections for incoming parameters, and their RegMask info
76 Node *StartNode::match( const ProjNode *proj, const Matcher *match ) {
77 switch (proj->_con) {
78 case TypeFunc::Control:
79 case TypeFunc::I_O:
80 case TypeFunc::Memory:
81 return new MachProjNode(this,proj->_con,RegMask::Empty,MachProjNode::unmatched_proj);
82 case TypeFunc::FramePtr:
83 return new MachProjNode(this,proj->_con,Matcher::c_frame_ptr_mask, Op_RegP);
84 case TypeFunc::ReturnAdr:
85 return new MachProjNode(this,proj->_con,match->_return_addr_mask,Op_RegP);
86 case TypeFunc::Parms:
87 default: {
88 uint parm_num = proj->_con - TypeFunc::Parms;
89 const Type *t = _domain->field_at(proj->_con);
90 if (t->base() == Type::Half) // 2nd half of Longs and Doubles
91 return new ConNode(Type::TOP);
92 uint ideal_reg = t->ideal_reg();
93 RegMask &rm = match->_calling_convention_mask[parm_num];
94 return new MachProjNode(this,proj->_con,rm,ideal_reg);
95 }
96 }
670 #ifndef PRODUCT
671 void CallNode::dump_req(outputStream *st) const {
672 // Dump the required inputs, enclosed in '(' and ')'
673 uint i; // Exit value of loop
674 for (i = 0; i < req(); i++) { // For all required inputs
675 if (i == TypeFunc::Parms) st->print("(");
676 if (in(i)) st->print("%c%d ", Compile::current()->node_arena()->contains(in(i)) ? ' ' : 'o', in(i)->_idx);
677 else st->print("_ ");
678 }
679 st->print(")");
680 }
681
682 void CallNode::dump_spec(outputStream *st) const {
683 st->print(" ");
684 if (tf() != NULL) tf()->dump_on(st);
685 if (_cnt != COUNT_UNKNOWN) st->print(" C=%f",_cnt);
686 if (jvms() != NULL) jvms()->dump_spec(st);
687 }
688 #endif
689
690 const Type *CallNode::bottom_type() const { return tf()->range(); }
691 const Type* CallNode::Value(PhaseGVN* phase) const {
692 if (phase->type(in(0)) == Type::TOP) return Type::TOP;
693 return tf()->range();
694 }
695
696 //------------------------------calling_convention-----------------------------
697 void CallNode::calling_convention( BasicType* sig_bt, VMRegPair *parm_regs, uint argcnt ) const {
698 // Use the standard compiler calling convention
699 Matcher::calling_convention( sig_bt, parm_regs, argcnt, true );
700 }
701
702
703 //------------------------------match------------------------------------------
704 // Construct projections for control, I/O, memory-fields, ..., and
705 // return result(s) along with their RegMask info
706 Node *CallNode::match( const ProjNode *proj, const Matcher *match ) {
707 switch (proj->_con) {
708 case TypeFunc::Control:
709 case TypeFunc::I_O:
710 case TypeFunc::Memory:
711 return new MachProjNode(this,proj->_con,RegMask::Empty,MachProjNode::unmatched_proj);
712
713 case TypeFunc::Parms+1: // For LONG & DOUBLE returns
714 assert(tf()->range()->field_at(TypeFunc::Parms+1) == Type::HALF, "");
715 // 2nd half of doubles and longs
716 return new MachProjNode(this,proj->_con, RegMask::Empty, (uint)OptoReg::Bad);
717
718 case TypeFunc::Parms: { // Normal returns
719 uint ideal_reg = tf()->range()->field_at(TypeFunc::Parms)->ideal_reg();
720 OptoRegPair regs = is_CallRuntime()
721 ? match->c_return_value(ideal_reg,true) // Calls into C runtime
722 : match-> return_value(ideal_reg,true); // Calls into compiled Java code
723 RegMask rm = RegMask(regs.first());
724 if( OptoReg::is_valid(regs.second()) )
725 rm.Insert( regs.second() );
726 return new MachProjNode(this,proj->_con,rm,ideal_reg);
727 }
728
729 case TypeFunc::ReturnAdr:
730 case TypeFunc::FramePtr:
731 default:
732 ShouldNotReachHere();
733 }
734 return NULL;
735 }
736
737 // Do we Match on this edge index or not? Match no edges
738 uint CallNode::match_edge(uint idx) const {
739 return 0;
740 }
741
742 //
743 // Determine whether the call could modify the field of the specified
744 // instance at the specified offset.
745 //
746 bool CallNode::may_modify(const TypeOopPtr *t_oop, PhaseTransform *phase) {
747 assert((t_oop != NULL), "sanity");
|
23 */
24
25 #include "precompiled.hpp"
26 #include "compiler/compileLog.hpp"
27 #include "ci/bcEscapeAnalyzer.hpp"
28 #include "compiler/oopMap.hpp"
29 #include "opto/callGenerator.hpp"
30 #include "opto/callnode.hpp"
31 #include "opto/castnode.hpp"
32 #include "opto/convertnode.hpp"
33 #include "opto/escape.hpp"
34 #include "opto/locknode.hpp"
35 #include "opto/machnode.hpp"
36 #include "opto/matcher.hpp"
37 #include "opto/parse.hpp"
38 #include "opto/regalloc.hpp"
39 #include "opto/regmask.hpp"
40 #include "opto/rootnode.hpp"
41 #include "opto/runtime.hpp"
42 #include "opto/valuetypenode.hpp"
43 #include "runtime/sharedRuntime.hpp"
44
45 // Portions of code courtesy of Clifford Click
46
47 // Optimization - Graph Style
48
49 //=============================================================================
50 uint StartNode::size_of() const { return sizeof(*this); }
51 uint StartNode::cmp( const Node &n ) const
52 { return _domain == ((StartNode&)n)._domain; }
53 const Type *StartNode::bottom_type() const { return _domain; }
54 const Type* StartNode::Value(PhaseGVN* phase) const { return _domain; }
55 #ifndef PRODUCT
56 void StartNode::dump_spec(outputStream *st) const { st->print(" #"); _domain->dump_on(st);}
57 void StartNode::dump_compact_spec(outputStream *st) const { /* empty */ }
58 #endif
59
60 //------------------------------Ideal------------------------------------------
61 Node *StartNode::Ideal(PhaseGVN *phase, bool can_reshape){
62 return remove_dead_region(phase, can_reshape) ? this : NULL;
63 }
64
65 //------------------------------calling_convention-----------------------------
66 void StartNode::calling_convention( BasicType* sig_bt, VMRegPair *parm_regs, uint argcnt ) const {
67 Matcher::calling_convention( sig_bt, parm_regs, argcnt, false );
68 }
69
70 //------------------------------Registers--------------------------------------
71 const RegMask &StartNode::in_RegMask(uint) const {
72 return RegMask::Empty;
73 }
74
75 //------------------------------match------------------------------------------
76 // Construct projections for incoming parameters, and their RegMask info
77 Node *StartNode::match(const ProjNode *proj, const Matcher *match, const RegMask* mask) {
78 switch (proj->_con) {
79 case TypeFunc::Control:
80 case TypeFunc::I_O:
81 case TypeFunc::Memory:
82 return new MachProjNode(this,proj->_con,RegMask::Empty,MachProjNode::unmatched_proj);
83 case TypeFunc::FramePtr:
84 return new MachProjNode(this,proj->_con,Matcher::c_frame_ptr_mask, Op_RegP);
85 case TypeFunc::ReturnAdr:
86 return new MachProjNode(this,proj->_con,match->_return_addr_mask,Op_RegP);
87 case TypeFunc::Parms:
88 default: {
89 uint parm_num = proj->_con - TypeFunc::Parms;
90 const Type *t = _domain->field_at(proj->_con);
91 if (t->base() == Type::Half) // 2nd half of Longs and Doubles
92 return new ConNode(Type::TOP);
93 uint ideal_reg = t->ideal_reg();
94 RegMask &rm = match->_calling_convention_mask[parm_num];
95 return new MachProjNode(this,proj->_con,rm,ideal_reg);
96 }
97 }
671 #ifndef PRODUCT
672 void CallNode::dump_req(outputStream *st) const {
673 // Dump the required inputs, enclosed in '(' and ')'
674 uint i; // Exit value of loop
675 for (i = 0; i < req(); i++) { // For all required inputs
676 if (i == TypeFunc::Parms) st->print("(");
677 if (in(i)) st->print("%c%d ", Compile::current()->node_arena()->contains(in(i)) ? ' ' : 'o', in(i)->_idx);
678 else st->print("_ ");
679 }
680 st->print(")");
681 }
682
683 void CallNode::dump_spec(outputStream *st) const {
684 st->print(" ");
685 if (tf() != NULL) tf()->dump_on(st);
686 if (_cnt != COUNT_UNKNOWN) st->print(" C=%f",_cnt);
687 if (jvms() != NULL) jvms()->dump_spec(st);
688 }
689 #endif
690
691 const Type *CallNode::bottom_type() const { return tf()->range_cc(); }
692 const Type* CallNode::Value(PhaseGVN* phase) const {
693 if (phase->type(in(0)) == Type::TOP) return Type::TOP;
694 return tf()->range_cc();
695 }
696
697 //------------------------------calling_convention-----------------------------
698 void CallNode::calling_convention(BasicType* sig_bt, VMRegPair *parm_regs, uint argcnt) const {
699 if (_entry_point == StubRoutines::store_value_type_fields_to_buf()) {
700 // The call to that stub is a special case: its inputs are
701 // multiple values returned from a call and so it should follow
702 // the return convention.
703 SharedRuntime::java_return_convention(sig_bt, parm_regs, argcnt);
704 return;
705 }
706 // Use the standard compiler calling convention
707 Matcher::calling_convention( sig_bt, parm_regs, argcnt, true );
708 }
709
710
711 //------------------------------match------------------------------------------
712 // Construct projections for control, I/O, memory-fields, ..., and
713 // return result(s) along with their RegMask info
714 Node *CallNode::match(const ProjNode *proj, const Matcher *match, const RegMask* mask) {
715 uint con = proj->_con;
716 const TypeTuple *range_cc = tf()->range_cc();
717 if (con >= TypeFunc::Parms) {
718 if (is_CallRuntime()) {
719 if (con == TypeFunc::Parms) {
720 uint ideal_reg = range_cc->field_at(TypeFunc::Parms)->ideal_reg();
721 OptoRegPair regs = match->c_return_value(ideal_reg,true);
722 RegMask rm = RegMask(regs.first());
723 if (OptoReg::is_valid(regs.second())) {
724 rm.Insert(regs.second());
725 }
726 return new MachProjNode(this,con,rm,ideal_reg);
727 } else {
728 assert(con == TypeFunc::Parms+1, "only one return value");
729 assert(range_cc->field_at(TypeFunc::Parms+1) == Type::HALF, "");
730 return new MachProjNode(this,con, RegMask::Empty, (uint)OptoReg::Bad);
731 }
732 } else {
733 // The Call may return multiple values (value type fields): we
734 // create one projection per returned values.
735 assert(con <= TypeFunc::Parms+1 || ValueTypeReturnedAsFields, "only for multi value return");
736 uint ideal_reg = range_cc->field_at(con)->ideal_reg();
737 return new MachProjNode(this, con, mask[con-TypeFunc::Parms], ideal_reg);
738 }
739 }
740
741 switch (con) {
742 case TypeFunc::Control:
743 case TypeFunc::I_O:
744 case TypeFunc::Memory:
745 return new MachProjNode(this,proj->_con,RegMask::Empty,MachProjNode::unmatched_proj);
746
747 case TypeFunc::ReturnAdr:
748 case TypeFunc::FramePtr:
749 default:
750 ShouldNotReachHere();
751 }
752 return NULL;
753 }
754
755 // Do we Match on this edge index or not? Match no edges
756 uint CallNode::match_edge(uint idx) const {
757 return 0;
758 }
759
760 //
761 // Determine whether the call could modify the field of the specified
762 // instance at the specified offset.
763 //
764 bool CallNode::may_modify(const TypeOopPtr *t_oop, PhaseTransform *phase) {
765 assert((t_oop != NULL), "sanity");
|