equal
deleted
inserted
replaced
460 } |
460 } |
461 #endif // COMPILER1 |
461 #endif // COMPILER1 |
462 |
462 |
463 |
463 |
464 // ------------------------------------------------------------------ |
464 // ------------------------------------------------------------------ |
|
465 // ciMethod::check_overflow |
|
466 // |
|
467 // Check whether the profile counter is overflowed and adjust if true. |
|
468 // For invoke* it will turn negative values into max_jint, |
|
469 // and for checkcast/aastore/instanceof turn positive values into min_jint. |
|
470 int ciMethod::check_overflow(int c, Bytecodes::Code code) { |
|
471 switch (code) { |
|
472 case Bytecodes::_aastore: // fall-through |
|
473 case Bytecodes::_checkcast: // fall-through |
|
474 case Bytecodes::_instanceof: { |
|
475 return (c > 0 ? min_jint : c); // always non-positive |
|
476 } |
|
477 default: { |
|
478 assert(Bytecodes::is_invoke(code), "%s", Bytecodes::name(code)); |
|
479 return (c < 0 ? max_jint : c); // always non-negative |
|
480 } |
|
481 } |
|
482 } |
|
483 |
|
484 |
|
485 // ------------------------------------------------------------------ |
465 // ciMethod::call_profile_at_bci |
486 // ciMethod::call_profile_at_bci |
466 // |
487 // |
467 // Get the ciCallProfile for the invocation of this method. |
488 // Get the ciCallProfile for the invocation of this method. |
468 // Also reports receiver types for non-call type checks (if TypeProfileCasts). |
489 // Also reports receiver types for non-call type checks (if TypeProfileCasts). |
469 ciCallProfile ciMethod::call_profile_at_bci(int bci) { |
490 ciCallProfile ciMethod::call_profile_at_bci(int bci) { |
471 ciCallProfile result; |
492 ciCallProfile result; |
472 if (method_data() != NULL && method_data()->is_mature()) { |
493 if (method_data() != NULL && method_data()->is_mature()) { |
473 ciProfileData* data = method_data()->bci_to_data(bci); |
494 ciProfileData* data = method_data()->bci_to_data(bci); |
474 if (data != NULL && data->is_CounterData()) { |
495 if (data != NULL && data->is_CounterData()) { |
475 // Every profiled call site has a counter. |
496 // Every profiled call site has a counter. |
476 int count = data->as_CounterData()->count(); |
497 int count = check_overflow(data->as_CounterData()->count(), java_code_at_bci(bci)); |
477 |
498 |
478 if (!data->is_ReceiverTypeData()) { |
499 if (!data->is_ReceiverTypeData()) { |
479 result._receiver_count[0] = 0; // that's a definite zero |
500 result._receiver_count[0] = 0; // that's a definite zero |
480 } else { // ReceiverTypeData is a subclass of CounterData |
501 } else { // ReceiverTypeData is a subclass of CounterData |
481 ciReceiverTypeData* call = (ciReceiverTypeData*)data->as_ReceiverTypeData(); |
502 ciReceiverTypeData* call = (ciReceiverTypeData*)data->as_ReceiverTypeData(); |
500 } |
521 } |
501 } |
522 } |
502 for (uint i = 0; i < call->row_limit(); i++) { |
523 for (uint i = 0; i < call->row_limit(); i++) { |
503 ciKlass* receiver = call->receiver(i); |
524 ciKlass* receiver = call->receiver(i); |
504 if (receiver == NULL) continue; |
525 if (receiver == NULL) continue; |
505 int rcount = call->receiver_count(i) + epsilon; |
526 int rcount = saturated_add(call->receiver_count(i), epsilon); |
506 if (rcount == 0) rcount = 1; // Should be valid value |
527 if (rcount == 0) rcount = 1; // Should be valid value |
507 receivers_count_total += rcount; |
528 receivers_count_total = saturated_add(receivers_count_total, rcount); |
508 // Add the receiver to result data. |
529 // Add the receiver to result data. |
509 result.add_receiver(receiver, rcount); |
530 result.add_receiver(receiver, rcount); |
510 // If we extend profiling to record methods, |
531 // If we extend profiling to record methods, |
511 // we will set result._method also. |
532 // we will set result._method also. |
512 } |
533 } |
532 // Make the count consistent if this is a call profile. If count is |
553 // Make the count consistent if this is a call profile. If count is |
533 // zero or less, presume that this is a typecheck profile and |
554 // zero or less, presume that this is a typecheck profile and |
534 // do nothing. Otherwise, increase count to be the sum of all |
555 // do nothing. Otherwise, increase count to be the sum of all |
535 // receiver's counts. |
556 // receiver's counts. |
536 if (count >= 0) { |
557 if (count >= 0) { |
537 count += receivers_count_total; |
558 count = saturated_add(count, receivers_count_total); |
538 } |
559 } |
539 } |
560 } |
540 result._count = count; |
561 result._count = count; |
541 } |
562 } |
542 } |
563 } |