comparison src/share/vm/opto/graphKit.cpp @ 14513:16c705d792be

Merge
author morris
date Fri, 28 Feb 2014 08:02:20 -0800
parents bb9356ec5967 484a359ff649
children d8041d695d19 5e2306b00977
comparison
equal deleted inserted replaced
14493:7d30d4f37d31 14513:16c705d792be
610 // create the stack trace. 610 // create the stack trace.
611 611
612 // Usual case: Bail to interpreter. 612 // Usual case: Bail to interpreter.
613 // Reserve the right to recompile if we haven't seen anything yet. 613 // Reserve the right to recompile if we haven't seen anything yet.
614 614
615 assert(!Deoptimization::reason_is_speculate(reason), "unsupported");
615 Deoptimization::DeoptAction action = Deoptimization::Action_maybe_recompile; 616 Deoptimization::DeoptAction action = Deoptimization::Action_maybe_recompile;
616 if (treat_throw_as_hot 617 if (treat_throw_as_hot
617 && (method()->method_data()->trap_recompiled_at(bci()) 618 && (method()->method_data()->trap_recompiled_at(bci(), NULL)
618 || C->too_many_traps(reason))) { 619 || C->too_many_traps(reason))) {
619 // We cannot afford to take more traps here. Suffer in the interpreter. 620 // We cannot afford to take more traps here. Suffer in the interpreter.
620 if (C->log() != NULL) 621 if (C->log() != NULL)
621 C->log()->elem("hot_throw preallocated='0' reason='%s' mcount='%d'", 622 C->log()->elem("hot_throw preallocated='0' reason='%s' mcount='%d'",
622 Deoptimization::trap_reason_name(reason), 623 Deoptimization::trap_reason_name(reason),
2110 * @param exact_kls type from profiling 2111 * @param exact_kls type from profiling
2111 * 2112 *
2112 * @return node with improved type 2113 * @return node with improved type
2113 */ 2114 */
2114 Node* GraphKit::record_profile_for_speculation(Node* n, ciKlass* exact_kls) { 2115 Node* GraphKit::record_profile_for_speculation(Node* n, ciKlass* exact_kls) {
2115 const TypeOopPtr* current_type = _gvn.type(n)->isa_oopptr(); 2116 const Type* current_type = _gvn.type(n);
2116 assert(UseTypeSpeculation, "type speculation must be on"); 2117 assert(UseTypeSpeculation, "type speculation must be on");
2117 if (exact_kls != NULL && 2118
2118 // nothing to improve if type is already exact 2119 const TypeOopPtr* speculative = current_type->speculative();
2119 (current_type == NULL || 2120
2120 (!current_type->klass_is_exact() && 2121 if (current_type->would_improve_type(exact_kls, jvms()->depth())) {
2121 (current_type->speculative() == NULL ||
2122 !current_type->speculative()->klass_is_exact())))) {
2123 const TypeKlassPtr* tklass = TypeKlassPtr::make(exact_kls); 2122 const TypeKlassPtr* tklass = TypeKlassPtr::make(exact_kls);
2124 const TypeOopPtr* xtype = tklass->as_instance_type(); 2123 const TypeOopPtr* xtype = tklass->as_instance_type();
2125 assert(xtype->klass_is_exact(), "Should be exact"); 2124 assert(xtype->klass_is_exact(), "Should be exact");
2126 2125 // record the new speculative type's depth
2126 speculative = xtype->with_inline_depth(jvms()->depth());
2127 }
2128
2129 if (speculative != current_type->speculative()) {
2127 // Build a type with a speculative type (what we think we know 2130 // Build a type with a speculative type (what we think we know
2128 // about the type but will need a guard when we use it) 2131 // about the type but will need a guard when we use it)
2129 const TypeOopPtr* spec_type = TypeOopPtr::make(TypePtr::BotPTR, Type::OffsetBot, TypeOopPtr::InstanceBot, xtype); 2132 const TypeOopPtr* spec_type = TypeOopPtr::make(TypePtr::BotPTR, Type::OffsetBot, TypeOopPtr::InstanceBot, speculative);
2130 // We're changing the type, we need a new cast node to carry the 2133 // We're changing the type, we need a new CheckCast node to carry
2131 // new type. The new type depends on the control: what profiling 2134 // the new type. The new type depends on the control: what
2132 // tells us is only valid from here as far as we can tell. 2135 // profiling tells us is only valid from here as far as we can
2133 Node* cast = new(C) CastPPNode(n, spec_type); 2136 // tell.
2134 cast->init_req(0, control()); 2137 Node* cast = new(C) CheckCastPPNode(control(), n, current_type->remove_speculative()->join_speculative(spec_type));
2135 cast = _gvn.transform(cast); 2138 cast = _gvn.transform(cast);
2136 replace_in_map(n, cast); 2139 replace_in_map(n, cast);
2137 n = cast; 2140 n = cast;
2138 } 2141 }
2142
2139 return n; 2143 return n;
2140 } 2144 }
2141 2145
2142 /** 2146 /**
2143 * Record profiling data from receiver profiling at an invoke with the 2147 * Record profiling data from receiver profiling at an invoke with the
2144 * type system so that it can propagate it (speculation) 2148 * type system so that it can propagate it (speculation)
2145 * 2149 *
2146 * @param n receiver node 2150 * @param n receiver node
2147 * 2151 *
2148 * @return node with improved type 2152 * @return node with improved type
2149 */ 2153 */
2150 Node* GraphKit::record_profiled_receiver_for_speculation(Node* n) { 2154 Node* GraphKit::record_profiled_receiver_for_speculation(Node* n) {
2151 if (!UseTypeSpeculation) { 2155 if (!UseTypeSpeculation) {
2152 return n; 2156 return n;
2153 } 2157 }
2737 //------------------------maybe_cast_profiled_receiver------------------------- 2741 //------------------------maybe_cast_profiled_receiver-------------------------
2738 // If the profile has seen exactly one type, narrow to exactly that type. 2742 // If the profile has seen exactly one type, narrow to exactly that type.
2739 // Subsequent type checks will always fold up. 2743 // Subsequent type checks will always fold up.
2740 Node* GraphKit::maybe_cast_profiled_receiver(Node* not_null_obj, 2744 Node* GraphKit::maybe_cast_profiled_receiver(Node* not_null_obj,
2741 ciKlass* require_klass, 2745 ciKlass* require_klass,
2742 ciKlass* spec_klass, 2746 ciKlass* spec_klass,
2743 bool safe_for_replace) { 2747 bool safe_for_replace) {
2744 if (!UseTypeProfile || !TypeProfileCasts) return NULL; 2748 if (!UseTypeProfile || !TypeProfileCasts) return NULL;
2745 2749
2750 Deoptimization::DeoptReason reason = spec_klass == NULL ? Deoptimization::Reason_class_check : Deoptimization::Reason_speculate_class_check;
2751
2746 // Make sure we haven't already deoptimized from this tactic. 2752 // Make sure we haven't already deoptimized from this tactic.
2747 if (too_many_traps(Deoptimization::Reason_class_check)) 2753 if (too_many_traps(reason))
2748 return NULL; 2754 return NULL;
2749 2755
2750 // (No, this isn't a call, but it's enough like a virtual call 2756 // (No, this isn't a call, but it's enough like a virtual call
2751 // to use the same ciMethod accessor to get the profile info...) 2757 // to use the same ciMethod accessor to get the profile info...)
2752 // If we have a speculative type use it instead of profiling (which 2758 // If we have a speculative type use it instead of profiling (which
2764 Node* exact_obj = not_null_obj; // will get updated in place... 2770 Node* exact_obj = not_null_obj; // will get updated in place...
2765 Node* slow_ctl = type_check_receiver(exact_obj, exact_kls, 1.0, 2771 Node* slow_ctl = type_check_receiver(exact_obj, exact_kls, 1.0,
2766 &exact_obj); 2772 &exact_obj);
2767 { PreserveJVMState pjvms(this); 2773 { PreserveJVMState pjvms(this);
2768 set_control(slow_ctl); 2774 set_control(slow_ctl);
2769 uncommon_trap(Deoptimization::Reason_class_check, 2775 uncommon_trap(reason,
2770 Deoptimization::Action_maybe_recompile); 2776 Deoptimization::Action_maybe_recompile);
2771 } 2777 }
2772 if (safe_for_replace) { 2778 if (safe_for_replace) {
2773 replace_in_map(not_null_obj, exact_obj); 2779 replace_in_map(not_null_obj, exact_obj);
2774 } 2780 }
2791 Node* GraphKit::maybe_cast_profiled_obj(Node* obj, 2797 Node* GraphKit::maybe_cast_profiled_obj(Node* obj,
2792 ciKlass* type, 2798 ciKlass* type,
2793 bool not_null) { 2799 bool not_null) {
2794 // type == NULL if profiling tells us this object is always null 2800 // type == NULL if profiling tells us this object is always null
2795 if (type != NULL) { 2801 if (type != NULL) {
2796 if (!too_many_traps(Deoptimization::Reason_null_check) && 2802 Deoptimization::DeoptReason class_reason = Deoptimization::Reason_speculate_class_check;
2797 !too_many_traps(Deoptimization::Reason_class_check)) { 2803 Deoptimization::DeoptReason null_reason = Deoptimization::Reason_null_check;
2804 if (!too_many_traps(null_reason) &&
2805 !too_many_traps(class_reason)) {
2798 Node* not_null_obj = NULL; 2806 Node* not_null_obj = NULL;
2799 // not_null is true if we know the object is not null and 2807 // not_null is true if we know the object is not null and
2800 // there's no need for a null check 2808 // there's no need for a null check
2801 if (!not_null) { 2809 if (!not_null) {
2802 Node* null_ctl = top(); 2810 Node* null_ctl = top();
2811 Node* slow_ctl = type_check_receiver(exact_obj, exact_kls, 1.0, 2819 Node* slow_ctl = type_check_receiver(exact_obj, exact_kls, 1.0,
2812 &exact_obj); 2820 &exact_obj);
2813 { 2821 {
2814 PreserveJVMState pjvms(this); 2822 PreserveJVMState pjvms(this);
2815 set_control(slow_ctl); 2823 set_control(slow_ctl);
2816 uncommon_trap(Deoptimization::Reason_class_check, 2824 uncommon_trap(class_reason,
2817 Deoptimization::Action_maybe_recompile); 2825 Deoptimization::Action_maybe_recompile);
2818 } 2826 }
2819 replace_in_map(not_null_obj, exact_obj); 2827 replace_in_map(not_null_obj, exact_obj);
2820 obj = exact_obj; 2828 obj = exact_obj;
2821 } 2829 }
2880 known_statically = (static_res == SSC_always_true || static_res == SSC_always_false); 2888 known_statically = (static_res == SSC_always_true || static_res == SSC_always_false);
2881 } 2889 }
2882 } 2890 }
2883 2891
2884 if (known_statically && UseTypeSpeculation) { 2892 if (known_statically && UseTypeSpeculation) {
2885 // If we know the type check always succeed then we don't use the 2893 // If we know the type check always succeeds then we don't use the
2886 // profiling data at this bytecode. Don't lose it, feed it to the 2894 // profiling data at this bytecode. Don't lose it, feed it to the
2887 // type system as a speculative type. 2895 // type system as a speculative type.
2888 not_null_obj = record_profiled_receiver_for_speculation(not_null_obj); 2896 not_null_obj = record_profiled_receiver_for_speculation(not_null_obj);
2889 } else { 2897 } else {
2890 const TypeOopPtr* obj_type = _gvn.type(obj)->is_oopptr(); 2898 const TypeOopPtr* obj_type = _gvn.type(obj)->is_oopptr();