< prev index next >

src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp

Print this page

1026                 if (if_ctrl != load_ctrl) {
1027                   // Skip possible CProj->NeverBranch in infinite loops
1028                   if ((if_ctrl->is_Proj() && if_ctrl->Opcode() == Op_CProj)
1029                       && (if_ctrl->in(0)->is_MultiBranch() && if_ctrl->in(0)->Opcode() == Op_NeverBranch)) {
1030                     if_ctrl = if_ctrl->in(0)->in(0);
1031                   }
1032                 }
1033                 assert(load_ctrl != NULL && if_ctrl == load_ctrl, "controls must match");
1034               }
1035             }
1036           }
1037         }
1038       }
1039     }
1040   }
1041 }
1042 #endif
1043 
1044 Node* ShenandoahBarrierSetC2::ideal_node(PhaseGVN* phase, Node* n, bool can_reshape) const {
1045   if (is_shenandoah_wb_pre_call(n)) {
1046     uint cnt = ShenandoahBarrierSetC2::write_ref_field_pre_entry_Type()->domain()->cnt();
1047     if (n->req() > cnt) {
1048       Node* addp = n->in(cnt);
1049       if (has_only_shenandoah_wb_pre_uses(addp)) {
1050         n->del_req(cnt);
1051         if (can_reshape) {
1052           phase->is_IterGVN()->_worklist.push(addp);
1053         }
1054         return n;
1055       }
1056     }
1057   }
1058   if (n->Opcode() == Op_CmpP) {
1059     Node* in1 = n->in(1);
1060     Node* in2 = n->in(2);
1061     if (in1->bottom_type() == TypePtr::NULL_PTR) {
1062       in2 = step_over_gc_barrier(in2);
1063     }
1064     if (in2->bottom_type() == TypePtr::NULL_PTR) {
1065       in1 = step_over_gc_barrier(in1);
1066     }

1113   return NULL;
1114 }
1115 
1116 bool ShenandoahBarrierSetC2::has_only_shenandoah_wb_pre_uses(Node* n) {
1117   for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) {
1118     Node* u = n->fast_out(i);
1119     if (!is_shenandoah_wb_pre_call(u)) {
1120       return false;
1121     }
1122   }
1123   return n->outcnt() > 0;
1124 }
1125 
1126 bool ShenandoahBarrierSetC2::final_graph_reshaping(Compile* compile, Node* n, uint opcode) const {
1127   switch (opcode) {
1128     case Op_CallLeaf:
1129     case Op_CallLeafNoFP: {
1130       assert (n->is_Call(), "");
1131       CallNode *call = n->as_Call();
1132       if (ShenandoahBarrierSetC2::is_shenandoah_wb_pre_call(call)) {
1133         uint cnt = ShenandoahBarrierSetC2::write_ref_field_pre_entry_Type()->domain()->cnt();
1134         if (call->req() > cnt) {
1135           assert(call->req() == cnt + 1, "only one extra input");
1136           Node *addp = call->in(cnt);
1137           assert(!ShenandoahBarrierSetC2::has_only_shenandoah_wb_pre_uses(addp), "useless address computation?");
1138           call->del_req(cnt);
1139         }
1140       }
1141       return false;
1142     }
1143     case Op_ShenandoahCompareAndSwapP:
1144     case Op_ShenandoahCompareAndSwapN:
1145     case Op_ShenandoahWeakCompareAndSwapN:
1146     case Op_ShenandoahWeakCompareAndSwapP:
1147     case Op_ShenandoahCompareAndExchangeP:
1148     case Op_ShenandoahCompareAndExchangeN:
1149 #ifdef ASSERT
1150       if( VerifyOptoOopOffsets ) {
1151         MemNode* mem  = n->as_Mem();
1152         // Check to see if address types have grounded out somehow.
1153         const TypeInstPtr *tp = mem->in(MemNode::Address)->bottom_type()->isa_instptr();

1026                 if (if_ctrl != load_ctrl) {
1027                   // Skip possible CProj->NeverBranch in infinite loops
1028                   if ((if_ctrl->is_Proj() && if_ctrl->Opcode() == Op_CProj)
1029                       && (if_ctrl->in(0)->is_MultiBranch() && if_ctrl->in(0)->Opcode() == Op_NeverBranch)) {
1030                     if_ctrl = if_ctrl->in(0)->in(0);
1031                   }
1032                 }
1033                 assert(load_ctrl != NULL && if_ctrl == load_ctrl, "controls must match");
1034               }
1035             }
1036           }
1037         }
1038       }
1039     }
1040   }
1041 }
1042 #endif
1043 
1044 Node* ShenandoahBarrierSetC2::ideal_node(PhaseGVN* phase, Node* n, bool can_reshape) const {
1045   if (is_shenandoah_wb_pre_call(n)) {
1046     uint cnt = ShenandoahBarrierSetC2::write_ref_field_pre_entry_Type()->domain_sig()->cnt();
1047     if (n->req() > cnt) {
1048       Node* addp = n->in(cnt);
1049       if (has_only_shenandoah_wb_pre_uses(addp)) {
1050         n->del_req(cnt);
1051         if (can_reshape) {
1052           phase->is_IterGVN()->_worklist.push(addp);
1053         }
1054         return n;
1055       }
1056     }
1057   }
1058   if (n->Opcode() == Op_CmpP) {
1059     Node* in1 = n->in(1);
1060     Node* in2 = n->in(2);
1061     if (in1->bottom_type() == TypePtr::NULL_PTR) {
1062       in2 = step_over_gc_barrier(in2);
1063     }
1064     if (in2->bottom_type() == TypePtr::NULL_PTR) {
1065       in1 = step_over_gc_barrier(in1);
1066     }

1113   return NULL;
1114 }
1115 
1116 bool ShenandoahBarrierSetC2::has_only_shenandoah_wb_pre_uses(Node* n) {
1117   for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) {
1118     Node* u = n->fast_out(i);
1119     if (!is_shenandoah_wb_pre_call(u)) {
1120       return false;
1121     }
1122   }
1123   return n->outcnt() > 0;
1124 }
1125 
1126 bool ShenandoahBarrierSetC2::final_graph_reshaping(Compile* compile, Node* n, uint opcode) const {
1127   switch (opcode) {
1128     case Op_CallLeaf:
1129     case Op_CallLeafNoFP: {
1130       assert (n->is_Call(), "");
1131       CallNode *call = n->as_Call();
1132       if (ShenandoahBarrierSetC2::is_shenandoah_wb_pre_call(call)) {
1133         uint cnt = ShenandoahBarrierSetC2::write_ref_field_pre_entry_Type()->domain_sig()->cnt();
1134         if (call->req() > cnt) {
1135           assert(call->req() == cnt + 1, "only one extra input");
1136           Node *addp = call->in(cnt);
1137           assert(!ShenandoahBarrierSetC2::has_only_shenandoah_wb_pre_uses(addp), "useless address computation?");
1138           call->del_req(cnt);
1139         }
1140       }
1141       return false;
1142     }
1143     case Op_ShenandoahCompareAndSwapP:
1144     case Op_ShenandoahCompareAndSwapN:
1145     case Op_ShenandoahWeakCompareAndSwapN:
1146     case Op_ShenandoahWeakCompareAndSwapP:
1147     case Op_ShenandoahCompareAndExchangeP:
1148     case Op_ShenandoahCompareAndExchangeN:
1149 #ifdef ASSERT
1150       if( VerifyOptoOopOffsets ) {
1151         MemNode* mem  = n->as_Mem();
1152         // Check to see if address types have grounded out somehow.
1153         const TypeInstPtr *tp = mem->in(MemNode::Address)->bottom_type()->isa_instptr();
< prev index next >