2514 * Return same type but drop speculative part if we know we won't use
2515 * it
2516 */
2517 const Type* TypePtr::cleanup_speculative() const {
2518 if (speculative() == NULL) {
2519 return this;
2520 }
2521 const Type* no_spec = remove_speculative();
2522 // If this is NULL_PTR then we don't need the speculative type
2523 // (with_inline_depth in case the current type inline depth is
2524 // InlineDepthTop)
2525 if (no_spec == NULL_PTR->with_inline_depth(inline_depth())) {
2526 return no_spec;
2527 }
2528 if (above_centerline(speculative()->ptr())) {
2529 return no_spec;
2530 }
2531 const TypeOopPtr* spec_oopptr = speculative()->isa_oopptr();
2532 // If the speculative may be null and is an inexact klass then it
2533 // doesn't help
2534 if (speculative()->maybe_null() && (spec_oopptr == NULL || !spec_oopptr->klass_is_exact())) {
2535 return no_spec;
2536 }
2537 return this;
2538 }
2539
2540 /**
2541 * dual of the speculative part of the type
2542 */
2543 const TypePtr* TypePtr::dual_speculative() const {
2544 if (_speculative == NULL) {
2545 return NULL;
2546 }
2547 return _speculative->dual()->is_ptr();
2548 }
2549
2550 /**
2551 * meet of the speculative parts of 2 types
2552 *
2553 * @param other type to meet with
2554 */
2643 if (_speculative != NULL && _speculative->isa_oopptr()) {
2644 const TypeOopPtr* speculative = _speculative->join(this)->is_oopptr();
2645 if (speculative->klass_is_exact()) {
2646 return speculative->klass();
2647 }
2648 }
2649 return NULL;
2650 }
2651
2652 /**
2653 * return true if speculative type may be null
2654 */
2655 bool TypePtr::speculative_maybe_null() const {
2656 if (_speculative != NULL) {
2657 const TypePtr* speculative = _speculative->join(this)->is_ptr();
2658 return speculative->maybe_null();
2659 }
2660 return true;
2661 }
2662
2663 /**
2664 * Same as TypePtr::speculative_type() but return the klass only if
2665 * the speculative tells us is not null
2666 */
2667 ciKlass* TypePtr::speculative_type_not_null() const {
2668 if (speculative_maybe_null()) {
2669 return NULL;
2670 }
2671 return speculative_type();
2672 }
2673
2674 /**
2675 * Check whether new profiling would improve speculative type
2676 *
2677 * @param exact_kls class from profiling
2678 * @param inline_depth inlining depth of profile point
2679 *
2680 * @return true if type profile is valuable
2681 */
2682 bool TypePtr::would_improve_type(ciKlass* exact_kls, int inline_depth) const {
2683 // no profiling?
2684 if (exact_kls == NULL) {
2685 return false;
2686 }
2687 // no speculative type or non exact speculative type?
2688 if (speculative_type() == NULL) {
2689 return true;
2690 }
2691 // If the node already has an exact speculative type keep it,
2692 // unless it was provided by profiling that is at a deeper
2693 // inlining level. Profiling at a higher inlining depth is
2694 // expected to be less accurate.
2695 if (_speculative->inline_depth() == InlineDepthBottom) {
2696 return false;
2697 }
2698 assert(_speculative->inline_depth() != InlineDepthTop, "can't do the comparison");
2699 return inline_depth < _speculative->inline_depth();
2700 }
2701
2702 /**
2703 * Check whether new profiling would improve ptr (= tells us it is non
2704 * null)
2705 *
2706 * @param maybe_null true if profiling tells the ptr may be null
2707 *
2708 * @return true if ptr profile is valuable
2709 */
2710 bool TypePtr::would_improve_ptr(bool maybe_null) const {
2711 // profiling doesn't tell us anything useful
2712 if (maybe_null) {
2713 return false;
2714 }
2715 // We already know this is not be null
2716 if (!this->maybe_null()) {
2717 return false;
2718 }
2719 // We already know the speculative type cannot be null
2720 if (!speculative_maybe_null()) {
2721 return false;
2722 }
2723 return true;
2724 }
2725
2726 //------------------------------dump2------------------------------------------
2727 const char *const TypePtr::ptr_msg[TypePtr::lastPTR] = {
2728 "TopPTR","AnyNull","Constant","NULL","NotNull","BotPTR"
2729 };
2730
2731 #ifndef PRODUCT
2732 void TypePtr::dump2( Dict &d, uint depth, outputStream *st ) const {
2733 if( _ptr == Null ) st->print("NULL");
2734 else st->print("%s *", ptr_msg[_ptr]);
2735 if( _offset == OffsetTop ) st->print("+top");
2736 else if( _offset == OffsetBot ) st->print("+bot");
2737 else if( _offset ) st->print("+%d", _offset);
2738 dump_inline_depth(st);
2739 dump_speculative(st);
2740 }
|
2514 * Return same type but drop speculative part if we know we won't use
2515 * it
2516 */
2517 const Type* TypePtr::cleanup_speculative() const {
2518 if (speculative() == NULL) {
2519 return this;
2520 }
2521 const Type* no_spec = remove_speculative();
2522 // If this is NULL_PTR then we don't need the speculative type
2523 // (with_inline_depth in case the current type inline depth is
2524 // InlineDepthTop)
2525 if (no_spec == NULL_PTR->with_inline_depth(inline_depth())) {
2526 return no_spec;
2527 }
2528 if (above_centerline(speculative()->ptr())) {
2529 return no_spec;
2530 }
2531 const TypeOopPtr* spec_oopptr = speculative()->isa_oopptr();
2532 // If the speculative may be null and is an inexact klass then it
2533 // doesn't help
2534 if (speculative() != TypePtr::NULL_PTR && speculative()->maybe_null() &&
2535 (spec_oopptr == NULL || !spec_oopptr->klass_is_exact())) {
2536 return no_spec;
2537 }
2538 return this;
2539 }
2540
2541 /**
2542 * dual of the speculative part of the type
2543 */
2544 const TypePtr* TypePtr::dual_speculative() const {
2545 if (_speculative == NULL) {
2546 return NULL;
2547 }
2548 return _speculative->dual()->is_ptr();
2549 }
2550
2551 /**
2552 * meet of the speculative parts of 2 types
2553 *
2554 * @param other type to meet with
2555 */
2644 if (_speculative != NULL && _speculative->isa_oopptr()) {
2645 const TypeOopPtr* speculative = _speculative->join(this)->is_oopptr();
2646 if (speculative->klass_is_exact()) {
2647 return speculative->klass();
2648 }
2649 }
2650 return NULL;
2651 }
2652
2653 /**
2654 * return true if speculative type may be null
2655 */
2656 bool TypePtr::speculative_maybe_null() const {
2657 if (_speculative != NULL) {
2658 const TypePtr* speculative = _speculative->join(this)->is_ptr();
2659 return speculative->maybe_null();
2660 }
2661 return true;
2662 }
2663
2664 bool TypePtr::speculative_always_null() const {
2665 if (_speculative != NULL) {
2666 const TypePtr* speculative = _speculative->join(this)->is_ptr();
2667 return speculative == TypePtr::NULL_PTR;
2668 }
2669 return false;
2670 }
2671
2672 /**
2673 * Same as TypePtr::speculative_type() but return the klass only if
2674 * the speculative tells us is not null
2675 */
2676 ciKlass* TypePtr::speculative_type_not_null() const {
2677 if (speculative_maybe_null()) {
2678 return NULL;
2679 }
2680 return speculative_type();
2681 }
2682
2683 /**
2684 * Check whether new profiling would improve speculative type
2685 *
2686 * @param exact_kls class from profiling
2687 * @param inline_depth inlining depth of profile point
2688 *
2689 * @return true if type profile is valuable
2690 */
2691 bool TypePtr::would_improve_type(ciKlass* exact_kls, int inline_depth) const {
2692 // no profiling?
2693 if (exact_kls == NULL) {
2694 return false;
2695 }
2696 if (speculative() == TypePtr::NULL_PTR) {
2697 return false;
2698 }
2699 // no speculative type or non exact speculative type?
2700 if (speculative_type() == NULL) {
2701 return true;
2702 }
2703 // If the node already has an exact speculative type keep it,
2704 // unless it was provided by profiling that is at a deeper
2705 // inlining level. Profiling at a higher inlining depth is
2706 // expected to be less accurate.
2707 if (_speculative->inline_depth() == InlineDepthBottom) {
2708 return false;
2709 }
2710 assert(_speculative->inline_depth() != InlineDepthTop, "can't do the comparison");
2711 return inline_depth < _speculative->inline_depth();
2712 }
2713
2714 /**
2715 * Check whether new profiling would improve ptr (= tells us it is non
2716 * null)
2717 *
2718 * @param ptr_kind always null or not null?
2719 *
2720 * @return true if ptr profile is valuable
2721 */
2722 bool TypePtr::would_improve_ptr(ProfilePtrKind ptr_kind) const {
2723 // profiling doesn't tell us anything useful
2724 if (ptr_kind != ProfileAlwaysNull && ptr_kind != ProfileNeverNull) {
2725 return false;
2726 }
2727 // We already know this is not null
2728 if (!this->maybe_null()) {
2729 return false;
2730 }
2731 // We already know the speculative type cannot be null
2732 if (!speculative_maybe_null()) {
2733 return false;
2734 }
2735 // We already know this is always null
2736 if (this == TypePtr::NULL_PTR) {
2737 return false;
2738 }
2739 // We already know the speculative type is always null
2740 if (speculative_always_null()) {
2741 return false;
2742 }
2743 if (ptr_kind == ProfileAlwaysNull && speculative() != NULL && speculative()->isa_oopptr()) {
2744 return false;
2745 }
2746 return true;
2747 }
2748
2749 //------------------------------dump2------------------------------------------
2750 const char *const TypePtr::ptr_msg[TypePtr::lastPTR] = {
2751 "TopPTR","AnyNull","Constant","NULL","NotNull","BotPTR"
2752 };
2753
2754 #ifndef PRODUCT
2755 void TypePtr::dump2( Dict &d, uint depth, outputStream *st ) const {
2756 if( _ptr == Null ) st->print("NULL");
2757 else st->print("%s *", ptr_msg[_ptr]);
2758 if( _offset == OffsetTop ) st->print("+top");
2759 else if( _offset == OffsetBot ) st->print("+bot");
2760 else if( _offset ) st->print("+%d", _offset);
2761 dump_inline_depth(st);
2762 dump_speculative(st);
2763 }
|