164 VMReg hotspot_reg = CodeInstaller::get_hotspot_reg(jvmci_reg_number, CHECK_NULL); 165 // HotSpot stack slots are 4 bytes 166 jint jvmci_slot = slots->int_at(i); 167 jint hotspot_slot = jvmci_slot * VMRegImpl::slots_per_word; 168 VMReg hotspot_slot_as_reg = VMRegImpl::stack2reg(hotspot_slot); 169 map->set_callee_saved(hotspot_slot_as_reg, hotspot_reg); 170 #ifdef _LP64 171 // (copied from generate_oop_map() in c1_Runtime1_x86.cpp) 172 VMReg hotspot_slot_hi_as_reg = VMRegImpl::stack2reg(hotspot_slot + 1); 173 map->set_callee_saved(hotspot_slot_hi_as_reg, hotspot_reg->next()); 174 #endif 175 } 176 } 177 return map; 178 } 179 180 void* CodeInstaller::record_metadata_reference(Handle constant, TRAPS) { 181 /* 182 * This method needs to return a raw (untyped) pointer, since the value of a pointer to the base 183 * class is in general not equal to the pointer of the subclass. When patching metaspace pointers, 184 * the compiler expects a direct pointer to the subclass (Klass*, Method* or Symbol*), not a 185 * pointer to the base class (Metadata* or MetaspaceObj*). 186 */ 187 oop obj = HotSpotMetaspaceConstantImpl::metaspaceObject(constant); 188 if (obj->is_a(HotSpotResolvedObjectTypeImpl::klass())) { 189 Klass* klass = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(obj)); 190 assert(!HotSpotMetaspaceConstantImpl::compressed(constant), "unexpected compressed klass pointer %s @ " INTPTR_FORMAT, klass->name()->as_C_string(), p2i(klass)); 191 int index = _oop_recorder->find_index(klass); 192 TRACE_jvmci_3("metadata[%d of %d] = %s", index, _oop_recorder->metadata_count(), klass->name()->as_C_string()); 193 return klass; 194 } else if (obj->is_a(HotSpotResolvedJavaMethodImpl::klass())) { 195 Method* method = (Method*) (address) HotSpotResolvedJavaMethodImpl::metaspaceMethod(obj); 196 assert(!HotSpotMetaspaceConstantImpl::compressed(constant), "unexpected compressed method pointer %s @ " INTPTR_FORMAT, method->name()->as_C_string(), p2i(method)); 197 int index = _oop_recorder->find_index(method); 198 TRACE_jvmci_3("metadata[%d of %d] = %s", index, _oop_recorder->metadata_count(), method->name()->as_C_string()); 199 return method; 200 } else if (obj->is_a(HotSpotSymbol::klass())) { 201 Symbol* symbol = (Symbol*) (address) HotSpotSymbol::pointer(obj); 202 assert(!HotSpotMetaspaceConstantImpl::compressed(constant), "unexpected compressed symbol pointer %s @ " INTPTR_FORMAT, symbol->as_C_string(), p2i(symbol)); 203 TRACE_jvmci_3("symbol = %s", symbol->as_C_string()); 204 return symbol; 205 } else { 206 JVMCI_ERROR_NULL("unexpected metadata reference for constant of type %s", obj->klass()->signature_name()); 207 } 208 } 209 210 #ifdef _LP64 211 narrowKlass CodeInstaller::record_narrow_metadata_reference(Handle constant, TRAPS) { 212 oop obj = HotSpotMetaspaceConstantImpl::metaspaceObject(constant); 213 assert(HotSpotMetaspaceConstantImpl::compressed(constant), "unexpected uncompressed pointer"); 214 215 if (!obj->is_a(HotSpotResolvedObjectTypeImpl::klass())) { 216 JVMCI_ERROR_0("unexpected compressed pointer of type %s", obj->klass()->signature_name()); 217 } 218 219 Klass* klass = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(obj)); 220 int index = _oop_recorder->find_index(klass); 221 TRACE_jvmci_3("narrowKlass[%d of %d] = %s", index, _oop_recorder->metadata_count(), klass->name()->as_C_string()); 222 return Klass::encode_klass(klass); 223 } 224 #endif | 164 VMReg hotspot_reg = CodeInstaller::get_hotspot_reg(jvmci_reg_number, CHECK_NULL); 165 // HotSpot stack slots are 4 bytes 166 jint jvmci_slot = slots->int_at(i); 167 jint hotspot_slot = jvmci_slot * VMRegImpl::slots_per_word; 168 VMReg hotspot_slot_as_reg = VMRegImpl::stack2reg(hotspot_slot); 169 map->set_callee_saved(hotspot_slot_as_reg, hotspot_reg); 170 #ifdef _LP64 171 // (copied from generate_oop_map() in c1_Runtime1_x86.cpp) 172 VMReg hotspot_slot_hi_as_reg = VMRegImpl::stack2reg(hotspot_slot + 1); 173 map->set_callee_saved(hotspot_slot_hi_as_reg, hotspot_reg->next()); 174 #endif 175 } 176 } 177 return map; 178 } 179 180 void* CodeInstaller::record_metadata_reference(Handle constant, TRAPS) { 181 /* 182 * This method needs to return a raw (untyped) pointer, since the value of a pointer to the base 183 * class is in general not equal to the pointer of the subclass. When patching metaspace pointers, 184 * the compiler expects a direct pointer to the subclass (Klass* or Method*), not a pointer to the 185 * base class (Metadata* or MetaspaceObj*). 186 */ 187 oop obj = HotSpotMetaspaceConstantImpl::metaspaceObject(constant); 188 if (obj->is_a(HotSpotResolvedObjectTypeImpl::klass())) { 189 Klass* klass = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(obj)); 190 assert(!HotSpotMetaspaceConstantImpl::compressed(constant), "unexpected compressed klass pointer %s @ " INTPTR_FORMAT, klass->name()->as_C_string(), p2i(klass)); 191 int index = _oop_recorder->find_index(klass); 192 TRACE_jvmci_3("metadata[%d of %d] = %s", index, _oop_recorder->metadata_count(), klass->name()->as_C_string()); 193 return klass; 194 } else if (obj->is_a(HotSpotResolvedJavaMethodImpl::klass())) { 195 Method* method = (Method*) (address) HotSpotResolvedJavaMethodImpl::metaspaceMethod(obj); 196 assert(!HotSpotMetaspaceConstantImpl::compressed(constant), "unexpected compressed method pointer %s @ " INTPTR_FORMAT, method->name()->as_C_string(), p2i(method)); 197 int index = _oop_recorder->find_index(method); 198 TRACE_jvmci_3("metadata[%d of %d] = %s", index, _oop_recorder->metadata_count(), method->name()->as_C_string()); 199 return method; 200 } else { 201 JVMCI_ERROR_NULL("unexpected metadata reference for constant of type %s", obj->klass()->signature_name()); 202 } 203 } 204 205 #ifdef _LP64 206 narrowKlass CodeInstaller::record_narrow_metadata_reference(Handle constant, TRAPS) { 207 oop obj = HotSpotMetaspaceConstantImpl::metaspaceObject(constant); 208 assert(HotSpotMetaspaceConstantImpl::compressed(constant), "unexpected uncompressed pointer"); 209 210 if (!obj->is_a(HotSpotResolvedObjectTypeImpl::klass())) { 211 JVMCI_ERROR_0("unexpected compressed pointer of type %s", obj->klass()->signature_name()); 212 } 213 214 Klass* klass = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(obj)); 215 int index = _oop_recorder->find_index(klass); 216 TRACE_jvmci_3("narrowKlass[%d of %d] = %s", index, _oop_recorder->metadata_count(), klass->name()->as_C_string()); 217 return Klass::encode_klass(klass); 218 } 219 #endif |