2873 } else {
2874 last->set_osr_link(next);
2875 }
2876 }
2877 n->set_osr_link(NULL);
2878 if (TieredCompilation) {
2879 cur = next;
2880 while (cur != NULL) {
2881 // Find max level after n
2882 if (m == cur->method()) {
2883 max_level = MAX2(max_level, cur->comp_level());
2884 }
2885 cur = cur->osr_link();
2886 }
2887 m->set_highest_osr_comp_level(max_level);
2888 }
2889 // Remember to unlock again
2890 OsrList_lock->unlock();
2891 }
2892
2893 nmethod* InstanceKlass::lookup_osr_nmethod(const Method* m, int bci, int comp_level, bool match_level) const {
2894 // This is a short non-blocking critical region, so the no safepoint check is ok.
2895 OsrList_lock->lock_without_safepoint_check();
2896 nmethod* osr = osr_nmethods_head();
2897 nmethod* best = NULL;
2898 while (osr != NULL) {
2899 assert(osr->is_osr_method(), "wrong kind of nmethod found in chain");
2900 // There can be a time when a c1 osr method exists but we are waiting
2901 // for a c2 version. When c2 completes its osr nmethod we will trash
2902 // the c1 version and only be able to find the c2 version. However
2903 // while we overflow in the c1 code at back branches we don't want to
2904 // try and switch to the same code as we are already running
2905
2906 if (osr->method() == m &&
2907 (bci == InvocationEntryBci || osr->osr_entry_bci() == bci)) {
2908 if (match_level) {
2909 if (osr->comp_level() == comp_level) {
2910 // Found a match - return it.
2911 OsrList_lock->unlock();
2912 return osr;
|
2873 } else {
2874 last->set_osr_link(next);
2875 }
2876 }
2877 n->set_osr_link(NULL);
2878 if (TieredCompilation) {
2879 cur = next;
2880 while (cur != NULL) {
2881 // Find max level after n
2882 if (m == cur->method()) {
2883 max_level = MAX2(max_level, cur->comp_level());
2884 }
2885 cur = cur->osr_link();
2886 }
2887 m->set_highest_osr_comp_level(max_level);
2888 }
2889 // Remember to unlock again
2890 OsrList_lock->unlock();
2891 }
2892
2893 int InstanceKlass::mark_osr_nmethods(const Method* m) {
2894 // This is a short non-blocking critical region, so the no safepoint check is ok.
2895 MutexLockerEx ml(OsrList_lock, Mutex::_no_safepoint_check_flag);
2896 nmethod* osr = osr_nmethods_head();
2897 int found = 0;
2898 while (osr != NULL) {
2899 assert(osr->is_osr_method(), "wrong kind of nmethod found in chain");
2900 if (osr->method() == m) {
2901 osr->mark_for_deoptimization();
2902 found++;
2903 }
2904 osr = osr->osr_link();
2905 }
2906 return found;
2907 }
2908
2909 nmethod* InstanceKlass::lookup_osr_nmethod(const Method* m, int bci, int comp_level, bool match_level) const {
2910 // This is a short non-blocking critical region, so the no safepoint check is ok.
2911 OsrList_lock->lock_without_safepoint_check();
2912 nmethod* osr = osr_nmethods_head();
2913 nmethod* best = NULL;
2914 while (osr != NULL) {
2915 assert(osr->is_osr_method(), "wrong kind of nmethod found in chain");
2916 // There can be a time when a c1 osr method exists but we are waiting
2917 // for a c2 version. When c2 completes its osr nmethod we will trash
2918 // the c1 version and only be able to find the c2 version. However
2919 // while we overflow in the c1 code at back branches we don't want to
2920 // try and switch to the same code as we are already running
2921
2922 if (osr->method() == m &&
2923 (bci == InvocationEntryBci || osr->osr_entry_bci() == bci)) {
2924 if (match_level) {
2925 if (osr->comp_level() == comp_level) {
2926 // Found a match - return it.
2927 OsrList_lock->unlock();
2928 return osr;
|