55 if (uin == oldref) {
56 if (j < req)
57 use->set_req(j, newref);
58 else
59 use->set_prec(j, newref);
60 nreplacements++;
61 } else if (j >= req && uin == NULL) {
62 break;
63 }
64 }
65 return nreplacements;
66 }
67
68 void PhaseMacroExpand::copy_call_debug_info(CallNode *oldcall, CallNode * newcall) {
69 // Copy debug information and adjust JVMState information
70 uint old_dbg_start = oldcall->tf()->domain()->cnt();
71 uint new_dbg_start = newcall->tf()->domain()->cnt();
72 int jvms_adj = new_dbg_start - old_dbg_start;
73 assert (new_dbg_start == newcall->req(), "argument count mismatch");
74
75 Dict* sosn_map = new Dict(cmpkey,hashkey);
76 for (uint i = old_dbg_start; i < oldcall->req(); i++) {
77 Node* old_in = oldcall->in(i);
78 // Clone old SafePointScalarObjectNodes, adjusting their field contents.
79 if (old_in != NULL && old_in->is_SafePointScalarObject()) {
80 SafePointScalarObjectNode* old_sosn = old_in->as_SafePointScalarObject();
81 uint old_unique = C->unique();
82 Node* new_in = old_sosn->clone(jvms_adj, sosn_map);
83 if (old_unique != C->unique()) {
84 new_in->set_req(0, C->root()); // reset control edge
85 new_in = transform_later(new_in); // Register new node.
86 }
87 old_in = new_in;
88 }
89 newcall->add_req(old_in);
90 }
91
92 newcall->set_jvms(oldcall->jvms());
93 for (JVMState *jvms = newcall->jvms(); jvms != NULL; jvms = jvms->caller()) {
94 jvms->set_map(newcall);
95 jvms->set_locoff(jvms->locoff()+jvms_adj);
96 jvms->set_stkoff(jvms->stkoff()+jvms_adj);
97 jvms->set_monoff(jvms->monoff()+jvms_adj);
98 jvms->set_scloff(jvms->scloff()+jvms_adj);
99 jvms->set_endoff(jvms->endoff()+jvms_adj);
100 }
101 }
102
103 Node* PhaseMacroExpand::opt_bits_test(Node* ctrl, Node* region, int edge, Node* word, int mask, int bits, bool return_fast_path) {
708 // find the fields of the class which will be needed for safepoint debug information
709 assert(klass->is_instance_klass(), "must be an instance klass.");
710 iklass = klass->as_instance_klass();
711 nfields = iklass->nof_nonstatic_fields();
712 } else {
713 // find the array's elements which will be needed for safepoint debug information
714 nfields = alloc->in(AllocateNode::ALength)->find_int_con(-1);
715 assert(klass->is_array_klass() && nfields >= 0, "must be an array klass.");
716 elem_type = klass->as_array_klass()->element_type();
717 basic_elem_type = elem_type->basic_type();
718 array_base = arrayOopDesc::base_offset_in_bytes(basic_elem_type);
719 element_size = type2aelembytes(basic_elem_type);
720 }
721 }
722 //
723 // Process the safepoint uses
724 //
725 while (safepoints.length() > 0) {
726 SafePointNode* sfpt = safepoints.pop();
727 Node* mem = sfpt->memory();
728 uint first_ind = sfpt->req();
729 SafePointScalarObjectNode* sobj = new (C) SafePointScalarObjectNode(res_type,
730 #ifdef ASSERT
731 alloc,
732 #endif
733 first_ind, nfields);
734 sobj->init_req(0, C->root());
735 transform_later(sobj);
736
737 // Scan object's fields adding an input to the safepoint for each field.
738 for (int j = 0; j < nfields; j++) {
739 intptr_t offset;
740 ciField* field = NULL;
741 if (iklass != NULL) {
742 field = iklass->nonstatic_field_at(j);
743 offset = field->offset();
744 elem_type = field->type();
745 basic_elem_type = field->layout_type();
746 } else {
747 offset = array_base + j * (intptr_t)element_size;
748 }
782 for (int k = 0; k < j; k++) {
783 sfpt->del_req(last--);
784 }
785 // rollback processed safepoints
786 while (safepoints_done.length() > 0) {
787 SafePointNode* sfpt_done = safepoints_done.pop();
788 // remove any extra entries we added to the safepoint
789 last = sfpt_done->req() - 1;
790 for (int k = 0; k < nfields; k++) {
791 sfpt_done->del_req(last--);
792 }
793 JVMState *jvms = sfpt_done->jvms();
794 jvms->set_endoff(sfpt_done->req());
795 // Now make a pass over the debug information replacing any references
796 // to SafePointScalarObjectNode with the allocated object.
797 int start = jvms->debug_start();
798 int end = jvms->debug_end();
799 for (int i = start; i < end; i++) {
800 if (sfpt_done->in(i)->is_SafePointScalarObject()) {
801 SafePointScalarObjectNode* scobj = sfpt_done->in(i)->as_SafePointScalarObject();
802 if (scobj->first_index() == sfpt_done->req() &&
803 scobj->n_fields() == (uint)nfields) {
804 assert(scobj->alloc() == alloc, "sanity");
805 sfpt_done->set_req(i, res);
806 }
807 }
808 }
809 }
810 #ifndef PRODUCT
811 if (PrintEliminateAllocations) {
812 if (field != NULL) {
813 tty->print("=== At SafePoint node %d can't find value of Field: ",
814 sfpt->_idx);
815 field->print();
816 int field_idx = C->get_alias_index(field_addr_type);
817 tty->print(" (alias_idx=%d)", field_idx);
818 } else { // Array's element
819 tty->print("=== At SafePoint node %d can't find value of array element [%d]",
820 sfpt->_idx, j);
821 }
822 tty->print(", which prevents elimination of: ");
|
55 if (uin == oldref) {
56 if (j < req)
57 use->set_req(j, newref);
58 else
59 use->set_prec(j, newref);
60 nreplacements++;
61 } else if (j >= req && uin == NULL) {
62 break;
63 }
64 }
65 return nreplacements;
66 }
67
68 void PhaseMacroExpand::copy_call_debug_info(CallNode *oldcall, CallNode * newcall) {
69 // Copy debug information and adjust JVMState information
70 uint old_dbg_start = oldcall->tf()->domain()->cnt();
71 uint new_dbg_start = newcall->tf()->domain()->cnt();
72 int jvms_adj = new_dbg_start - old_dbg_start;
73 assert (new_dbg_start == newcall->req(), "argument count mismatch");
74
75 // SafePointScalarObject node could be referenced several times in debug info.
76 // Use Dict to record cloned nodes.
77 Dict* sosn_map = new Dict(cmpkey,hashkey);
78 for (uint i = old_dbg_start; i < oldcall->req(); i++) {
79 Node* old_in = oldcall->in(i);
80 // Clone old SafePointScalarObjectNodes, adjusting their field contents.
81 if (old_in != NULL && old_in->is_SafePointScalarObject()) {
82 SafePointScalarObjectNode* old_sosn = old_in->as_SafePointScalarObject();
83 uint old_unique = C->unique();
84 Node* new_in = old_sosn->clone(sosn_map);
85 if (old_unique != C->unique()) { // New node?
86 new_in->set_req(0, C->root()); // reset control edge
87 new_in = transform_later(new_in); // Register new node.
88 }
89 old_in = new_in;
90 }
91 newcall->add_req(old_in);
92 }
93
94 newcall->set_jvms(oldcall->jvms());
95 for (JVMState *jvms = newcall->jvms(); jvms != NULL; jvms = jvms->caller()) {
96 jvms->set_map(newcall);
97 jvms->set_locoff(jvms->locoff()+jvms_adj);
98 jvms->set_stkoff(jvms->stkoff()+jvms_adj);
99 jvms->set_monoff(jvms->monoff()+jvms_adj);
100 jvms->set_scloff(jvms->scloff()+jvms_adj);
101 jvms->set_endoff(jvms->endoff()+jvms_adj);
102 }
103 }
104
105 Node* PhaseMacroExpand::opt_bits_test(Node* ctrl, Node* region, int edge, Node* word, int mask, int bits, bool return_fast_path) {
710 // find the fields of the class which will be needed for safepoint debug information
711 assert(klass->is_instance_klass(), "must be an instance klass.");
712 iklass = klass->as_instance_klass();
713 nfields = iklass->nof_nonstatic_fields();
714 } else {
715 // find the array's elements which will be needed for safepoint debug information
716 nfields = alloc->in(AllocateNode::ALength)->find_int_con(-1);
717 assert(klass->is_array_klass() && nfields >= 0, "must be an array klass.");
718 elem_type = klass->as_array_klass()->element_type();
719 basic_elem_type = elem_type->basic_type();
720 array_base = arrayOopDesc::base_offset_in_bytes(basic_elem_type);
721 element_size = type2aelembytes(basic_elem_type);
722 }
723 }
724 //
725 // Process the safepoint uses
726 //
727 while (safepoints.length() > 0) {
728 SafePointNode* sfpt = safepoints.pop();
729 Node* mem = sfpt->memory();
730 assert(sfpt->jvms() != NULL, "missed JVMS");
731 // Fields of scalar objs are referenced only at the end
732 // of regular debuginfo at the last (youngest) JVMS.
733 // Record relative start index.
734 uint first_ind = (sfpt->req() - sfpt->jvms()->scloff());
735 SafePointScalarObjectNode* sobj = new (C) SafePointScalarObjectNode(res_type,
736 #ifdef ASSERT
737 alloc,
738 #endif
739 first_ind, nfields);
740 sobj->init_req(0, C->root());
741 transform_later(sobj);
742
743 // Scan object's fields adding an input to the safepoint for each field.
744 for (int j = 0; j < nfields; j++) {
745 intptr_t offset;
746 ciField* field = NULL;
747 if (iklass != NULL) {
748 field = iklass->nonstatic_field_at(j);
749 offset = field->offset();
750 elem_type = field->type();
751 basic_elem_type = field->layout_type();
752 } else {
753 offset = array_base + j * (intptr_t)element_size;
754 }
788 for (int k = 0; k < j; k++) {
789 sfpt->del_req(last--);
790 }
791 // rollback processed safepoints
792 while (safepoints_done.length() > 0) {
793 SafePointNode* sfpt_done = safepoints_done.pop();
794 // remove any extra entries we added to the safepoint
795 last = sfpt_done->req() - 1;
796 for (int k = 0; k < nfields; k++) {
797 sfpt_done->del_req(last--);
798 }
799 JVMState *jvms = sfpt_done->jvms();
800 jvms->set_endoff(sfpt_done->req());
801 // Now make a pass over the debug information replacing any references
802 // to SafePointScalarObjectNode with the allocated object.
803 int start = jvms->debug_start();
804 int end = jvms->debug_end();
805 for (int i = start; i < end; i++) {
806 if (sfpt_done->in(i)->is_SafePointScalarObject()) {
807 SafePointScalarObjectNode* scobj = sfpt_done->in(i)->as_SafePointScalarObject();
808 if (scobj->first_index(jvms) == sfpt_done->req() &&
809 scobj->n_fields() == (uint)nfields) {
810 assert(scobj->alloc() == alloc, "sanity");
811 sfpt_done->set_req(i, res);
812 }
813 }
814 }
815 }
816 #ifndef PRODUCT
817 if (PrintEliminateAllocations) {
818 if (field != NULL) {
819 tty->print("=== At SafePoint node %d can't find value of Field: ",
820 sfpt->_idx);
821 field->print();
822 int field_idx = C->get_alias_index(field_addr_type);
823 tty->print(" (alias_idx=%d)", field_idx);
824 } else { // Array's element
825 tty->print("=== At SafePoint node %d can't find value of array element [%d]",
826 sfpt->_idx, j);
827 }
828 tty->print(", which prevents elimination of: ");
|