Mercurial > hg > graal-jvmci-8
comparison src/share/vm/graal/graalVMEntries.cpp @ 3646:148584b96a34
Remove ci usage for accessing branch probability.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Wed, 16 Nov 2011 15:58:18 +0100 |
parents | a8021a9f2a14 |
children | dea89750a867 |
comparison
equal
deleted
inserted
replaced
3645:9c2c0a182f13 | 3646:148584b96a34 |
---|---|
39 methodOop getMethodFromHotSpotMethod(jobject hotspot_method) { | 39 methodOop getMethodFromHotSpotMethod(jobject hotspot_method) { |
40 return getMethodFromHotSpotMethod(JNIHandles::resolve(hotspot_method)); | 40 return getMethodFromHotSpotMethod(JNIHandles::resolve(hotspot_method)); |
41 } | 41 } |
42 | 42 |
43 methodOop getMethodFromHotSpotMethod(oop hotspot_method) { | 43 methodOop getMethodFromHotSpotMethod(oop hotspot_method) { |
44 oop reflected = HotSpotMethodResolved::javaMirror(hotspot_method); | 44 return (methodOop)HotSpotMethodResolved::javaMirror(hotspot_method); |
45 assert(reflected != NULL, "NULL not expected"); | |
46 return (methodOop)reflected; | |
47 | |
48 // (tw) Cannot use reflection code, because then the compiler can dead lock with the user application (test using -Xcomp). | |
49 /* | |
50 // method is a handle to a java.lang.reflect.Method object | |
51 oop mirror = NULL; | |
52 int slot = 0; | |
53 | |
54 if (reflected->klass() == SystemDictionary::reflect_Constructor_klass()) { | |
55 mirror = java_lang_reflect_Constructor::clazz(reflected); | |
56 slot = java_lang_reflect_Constructor::slot(reflected); | |
57 } else { | |
58 assert(reflected->klass() == SystemDictionary::reflect_Method_klass(), "wrong type"); | |
59 mirror = java_lang_reflect_Method::clazz(reflected); | |
60 slot = java_lang_reflect_Method::slot(reflected); | |
61 } | |
62 klassOop k = java_lang_Class::as_klassOop(mirror); | |
63 | |
64 // Make sure class is initialized before handing id's out to methods | |
65 // assert(instanceKlass::cast(k)->is_initialized(), "only initialized classes expected"); | |
66 methodOop m = instanceKlass::cast(k)->method_with_idnum(slot); | |
67 assert(m != NULL, "deleted method?"); | |
68 return m;*/ | |
69 } | |
70 | |
71 oop getReflectedMethod(methodOop method, TRAPS) { | |
72 assert(method != NULL, "NULL not expected"); | |
73 | |
74 if (!method->is_initializer() || method->is_static()) { | |
75 return Reflection::new_method(method, true, true, CHECK_NULL); | |
76 } else { | |
77 return Reflection::new_constructor(method, CHECK_NULL); | |
78 } | |
79 } | 45 } |
80 | 46 |
81 // public byte[] RiMethod_code(HotSpotResolvedMethod method); | 47 // public byte[] RiMethod_code(HotSpotResolvedMethod method); |
82 JNIEXPORT jbyteArray JNICALL Java_com_oracle_graal_hotspot_VMEntries_RiMethod_1code(JNIEnv *env, jobject, jobject hotspot_method) { | 48 JNIEXPORT jbyteArray JNICALL Java_com_oracle_graal_hotspot_VMEntries_RiMethod_1code(JNIEnv *env, jobject, jobject hotspot_method) { |
83 TRACE_graal_3("VMEntries::RiMethod_code"); | 49 TRACE_graal_3("VMEntries::RiMethod_code"); |
327 return JNIHandles::make_local(obj()); | 293 return JNIHandles::make_local(obj()); |
328 } | 294 } |
329 | 295 |
330 JNIEXPORT jdouble JNICALL Java_com_oracle_graal_hotspot_VMEntries_RiMethod_2branchProbability(JNIEnv *, jobject, jobject hotspot_method, jint bci) { | 296 JNIEXPORT jdouble JNICALL Java_com_oracle_graal_hotspot_VMEntries_RiMethod_2branchProbability(JNIEnv *, jobject, jobject hotspot_method, jint bci) { |
331 TRACE_graal_3("VMEntries::RiMethod_typeProfile"); | 297 TRACE_graal_3("VMEntries::RiMethod_typeProfile"); |
332 ciMethodData* method_data; | 298 methodOop method = getMethodFromHotSpotMethod(hotspot_method); |
333 ciMethod* cimethod; | 299 methodDataOop method_data = method->method_data(); |
334 { | |
335 VM_ENTRY_MARK; | |
336 assert(hotspot_method != NULL, "must not be null"); | |
337 methodOop method = getMethodFromHotSpotMethod(hotspot_method); | |
338 assert(method != NULL, "method not found"); | |
339 if (CURRENT_ENV == NULL) { | |
340 return -1; | |
341 } | |
342 assert(CURRENT_ENV != NULL, "current environment must be present"); | |
343 cimethod = (ciMethod*)CURRENT_ENV->get_object(method); | |
344 } | |
345 assert(cimethod != NULL, "cimethod not found"); | |
346 method_data = cimethod->method_data(); | |
347 | |
348 jfloat probability = -1; | |
349 | 300 |
350 if (method_data == NULL || !method_data->is_mature()) return -1; | 301 if (method_data == NULL || !method_data->is_mature()) return -1; |
351 | 302 method_data->bci_to_data(bci); |
352 ciProfileData* data = method_data->bci_to_data(bci); | 303 |
304 ProfileData* data = method_data->bci_to_data(bci); | |
353 if (data == NULL || !data->is_JumpData()) return -1; | 305 if (data == NULL || !data->is_JumpData()) return -1; |
354 | 306 |
355 // get taken and not taken values | 307 // get taken and not taken values |
356 int taken = data->as_JumpData()->taken(); | 308 int taken = data->as_JumpData()->taken(); |
357 int not_taken = 0; | 309 int not_taken = 0; |