69 Method* getMethodFromHotSpotMethod(oop hotspot_method) { |
69 Method* getMethodFromHotSpotMethod(oop hotspot_method) { |
70 assert(hotspot_method != NULL && hotspot_method->is_a(HotSpotResolvedJavaMethodImpl::klass()), "sanity"); |
70 assert(hotspot_method != NULL && hotspot_method->is_a(HotSpotResolvedJavaMethodImpl::klass()), "sanity"); |
71 return CompilerToVM::asMethod(hotspot_method); |
71 return CompilerToVM::asMethod(hotspot_method); |
72 } |
72 } |
73 |
73 |
74 VMReg getVMRegFromLocation(oop location, int total_frame_size) { |
74 VMReg getVMRegFromLocation(Handle location, int total_frame_size, TRAPS) { |
75 oop reg = code_Location::reg(location); |
75 if (location.is_null()) { |
|
76 THROW_NULL(vmSymbols::java_lang_NullPointerException()); |
|
77 } |
|
78 |
|
79 Handle reg = code_Location::reg(location); |
76 jint offset = code_Location::offset(location); |
80 jint offset = code_Location::offset(location); |
77 |
81 |
78 if (reg != NULL) { |
82 if (reg.not_null()) { |
79 // register |
83 // register |
80 jint number = code_Register::number(reg); |
84 jint number = code_Register::number(reg); |
81 VMReg vmReg = CodeInstaller::get_hotspot_reg(number); |
85 VMReg vmReg = CodeInstaller::get_hotspot_reg(number, CHECK_NULL); |
82 assert(offset % 4 == 0, "must be aligned"); |
86 if (offset % 4 == 0) { |
83 return vmReg->next(offset / 4); |
87 return vmReg->next(offset / 4); |
|
88 } else { |
|
89 JVMCI_ERROR_NULL("unaligned subregister offset %d in oop map", offset); |
|
90 } |
84 } else { |
91 } else { |
85 // stack slot |
92 // stack slot |
86 assert(offset % 4 == 0, "must be aligned"); |
93 if (offset % 4 == 0) { |
87 return VMRegImpl::stack2reg(offset / 4); |
94 return VMRegImpl::stack2reg(offset / 4); |
|
95 } else { |
|
96 JVMCI_ERROR_NULL("unaligned stack offset %d in oop map", offset); |
|
97 } |
88 } |
98 } |
89 } |
99 } |
90 |
100 |
91 // creates a HotSpot oop map out of the byte arrays provided by DebugInfo |
101 // creates a HotSpot oop map out of the byte arrays provided by DebugInfo |
92 OopMap* CodeInstaller::create_oop_map(oop debug_info) { |
102 OopMap* CodeInstaller::create_oop_map(Handle debug_info, TRAPS) { |
93 oop reference_map = DebugInfo::referenceMap(debug_info); |
103 Handle reference_map = DebugInfo::referenceMap(debug_info); |
|
104 if (reference_map.is_null()) { |
|
105 THROW_NULL(vmSymbols::java_lang_NullPointerException()); |
|
106 } |
|
107 if (!reference_map->is_a(HotSpotReferenceMap::klass())) { |
|
108 JVMCI_ERROR_NULL("unknown reference map: %s", reference_map->klass()->signature_name()); |
|
109 } |
94 if (HotSpotReferenceMap::maxRegisterSize(reference_map) > 16) { |
110 if (HotSpotReferenceMap::maxRegisterSize(reference_map) > 16) { |
95 _has_wide_vector = true; |
111 _has_wide_vector = true; |
96 } |
112 } |
97 OopMap* map = new OopMap(_total_frame_size, _parameter_count); |
113 OopMap* map = new OopMap(_total_frame_size, _parameter_count); |
98 objArrayOop objects = HotSpotReferenceMap::objects(reference_map); |
114 objArrayHandle objects = HotSpotReferenceMap::objects(reference_map); |
99 objArrayOop derivedBase = HotSpotReferenceMap::derivedBase(reference_map); |
115 objArrayHandle derivedBase = HotSpotReferenceMap::derivedBase(reference_map); |
100 typeArrayOop sizeInBytes = HotSpotReferenceMap::sizeInBytes(reference_map); |
116 typeArrayHandle sizeInBytes = HotSpotReferenceMap::sizeInBytes(reference_map); |
|
117 if (objects.is_null() || derivedBase.is_null() || sizeInBytes.is_null()) { |
|
118 THROW_NULL(vmSymbols::java_lang_NullPointerException()); |
|
119 } |
|
120 if (objects->length() != derivedBase->length() || objects->length() != sizeInBytes->length()) { |
|
121 JVMCI_ERROR_NULL("arrays in reference map have different sizes: %d %d %d", objects->length(), derivedBase->length(), sizeInBytes->length()); |
|
122 } |
101 for (int i = 0; i < objects->length(); i++) { |
123 for (int i = 0; i < objects->length(); i++) { |
102 oop location = objects->obj_at(i); |
124 Handle location = objects->obj_at(i); |
103 oop baseLocation = derivedBase->obj_at(i); |
125 Handle baseLocation = derivedBase->obj_at(i); |
104 int bytes = sizeInBytes->int_at(i); |
126 int bytes = sizeInBytes->int_at(i); |
105 |
127 |
106 VMReg vmReg = getVMRegFromLocation(location, _total_frame_size); |
128 VMReg vmReg = getVMRegFromLocation(location, _total_frame_size, CHECK_NULL); |
107 if (baseLocation != NULL) { |
129 if (baseLocation.not_null()) { |
108 // derived oop |
130 // derived oop |
109 assert(bytes == 8, "derived oop can't be compressed"); |
131 #ifdef _LP64 |
110 VMReg baseReg = getVMRegFromLocation(baseLocation, _total_frame_size); |
132 if (bytes == 8) { |
111 map->set_derived_oop(vmReg, baseReg); |
133 #else |
|
134 if (bytes == 4) { |
|
135 #endif |
|
136 VMReg baseReg = getVMRegFromLocation(baseLocation, _total_frame_size, CHECK_NULL); |
|
137 map->set_derived_oop(vmReg, baseReg); |
|
138 } else { |
|
139 JVMCI_ERROR_NULL("invalid derived oop size in ReferenceMap: %d", bytes); |
|
140 } |
|
141 #ifdef _LP64 |
112 } else if (bytes == 8) { |
142 } else if (bytes == 8) { |
113 // wide oop |
143 // wide oop |
114 map->set_oop(vmReg); |
144 map->set_oop(vmReg); |
|
145 } else if (bytes == 4) { |
|
146 // narrow oop |
|
147 map->set_narrowoop(vmReg); |
|
148 #else |
|
149 } else if (bytes == 4) { |
|
150 map->set_oop(vmReg); |
|
151 #endif |
115 } else { |
152 } else { |
116 // narrow oop |
153 JVMCI_ERROR_NULL("invalid oop size in ReferenceMap: %d", bytes); |
117 assert(bytes == 4, "wrong size"); |
154 } |
118 map->set_narrowoop(vmReg); |
155 } |
119 } |
156 |
120 } |
157 Handle callee_save_info = (oop) DebugInfo::calleeSaveInfo(debug_info); |
121 |
158 if (callee_save_info.not_null()) { |
122 oop callee_save_info = (oop) DebugInfo::calleeSaveInfo(debug_info); |
159 objArrayHandle registers = RegisterSaveLayout::registers(callee_save_info); |
123 if (callee_save_info != NULL) { |
160 typeArrayHandle slots = RegisterSaveLayout::slots(callee_save_info); |
124 objArrayOop registers = RegisterSaveLayout::registers(callee_save_info); |
|
125 typeArrayOop slots = RegisterSaveLayout::slots(callee_save_info); |
|
126 for (jint i = 0; i < slots->length(); i++) { |
161 for (jint i = 0; i < slots->length(); i++) { |
127 oop jvmci_reg = registers->obj_at(i); |
162 Handle jvmci_reg = registers->obj_at(i); |
128 jint jvmci_reg_number = code_Register::number(jvmci_reg); |
163 jint jvmci_reg_number = code_Register::number(jvmci_reg); |
129 VMReg hotspot_reg = CodeInstaller::get_hotspot_reg(jvmci_reg_number); |
164 VMReg hotspot_reg = CodeInstaller::get_hotspot_reg(jvmci_reg_number, CHECK_NULL); |
130 // HotSpot stack slots are 4 bytes |
165 // HotSpot stack slots are 4 bytes |
131 jint jvmci_slot = slots->int_at(i); |
166 jint jvmci_slot = slots->int_at(i); |
132 jint hotspot_slot = jvmci_slot * VMRegImpl::slots_per_word; |
167 jint hotspot_slot = jvmci_slot * VMRegImpl::slots_per_word; |
133 VMReg hotspot_slot_as_reg = VMRegImpl::stack2reg(hotspot_slot); |
168 VMReg hotspot_slot_as_reg = VMRegImpl::stack2reg(hotspot_slot); |
134 map->set_callee_saved(hotspot_slot_as_reg, hotspot_reg); |
169 map->set_callee_saved(hotspot_slot_as_reg, hotspot_reg); |
155 assert(!HotSpotMetaspaceConstantImpl::compressed(constant), "unexpected compressed method pointer %s @ " INTPTR_FORMAT, method->name()->as_C_string(), p2i(method)); |
190 assert(!HotSpotMetaspaceConstantImpl::compressed(constant), "unexpected compressed method pointer %s @ " INTPTR_FORMAT, method->name()->as_C_string(), p2i(method)); |
156 int index = _oop_recorder->find_index(method); |
191 int index = _oop_recorder->find_index(method); |
157 TRACE_jvmci_3("metadata[%d of %d] = %s", index, _oop_recorder->metadata_count(), method->name()->as_C_string()); |
192 TRACE_jvmci_3("metadata[%d of %d] = %s", index, _oop_recorder->metadata_count(), method->name()->as_C_string()); |
158 return method; |
193 return method; |
159 } else { |
194 } else { |
160 fatal("unexpected metadata reference for constant of type %s", obj->klass()->name()->as_C_string()); |
195 JVMCI_ERROR_NULL("unexpected metadata reference for constant of type %s", obj->klass()->signature_name()); |
161 return NULL; |
|
162 } |
196 } |
163 } |
197 } |
164 |
198 |
165 #ifdef _LP64 |
199 #ifdef _LP64 |
166 narrowKlass CodeInstaller::record_narrow_metadata_reference(Handle& constant) { |
200 narrowKlass CodeInstaller::record_narrow_metadata_reference(Handle constant, TRAPS) { |
167 oop obj = HotSpotMetaspaceConstantImpl::metaspaceObject(constant); |
201 oop obj = HotSpotMetaspaceConstantImpl::metaspaceObject(constant); |
168 assert(HotSpotMetaspaceConstantImpl::compressed(constant), "unexpected uncompressed pointer"); |
202 assert(HotSpotMetaspaceConstantImpl::compressed(constant), "unexpected uncompressed pointer"); |
169 assert(obj->is_a(HotSpotResolvedObjectTypeImpl::klass()), "unexpected compressed pointer of type %s", obj->klass()->name()->as_C_string()); |
203 |
|
204 if (!obj->is_a(HotSpotResolvedObjectTypeImpl::klass())) { |
|
205 JVMCI_ERROR_0("unexpected compressed pointer of type %s", obj->klass()->signature_name()); |
|
206 } |
170 |
207 |
171 Klass* klass = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(obj)); |
208 Klass* klass = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(obj)); |
172 int index = _oop_recorder->find_index(klass); |
209 int index = _oop_recorder->find_index(klass); |
173 TRACE_jvmci_3("narrowKlass[%d of %d] = %s", index, _oop_recorder->metadata_count(), klass->name()->as_C_string()); |
210 TRACE_jvmci_3("narrowKlass[%d of %d] = %s", index, _oop_recorder->metadata_count(), klass->name()->as_C_string()); |
174 return Klass::encode_klass(klass); |
211 return Klass::encode_klass(klass); |
175 } |
212 } |
176 #endif |
213 #endif |
177 |
214 |
178 Location::Type CodeInstaller::get_oop_type(oop value) { |
215 Location::Type CodeInstaller::get_oop_type(Handle value) { |
179 oop lirKind = Value::lirKind(value); |
216 Handle lirKind = Value::lirKind(value); |
180 oop platformKind = LIRKind::platformKind(lirKind); |
217 Handle platformKind = LIRKind::platformKind(lirKind); |
181 assert(LIRKind::referenceMask(lirKind) == 1, "unexpected referenceMask"); |
218 assert(LIRKind::referenceMask(lirKind) == 1, "unexpected referenceMask"); |
182 |
219 |
183 if (platformKind == word_kind()) { |
220 if (platformKind == word_kind()) { |
184 return Location::oop; |
221 return Location::oop; |
185 } else { |
222 } else { |
186 return Location::narrowoop; |
223 return Location::narrowoop; |
187 } |
224 } |
188 } |
225 } |
189 |
226 |
190 ScopeValue* CodeInstaller::get_scope_value(oop value, BasicType type, GrowableArray<ScopeValue*>* objects, ScopeValue* &second) { |
227 ScopeValue* CodeInstaller::get_scope_value(Handle value, BasicType type, GrowableArray<ScopeValue*>* objects, ScopeValue* &second, TRAPS) { |
191 second = NULL; |
228 second = NULL; |
192 if (value == Value::ILLEGAL()) { |
229 if (value.is_null()) { |
193 assert(type == T_ILLEGAL, "expected legal value"); |
230 THROW_NULL(vmSymbols::java_lang_NullPointerException()); |
|
231 } else if (value == Value::ILLEGAL()) { |
|
232 if (type != T_ILLEGAL) { |
|
233 JVMCI_ERROR_NULL("unexpected illegal value, expected %s", basictype_to_str(type)); |
|
234 } |
194 return _illegal_value; |
235 return _illegal_value; |
195 } else if (value->is_a(RegisterValue::klass())) { |
236 } else if (value->is_a(RegisterValue::klass())) { |
196 oop reg = RegisterValue::reg(value); |
237 Handle reg = RegisterValue::reg(value); |
197 jint number = code_Register::number(reg); |
238 jint number = code_Register::number(reg); |
198 VMReg hotspotRegister = get_hotspot_reg(number); |
239 VMReg hotspotRegister = get_hotspot_reg(number, CHECK_NULL); |
199 if (is_general_purpose_reg(hotspotRegister)) { |
240 if (is_general_purpose_reg(hotspotRegister)) { |
200 Location::Type locationType; |
241 Location::Type locationType; |
201 if (type == T_OBJECT) { |
242 if (type == T_OBJECT) { |
202 locationType = get_oop_type(value); |
243 locationType = get_oop_type(value); |
203 } else if (type == T_LONG) { |
244 } else if (type == T_LONG) { |
204 locationType = Location::lng; |
245 locationType = Location::lng; |
|
246 } else if (type == T_INT || type == T_FLOAT || type == T_SHORT || type == T_CHAR || type == T_BYTE || type == T_BOOLEAN) { |
|
247 locationType = Location::int_in_long; |
205 } else { |
248 } else { |
206 assert(type == T_INT || type == T_FLOAT || type == T_SHORT || type == T_CHAR || type == T_BYTE || type == T_BOOLEAN, "unexpected type in cpu register"); |
249 JVMCI_ERROR_NULL("unexpected type %s in cpu register", basictype_to_str(type)); |
207 locationType = Location::int_in_long; |
|
208 } |
250 } |
209 ScopeValue* value = new LocationValue(Location::new_reg_loc(locationType, hotspotRegister)); |
251 ScopeValue* value = new LocationValue(Location::new_reg_loc(locationType, hotspotRegister)); |
210 if (type == T_LONG) { |
252 if (type == T_LONG) { |
211 second = value; |
253 second = value; |
212 } |
254 } |
213 return value; |
255 return value; |
214 } else { |
256 } else { |
215 assert(type == T_FLOAT || type == T_DOUBLE, "only float and double expected in xmm register"); |
|
216 Location::Type locationType; |
257 Location::Type locationType; |
217 if (type == T_FLOAT) { |
258 if (type == T_FLOAT) { |
218 // this seems weird, but the same value is used in c1_LinearScan |
259 // this seems weird, but the same value is used in c1_LinearScan |
219 locationType = Location::normal; |
260 locationType = Location::normal; |
|
261 } else if (type == T_DOUBLE) { |
|
262 locationType = Location::dbl; |
220 } else { |
263 } else { |
221 locationType = Location::dbl; |
264 JVMCI_ERROR_NULL("unexpected type %s in floating point register", basictype_to_str(type)); |
222 } |
265 } |
223 ScopeValue* value = new LocationValue(Location::new_reg_loc(locationType, hotspotRegister)); |
266 ScopeValue* value = new LocationValue(Location::new_reg_loc(locationType, hotspotRegister)); |
224 if (type == T_DOUBLE) { |
267 if (type == T_DOUBLE) { |
225 second = value; |
268 second = value; |
226 } |
269 } |
252 if (value->is_a(PrimitiveConstant::klass())) { |
296 if (value->is_a(PrimitiveConstant::klass())) { |
253 if (value->is_a(RawConstant::klass())) { |
297 if (value->is_a(RawConstant::klass())) { |
254 jlong prim = PrimitiveConstant::primitive(value); |
298 jlong prim = PrimitiveConstant::primitive(value); |
255 return new ConstantLongValue(prim); |
299 return new ConstantLongValue(prim); |
256 } else { |
300 } else { |
257 assert(type == JVMCIRuntime::kindToBasicType(JavaKind::typeChar(PrimitiveConstant::kind(value))), "primitive constant type doesn't match"); |
301 BasicType constantType = JVMCIRuntime::kindToBasicType(PrimitiveConstant::kind(value), CHECK_NULL); |
|
302 if (type != constantType) { |
|
303 JVMCI_ERROR_NULL("primitive constant type doesn't match, expected %s but got %s", basictype_to_str(type), basictype_to_str(constantType)); |
|
304 } |
258 if (type == T_INT || type == T_FLOAT) { |
305 if (type == T_INT || type == T_FLOAT) { |
259 jint prim = (jint)PrimitiveConstant::primitive(value); |
306 jint prim = (jint)PrimitiveConstant::primitive(value); |
260 switch (prim) { |
307 switch (prim) { |
261 case -1: return _int_m1_scope_value; |
308 case -1: return _int_m1_scope_value; |
262 case 0: return _int_0_scope_value; |
309 case 0: return _int_0_scope_value; |
263 case 1: return _int_1_scope_value; |
310 case 1: return _int_1_scope_value; |
264 case 2: return _int_2_scope_value; |
311 case 2: return _int_2_scope_value; |
265 default: return new ConstantIntValue(prim); |
312 default: return new ConstantIntValue(prim); |
266 } |
313 } |
267 } else { |
314 } else if (type == T_LONG || type == T_DOUBLE) { |
268 assert(type == T_LONG || type == T_DOUBLE, "unexpected primitive constant type"); |
|
269 jlong prim = PrimitiveConstant::primitive(value); |
315 jlong prim = PrimitiveConstant::primitive(value); |
270 second = _int_1_scope_value; |
316 second = _int_1_scope_value; |
271 return new ConstantLongValue(prim); |
317 return new ConstantLongValue(prim); |
|
318 } else { |
|
319 JVMCI_ERROR_NULL("unexpected primitive constant type %s", basictype_to_str(type)); |
272 } |
320 } |
273 } |
321 } |
274 } else { |
322 } else if (value->is_a(NullConstant::klass()) || value->is_a(HotSpotCompressedNullConstant::klass())) { |
275 assert(type == T_OBJECT, "unexpected object constant"); |
323 if (type == T_OBJECT) { |
276 if (value->is_a(NullConstant::klass()) || value->is_a(HotSpotCompressedNullConstant::klass())) { |
|
277 return _oop_null_scope_value; |
324 return _oop_null_scope_value; |
278 } else { |
325 } else { |
279 assert(value->is_a(HotSpotObjectConstantImpl::klass()), "unexpected constant type"); |
326 JVMCI_ERROR_NULL("unexpected null constant, expected %s", basictype_to_str(type)); |
|
327 } |
|
328 } else if (value->is_a(HotSpotObjectConstantImpl::klass())) { |
|
329 if (type == T_OBJECT) { |
280 oop obj = HotSpotObjectConstantImpl::object(value); |
330 oop obj = HotSpotObjectConstantImpl::object(value); |
281 assert(obj != NULL, "null value must be in NullConstant"); |
331 if (obj == NULL) { |
|
332 JVMCI_ERROR_NULL("null value must be in NullConstant"); |
|
333 } |
282 return new ConstantOopWriteValue(JNIHandles::make_local(obj)); |
334 return new ConstantOopWriteValue(JNIHandles::make_local(obj)); |
|
335 } else { |
|
336 JVMCI_ERROR_NULL("unexpected object constant, expected %s", basictype_to_str(type)); |
283 } |
337 } |
284 } |
338 } |
285 } else if (value->is_a(VirtualObject::klass())) { |
339 } else if (value->is_a(VirtualObject::klass())) { |
286 assert(type == T_OBJECT, "unexpected virtual object"); |
340 if (type == T_OBJECT) { |
287 int id = VirtualObject::id(value); |
341 int id = VirtualObject::id(value); |
288 ScopeValue* object = objects->at(id); |
342 if (0 <= id && id < objects->length()) { |
289 assert(object != NULL, "missing value"); |
343 ScopeValue* object = objects->at(id); |
290 return object; |
344 if (object != NULL) { |
291 } else { |
345 return object; |
292 value->klass()->print(); |
346 } |
293 value->print(); |
347 } |
294 } |
348 JVMCI_ERROR_NULL("unknown virtual object id %d", id); |
295 ShouldNotReachHere(); |
349 } else { |
296 return NULL; |
350 JVMCI_ERROR_NULL("unexpected virtual object, expected %s", basictype_to_str(type)); |
297 } |
351 } |
298 |
352 } |
299 void CodeInstaller::record_object_value(ObjectValue* sv, oop value, GrowableArray<ScopeValue*>* objects) { |
353 |
300 oop type = VirtualObject::type(value); |
354 JVMCI_ERROR_NULL("unexpected value in scope: %s", value->klass()->signature_name()) |
|
355 } |
|
356 |
|
357 void CodeInstaller::record_object_value(ObjectValue* sv, Handle value, GrowableArray<ScopeValue*>* objects, TRAPS) { |
|
358 Handle type = VirtualObject::type(value); |
301 int id = VirtualObject::id(value); |
359 int id = VirtualObject::id(value); |
302 oop javaMirror = HotSpotResolvedObjectTypeImpl::javaClass(type); |
360 oop javaMirror = HotSpotResolvedObjectTypeImpl::javaClass(type); |
303 Klass* klass = java_lang_Class::as_Klass(javaMirror); |
361 Klass* klass = java_lang_Class::as_Klass(javaMirror); |
304 bool isLongArray = klass == Universe::longArrayKlassObj(); |
362 bool isLongArray = klass == Universe::longArrayKlassObj(); |
305 |
363 |
306 objArrayOop values = VirtualObject::values(value); |
364 objArrayHandle values = VirtualObject::values(value); |
307 objArrayOop slotKinds = VirtualObject::slotKinds(value); |
365 objArrayHandle slotKinds = VirtualObject::slotKinds(value); |
308 for (jint i = 0; i < values->length(); i++) { |
366 for (jint i = 0; i < values->length(); i++) { |
309 ScopeValue* cur_second = NULL; |
367 ScopeValue* cur_second = NULL; |
310 oop object = values->obj_at(i); |
368 Handle object = values->obj_at(i); |
311 oop kind = slotKinds->obj_at(i); |
369 BasicType type = JVMCIRuntime::kindToBasicType(slotKinds->obj_at(i), CHECK); |
312 BasicType type = JVMCIRuntime::kindToBasicType(JavaKind::typeChar(kind)); |
370 ScopeValue* value = get_scope_value(object, type, objects, cur_second, CHECK); |
313 ScopeValue* value = get_scope_value(object, type, objects, cur_second); |
|
314 |
371 |
315 if (isLongArray && cur_second == NULL) { |
372 if (isLongArray && cur_second == NULL) { |
316 // we're trying to put ints into a long array... this isn't really valid, but it's used for some optimizations. |
373 // we're trying to put ints into a long array... this isn't really valid, but it's used for some optimizations. |
317 // add an int 0 constant |
374 // add an int 0 constant |
318 cur_second = _int_0_scope_value; |
375 cur_second = _int_0_scope_value; |
598 memcpy(_instructions->start(), code()->base(T_BYTE), _code_size); |
664 memcpy(_instructions->start(), code()->base(T_BYTE), _code_size); |
599 _instructions->set_end(end_pc); |
665 _instructions->set_end(end_pc); |
600 |
666 |
601 for (int i = 0; i < data_section_patches()->length(); i++) { |
667 for (int i = 0; i < data_section_patches()->length(); i++) { |
602 Handle patch = data_section_patches()->obj_at(i); |
668 Handle patch = data_section_patches()->obj_at(i); |
|
669 if (patch.is_null()) { |
|
670 THROW_(vmSymbols::java_lang_NullPointerException(), JVMCIEnv::ok); |
|
671 } |
603 Handle reference = CompilationResult_DataPatch::reference(patch); |
672 Handle reference = CompilationResult_DataPatch::reference(patch); |
604 assert(reference->is_a(CompilationResult_ConstantReference::klass()), "patch in data section must be a ConstantReference"); |
673 if (reference.is_null()) { |
|
674 THROW_(vmSymbols::java_lang_NullPointerException(), JVMCIEnv::ok); |
|
675 } |
|
676 if (!reference->is_a(CompilationResult_ConstantReference::klass())) { |
|
677 JVMCI_ERROR_OK("invalid patch in data section: %s", reference->klass()->signature_name()); |
|
678 } |
605 Handle constant = CompilationResult_ConstantReference::constant(reference); |
679 Handle constant = CompilationResult_ConstantReference::constant(reference); |
|
680 if (constant.is_null()) { |
|
681 THROW_(vmSymbols::java_lang_NullPointerException(), JVMCIEnv::ok); |
|
682 } |
606 address dest = _constants->start() + CompilationResult_Site::pcOffset(patch); |
683 address dest = _constants->start() + CompilationResult_Site::pcOffset(patch); |
607 if (constant->is_a(HotSpotMetaspaceConstantImpl::klass())) { |
684 if (constant->is_a(HotSpotMetaspaceConstantImpl::klass())) { |
608 if (HotSpotMetaspaceConstantImpl::compressed(constant)) { |
685 if (HotSpotMetaspaceConstantImpl::compressed(constant)) { |
609 #ifdef _LP64 |
686 #ifdef _LP64 |
610 *((narrowKlass*) dest) = record_narrow_metadata_reference(constant); |
687 *((narrowKlass*) dest) = record_narrow_metadata_reference(constant, CHECK_OK); |
611 #else |
688 #else |
612 fatal("unexpected compressed Klass* in 32-bit mode"); |
689 JVMCI_ERROR_OK("unexpected compressed Klass* in 32-bit mode"); |
613 #endif |
690 #endif |
614 } else { |
691 } else { |
615 *((Metadata**) dest) = record_metadata_reference(constant); |
692 *((Metadata**) dest) = record_metadata_reference(constant, CHECK_OK); |
616 } |
693 } |
617 } else if (constant->is_a(HotSpotObjectConstantImpl::klass())) { |
694 } else if (constant->is_a(HotSpotObjectConstantImpl::klass())) { |
618 Handle obj = HotSpotObjectConstantImpl::object(constant); |
695 Handle obj = HotSpotObjectConstantImpl::object(constant); |
619 jobject value = JNIHandles::make_local(obj()); |
696 jobject value = JNIHandles::make_local(obj()); |
620 int oop_index = _oop_recorder->find_index(value); |
697 int oop_index = _oop_recorder->find_index(value); |
621 |
698 |
622 if (HotSpotObjectConstantImpl::compressed(constant)) { |
699 if (HotSpotObjectConstantImpl::compressed(constant)) { |
623 #ifdef _LP64 |
700 #ifdef _LP64 |
624 _constants->relocate(dest, oop_Relocation::spec(oop_index), relocInfo::narrow_oop_in_const); |
701 _constants->relocate(dest, oop_Relocation::spec(oop_index), relocInfo::narrow_oop_in_const); |
625 #else |
702 #else |
626 fatal("unexpected compressed oop in 32-bit mode"); |
703 JVMCI_ERROR_OK("unexpected compressed oop in 32-bit mode"); |
627 #endif |
704 #endif |
628 } else { |
705 } else { |
629 _constants->relocate(dest, oop_Relocation::spec(oop_index)); |
706 _constants->relocate(dest, oop_Relocation::spec(oop_index)); |
630 } |
707 } |
631 } else { |
708 } else { |
632 ShouldNotReachHere(); |
709 JVMCI_ERROR_OK("invalid constant in data section: %s", constant->klass()->signature_name()); |
633 } |
710 } |
634 } |
711 } |
635 jint last_pc_offset = -1; |
712 jint last_pc_offset = -1; |
636 for (int i = 0; i < sites->length(); i++) { |
713 for (int i = 0; i < sites->length(); i++) { |
637 { |
714 Handle site = sites->obj_at(i); |
638 No_Safepoint_Verifier no_safepoint; |
715 if (site.is_null()) { |
639 oop site = sites->obj_at(i); |
716 THROW_(vmSymbols::java_lang_NullPointerException(), JVMCIEnv::ok); |
640 jint pc_offset = CompilationResult_Site::pcOffset(site); |
717 } |
641 |
718 |
642 if (site->is_a(CompilationResult_Call::klass())) { |
719 jint pc_offset = CompilationResult_Site::pcOffset(site); |
643 TRACE_jvmci_4("call at %i", pc_offset); |
720 |
644 site_Call(buffer, pc_offset, site); |
721 if (site->is_a(CompilationResult_Call::klass())) { |
645 } else if (site->is_a(CompilationResult_Infopoint::klass())) { |
722 TRACE_jvmci_4("call at %i", pc_offset); |
646 // three reasons for infopoints denote actual safepoints |
723 site_Call(buffer, pc_offset, site, CHECK_OK); |
647 oop reason = CompilationResult_Infopoint::reason(site); |
724 } else if (site->is_a(CompilationResult_Infopoint::klass())) { |
648 if (InfopointReason::SAFEPOINT() == reason || InfopointReason::CALL() == reason || InfopointReason::IMPLICIT_EXCEPTION() == reason) { |
725 // three reasons for infopoints denote actual safepoints |
649 TRACE_jvmci_4("safepoint at %i", pc_offset); |
726 oop reason = CompilationResult_Infopoint::reason(site); |
650 site_Safepoint(buffer, pc_offset, site); |
727 if (InfopointReason::SAFEPOINT() == reason || InfopointReason::CALL() == reason || InfopointReason::IMPLICIT_EXCEPTION() == reason) { |
651 } else { |
728 TRACE_jvmci_4("safepoint at %i", pc_offset); |
652 // if the infopoint is not an actual safepoint, it must have one of the other reasons |
729 site_Safepoint(buffer, pc_offset, site, CHECK_OK); |
653 // (safeguard against new safepoint types that require handling above) |
730 } else if (InfopointReason::METHOD_START() == reason || InfopointReason::METHOD_END() == reason || InfopointReason::LINE_NUMBER() == reason) { |
654 assert(InfopointReason::METHOD_START() == reason || InfopointReason::METHOD_END() == reason || InfopointReason::LINE_NUMBER() == reason, ""); |
731 site_Infopoint(buffer, pc_offset, site, CHECK_OK); |
655 site_Infopoint(buffer, pc_offset, site); |
732 } else { |
656 } |
733 JVMCI_ERROR_OK("unknown infopoint reason at %i", pc_offset); |
657 } else if (site->is_a(CompilationResult_DataPatch::klass())) { |
734 } |
658 TRACE_jvmci_4("datapatch at %i", pc_offset); |
735 } else if (site->is_a(CompilationResult_DataPatch::klass())) { |
659 site_DataPatch(buffer, pc_offset, site); |
736 TRACE_jvmci_4("datapatch at %i", pc_offset); |
660 } else if (site->is_a(CompilationResult_Mark::klass())) { |
737 site_DataPatch(buffer, pc_offset, site, CHECK_OK); |
661 TRACE_jvmci_4("mark at %i", pc_offset); |
738 } else if (site->is_a(CompilationResult_Mark::klass())) { |
662 site_Mark(buffer, pc_offset, site); |
739 TRACE_jvmci_4("mark at %i", pc_offset); |
663 } else { |
740 site_Mark(buffer, pc_offset, site, CHECK_OK); |
664 fatal("unexpected Site subclass"); |
741 } else { |
665 } |
742 JVMCI_ERROR_OK("unexpected site subclass: %s", site->klass()->signature_name()); |
666 last_pc_offset = pc_offset; |
743 } |
667 } |
744 last_pc_offset = pc_offset; |
|
745 |
668 if (CodeInstallSafepointChecks && SafepointSynchronize::do_call_back()) { |
746 if (CodeInstallSafepointChecks && SafepointSynchronize::do_call_back()) { |
669 // this is a hacky way to force a safepoint check but nothing else was jumping out at me. |
747 // this is a hacky way to force a safepoint check but nothing else was jumping out at me. |
670 ThreadToNativeFromVM ttnfv(JavaThread::current()); |
748 ThreadToNativeFromVM ttnfv(JavaThread::current()); |
671 } |
749 } |
672 } |
750 } |
673 |
751 |
674 #ifndef PRODUCT |
752 #ifndef PRODUCT |
675 if (comments() != NULL) { |
753 if (comments() != NULL) { |
676 No_Safepoint_Verifier no_safepoint; |
|
677 for (int i = 0; i < comments()->length(); i++) { |
754 for (int i = 0; i < comments()->length(); i++) { |
678 oop comment = comments()->obj_at(i); |
755 oop comment = comments()->obj_at(i); |
679 assert(comment->is_a(HotSpotCompiledCode_Comment::klass()), "cce"); |
756 assert(comment->is_a(HotSpotCompiledCode_Comment::klass()), "cce"); |
680 jint offset = HotSpotCompiledCode_Comment::pcOffset(comment); |
757 jint offset = HotSpotCompiledCode_Comment::pcOffset(comment); |
681 char* text = java_lang_String::as_utf8_string(HotSpotCompiledCode_Comment::text(comment)); |
758 char* text = java_lang_String::as_utf8_string(HotSpotCompiledCode_Comment::text(comment)); |
757 return true; |
834 return true; |
758 } |
835 } |
759 return true; |
836 return true; |
760 } |
837 } |
761 |
838 |
762 GrowableArray<ScopeValue*>* CodeInstaller::record_virtual_objects(oop debug_info) { |
839 GrowableArray<ScopeValue*>* CodeInstaller::record_virtual_objects(Handle debug_info, TRAPS) { |
763 objArrayOop virtualObjects = DebugInfo::virtualObjectMapping(debug_info); |
840 objArrayHandle virtualObjects = DebugInfo::virtualObjectMapping(debug_info); |
764 if (virtualObjects == NULL) { |
841 if (virtualObjects.is_null()) { |
765 return NULL; |
842 return NULL; |
766 } |
843 } |
767 GrowableArray<ScopeValue*>* objects = new GrowableArray<ScopeValue*>(virtualObjects->length(), virtualObjects->length(), NULL); |
844 GrowableArray<ScopeValue*>* objects = new GrowableArray<ScopeValue*>(virtualObjects->length(), virtualObjects->length(), NULL); |
768 // Create the unique ObjectValues |
845 // Create the unique ObjectValues |
769 for (int i = 0; i < virtualObjects->length(); i++) { |
846 for (int i = 0; i < virtualObjects->length(); i++) { |
770 oop value = virtualObjects->obj_at(i); |
847 Handle value = virtualObjects->obj_at(i); |
771 int id = VirtualObject::id(value); |
848 int id = VirtualObject::id(value); |
772 oop type = VirtualObject::type(value); |
849 Handle type = VirtualObject::type(value); |
773 oop javaMirror = HotSpotResolvedObjectTypeImpl::javaClass(type); |
850 oop javaMirror = HotSpotResolvedObjectTypeImpl::javaClass(type); |
774 ObjectValue* sv = new ObjectValue(id, new ConstantOopWriteValue(JNIHandles::make_local(Thread::current(), javaMirror))); |
851 ObjectValue* sv = new ObjectValue(id, new ConstantOopWriteValue(JNIHandles::make_local(Thread::current(), javaMirror))); |
775 assert(objects->at(id) == NULL, "once"); |
852 if (id < 0 || id >= objects->length()) { |
|
853 JVMCI_ERROR_NULL("virtual object id %d out of bounds", id); |
|
854 } |
|
855 if (objects->at(id) != NULL) { |
|
856 JVMCI_ERROR_NULL("duplicate virtual object id %d", id); |
|
857 } |
776 objects->at_put(id, sv); |
858 objects->at_put(id, sv); |
777 } |
859 } |
778 // All the values which could be referenced by the VirtualObjects |
860 // All the values which could be referenced by the VirtualObjects |
779 // exist, so now describe all the VirtualObjects themselves. |
861 // exist, so now describe all the VirtualObjects themselves. |
780 for (int i = 0; i < virtualObjects->length(); i++) { |
862 for (int i = 0; i < virtualObjects->length(); i++) { |
781 oop value = virtualObjects->obj_at(i); |
863 Handle value = virtualObjects->obj_at(i); |
782 int id = VirtualObject::id(value); |
864 int id = VirtualObject::id(value); |
783 record_object_value(objects->at(id)->as_ObjectValue(), value, objects); |
865 record_object_value(objects->at(id)->as_ObjectValue(), value, objects, CHECK_NULL); |
784 } |
866 } |
785 _debug_recorder->dump_object_pool(objects); |
867 _debug_recorder->dump_object_pool(objects); |
786 return objects; |
868 return objects; |
787 } |
869 } |
788 |
870 |
789 void CodeInstaller::record_scope(jint pc_offset, oop debug_info) { |
871 void CodeInstaller::record_scope(jint pc_offset, Handle debug_info, TRAPS) { |
790 oop position = DebugInfo::bytecodePosition(debug_info); |
872 Handle position = DebugInfo::bytecodePosition(debug_info); |
791 if (position == NULL) { |
873 if (position.is_null()) { |
792 // Stubs do not record scope info, just oop maps |
874 // Stubs do not record scope info, just oop maps |
793 return; |
875 return; |
794 } |
876 } |
795 |
877 |
796 GrowableArray<ScopeValue*>* objectMapping = record_virtual_objects(debug_info); |
878 GrowableArray<ScopeValue*>* objectMapping = record_virtual_objects(debug_info, CHECK); |
797 record_scope(pc_offset, position, objectMapping); |
879 record_scope(pc_offset, position, objectMapping, CHECK); |
798 } |
880 } |
799 |
881 |
800 void CodeInstaller::record_scope(jint pc_offset, oop position, GrowableArray<ScopeValue*>* objects) { |
882 void CodeInstaller::record_scope(jint pc_offset, Handle position, GrowableArray<ScopeValue*>* objects, TRAPS) { |
801 oop frame = NULL; |
883 Handle frame; |
802 if (position->is_a(BytecodeFrame::klass())) { |
884 if (position->is_a(BytecodeFrame::klass())) { |
803 frame = position; |
885 frame = position; |
804 } |
886 } |
805 oop caller_frame = BytecodePosition::caller(position); |
887 Handle caller_frame = BytecodePosition::caller(position); |
806 if (caller_frame != NULL) { |
888 if (caller_frame.not_null()) { |
807 record_scope(pc_offset, caller_frame, objects); |
889 record_scope(pc_offset, caller_frame, objects, CHECK); |
808 } |
890 } |
809 |
891 |
810 oop hotspot_method = BytecodePosition::method(position); |
892 Handle hotspot_method = BytecodePosition::method(position); |
811 Method* method = getMethodFromHotSpotMethod(hotspot_method); |
893 Method* method = getMethodFromHotSpotMethod(hotspot_method()); |
812 jint bci = BytecodePosition::bci(position); |
894 jint bci = BytecodePosition::bci(position); |
813 if (bci == BytecodeFrame::BEFORE_BCI()) { |
895 if (bci == BytecodeFrame::BEFORE_BCI()) { |
814 bci = SynchronizationEntryBCI; |
896 bci = SynchronizationEntryBCI; |
815 } |
897 } |
816 |
898 |
817 TRACE_jvmci_2("Recording scope pc_offset=%d bci=%d method=%s", pc_offset, bci, method->name_and_sig_as_C_string()); |
899 TRACE_jvmci_2("Recording scope pc_offset=%d bci=%d method=%s", pc_offset, bci, method->name_and_sig_as_C_string()); |
818 |
900 |
819 bool reexecute = false; |
901 bool reexecute = false; |
820 if (frame != NULL) { |
902 if (frame.not_null()) { |
821 if (bci == SynchronizationEntryBCI){ |
903 if (bci == SynchronizationEntryBCI){ |
822 reexecute = false; |
904 reexecute = false; |
823 } else { |
905 } else { |
824 Bytecodes::Code code = Bytecodes::java_code_at(method, method->bcp_from(bci)); |
906 Bytecodes::Code code = Bytecodes::java_code_at(method, method->bcp_from(bci)); |
825 reexecute = bytecode_should_reexecute(code); |
907 reexecute = bytecode_should_reexecute(code); |
826 if (frame != NULL) { |
908 if (frame.not_null()) { |
827 reexecute = (BytecodeFrame::duringCall(frame) == JNI_FALSE); |
909 reexecute = (BytecodeFrame::duringCall(frame) == JNI_FALSE); |
828 } |
910 } |
829 } |
911 } |
830 } |
912 } |
831 |
913 |
832 DebugToken* locals_token = NULL; |
914 DebugToken* locals_token = NULL; |
833 DebugToken* expressions_token = NULL; |
915 DebugToken* expressions_token = NULL; |
834 DebugToken* monitors_token = NULL; |
916 DebugToken* monitors_token = NULL; |
835 bool throw_exception = false; |
917 bool throw_exception = false; |
836 |
918 |
837 if (frame != NULL) { |
919 if (frame.not_null()) { |
838 jint local_count = BytecodeFrame::numLocals(frame); |
920 jint local_count = BytecodeFrame::numLocals(frame); |
839 jint expression_count = BytecodeFrame::numStack(frame); |
921 jint expression_count = BytecodeFrame::numStack(frame); |
840 jint monitor_count = BytecodeFrame::numLocks(frame); |
922 jint monitor_count = BytecodeFrame::numLocks(frame); |
841 objArrayOop values = BytecodeFrame::values(frame); |
923 objArrayHandle values = BytecodeFrame::values(frame); |
842 objArrayOop slotKinds = BytecodeFrame::slotKinds(frame); |
924 objArrayHandle slotKinds = BytecodeFrame::slotKinds(frame); |
843 |
925 |
844 assert(local_count + expression_count + monitor_count == values->length(), "unexpected values length"); |
926 if (values.is_null() || slotKinds.is_null()) { |
845 assert(local_count + expression_count == slotKinds->length(), "unexpected slotKinds length"); |
927 THROW(vmSymbols::java_lang_NullPointerException()); |
|
928 } |
|
929 if (local_count + expression_count + monitor_count != values->length()) { |
|
930 JVMCI_ERROR("unexpected values length %d in scope (%d locals, %d expressions, %d monitors)", values->length(), local_count, expression_count, monitor_count); |
|
931 } |
|
932 if (local_count + expression_count != slotKinds->length()) { |
|
933 JVMCI_ERROR("unexpected slotKinds length %d in scope (%d locals, %d expressions)", slotKinds->length(), local_count, expression_count); |
|
934 } |
846 |
935 |
847 GrowableArray<ScopeValue*>* locals = local_count > 0 ? new GrowableArray<ScopeValue*> (local_count) : NULL; |
936 GrowableArray<ScopeValue*>* locals = local_count > 0 ? new GrowableArray<ScopeValue*> (local_count) : NULL; |
848 GrowableArray<ScopeValue*>* expressions = expression_count > 0 ? new GrowableArray<ScopeValue*> (expression_count) : NULL; |
937 GrowableArray<ScopeValue*>* expressions = expression_count > 0 ? new GrowableArray<ScopeValue*> (expression_count) : NULL; |
849 GrowableArray<MonitorValue*>* monitors = monitor_count > 0 ? new GrowableArray<MonitorValue*> (monitor_count) : NULL; |
938 GrowableArray<MonitorValue*>* monitors = monitor_count > 0 ? new GrowableArray<MonitorValue*> (monitor_count) : NULL; |
850 |
939 |
851 TRACE_jvmci_2("Scope at bci %d with %d values", bci, values->length()); |
940 TRACE_jvmci_2("Scope at bci %d with %d values", bci, values->length()); |
852 TRACE_jvmci_2("%d locals %d expressions, %d monitors", local_count, expression_count, monitor_count); |
941 TRACE_jvmci_2("%d locals %d expressions, %d monitors", local_count, expression_count, monitor_count); |
853 |
942 |
854 for (jint i = 0; i < values->length(); i++) { |
943 for (jint i = 0; i < values->length(); i++) { |
855 ScopeValue* second = NULL; |
944 ScopeValue* second = NULL; |
856 oop value = values->obj_at(i); |
945 Handle value = values->obj_at(i); |
857 if (i < local_count) { |
946 if (i < local_count) { |
858 oop kind = slotKinds->obj_at(i); |
947 BasicType type = JVMCIRuntime::kindToBasicType(slotKinds->obj_at(i), CHECK); |
859 BasicType type = JVMCIRuntime::kindToBasicType(JavaKind::typeChar(kind)); |
948 ScopeValue* first = get_scope_value(value, type, objects, second, CHECK); |
860 ScopeValue* first = get_scope_value(value, type, objects, second); |
|
861 if (second != NULL) { |
949 if (second != NULL) { |
862 locals->append(second); |
950 locals->append(second); |
863 } |
951 } |
864 locals->append(first); |
952 locals->append(first); |
865 } else if (i < local_count + expression_count) { |
953 } else if (i < local_count + expression_count) { |
866 oop kind = slotKinds->obj_at(i); |
954 BasicType type = JVMCIRuntime::kindToBasicType(slotKinds->obj_at(i), CHECK); |
867 BasicType type = JVMCIRuntime::kindToBasicType(JavaKind::typeChar(kind)); |
955 ScopeValue* first = get_scope_value(value, type, objects, second, CHECK); |
868 ScopeValue* first = get_scope_value(value, type, objects, second); |
|
869 if (second != NULL) { |
956 if (second != NULL) { |
870 expressions->append(second); |
957 expressions->append(second); |
871 } |
958 } |
872 expressions->append(first); |
959 expressions->append(first); |
873 } else { |
960 } else { |
874 monitors->append(get_monitor_value(value, objects)); |
961 MonitorValue *monitor = get_monitor_value(value, objects, CHECK); |
|
962 monitors->append(monitor); |
875 } |
963 } |
876 if (second != NULL) { |
964 if (second != NULL) { |
877 i++; |
965 i++; |
878 assert(i < values->length(), "double-slot value not followed by Value.ILLEGAL"); |
966 if (i >= values->length() || values->obj_at(i) != Value::ILLEGAL()) { |
879 assert(values->obj_at(i) == Value::ILLEGAL(), "double-slot value not followed by Value.ILLEGAL"); |
967 JVMCI_ERROR("double-slot value not followed by Value.ILLEGAL"); |
|
968 } |
880 } |
969 } |
881 } |
970 } |
882 |
971 |
883 locals_token = _debug_recorder->create_scope_values(locals); |
972 locals_token = _debug_recorder->create_scope_values(locals); |
884 expressions_token = _debug_recorder->create_scope_values(expressions); |
973 expressions_token = _debug_recorder->create_scope_values(expressions); |
889 |
978 |
890 _debug_recorder->describe_scope(pc_offset, method, NULL, bci, reexecute, throw_exception, false, false, |
979 _debug_recorder->describe_scope(pc_offset, method, NULL, bci, reexecute, throw_exception, false, false, |
891 locals_token, expressions_token, monitors_token); |
980 locals_token, expressions_token, monitors_token); |
892 } |
981 } |
893 |
982 |
894 void CodeInstaller::site_Safepoint(CodeBuffer& buffer, jint pc_offset, oop site) { |
983 void CodeInstaller::site_Safepoint(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS) { |
895 oop debug_info = CompilationResult_Infopoint::debugInfo(site); |
984 Handle debug_info = CompilationResult_Infopoint::debugInfo(site); |
896 assert(debug_info != NULL, "debug info expected"); |
985 if (debug_info.is_null()) { |
|
986 JVMCI_ERROR("debug info expected at safepoint at %i", pc_offset); |
|
987 } |
897 |
988 |
898 // address instruction = _instructions->start() + pc_offset; |
989 // address instruction = _instructions->start() + pc_offset; |
899 // jint next_pc_offset = Assembler::locate_next_instruction(instruction) - _instructions->start(); |
990 // jint next_pc_offset = Assembler::locate_next_instruction(instruction) - _instructions->start(); |
900 _debug_recorder->add_safepoint(pc_offset, create_oop_map(debug_info)); |
991 OopMap *map = create_oop_map(debug_info, CHECK); |
901 record_scope(pc_offset, debug_info); |
992 _debug_recorder->add_safepoint(pc_offset, map); |
|
993 record_scope(pc_offset, debug_info, CHECK); |
902 _debug_recorder->end_safepoint(pc_offset); |
994 _debug_recorder->end_safepoint(pc_offset); |
903 } |
995 } |
904 |
996 |
905 void CodeInstaller::site_Infopoint(CodeBuffer& buffer, jint pc_offset, oop site) { |
997 void CodeInstaller::site_Infopoint(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS) { |
906 oop debug_info = CompilationResult_Infopoint::debugInfo(site); |
998 Handle debug_info = CompilationResult_Infopoint::debugInfo(site); |
907 assert(debug_info != NULL, "debug info expected"); |
999 if (debug_info.is_null()) { |
|
1000 JVMCI_ERROR("debug info expected at infopoint at %i", pc_offset); |
|
1001 } |
908 |
1002 |
909 _debug_recorder->add_non_safepoint(pc_offset); |
1003 _debug_recorder->add_non_safepoint(pc_offset); |
910 record_scope(pc_offset, debug_info); |
1004 record_scope(pc_offset, debug_info, CHECK); |
911 _debug_recorder->end_non_safepoint(pc_offset); |
1005 _debug_recorder->end_non_safepoint(pc_offset); |
912 } |
1006 } |
913 |
1007 |
914 void CodeInstaller::site_Call(CodeBuffer& buffer, jint pc_offset, oop site) { |
1008 void CodeInstaller::site_Call(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS) { |
915 oop target = CompilationResult_Call::target(site); |
1009 Handle target = CompilationResult_Call::target(site); |
916 InstanceKlass* target_klass = InstanceKlass::cast(target->klass()); |
1010 InstanceKlass* target_klass = InstanceKlass::cast(target->klass()); |
917 |
1011 |
918 oop hotspot_method = NULL; // JavaMethod |
1012 Handle hotspot_method; // JavaMethod |
919 oop foreign_call = NULL; |
1013 Handle foreign_call; |
920 |
1014 |
921 if (target_klass->is_subclass_of(SystemDictionary::HotSpotForeignCallTarget_klass())) { |
1015 if (target_klass->is_subclass_of(SystemDictionary::HotSpotForeignCallTarget_klass())) { |
922 foreign_call = target; |
1016 foreign_call = target; |
923 } else { |
1017 } else { |
924 hotspot_method = target; |
1018 hotspot_method = target; |
925 } |
1019 } |
926 |
1020 |
927 oop debug_info = CompilationResult_Call::debugInfo(site); |
1021 Handle debug_info = CompilationResult_Call::debugInfo(site); |
928 |
1022 |
929 assert(!!hotspot_method ^ !!foreign_call, "Call site needs exactly one type"); |
1023 assert(hotspot_method.not_null() ^ foreign_call.not_null(), "Call site needs exactly one type"); |
930 |
1024 |
931 NativeInstruction* inst = nativeInstruction_at(_instructions->start() + pc_offset); |
1025 NativeInstruction* inst = nativeInstruction_at(_instructions->start() + pc_offset); |
932 jint next_pc_offset = CodeInstaller::pd_next_offset(inst, pc_offset, hotspot_method); |
1026 jint next_pc_offset = CodeInstaller::pd_next_offset(inst, pc_offset, hotspot_method, CHECK); |
933 |
1027 |
934 if (debug_info != NULL) { |
1028 if (debug_info.not_null()) { |
935 _debug_recorder->add_safepoint(next_pc_offset, create_oop_map(debug_info)); |
1029 OopMap *map = create_oop_map(debug_info, CHECK); |
936 record_scope(next_pc_offset, debug_info); |
1030 _debug_recorder->add_safepoint(next_pc_offset, map); |
937 } |
1031 record_scope(next_pc_offset, debug_info, CHECK); |
938 |
1032 } |
939 if (foreign_call != NULL) { |
1033 |
|
1034 if (foreign_call.not_null()) { |
940 jlong foreign_call_destination = HotSpotForeignCallTarget::address(foreign_call); |
1035 jlong foreign_call_destination = HotSpotForeignCallTarget::address(foreign_call); |
941 CodeInstaller::pd_relocate_ForeignCall(inst, foreign_call_destination); |
1036 CodeInstaller::pd_relocate_ForeignCall(inst, foreign_call_destination, CHECK); |
942 } else { // method != NULL |
1037 } else { // method != NULL |
943 assert(hotspot_method != NULL, "unexpected JavaMethod"); |
1038 if (debug_info.is_null()) { |
944 assert(debug_info != NULL, "debug info expected"); |
1039 JVMCI_ERROR("debug info expected at call at %i", pc_offset); |
|
1040 } |
945 |
1041 |
946 TRACE_jvmci_3("method call"); |
1042 TRACE_jvmci_3("method call"); |
947 CodeInstaller::pd_relocate_JavaMethod(hotspot_method, pc_offset); |
1043 CodeInstaller::pd_relocate_JavaMethod(hotspot_method, pc_offset, CHECK); |
948 if (_next_call_type == INVOKESTATIC || _next_call_type == INVOKESPECIAL) { |
1044 if (_next_call_type == INVOKESTATIC || _next_call_type == INVOKESPECIAL) { |
949 // Need a static call stub for transitions from compiled to interpreted. |
1045 // Need a static call stub for transitions from compiled to interpreted. |
950 CompiledStaticCall::emit_to_interp_stub(buffer, _instructions->start() + pc_offset); |
1046 CompiledStaticCall::emit_to_interp_stub(buffer, _instructions->start() + pc_offset); |
951 } |
1047 } |
952 } |
1048 } |
953 |
1049 |
954 _next_call_type = INVOKE_INVALID; |
1050 _next_call_type = INVOKE_INVALID; |
955 |
1051 |
956 if (debug_info != NULL) { |
1052 if (debug_info.not_null()) { |
957 _debug_recorder->end_safepoint(next_pc_offset); |
1053 _debug_recorder->end_safepoint(next_pc_offset); |
958 } |
1054 } |
959 } |
1055 } |
960 |
1056 |
961 void CodeInstaller::site_DataPatch(CodeBuffer& buffer, jint pc_offset, oop site) { |
1057 void CodeInstaller::site_DataPatch(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS) { |
962 oop reference = CompilationResult_DataPatch::reference(site); |
1058 Handle reference = CompilationResult_DataPatch::reference(site); |
963 if (reference->is_a(CompilationResult_ConstantReference::klass())) { |
1059 if (reference.is_null()) { |
|
1060 THROW(vmSymbols::java_lang_NullPointerException()); |
|
1061 } else if (reference->is_a(CompilationResult_ConstantReference::klass())) { |
964 Handle constant = CompilationResult_ConstantReference::constant(reference); |
1062 Handle constant = CompilationResult_ConstantReference::constant(reference); |
965 if (constant->is_a(HotSpotObjectConstantImpl::klass())) { |
1063 if (constant.is_null()) { |
966 pd_patch_OopConstant(pc_offset, constant); |
1064 THROW(vmSymbols::java_lang_NullPointerException()); |
|
1065 } else if (constant->is_a(HotSpotObjectConstantImpl::klass())) { |
|
1066 pd_patch_OopConstant(pc_offset, constant, CHECK); |
967 } else if (constant->is_a(HotSpotMetaspaceConstantImpl::klass())) { |
1067 } else if (constant->is_a(HotSpotMetaspaceConstantImpl::klass())) { |
968 pd_patch_MetaspaceConstant(pc_offset, constant); |
1068 pd_patch_MetaspaceConstant(pc_offset, constant, CHECK); |
969 } else if (constant->is_a(HotSpotSentinelConstant::klass())) { |
|
970 fatal("sentinel constant unsupported"); |
|
971 } else { |
1069 } else { |
972 fatal("unknown constant type in data patch"); |
1070 JVMCI_ERROR("unknown constant type in data patch: %s", constant->klass()->signature_name()); |
973 } |
1071 } |
974 } else if (reference->is_a(CompilationResult_DataSectionReference::klass())) { |
1072 } else if (reference->is_a(CompilationResult_DataSectionReference::klass())) { |
975 int data_offset = CompilationResult_DataSectionReference::offset(reference); |
1073 int data_offset = CompilationResult_DataSectionReference::offset(reference); |
976 assert(0 <= data_offset && data_offset < _constants_size, "data offset 0x%X points outside data section (size 0x%X)", data_offset, _constants_size); |
1074 if (0 <= data_offset && data_offset < _constants_size) { |
977 pd_patch_DataSectionReference(pc_offset, data_offset); |
1075 pd_patch_DataSectionReference(pc_offset, data_offset); |
|
1076 } else { |
|
1077 JVMCI_ERROR("data offset 0x%X points outside data section (size 0x%X)", data_offset, _constants_size); |
|
1078 } |
978 } else { |
1079 } else { |
979 fatal("unknown data patch type"); |
1080 JVMCI_ERROR("unknown data patch type: %s", reference->klass()->signature_name()); |
980 } |
1081 } |
981 } |
1082 } |
982 |
1083 |
983 void CodeInstaller::site_Mark(CodeBuffer& buffer, jint pc_offset, oop site) { |
1084 void CodeInstaller::site_Mark(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS) { |
984 oop id_obj = CompilationResult_Mark::id(site); |
1085 Handle id_obj = CompilationResult_Mark::id(site); |
985 |
1086 |
986 if (id_obj != NULL) { |
1087 if (id_obj.not_null()) { |
987 assert(java_lang_boxing_object::is_instance(id_obj, T_INT), "Integer id expected"); |
1088 if (!java_lang_boxing_object::is_instance(id_obj(), T_INT)) { |
|
1089 JVMCI_ERROR("expected Integer id, got %s", id_obj->klass()->signature_name()); |
|
1090 } |
988 jint id = id_obj->int_field(java_lang_boxing_object::value_offset_in_bytes(T_INT)); |
1091 jint id = id_obj->int_field(java_lang_boxing_object::value_offset_in_bytes(T_INT)); |
989 |
1092 |
990 address pc = _instructions->start() + pc_offset; |
1093 address pc = _instructions->start() + pc_offset; |
991 |
1094 |
992 switch (id) { |
1095 switch (id) { |