47 _var_ct = 0;
48 _cvstate = NULL;
49 // We can go memory state free or else we need the entire memory state
50 assert(_initial_memory == NULL || _initial_memory->Opcode() == Op_MergeMem, "memory must be pre-split");
51 assert(!_gvn.is_IterGVN(), "IdealKit can't be used during Optimize phase");
52 int init_size = 5;
53 _pending_cvstates = new (C->node_arena()) GrowableArray<Node*>(C->node_arena(), init_size, 0, 0);
54 DEBUG_ONLY(_state = new (C->node_arena()) GrowableArray<int>(C->node_arena(), init_size, 0, 0));
55 if (!has_declarations) {
56 declarations_done();
57 }
58 }
59
60 //----------------------------sync_kit-----------------------------------------
61 void IdealKit::sync_kit(GraphKit* gkit) {
62 set_all_memory(gkit->merged_memory());
63 set_i_o(gkit->i_o());
64 set_ctrl(gkit->control());
65 }
66
67 //-------------------------------if_then-------------------------------------
68 // Create: if(left relop right)
69 // / \
70 // iffalse iftrue
71 // Push the iffalse cvstate onto the stack. The iftrue becomes the current cvstate.
72 void IdealKit::if_then(Node* left, BoolTest::mask relop,
73 Node* right, float prob, float cnt, bool push_new_state) {
74 assert((state() & (BlockS|LoopS|IfThenS|ElseS)), "bad state for new If");
75 Node* bol;
76 if (left->bottom_type()->isa_ptr() == NULL) {
77 if (left->bottom_type()->isa_int() != NULL) {
78 bol = Bool(CmpI(left, right), relop);
79 } else {
80 assert(left->bottom_type()->isa_long() != NULL, "what else?");
81 bol = Bool(CmpL(left, right), relop);
82 }
83
84 } else {
85 bol = Bool(CmpP(left, right), relop);
86 }
87 // Delay gvn.tranform on if-nodes until construction is finished
88 // to prevent a constant bool input from discarding a control output.
89 IfNode* iff = delay_transform(new IfNode(ctrl(), bol, prob, cnt))->as_If();
90 Node* then = IfTrue(iff);
91 Node* elsen = IfFalse(iff);
92 Node* else_cvstate = copy_cvstate();
93 else_cvstate->set_req(TypeFunc::Control, elsen);
94 _pending_cvstates->push(else_cvstate);
95 DEBUG_ONLY(if (push_new_state) _state->push(IfThenS));
96 set_ctrl(then);
97 }
98
99 //-------------------------------else_-------------------------------------
100 // Pop the else cvstate off the stack, and push the (current) then cvstate.
101 // The else cvstate becomes the current cvstate.
102 void IdealKit::else_() {
103 assert(state() == IfThenS, "bad state for new Else");
104 Node* else_cvstate = _pending_cvstates->pop();
105 DEBUG_ONLY(_state->pop());
106 // save current (then) cvstate for later use at endif
|
47 _var_ct = 0;
48 _cvstate = NULL;
49 // We can go memory state free or else we need the entire memory state
50 assert(_initial_memory == NULL || _initial_memory->Opcode() == Op_MergeMem, "memory must be pre-split");
51 assert(!_gvn.is_IterGVN(), "IdealKit can't be used during Optimize phase");
52 int init_size = 5;
53 _pending_cvstates = new (C->node_arena()) GrowableArray<Node*>(C->node_arena(), init_size, 0, 0);
54 DEBUG_ONLY(_state = new (C->node_arena()) GrowableArray<int>(C->node_arena(), init_size, 0, 0));
55 if (!has_declarations) {
56 declarations_done();
57 }
58 }
59
60 //----------------------------sync_kit-----------------------------------------
61 void IdealKit::sync_kit(GraphKit* gkit) {
62 set_all_memory(gkit->merged_memory());
63 set_i_o(gkit->i_o());
64 set_ctrl(gkit->control());
65 }
66
67 //-------------------------------uif_then-------------------------------------
68 // Create: unsigned if(left relop right)
69 // / \
70 // iffalse iftrue
71 // Push the iffalse cvstate onto the stack. The iftrue becomes the current cvstate.
72 void IdealKit::uif_then(Node* left, BoolTest::mask relop,
73 Node* right, float prob, float cnt, bool push_new_state) {
74 assert((state() & (BlockS|LoopS|IfThenS|ElseS)), "bad state for new If");
75 Node* bol;
76 if (left->bottom_type()->isa_ptr() == NULL) {
77 if (left->bottom_type()->isa_int() != NULL) {
78 bol = Bool(CmpU(left, right), relop);
79 } else {
80 assert(left->bottom_type()->isa_long() != NULL, "what else?");
81 bol = Bool(CmpUL(left, right), relop);
82 }
83
84 } else {
85 bol = Bool(CmpP(left, right), relop);
86 }
87
88 if_then_common(bol, prob, cnt, push_new_state);
89 }
90
91 //-------------------------------if_then-------------------------------------
92 // Create: if(left relop right)
93 // / \
94 // iffalse iftrue
95 // Push the iffalse cvstate onto the stack. The iftrue becomes the current cvstate.
96 void IdealKit::if_then(Node* left, BoolTest::mask relop,
97 Node* right, float prob, float cnt, bool push_new_state) {
98 assert((state() & (BlockS|LoopS|IfThenS|ElseS)), "bad state for new If");
99 Node* bol;
100 if (left->bottom_type()->isa_ptr() == NULL) {
101 if (left->bottom_type()->isa_int() != NULL) {
102 bol = Bool(CmpI(left, right), relop);
103 } else {
104 assert(left->bottom_type()->isa_long() != NULL, "what else?");
105 bol = Bool(CmpL(left, right), relop);
106 }
107
108 } else {
109 bol = Bool(CmpP(left, right), relop);
110 }
111
112 if_then_common(bol, prob, cnt, push_new_state);
113 }
114
115 // Common helper to create the If nodes for if_then and uif_then
116 void IdealKit::if_then_common(Node* bol, float prob, float cnt,
117 bool push_new_state) {
118 // Delay gvn.tranform on if-nodes until construction is finished
119 // to prevent a constant bool input from discarding a control output.
120 IfNode* iff = delay_transform(new IfNode(ctrl(), bol, prob, cnt))->as_If();
121 Node* then = IfTrue(iff);
122 Node* elsen = IfFalse(iff);
123 Node* else_cvstate = copy_cvstate();
124 else_cvstate->set_req(TypeFunc::Control, elsen);
125 _pending_cvstates->push(else_cvstate);
126 DEBUG_ONLY(if (push_new_state) _state->push(IfThenS));
127 set_ctrl(then);
128 }
129
130 //-------------------------------else_-------------------------------------
131 // Pop the else cvstate off the stack, and push the (current) then cvstate.
132 // The else cvstate becomes the current cvstate.
133 void IdealKit::else_() {
134 assert(state() == IfThenS, "bad state for new Else");
135 Node* else_cvstate = _pending_cvstates->pop();
136 DEBUG_ONLY(_state->pop());
137 // save current (then) cvstate for later use at endif
|