< prev index next >

src/share/vm/oops/instanceKlass.cpp

Print this page




2409   // Can't release the constant pool here because the constant pool can be
2410   // deallocated separately from the InstanceKlass for default methods and
2411   // redefine classes.
2412 
2413   // Deallocate oop map cache
2414   if (_oop_map_cache != NULL) {
2415     delete _oop_map_cache;
2416     _oop_map_cache = NULL;
2417   }
2418 
2419   // Deallocate JNI identifiers for jfieldIDs
2420   JNIid::deallocate(jni_ids());
2421   set_jni_ids(NULL);
2422 
2423   jmethodID* jmeths = methods_jmethod_ids_acquire();
2424   if (jmeths != (jmethodID*)NULL) {
2425     release_set_methods_jmethod_ids(NULL);
2426     FreeHeap(jmeths);
2427   }
2428 
2429   // Deallocate MemberNameTable
2430   {
2431     Mutex* lock_or_null = SafepointSynchronize::is_at_safepoint() ? NULL : MemberNameTable_lock;
2432     MutexLockerEx ml(lock_or_null, Mutex::_no_safepoint_check_flag);
2433     MemberNameTable* mnt = member_names();
2434     if (mnt != NULL) {
2435       delete mnt;
2436       set_member_names(NULL);
2437     }
2438   }
2439 
2440   // release dependencies
2441   nmethodBucket* b = _dependencies;
2442   _dependencies = NULL;
2443   while (b != NULL) {
2444     nmethodBucket* next = b->next();
2445     delete b;
2446     b = next;
2447   }
2448 
2449   // Deallocate breakpoint records
2450   if (breakpoints() != 0x0) {
2451     methods_do(clear_all_breakpoints);
2452     assert(breakpoints() == 0x0, "should have cleared breakpoints");
2453   }
2454 
2455   // deallocate the cached class file
2456   if (_cached_class_file != NULL) {
2457     os::free(_cached_class_file, mtClass);
2458     _cached_class_file = NULL;
2459   }


2770       for (int index = 0; index < default_methods()->length(); index ++) {
2771         if (default_methods()->at(index) == old_method) {
2772           default_methods()->at_put(index, new_method);
2773           if (RC_TRACE_IN_RANGE(0x00100000, 0x00400000)) {
2774             if (!(*trace_name_printed)) {
2775               // RC_TRACE_MESG macro has an embedded ResourceMark
2776               RC_TRACE_MESG(("adjust: klassname=%s default methods from name=%s",
2777                              external_name(),
2778                              old_method->method_holder()->external_name()));
2779               *trace_name_printed = true;
2780             }
2781             RC_TRACE(0x00100000, ("default method update: %s(%s) ",
2782                                   new_method->name()->as_C_string(),
2783                                   new_method->signature()->as_C_string()));
2784           }
2785         }
2786       }
2787     }
2788   }
2789 }


















































2790 #endif // INCLUDE_JVMTI
2791 
2792 // On-stack replacement stuff
2793 void InstanceKlass::add_osr_nmethod(nmethod* n) {
2794   // only one compilation can be active
2795   {
2796     // This is a short non-blocking critical region, so the no safepoint check is ok.
2797     MutexLockerEx ml(OsrList_lock, Mutex::_no_safepoint_check_flag);
2798     assert(n->is_osr_method(), "wrong kind of nmethod");
2799     n->set_osr_link(osr_nmethods_head());
2800     set_osr_nmethods_head(n);
2801     // Raise the highest osr level if necessary
2802     if (TieredCompilation) {
2803       Method* m = n->method();
2804       m->set_highest_osr_comp_level(MAX2(m->highest_osr_comp_level(), n->comp_level()));
2805     }
2806   }
2807 
2808   // Get rid of the osr methods for the same bci that have lower levels.
2809   if (TieredCompilation) {


2893         if (osr->comp_level() == comp_level) {
2894           // Found a match - return it.
2895           return osr;
2896         }
2897       } else {
2898         if (best == NULL || (osr->comp_level() > best->comp_level())) {
2899           if (osr->comp_level() == CompLevel_highest_tier) {
2900             // Found the best possible - return it.
2901             return osr;
2902           }
2903           best = osr;
2904         }
2905       }
2906     }
2907     osr = osr->osr_link();
2908   }
2909   if (best != NULL && best->comp_level() >= comp_level && match_level == false) {
2910     return best;
2911   }
2912   return NULL;
2913 }
2914 
2915 void InstanceKlass::add_member_name(int index, Handle mem_name) {
2916   jweak mem_name_wref = JNIHandles::make_weak_global(mem_name);
2917   MutexLocker ml(MemberNameTable_lock);
2918   assert(0 <= index && index < idnum_allocated_count(), "index is out of bounds");
2919   DEBUG_ONLY(No_Safepoint_Verifier nsv);
2920 
2921   if (_member_names == NULL) {
2922     _member_names = new (ResourceObj::C_HEAP, mtClass) MemberNameTable(idnum_allocated_count());
2923   }
2924   _member_names->add_member_name(index, mem_name_wref);
2925 }
2926 
2927 oop InstanceKlass::get_member_name(int index) {
2928   MutexLocker ml(MemberNameTable_lock);
2929   assert(0 <= index && index < idnum_allocated_count(), "index is out of bounds");
2930   DEBUG_ONLY(No_Safepoint_Verifier nsv);
2931 
2932   if (_member_names == NULL) {
2933     return NULL;
2934   }
2935   oop mem_name =_member_names->get_member_name(index);
2936   return mem_name;
2937 }
2938 
2939 // -----------------------------------------------------------------------------------------------------
2940 // Printing
2941 
2942 #ifndef PRODUCT
2943 
2944 #define BULLET  " - "
2945 
2946 static const char* state_names[] = {
2947   "allocated", "loaded", "linked", "being_initialized", "fully_initialized", "initialization_error"
2948 };
2949 
2950 static void print_vtable(intptr_t* start, int len, outputStream* st) {
2951   for (int i = 0; i < len; i++) {
2952     intptr_t e = start[i];
2953     st->print("%d : " INTPTR_FORMAT, i, e);
2954     if (e != 0 && ((Metadata*)e)->is_metaspace_object()) {
2955       st->print(" ");
2956       ((Metadata*)e)->print_value_on(st);




2409   // Can't release the constant pool here because the constant pool can be
2410   // deallocated separately from the InstanceKlass for default methods and
2411   // redefine classes.
2412 
2413   // Deallocate oop map cache
2414   if (_oop_map_cache != NULL) {
2415     delete _oop_map_cache;
2416     _oop_map_cache = NULL;
2417   }
2418 
2419   // Deallocate JNI identifiers for jfieldIDs
2420   JNIid::deallocate(jni_ids());
2421   set_jni_ids(NULL);
2422 
2423   jmethodID* jmeths = methods_jmethod_ids_acquire();
2424   if (jmeths != (jmethodID*)NULL) {
2425     release_set_methods_jmethod_ids(NULL);
2426     FreeHeap(jmeths);
2427   }
2428 











2429   // release dependencies
2430   nmethodBucket* b = _dependencies;
2431   _dependencies = NULL;
2432   while (b != NULL) {
2433     nmethodBucket* next = b->next();
2434     delete b;
2435     b = next;
2436   }
2437 
2438   // Deallocate breakpoint records
2439   if (breakpoints() != 0x0) {
2440     methods_do(clear_all_breakpoints);
2441     assert(breakpoints() == 0x0, "should have cleared breakpoints");
2442   }
2443 
2444   // deallocate the cached class file
2445   if (_cached_class_file != NULL) {
2446     os::free(_cached_class_file, mtClass);
2447     _cached_class_file = NULL;
2448   }


2759       for (int index = 0; index < default_methods()->length(); index ++) {
2760         if (default_methods()->at(index) == old_method) {
2761           default_methods()->at_put(index, new_method);
2762           if (RC_TRACE_IN_RANGE(0x00100000, 0x00400000)) {
2763             if (!(*trace_name_printed)) {
2764               // RC_TRACE_MESG macro has an embedded ResourceMark
2765               RC_TRACE_MESG(("adjust: klassname=%s default methods from name=%s",
2766                              external_name(),
2767                              old_method->method_holder()->external_name()));
2768               *trace_name_printed = true;
2769             }
2770             RC_TRACE(0x00100000, ("default method update: %s(%s) ",
2771                                   new_method->name()->as_C_string(),
2772                                   new_method->signature()->as_C_string()));
2773           }
2774         }
2775       }
2776     }
2777   }
2778 }
2779 
2780 static void adjust_member_name_by_method(oop publishedToVM, bool *trace_name_printed,
2781                                       Method* old_method, Method* new_method) {
2782   // A method may appear once or twice in the member name table with different
2783   // ReferenceKind, so continue looking after the first one is found.
2784   for (oop member_name = publishedToVM; member_name != NULL;
2785           member_name = java_lang_invoke_MemberName::next(member_name)) {
2786     Method* method = (Method*) java_lang_invoke_MemberName::vmtarget(member_name);
2787     if (method == old_method) {
2788       java_lang_invoke_MemberName::adjust_vmtarget(member_name, new_method);
2789 
2790       if (RC_TRACE_IN_RANGE(0x00100000, 0x00400000)) {
2791         if (!(*trace_name_printed)) {
2792           // RC_TRACE_MESG macro has an embedded ResourceMark
2793           RC_TRACE_MESG(("adjust: name=%s",
2794                          old_method->method_holder()->external_name()));
2795           *trace_name_printed = true;
2796         }
2797         // RC_TRACE macro has an embedded ResourceMark
2798         RC_TRACE(0x00400000, ("MemberName method update: %s(%s)",
2799                               new_method->name()->as_C_string(),
2800                               new_method->signature()->as_C_string()));
2801       }
2802     }
2803   }
2804 }
2805 
2806 /**
2807  * Adjust the java.lang.invoke.MemberName entries in the member name table in
2808  * java.lang.Class$ClassData.memberNameTable.
2809  *
2810  * NOTE: This is called at a safepoint only!
2811  */
2812 void InstanceKlass::adjust_member_name_table(Method** old_methods, Method** new_methods,
2813                                              int methods_length, bool *trace_name_printed) {
2814   assert(SafepointSynchronize::is_at_safepoint(), "only called at safepoint");
2815 
2816   // Dig out the member name table array.
2817   oop class_data = java_lang_Class::classData(java_mirror());
2818   if (class_data == NULL)
2819     return; // was never initialized
2820   oop publishedToVM = java_lang_invoke_MemberName_ClassData::publishedToVM(class_data);
2821 
2822   // Search the MemberNameTable for uses of either obsolete or EMCP methods.
2823   for (int i = 0; i < methods_length; i++) {
2824     Method* old_method = old_methods[i];
2825     Method* new_method = new_methods[i];
2826     adjust_member_name_by_method(publishedToVM, trace_name_printed, old_method, new_method);
2827   }
2828 }
2829 #endif // INCLUDE_JVMTI
2830 
2831 // On-stack replacement stuff
2832 void InstanceKlass::add_osr_nmethod(nmethod* n) {
2833   // only one compilation can be active
2834   {
2835     // This is a short non-blocking critical region, so the no safepoint check is ok.
2836     MutexLockerEx ml(OsrList_lock, Mutex::_no_safepoint_check_flag);
2837     assert(n->is_osr_method(), "wrong kind of nmethod");
2838     n->set_osr_link(osr_nmethods_head());
2839     set_osr_nmethods_head(n);
2840     // Raise the highest osr level if necessary
2841     if (TieredCompilation) {
2842       Method* m = n->method();
2843       m->set_highest_osr_comp_level(MAX2(m->highest_osr_comp_level(), n->comp_level()));
2844     }
2845   }
2846 
2847   // Get rid of the osr methods for the same bci that have lower levels.
2848   if (TieredCompilation) {


2932         if (osr->comp_level() == comp_level) {
2933           // Found a match - return it.
2934           return osr;
2935         }
2936       } else {
2937         if (best == NULL || (osr->comp_level() > best->comp_level())) {
2938           if (osr->comp_level() == CompLevel_highest_tier) {
2939             // Found the best possible - return it.
2940             return osr;
2941           }
2942           best = osr;
2943         }
2944       }
2945     }
2946     osr = osr->osr_link();
2947   }
2948   if (best != NULL && best->comp_level() >= comp_level && match_level == false) {
2949     return best;
2950   }
2951   return NULL;
























2952 }
2953 
2954 // -----------------------------------------------------------------------------------------------------
2955 // Printing
2956 
2957 #ifndef PRODUCT
2958 
2959 #define BULLET  " - "
2960 
2961 static const char* state_names[] = {
2962   "allocated", "loaded", "linked", "being_initialized", "fully_initialized", "initialization_error"
2963 };
2964 
2965 static void print_vtable(intptr_t* start, int len, outputStream* st) {
2966   for (int i = 0; i < len; i++) {
2967     intptr_t e = start[i];
2968     st->print("%d : " INTPTR_FORMAT, i, e);
2969     if (e != 0 && ((Metadata*)e)->is_metaspace_object()) {
2970       st->print(" ");
2971       ((Metadata*)e)->print_value_on(st);


< prev index next >