< prev index next >

src/share/vm/c1/c1_Runtime1.cpp

Print this page
rev 8069 : 8164652: aarch32: C1 port


1032             }
1033 
1034             if (TracePatching) {
1035               Disassembler::decode(copy_buff, copy_buff + *byte_count, tty);
1036             }
1037           }
1038         } else if (stub_id == Runtime1::load_appendix_patching_id) {
1039           NativeMovConstReg* n_copy = nativeMovConstReg_at(copy_buff);
1040           assert(n_copy->data() == 0 ||
1041                  n_copy->data() == (intptr_t)Universe::non_oop_word(),
1042                  "illegal init value");
1043           n_copy->set_data(cast_from_oop<intx>(appendix()));
1044 
1045           if (TracePatching) {
1046             Disassembler::decode(copy_buff, copy_buff + *byte_count, tty);
1047           }
1048         } else {
1049           ShouldNotReachHere();
1050         }
1051 
1052 #if defined(SPARC) || defined(PPC)
1053         if (load_klass_or_mirror_patch_id ||
1054             stub_id == Runtime1::load_appendix_patching_id) {
1055           // Update the location in the nmethod with the proper
1056           // metadata.  When the code was generated, a NULL was stuffed
1057           // in the metadata table and that table needs to be update to
1058           // have the right value.  On intel the value is kept
1059           // directly in the instruction instead of in the metadata
1060           // table, so set_data above effectively updated the value.
1061           nmethod* nm = CodeCache::find_nmethod(instr_pc);
1062           assert(nm != NULL, "invalid nmethod_pc");
1063           RelocIterator mds(nm, copy_buff, copy_buff + 1);
1064           bool found = false;
1065           while (mds.next() && !found) {
1066             if (mds.type() == relocInfo::oop_type) {
1067               assert(stub_id == Runtime1::load_mirror_patching_id ||
1068                      stub_id == Runtime1::load_appendix_patching_id, "wrong stub id");
1069               oop_Relocation* r = mds.oop_reloc();
1070               oop* oop_adr = r->oop_addr();
1071               *oop_adr = stub_id == Runtime1::load_mirror_patching_id ? mirror() : appendix();
1072               r->fix_oop_relocation();
1073               found = true;
1074             } else if (mds.type() == relocInfo::metadata_type) {
1075               assert(stub_id == Runtime1::load_klass_patching_id, "wrong stub id");
1076               metadata_Relocation* r = mds.metadata_reloc();
1077               Metadata** metadata_adr = r->metadata_addr();
1078               *metadata_adr = load_klass();
1079               r->fix_metadata_relocation();
1080               found = true;
1081             }
1082           }
1083           assert(found, "the metadata must exist!");
1084         }
1085 #endif
1086         if (do_patch) {
1087           // replace instructions
1088           // first replace the tail, then the call
1089 #ifdef ARM
1090           if((load_klass_or_mirror_patch_id ||
1091               stub_id == Runtime1::load_appendix_patching_id) &&
1092               nativeMovConstReg_at(copy_buff)->is_pc_relative()) {
1093             nmethod* nm = CodeCache::find_nmethod(instr_pc);
1094             address addr = NULL;
1095             assert(nm != NULL, "invalid nmethod_pc");
1096             RelocIterator mds(nm, copy_buff, copy_buff + 1);
1097             while (mds.next()) {
1098               if (mds.type() == relocInfo::oop_type) {
1099                 assert(stub_id == Runtime1::load_mirror_patching_id ||
1100                        stub_id == Runtime1::load_appendix_patching_id, "wrong stub id");
1101                 oop_Relocation* r = mds.oop_reloc();
1102                 addr = (address)r->oop_addr();
1103                 break;
1104               } else if (mds.type() == relocInfo::metadata_type) {
1105                 assert(stub_id == Runtime1::load_klass_patching_id, "wrong stub id");
1106                 metadata_Relocation* r = mds.metadata_reloc();
1107                 addr = (address)r->metadata_addr();
1108                 break;
1109               }


1117 
1118           for (int i = NativeCall::instruction_size; i < *byte_count; i++) {
1119             address ptr = copy_buff + i;
1120             int a_byte = (*ptr) & 0xFF;
1121             address dst = instr_pc + i;
1122             *(unsigned char*)dst = (unsigned char) a_byte;
1123           }
1124           ICache::invalidate_range(instr_pc, *byte_count);
1125           NativeGeneralJump::replace_mt_safe(instr_pc, copy_buff);
1126 
1127           if (load_klass_or_mirror_patch_id ||
1128               stub_id == Runtime1::load_appendix_patching_id) {
1129             relocInfo::relocType rtype =
1130               (stub_id == Runtime1::load_klass_patching_id) ?
1131                                    relocInfo::metadata_type :
1132                                    relocInfo::oop_type;
1133             // update relocInfo to metadata
1134             nmethod* nm = CodeCache::find_nmethod(instr_pc);
1135             assert(nm != NULL, "invalid nmethod_pc");
1136 

1137             // The old patch site is now a move instruction so update
1138             // the reloc info so that it will get updated during
1139             // future GCs.
1140             RelocIterator iter(nm, (address)instr_pc, (address)(instr_pc + 1));
1141             relocInfo::change_reloc_info_for_address(&iter, (address) instr_pc,
1142                                                      relocInfo::none, rtype);

1143 #ifdef SPARC
1144             // Sparc takes two relocations for an metadata so update the second one.
1145             address instr_pc2 = instr_pc + NativeMovConstReg::add_offset;
1146             RelocIterator iter2(nm, instr_pc2, instr_pc2 + 1);
1147             relocInfo::change_reloc_info_for_address(&iter2, (address) instr_pc2,
1148                                                      relocInfo::none, rtype);
1149 #endif
1150 #ifdef PPC
1151           { address instr_pc2 = instr_pc + NativeMovConstReg::lo_offset;
1152             RelocIterator iter2(nm, instr_pc2, instr_pc2 + 1);
1153             relocInfo::change_reloc_info_for_address(&iter2, (address) instr_pc2,
1154                                                      relocInfo::none, rtype);
1155           }
1156 #endif
1157           }
1158 
1159         } else {
1160           ICache::invalidate_range(copy_buff, *byte_count);
1161           NativeGeneralJump::insert_unconditional(instr_pc, being_initialized_entry);
1162         }




1032             }
1033 
1034             if (TracePatching) {
1035               Disassembler::decode(copy_buff, copy_buff + *byte_count, tty);
1036             }
1037           }
1038         } else if (stub_id == Runtime1::load_appendix_patching_id) {
1039           NativeMovConstReg* n_copy = nativeMovConstReg_at(copy_buff);
1040           assert(n_copy->data() == 0 ||
1041                  n_copy->data() == (intptr_t)Universe::non_oop_word(),
1042                  "illegal init value");
1043           n_copy->set_data(cast_from_oop<intx>(appendix()));
1044 
1045           if (TracePatching) {
1046             Disassembler::decode(copy_buff, copy_buff + *byte_count, tty);
1047           }
1048         } else {
1049           ShouldNotReachHere();
1050         }
1051 
1052 #if defined(SPARC) || defined(PPC) || defined(AARCH32)
1053         if (load_klass_or_mirror_patch_id ||
1054             stub_id == Runtime1::load_appendix_patching_id) {
1055           // Update the location in the nmethod with the proper
1056           // metadata.  When the code was generated, a NULL was stuffed
1057           // in the metadata table and that table needs to be update to
1058           // have the right value.  On intel the value is kept
1059           // directly in the instruction instead of in the metadata
1060           // table, so set_data above effectively updated the value.
1061           nmethod* nm = CodeCache::find_nmethod(instr_pc);
1062           assert(nm != NULL, "invalid nmethod_pc");
1063           RelocIterator mds(nm, copy_buff, copy_buff + 1);
1064           bool found = false;
1065           while (mds.next() && !found) {
1066             if (mds.type() == relocInfo::oop_type) {
1067               assert(stub_id == Runtime1::load_mirror_patching_id ||
1068                      stub_id == Runtime1::load_appendix_patching_id, "wrong stub id");
1069               oop_Relocation* r = mds.oop_reloc();
1070               oop* oop_adr = r->oop_addr();
1071               *oop_adr = stub_id == Runtime1::load_mirror_patching_id ? mirror() : appendix();
1072               r->fix_oop_relocation();
1073               found = true;
1074             } else if (mds.type() == relocInfo::metadata_type) {
1075               assert(stub_id == Runtime1::load_klass_patching_id, "wrong stub id");
1076               metadata_Relocation* r = mds.metadata_reloc();
1077               Metadata** metadata_adr = r->metadata_addr();
1078               *metadata_adr = load_klass();
1079               r->fix_metadata_relocation();
1080               found = true;
1081             }
1082           }
1083           assert(found, "the metadata must exist!");
1084         }
1085 #endif
1086         if (do_patch) {
1087           // replace instructions
1088           // first replace the tail, then the call
1089 #if defined(ARM) && !defined(AARCH32)
1090           if((load_klass_or_mirror_patch_id ||
1091               stub_id == Runtime1::load_appendix_patching_id) &&
1092               nativeMovConstReg_at(copy_buff)->is_pc_relative()) {
1093             nmethod* nm = CodeCache::find_nmethod(instr_pc);
1094             address addr = NULL;
1095             assert(nm != NULL, "invalid nmethod_pc");
1096             RelocIterator mds(nm, copy_buff, copy_buff + 1);
1097             while (mds.next()) {
1098               if (mds.type() == relocInfo::oop_type) {
1099                 assert(stub_id == Runtime1::load_mirror_patching_id ||
1100                        stub_id == Runtime1::load_appendix_patching_id, "wrong stub id");
1101                 oop_Relocation* r = mds.oop_reloc();
1102                 addr = (address)r->oop_addr();
1103                 break;
1104               } else if (mds.type() == relocInfo::metadata_type) {
1105                 assert(stub_id == Runtime1::load_klass_patching_id, "wrong stub id");
1106                 metadata_Relocation* r = mds.metadata_reloc();
1107                 addr = (address)r->metadata_addr();
1108                 break;
1109               }


1117 
1118           for (int i = NativeCall::instruction_size; i < *byte_count; i++) {
1119             address ptr = copy_buff + i;
1120             int a_byte = (*ptr) & 0xFF;
1121             address dst = instr_pc + i;
1122             *(unsigned char*)dst = (unsigned char) a_byte;
1123           }
1124           ICache::invalidate_range(instr_pc, *byte_count);
1125           NativeGeneralJump::replace_mt_safe(instr_pc, copy_buff);
1126 
1127           if (load_klass_or_mirror_patch_id ||
1128               stub_id == Runtime1::load_appendix_patching_id) {
1129             relocInfo::relocType rtype =
1130               (stub_id == Runtime1::load_klass_patching_id) ?
1131                                    relocInfo::metadata_type :
1132                                    relocInfo::oop_type;
1133             // update relocInfo to metadata
1134             nmethod* nm = CodeCache::find_nmethod(instr_pc);
1135             assert(nm != NULL, "invalid nmethod_pc");
1136 
1137 #if !defined(AARCH32)
1138             // The old patch site is now a move instruction so update
1139             // the reloc info so that it will get updated during
1140             // future GCs.
1141             RelocIterator iter(nm, (address)instr_pc, (address)(instr_pc + 1));
1142             relocInfo::change_reloc_info_for_address(&iter, (address) instr_pc,
1143                                                      relocInfo::none, rtype);
1144 #endif
1145 #ifdef SPARC
1146             // Sparc takes two relocations for an metadata so update the second one.
1147             address instr_pc2 = instr_pc + NativeMovConstReg::add_offset;
1148             RelocIterator iter2(nm, instr_pc2, instr_pc2 + 1);
1149             relocInfo::change_reloc_info_for_address(&iter2, (address) instr_pc2,
1150                                                      relocInfo::none, rtype);
1151 #endif
1152 #ifdef PPC
1153           { address instr_pc2 = instr_pc + NativeMovConstReg::lo_offset;
1154             RelocIterator iter2(nm, instr_pc2, instr_pc2 + 1);
1155             relocInfo::change_reloc_info_for_address(&iter2, (address) instr_pc2,
1156                                                      relocInfo::none, rtype);
1157           }
1158 #endif
1159           }
1160 
1161         } else {
1162           ICache::invalidate_range(copy_buff, *byte_count);
1163           NativeGeneralJump::insert_unconditional(instr_pc, being_initialized_entry);
1164         }


< prev index next >