comparison src/share/vm/graal/graalVMEntries.cpp @ 3565:b3f0f8a01ca2

remove some ci-dependencies
author Lukas Stadler <lukas.stadler@jku.at>
date Wed, 31 Aug 2011 09:58:35 +0200
parents f70a4cc629e7
children b0d192f86f34
comparison
equal deleted inserted replaced
3561:bea018622324 3565:b3f0f8a01ca2
212 } 212 }
213 213
214 // public native int RiMethod_exceptionProbability(long vmId, int bci); 214 // public native int RiMethod_exceptionProbability(long vmId, int bci);
215 JNIEXPORT jint JNICALL Java_com_oracle_graal_runtime_VMEntries_RiMethod_2exceptionProbability(JNIEnv *, jobject, jobject hotspot_method, jint bci) { 215 JNIEXPORT jint JNICALL Java_com_oracle_graal_runtime_VMEntries_RiMethod_2exceptionProbability(JNIEnv *, jobject, jobject hotspot_method, jint bci) {
216 TRACE_graal_3("VMEntries::RiMethod_exceptionProbability"); 216 TRACE_graal_3("VMEntries::RiMethod_exceptionProbability");
217 ciMethod* cimethod;
218 { 217 {
219 VM_ENTRY_MARK; 218 VM_ENTRY_MARK;
220 methodOop method = getMethodFromHotSpotMethod(hotspot_method); 219 methodOop method = getMethodFromHotSpotMethod(hotspot_method);
221 cimethod = (ciMethod*)CURRENT_ENV->get_object(method); 220 methodDataOop method_data = method->method_data();
222 } 221 if (method_data == NULL || !method_data->is_mature()) {
223 ciMethodData* method_data = cimethod->method_data(); 222 return -1;
224 223 }
225 if (method_data == NULL || !method_data->is_mature()) return -1; 224 ProfileData* data = method_data->bci_to_data(bci);
226 225 if (data == NULL) {
227 ciProfileData* profile = method_data->bci_to_data(bci); 226 return 0;
228 if (profile == NULL) { 227 }
229 return 0; 228 uint trap = Deoptimization::trap_state_is_recompiled(data->trap_state())? 1: 0;
230 } 229 if (trap > 0) {
231 uint trap = method_data->trap_recompiled_at(profile); 230 return 100;
232 if (trap > 0) { 231 } else {
233 return 100; 232 return trap;
234 } else { 233 }
235 return trap; 234 }
236 } 235 }
236
237 // ------------------------------------------------------------------
238 // Adjust a CounterData count to be commensurate with
239 // interpreter_invocation_count. If the MDO exists for
240 // only 25% of the time the method exists, then the
241 // counts in the MDO should be scaled by 4X, so that
242 // they can be usefully and stably compared against the
243 // invocation counts in methods.
244 int scale_count(methodDataOop method_data, int count) {
245 if (count > 0) {
246 int method_life = method_data->method()->invocation_count();
247 int counter_life = method_life - method_data->creation_mileage();
248
249 if (method_life > 0 && counter_life > 0 && method_life > counter_life) {
250 double factor = method_life / (double) counter_life;
251 count = (int)(count * factor);
252 count = (count > 0) ? count : 1;
253 }
254 }
255 return count;
237 } 256 }
238 257
239 // public native RiTypeProfile RiMethod_typeProfile(long vmId, int bci); 258 // public native RiTypeProfile RiMethod_typeProfile(long vmId, int bci);
240 JNIEXPORT jobject JNICALL Java_com_oracle_graal_runtime_VMEntries_RiMethod_2typeProfile(JNIEnv *, jobject, jobject hotspot_method, jint bci) { 259 JNIEXPORT jobject JNICALL Java_com_oracle_graal_runtime_VMEntries_RiMethod_2typeProfile(JNIEnv *, jobject, jobject hotspot_method, jint bci) {
241 TRACE_graal_3("VMEntries::RiMethod_typeProfile"); 260 TRACE_graal_3("VMEntries::RiMethod_typeProfile");
242 ciMethod* cimethod;
243 {
244 VM_ENTRY_MARK;
245 methodOop method = getMethodFromHotSpotMethod(hotspot_method);
246 cimethod = (ciMethod*)CURRENT_ENV->get_object(method);
247 }
248
249 ciCallProfile profile = cimethod->call_profile_at_bci(bci);
250
251 Handle obj; 261 Handle obj;
252 { 262 {
263 /*
253 VM_ENTRY_MARK; 264 VM_ENTRY_MARK;
254 instanceKlass::cast(RiTypeProfile::klass())->initialize(CHECK_NULL); 265 methodHandle method = getMethodFromHotSpotMethod(hotspot_method);
255 obj = instanceKlass::cast(RiTypeProfile::klass())->allocate_instance(CHECK_NULL); 266 methodDataHandle method_data = method->method_data();
256 assert(obj() != NULL, "must succeed in allocating instance"); 267 if (method_data == NULL || !method_data->is_mature()) {
257 268 return NULL;
258 RiTypeProfile::set_count(obj, cimethod->scale_count(profile.count(), 1)); 269 }
259 RiTypeProfile::set_morphism(obj, profile.morphism()); 270 ProfileData* data = method_data->bci_to_data(bci);
260 271 if (data != NULL && data->is_ReceiverTypeData()) {
261 typeArrayHandle probabilities = oopFactory::new_typeArray(T_FLOAT, profile.limit(), CHECK_NULL); 272 ReceiverTypeData* recv = data->as_ReceiverTypeData();
262 objArrayHandle types = oopFactory::new_objArray(SystemDictionary::RiType_klass(), profile.limit(), CHECK_NULL); 273 // determine morphism
263 for (int i=0; i<profile.limit(); i++) { 274 int morphism = 0;
264 float prob = profile.receiver_prob(i); 275 int total_count = 0;
265 ciKlass* receiver = profile.receiver(i); 276 for (uint i = 0; i < recv->row_limit(); i++) {
266 oop type = GraalCompiler::get_RiType(receiver, KlassHandle(), CHECK_NULL); 277 klassOop receiver = recv->receiver(i);
267 278 if (receiver == NULL) continue;
268 probabilities->float_at_put(i, prob); 279 morphism++;
269 types->obj_at_put(i, type); 280 total_count += recv->receiver_count(i);
270 } 281 }
271 282
272 RiTypeProfile::set_probabilities(obj, probabilities()); 283 if (morphism > 0) {
273 RiTypeProfile::set_types(obj, types()); 284 instanceKlass::cast(RiTypeProfile::klass())->initialize(CHECK_NULL);
274 285 obj = instanceKlass::cast(RiTypeProfile::klass())->allocate_instance(CHECK_NULL);
286 assert(obj() != NULL, "must succeed in allocating instance");
287
288 RiTypeProfile::set_count(obj, scale_count(method_data(), recv->count()));
289 RiTypeProfile::set_morphism(obj, morphism);
290
291 typeArrayHandle probabilities = oopFactory::new_typeArray(T_FLOAT, morphism, CHECK_NULL);
292 objArrayHandle types = oopFactory::new_objArray(SystemDictionary::RiType_klass(), morphism, CHECK_NULL);
293 int pos = 0;
294 for (uint i = 0; i < recv->row_limit(); i++) {
295 KlassHandle receiver = recv->receiver(i);
296 if (receiver.is_null()) continue;
297
298 float prob = recv->receiver_count(i) / (float) total_count;
299 oop type = GraalCompiler::get_RiType(receiver, KlassHandle(), CHECK_NULL);
300
301 probabilities->float_at_put(pos, prob);
302 types->obj_at_put(pos, type);
303
304 pos++;
305 }
306
307 RiTypeProfile::set_probabilities(obj, probabilities());
308 RiTypeProfile::set_types(obj, types());
309 }
310 }*/
275 } 311 }
276 312
277 return JNIHandles::make_local(obj()); 313 return JNIHandles::make_local(obj());
278 } 314 }
279 315