Mercurial > hg > graal-compiler
comparison src/share/vm/graal/graalVMEntries.cpp @ 3566:b0d192f86f34
more work on ci removal
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Thu, 01 Sep 2011 09:43:10 +0200 |
parents | b3f0f8a01ca2 |
children | dbf8d6a4201f |
comparison
equal
deleted
inserted
replaced
3565:b3f0f8a01ca2 | 3566:b0d192f86f34 |
---|---|
241 // counts in the MDO should be scaled by 4X, so that | 241 // counts in the MDO should be scaled by 4X, so that |
242 // they can be usefully and stably compared against the | 242 // they can be usefully and stably compared against the |
243 // invocation counts in methods. | 243 // invocation counts in methods. |
244 int scale_count(methodDataOop method_data, int count) { | 244 int scale_count(methodDataOop method_data, int count) { |
245 if (count > 0) { | 245 if (count > 0) { |
246 int method_life = method_data->method()->invocation_count(); | 246 int counter_life; |
247 int counter_life = method_life - method_data->creation_mileage(); | 247 int method_life = method_data->method()->interpreter_invocation_count(); |
248 | 248 int current_mileage = methodDataOopDesc::mileage_of(method_data->method()); |
249 if (method_life > 0 && counter_life > 0 && method_life > counter_life) { | 249 int creation_mileage = method_data->creation_mileage(); |
250 double factor = method_life / (double) counter_life; | 250 counter_life = current_mileage - creation_mileage; |
251 count = (int)(count * factor); | 251 |
252 // counter_life due to backedge_counter could be > method_life | |
253 if (counter_life > method_life) | |
254 counter_life = method_life; | |
255 if (0 < counter_life && counter_life <= method_life) { | |
256 count = (int)((double)count * method_life / counter_life + 0.5); | |
252 count = (count > 0) ? count : 1; | 257 count = (count > 0) ? count : 1; |
253 } | 258 } |
254 } | 259 } |
255 return count; | 260 return count; |
256 } | 261 } |
258 // public native RiTypeProfile RiMethod_typeProfile(long vmId, int bci); | 263 // public native RiTypeProfile RiMethod_typeProfile(long vmId, int bci); |
259 JNIEXPORT jobject JNICALL Java_com_oracle_graal_runtime_VMEntries_RiMethod_2typeProfile(JNIEnv *, jobject, jobject hotspot_method, jint bci) { | 264 JNIEXPORT jobject JNICALL Java_com_oracle_graal_runtime_VMEntries_RiMethod_2typeProfile(JNIEnv *, jobject, jobject hotspot_method, jint bci) { |
260 TRACE_graal_3("VMEntries::RiMethod_typeProfile"); | 265 TRACE_graal_3("VMEntries::RiMethod_typeProfile"); |
261 Handle obj; | 266 Handle obj; |
262 { | 267 { |
263 /* | |
264 VM_ENTRY_MARK; | 268 VM_ENTRY_MARK; |
265 methodHandle method = getMethodFromHotSpotMethod(hotspot_method); | 269 methodHandle method = getMethodFromHotSpotMethod(hotspot_method); |
270 if (strstr(method->name_and_sig_as_C_string(), "factor") != NULL) { | |
271 // tty->print_cr("here"); | |
272 } | |
273 if (bci == 123) { | |
274 // tty->print_cr("here2"); | |
275 } | |
266 methodDataHandle method_data = method->method_data(); | 276 methodDataHandle method_data = method->method_data(); |
267 if (method_data == NULL || !method_data->is_mature()) { | 277 if (method_data == NULL || !method_data->is_mature()) { |
268 return NULL; | 278 return NULL; |
269 } | 279 } |
270 ProfileData* data = method_data->bci_to_data(bci); | 280 ProfileData* data = method_data->bci_to_data(bci); |
271 if (data != NULL && data->is_ReceiverTypeData()) { | 281 if (data != NULL && data->is_ReceiverTypeData()) { |
272 ReceiverTypeData* recv = data->as_ReceiverTypeData(); | 282 ReceiverTypeData* recv = data->as_ReceiverTypeData(); |
273 // determine morphism | 283 // determine morphism |
274 int morphism = 0; | 284 int morphism = 0; |
275 int total_count = 0; | 285 uint total_count = 0; |
276 for (uint i = 0; i < recv->row_limit(); i++) { | 286 for (uint i = 0; i < recv->row_limit(); i++) { |
277 klassOop receiver = recv->receiver(i); | 287 klassOop receiver = recv->receiver(i); |
278 if (receiver == NULL) continue; | 288 if (receiver == NULL) continue; |
279 morphism++; | 289 morphism++; |
280 total_count += recv->receiver_count(i); | 290 total_count += recv->receiver_count(i); |
281 } | 291 } |
282 | 292 |
283 if (morphism > 0) { | |
284 instanceKlass::cast(RiTypeProfile::klass())->initialize(CHECK_NULL); | 293 instanceKlass::cast(RiTypeProfile::klass())->initialize(CHECK_NULL); |
285 obj = instanceKlass::cast(RiTypeProfile::klass())->allocate_instance(CHECK_NULL); | 294 obj = instanceKlass::cast(RiTypeProfile::klass())->allocate_instance(CHECK_NULL); |
286 assert(obj() != NULL, "must succeed in allocating instance"); | 295 assert(obj() != NULL, "must succeed in allocating instance"); |
287 | 296 |
288 RiTypeProfile::set_count(obj, scale_count(method_data(), recv->count())); | 297 int count = MAX2(total_count, recv->count()); |
298 RiTypeProfile::set_count(obj, scale_count(method_data(), count)); | |
289 RiTypeProfile::set_morphism(obj, morphism); | 299 RiTypeProfile::set_morphism(obj, morphism); |
290 | 300 |
301 if (morphism > 0) { | |
291 typeArrayHandle probabilities = oopFactory::new_typeArray(T_FLOAT, morphism, CHECK_NULL); | 302 typeArrayHandle probabilities = oopFactory::new_typeArray(T_FLOAT, morphism, CHECK_NULL); |
292 objArrayHandle types = oopFactory::new_objArray(SystemDictionary::RiType_klass(), morphism, CHECK_NULL); | 303 objArrayHandle types = oopFactory::new_objArray(SystemDictionary::RiType_klass(), morphism, CHECK_NULL); |
293 int pos = 0; | 304 int pos = 0; |
294 for (uint i = 0; i < recv->row_limit(); i++) { | 305 for (uint i = 0; i < recv->row_limit(); i++) { |
295 KlassHandle receiver = recv->receiver(i); | 306 KlassHandle receiver = recv->receiver(i); |
304 pos++; | 315 pos++; |
305 } | 316 } |
306 | 317 |
307 RiTypeProfile::set_probabilities(obj, probabilities()); | 318 RiTypeProfile::set_probabilities(obj, probabilities()); |
308 RiTypeProfile::set_types(obj, types()); | 319 RiTypeProfile::set_types(obj, types()); |
320 } else { | |
321 RiTypeProfile::set_probabilities(obj, NULL); | |
322 RiTypeProfile::set_types(obj, NULL); | |
309 } | 323 } |
310 }*/ | 324 } |
311 } | 325 } |
312 | 326 |
313 return JNIHandles::make_local(obj()); | 327 return JNIHandles::make_local(obj()); |
314 } | 328 } |
315 | 329 |