src/share/vm/oops/instanceKlass.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/oops

src/share/vm/oops/instanceKlass.cpp

Print this page




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


2757       for (int index = 0; index < default_methods()->length(); index ++) {
2758         if (default_methods()->at(index) == old_method) {
2759           default_methods()->at_put(index, new_method);
2760           if (RC_TRACE_IN_RANGE(0x00100000, 0x00400000)) {
2761             if (!(*trace_name_printed)) {
2762               // RC_TRACE_MESG macro has an embedded ResourceMark
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.


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);
2906   assert(0 <= index && index < idnum_allocated_count(), "index is out of bounds");
2907   DEBUG_ONLY(No_Safepoint_Verifier nsv);
2908 
2909   if (_member_names == NULL) {
2910     return NULL;
2911   }
2912   oop mem_name =_member_names->get_member_name(index);
2913   return mem_name;
2914 }
2915 
2916 // -----------------------------------------------------------------------------------------------------
2917 // Printing
2918 
2919 #ifndef PRODUCT
2920 
2921 #define BULLET  " - "
2922 
2923 static const char* state_names[] = {
2924   "allocated", "loaded", "linked", "being_initialized", "fully_initialized", "initialization_error"
2925 };
2926 
2927 static void print_vtable(intptr_t* start, int len, outputStream* st) {
2928   for (int i = 0; i < len; i++) {
2929     intptr_t e = start[i];
2930     st->print("%d : " INTPTR_FORMAT, i, e);
2931     if (e != 0 && ((Metadata*)e)->is_metaspace_object()) {
2932       st->print(" ");
2933       ((Metadata*)e)->print_value_on(st);
2934     }
2935     st->cr();




2396   // Can't release the constant pool here because the constant pool can be
2397   // deallocated separately from the InstanceKlass for default methods and
2398   // redefine classes.
2399 
2400   // Deallocate oop map cache
2401   if (_oop_map_cache != NULL) {
2402     delete _oop_map_cache;
2403     _oop_map_cache = NULL;
2404   }
2405 
2406   // Deallocate JNI identifiers for jfieldIDs
2407   JNIid::deallocate(jni_ids());
2408   set_jni_ids(NULL);
2409 
2410   jmethodID* jmeths = methods_jmethod_ids_acquire();
2411   if (jmeths != (jmethodID*)NULL) {
2412     release_set_methods_jmethod_ids(NULL);
2413     FreeHeap(jmeths);
2414   }
2415 











2416   // release dependencies
2417   nmethodBucket* b = _dependencies;
2418   _dependencies = NULL;
2419   while (b != NULL) {
2420     nmethodBucket* next = b->next();
2421     delete b;
2422     b = next;
2423   }
2424 
2425   // Deallocate breakpoint records
2426   if (breakpoints() != 0x0) {
2427     methods_do(clear_all_breakpoints);
2428     assert(breakpoints() == 0x0, "should have cleared breakpoints");
2429   }
2430 
2431   // deallocate the cached class file
2432   if (_cached_class_file != NULL) {
2433     os::free(_cached_class_file, mtClass);
2434     _cached_class_file = NULL;
2435   }


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


2914       } else {
2915         if (best == NULL || (osr->comp_level() > best->comp_level())) {
2916           if (osr->comp_level() == CompLevel_highest_tier) {
2917             // Found the best possible - return it.
2918             OsrList_lock->unlock();
2919             return osr;
2920           }
2921           best = osr;
2922         }
2923       }
2924     }
2925     osr = osr->osr_link();
2926   }
2927   OsrList_lock->unlock();
2928   if (best != NULL && best->comp_level() >= comp_level && match_level == false) {
2929     return best;
2930   }
2931   return NULL;
2932 }
2933 
























2934 // -----------------------------------------------------------------------------------------------------
2935 // Printing
2936 
2937 #ifndef PRODUCT
2938 
2939 #define BULLET  " - "
2940 
2941 static const char* state_names[] = {
2942   "allocated", "loaded", "linked", "being_initialized", "fully_initialized", "initialization_error"
2943 };
2944 
2945 static void print_vtable(intptr_t* start, int len, outputStream* st) {
2946   for (int i = 0; i < len; i++) {
2947     intptr_t e = start[i];
2948     st->print("%d : " INTPTR_FORMAT, i, e);
2949     if (e != 0 && ((Metadata*)e)->is_metaspace_object()) {
2950       st->print(" ");
2951       ((Metadata*)e)->print_value_on(st);
2952     }
2953     st->cr();


src/share/vm/oops/instanceKlass.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File