2763 RC_TRACE_MESG(("adjust: klassname=%s default methods from name=%s", 2764 external_name(), 2765 old_method->method_holder()->external_name())); 2766 *trace_name_printed = true; 2767 } 2768 RC_TRACE(0x00100000, ("default method update: %s(%s) ", 2769 new_method->name()->as_C_string(), 2770 new_method->signature()->as_C_string())); 2771 } 2772 } 2773 } 2774 } 2775 } 2776 } 2777 #endif // INCLUDE_JVMTI 2778 2779 // On-stack replacement stuff 2780 void InstanceKlass::add_osr_nmethod(nmethod* n) { 2781 // only one compilation can be active 2782 NEEDS_CLEANUP 2783 // This is a short non-blocking critical region, so the no safepoint check is ok. 2784 OsrList_lock->lock_without_safepoint_check(); 2785 assert(n->is_osr_method(), "wrong kind of nmethod"); 2786 n->set_osr_link(osr_nmethods_head()); 2787 set_osr_nmethods_head(n); 2788 // Raise the highest osr level if necessary 2789 if (TieredCompilation) { 2790 Method* m = n->method(); 2791 m->set_highest_osr_comp_level(MAX2(m->highest_osr_comp_level(), n->comp_level())); 2792 } 2793 // Remember to unlock again 2794 OsrList_lock->unlock(); 2795 2796 // Get rid of the osr methods for the same bci that have lower levels. 2797 if (TieredCompilation) { 2798 for (int l = CompLevel_limited_profile; l < n->comp_level(); l++) { 2799 nmethod *inv = lookup_osr_nmethod(n->method(), n->osr_entry_bci(), l, true); 2800 if (inv != NULL && inv->is_in_use()) { 2801 inv->make_not_entrant(); 2802 } 2803 } 2804 } 2805 } 2806 2807 2808 void InstanceKlass::remove_osr_nmethod(nmethod* n) { 2809 // This is a short non-blocking critical region, so the no safepoint check is ok. 2810 OsrList_lock->lock_without_safepoint_check(); 2811 assert(n->is_osr_method(), "wrong kind of nmethod"); 2812 nmethod* last = NULL; 2813 nmethod* cur = osr_nmethods_head(); 2814 int max_level = CompLevel_none; // Find the max comp level excluding n 2815 Method* m = n->method(); 2816 // Search for match 2817 while(cur != NULL && cur != n) { 2818 if (TieredCompilation && m == cur->method()) { 2819 // Find max level before n 2820 max_level = MAX2(max_level, cur->comp_level()); 2821 } 2822 last = cur; 2823 cur = cur->osr_link(); 2824 } 2825 nmethod* next = NULL; 2826 if (cur == n) { 2827 next = cur->osr_link(); 2828 if (last == NULL) { 2829 // Remove first element 2830 set_osr_nmethods_head(next); 2831 } else { 2832 last->set_osr_link(next); 2833 } 2834 } 2835 n->set_osr_link(NULL); 2836 if (TieredCompilation) { 2837 cur = next; 2838 while (cur != NULL) { 2839 // Find max level after n 2840 if (m == cur->method()) { 2841 max_level = MAX2(max_level, cur->comp_level()); 2842 } 2843 cur = cur->osr_link(); 2844 } 2845 m->set_highest_osr_comp_level(max_level); 2846 } 2847 // Remember to unlock again 2848 OsrList_lock->unlock(); 2849 } 2850 2851 nmethod* InstanceKlass::lookup_osr_nmethod(const Method* m, int bci, int comp_level, bool match_level) const { 2852 // This is a short non-blocking critical region, so the no safepoint check is ok. 2853 OsrList_lock->lock_without_safepoint_check(); 2854 nmethod* osr = osr_nmethods_head(); 2855 nmethod* best = NULL; 2856 while (osr != NULL) { 2857 assert(osr->is_osr_method(), "wrong kind of nmethod found in chain"); 2858 // There can be a time when a c1 osr method exists but we are waiting 2859 // for a c2 version. When c2 completes its osr nmethod we will trash 2860 // the c1 version and only be able to find the c2 version. However 2861 // while we overflow in the c1 code at back branches we don't want to 2862 // try and switch to the same code as we are already running 2863 2864 if (osr->method() == m && 2865 (bci == InvocationEntryBci || osr->osr_entry_bci() == bci)) { 2866 if (match_level) { 2867 if (osr->comp_level() == comp_level) { 2868 // Found a match - return it. 2869 OsrList_lock->unlock(); 2870 return osr; 2871 } 2872 } else { 2873 if (best == NULL || (osr->comp_level() > best->comp_level())) { 2874 if (osr->comp_level() == CompLevel_highest_tier) { 2875 // Found the best possible - return it. 2876 OsrList_lock->unlock(); 2877 return osr; 2878 } 2879 best = osr; 2880 } 2881 } 2882 } 2883 osr = osr->osr_link(); 2884 } 2885 OsrList_lock->unlock(); 2886 if (best != NULL && best->comp_level() >= comp_level && match_level == false) { 2887 return best; 2888 } 2889 return NULL; 2890 } 2891 2892 void InstanceKlass::add_member_name(int index, Handle mem_name) { 2893 jweak mem_name_wref = JNIHandles::make_weak_global(mem_name); 2894 MutexLocker ml(MemberNameTable_lock); 2895 assert(0 <= index && index < idnum_allocated_count(), "index is out of bounds"); 2896 DEBUG_ONLY(No_Safepoint_Verifier nsv); 2897 2898 if (_member_names == NULL) { 2899 _member_names = new (ResourceObj::C_HEAP, mtClass) MemberNameTable(idnum_allocated_count()); 2900 } 2901 _member_names->add_member_name(index, mem_name_wref); 2902 } 2903 2904 oop InstanceKlass::get_member_name(int index) { 2905 MutexLocker ml(MemberNameTable_lock); | 2763 RC_TRACE_MESG(("adjust: klassname=%s default methods from name=%s", 2764 external_name(), 2765 old_method->method_holder()->external_name())); 2766 *trace_name_printed = true; 2767 } 2768 RC_TRACE(0x00100000, ("default method update: %s(%s) ", 2769 new_method->name()->as_C_string(), 2770 new_method->signature()->as_C_string())); 2771 } 2772 } 2773 } 2774 } 2775 } 2776 } 2777 #endif // INCLUDE_JVMTI 2778 2779 // On-stack replacement stuff 2780 void InstanceKlass::add_osr_nmethod(nmethod* n) { 2781 // only one compilation can be active 2782 NEEDS_CLEANUP 2783 { 2784 // This is a short non-blocking critical region, so the no safepoint check is ok. 2785 MutexLockerEx ml(OsrList_lock, Mutex::_no_safepoint_check_flag); 2786 assert(n->is_osr_method(), "wrong kind of nmethod"); 2787 n->set_osr_link(osr_nmethods_head()); 2788 set_osr_nmethods_head(n); 2789 // Raise the highest osr level if necessary 2790 if (TieredCompilation) { 2791 Method* m = n->method(); 2792 m->set_highest_osr_comp_level(MAX2(m->highest_osr_comp_level(), n->comp_level())); 2793 } 2794 } 2795 2796 // Get rid of the osr methods for the same bci that have lower levels. 2797 if (TieredCompilation) { 2798 for (int l = CompLevel_limited_profile; l < n->comp_level(); l++) { 2799 nmethod *inv = lookup_osr_nmethod(n->method(), n->osr_entry_bci(), l, true); 2800 if (inv != NULL && inv->is_in_use()) { 2801 inv->make_not_entrant(); 2802 } 2803 } 2804 } 2805 } 2806 2807 2808 void InstanceKlass::remove_osr_nmethod(nmethod* n) { 2809 // This is a short non-blocking critical region, so the no safepoint check is ok. 2810 MutexLockerEx ml(OsrList_lock, Mutex::_no_safepoint_check_flag); 2811 assert(n->is_osr_method(), "wrong kind of nmethod"); 2812 nmethod* last = NULL; 2813 nmethod* cur = osr_nmethods_head(); 2814 int max_level = CompLevel_none; // Find the max comp level excluding n 2815 Method* m = n->method(); 2816 // Search for match 2817 while(cur != NULL && cur != n) { 2818 if (TieredCompilation && m == cur->method()) { 2819 // Find max level before n 2820 max_level = MAX2(max_level, cur->comp_level()); 2821 } 2822 last = cur; 2823 cur = cur->osr_link(); 2824 } 2825 nmethod* next = NULL; 2826 if (cur == n) { 2827 next = cur->osr_link(); 2828 if (last == NULL) { 2829 // Remove first element 2830 set_osr_nmethods_head(next); 2831 } else { 2832 last->set_osr_link(next); 2833 } 2834 } 2835 n->set_osr_link(NULL); 2836 if (TieredCompilation) { 2837 cur = next; 2838 while (cur != NULL) { 2839 // Find max level after n 2840 if (m == cur->method()) { 2841 max_level = MAX2(max_level, cur->comp_level()); 2842 } 2843 cur = cur->osr_link(); 2844 } 2845 m->set_highest_osr_comp_level(max_level); 2846 } 2847 } 2848 2849 nmethod* InstanceKlass::lookup_osr_nmethod(const Method* m, int bci, int comp_level, bool match_level) const { 2850 // This is a short non-blocking critical region, so the no safepoint check is ok. 2851 MutexLockerEx ml(OsrList_lock, Mutex::_no_safepoint_check_flag); 2852 nmethod* osr = osr_nmethods_head(); 2853 nmethod* best = NULL; 2854 while (osr != NULL) { 2855 assert(osr->is_osr_method(), "wrong kind of nmethod found in chain"); 2856 // There can be a time when a c1 osr method exists but we are waiting 2857 // for a c2 version. When c2 completes its osr nmethod we will trash 2858 // the c1 version and only be able to find the c2 version. However 2859 // while we overflow in the c1 code at back branches we don't want to 2860 // try and switch to the same code as we are already running 2861 2862 if (osr->method() == m && 2863 (bci == InvocationEntryBci || osr->osr_entry_bci() == bci)) { 2864 if (match_level) { 2865 if (osr->comp_level() == comp_level) { 2866 // Found a match - return it. 2867 return osr; 2868 } 2869 } else { 2870 if (best == NULL || (osr->comp_level() > best->comp_level())) { 2871 if (osr->comp_level() == CompLevel_highest_tier) { 2872 // Found the best possible - return it. 2873 return osr; 2874 } 2875 best = osr; 2876 } 2877 } 2878 } 2879 osr = osr->osr_link(); 2880 } 2881 if (best != NULL && best->comp_level() >= comp_level && match_level == false) { 2882 return best; 2883 } 2884 return NULL; 2885 } 2886 2887 void InstanceKlass::add_member_name(int index, Handle mem_name) { 2888 jweak mem_name_wref = JNIHandles::make_weak_global(mem_name); 2889 MutexLocker ml(MemberNameTable_lock); 2890 assert(0 <= index && index < idnum_allocated_count(), "index is out of bounds"); 2891 DEBUG_ONLY(No_Safepoint_Verifier nsv); 2892 2893 if (_member_names == NULL) { 2894 _member_names = new (ResourceObj::C_HEAP, mtClass) MemberNameTable(idnum_allocated_count()); 2895 } 2896 _member_names->add_member_name(index, mem_name_wref); 2897 } 2898 2899 oop InstanceKlass::get_member_name(int index) { 2900 MutexLocker ml(MemberNameTable_lock); |