hotspot/src/share/vm/oops/instanceKlass.cpp
changeset 33148 68fa8b6c4340
parent 33105 294e48b4f704
child 33151 686d694f5c6a
equal deleted inserted replaced
33146:77349b58b4c0 33148:68fa8b6c4340
    64 #include "utilities/macros.hpp"
    64 #include "utilities/macros.hpp"
    65 #ifdef COMPILER1
    65 #ifdef COMPILER1
    66 #include "c1/c1_Compiler.hpp"
    66 #include "c1/c1_Compiler.hpp"
    67 #endif
    67 #endif
    68 
    68 
    69 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
       
    70 
       
    71 #ifdef DTRACE_ENABLED
    69 #ifdef DTRACE_ENABLED
    72 
    70 
    73 
    71 
    74 #define HOTSPOT_CLASS_INITIALIZATION_required HOTSPOT_CLASS_INITIALIZATION_REQUIRED
    72 #define HOTSPOT_CLASS_INITIALIZATION_required HOTSPOT_CLASS_INITIALIZATION_REQUIRED
    75 #define HOTSPOT_CLASS_INITIALIZATION_recursive HOTSPOT_CLASS_INITIALIZATION_RECURSIVE
    73 #define HOTSPOT_CLASS_INITIALIZATION_recursive HOTSPOT_CLASS_INITIALIZATION_RECURSIVE
  1026 
  1024 
  1027 instanceOop InstanceKlass::register_finalizer(instanceOop i, TRAPS) {
  1025 instanceOop InstanceKlass::register_finalizer(instanceOop i, TRAPS) {
  1028   if (TraceFinalizerRegistration) {
  1026   if (TraceFinalizerRegistration) {
  1029     tty->print("Registered ");
  1027     tty->print("Registered ");
  1030     i->print_value_on(tty);
  1028     i->print_value_on(tty);
  1031     tty->print_cr(" (" INTPTR_FORMAT ") as finalizable", (address)i);
  1029     tty->print_cr(" (" INTPTR_FORMAT ") as finalizable", p2i(i));
  1032   }
  1030   }
  1033   instanceHandle h_i(THREAD, i);
  1031   instanceHandle h_i(THREAD, i);
  1034   // Pass the handle as argument, JavaCalls::call expects oop as jobjects
  1032   // Pass the handle as argument, JavaCalls::call expects oop as jobjects
  1035   JavaValue result(T_VOID);
  1033   JavaValue result(T_VOID);
  1036   JavaCallArguments args(h_i);
  1034   JavaCallArguments args(h_i);
  1129   methodHandle h_method(THREAD, this_k->class_initializer());
  1127   methodHandle h_method(THREAD, this_k->class_initializer());
  1130   assert(!this_k->is_initialized(), "we cannot initialize twice");
  1128   assert(!this_k->is_initialized(), "we cannot initialize twice");
  1131   if (TraceClassInitialization) {
  1129   if (TraceClassInitialization) {
  1132     tty->print("%d Initializing ", call_class_initializer_impl_counter++);
  1130     tty->print("%d Initializing ", call_class_initializer_impl_counter++);
  1133     this_k->name()->print_value();
  1131     this_k->name()->print_value();
  1134     tty->print_cr("%s (" INTPTR_FORMAT ")", h_method() == NULL ? "(no method)" : "", (address)this_k());
  1132     tty->print_cr("%s (" INTPTR_FORMAT ")", h_method() == NULL ? "(no method)" : "", p2i(this_k()));
  1135   }
  1133   }
  1136   if (h_method() != NULL) {
  1134   if (h_method() != NULL) {
  1137     JavaCallArguments args; // No arguments
  1135     JavaCallArguments args; // No arguments
  1138     JavaValue result(T_VOID);
  1136     JavaValue result(T_VOID);
  1139     JavaCalls::call(&result, h_method, &args, CHECK); // Static call (no args)
  1137     JavaCalls::call(&result, h_method, &args, CHECK); // Static call (no args)
  2795     if (n < MaxSubklassPrintSize) {
  2793     if (n < MaxSubklassPrintSize) {
  2796       sub->print_value_on(st);
  2794       sub->print_value_on(st);
  2797       st->print("   ");
  2795       st->print("   ");
  2798     }
  2796     }
  2799   }
  2797   }
  2800   if (n >= MaxSubklassPrintSize) st->print("(%d more klasses...)", n - MaxSubklassPrintSize);
  2798   if (n >= MaxSubklassPrintSize) st->print("(" INTX_FORMAT " more klasses...)", n - MaxSubklassPrintSize);
  2801   st->cr();
  2799   st->cr();
  2802 
  2800 
  2803   if (is_interface()) {
  2801   if (is_interface()) {
  2804     st->print_cr(BULLET"nof implementors:  %d", nof_implementors());
  2802     st->print_cr(BULLET"nof implementors:  %d", nof_implementors());
  2805     if (nof_implementors() == 1) {
  2803     if (nof_implementors() == 1) {
  2871     generic_signature()->print_value_on(st);
  2869     generic_signature()->print_value_on(st);
  2872     st->cr();
  2870     st->cr();
  2873   }
  2871   }
  2874   st->print(BULLET"inner classes:     "); inner_classes()->print_value_on(st);     st->cr();
  2872   st->print(BULLET"inner classes:     "); inner_classes()->print_value_on(st);     st->cr();
  2875   st->print(BULLET"java mirror:       "); java_mirror()->print_value_on(st);       st->cr();
  2873   st->print(BULLET"java mirror:       "); java_mirror()->print_value_on(st);       st->cr();
  2876   st->print(BULLET"vtable length      %d  (start addr: " INTPTR_FORMAT ")", vtable_length(), start_of_vtable());  st->cr();
  2874   st->print(BULLET"vtable length      %d  (start addr: " INTPTR_FORMAT ")", vtable_length(), p2i(start_of_vtable())); st->cr();
  2877   if (vtable_length() > 0 && (Verbose || WizardMode))  print_vtable(start_of_vtable(), vtable_length(), st);
  2875   if (vtable_length() > 0 && (Verbose || WizardMode))  print_vtable(start_of_vtable(), vtable_length(), st);
  2878   st->print(BULLET"itable length      %d (start addr: " INTPTR_FORMAT ")", itable_length(), start_of_itable()); st->cr();
  2876   st->print(BULLET"itable length      %d (start addr: " INTPTR_FORMAT ")", itable_length(), p2i(start_of_itable())); st->cr();
  2879   if (itable_length() > 0 && (Verbose || WizardMode))  print_vtable(start_of_itable(), itable_length(), st);
  2877   if (itable_length() > 0 && (Verbose || WizardMode))  print_vtable(start_of_itable(), itable_length(), st);
  2880   st->print_cr(BULLET"---- static fields (%d words):", static_field_size());
  2878   st->print_cr(BULLET"---- static fields (%d words):", static_field_size());
  2881   FieldPrinter print_static_field(st);
  2879   FieldPrinter print_static_field(st);
  2882   ((InstanceKlass*)this)->do_local_static_fields(&print_static_field);
  2880   ((InstanceKlass*)this)->do_local_static_fields(&print_static_field);
  2883   st->print_cr(BULLET"---- non-static fields (%d words):", nonstatic_field_size());
  2881   st->print_cr(BULLET"---- non-static fields (%d words):", nonstatic_field_size());
  3066 class VerifyFieldClosure: public OopClosure {
  3064 class VerifyFieldClosure: public OopClosure {
  3067  protected:
  3065  protected:
  3068   template <class T> void do_oop_work(T* p) {
  3066   template <class T> void do_oop_work(T* p) {
  3069     oop obj = oopDesc::load_decode_heap_oop(p);
  3067     oop obj = oopDesc::load_decode_heap_oop(p);
  3070     if (!obj->is_oop_or_null()) {
  3068     if (!obj->is_oop_or_null()) {
  3071       tty->print_cr("Failed: " PTR_FORMAT " -> " PTR_FORMAT, p, (address)obj);
  3069       tty->print_cr("Failed: " PTR_FORMAT " -> " PTR_FORMAT, p2i(p), p2i(obj));
  3072       Universe::print();
  3070       Universe::print();
  3073       guarantee(false, "boom");
  3071       guarantee(false, "boom");
  3074     }
  3072     }
  3075   }
  3073   }
  3076  public:
  3074  public:
  3108   // Verify siblings
  3106   // Verify siblings
  3109   Klass* super = this->super();
  3107   Klass* super = this->super();
  3110   Klass* sib = next_sibling();
  3108   Klass* sib = next_sibling();
  3111   if (sib != NULL) {
  3109   if (sib != NULL) {
  3112     if (sib == this) {
  3110     if (sib == this) {
  3113       fatal("subclass points to itself " PTR_FORMAT, sib);
  3111       fatal("subclass points to itself " PTR_FORMAT, p2i(sib));
  3114     }
  3112     }
  3115 
  3113 
  3116     guarantee(sib->is_klass(), "should be klass");
  3114     guarantee(sib->is_klass(), "should be klass");
  3117     guarantee(sib->super() == super, "siblings should have same superklass");
  3115     guarantee(sib->super() == super, "siblings should have same superklass");
  3118   }
  3116   }
  3308         // If the constant pool isn't on stack, none of the methods
  3306         // If the constant pool isn't on stack, none of the methods
  3309         // are executing.  Unlink this previous_version.
  3307         // are executing.  Unlink this previous_version.
  3310         // The previous version InstanceKlass is on the ClassLoaderData deallocate list
  3308         // The previous version InstanceKlass is on the ClassLoaderData deallocate list
  3311         // so will be deallocated during the next phase of class unloading.
  3309         // so will be deallocated during the next phase of class unloading.
  3312         RC_TRACE(0x00000200, ("purge: previous version " INTPTR_FORMAT " is dead",
  3310         RC_TRACE(0x00000200, ("purge: previous version " INTPTR_FORMAT " is dead",
  3313                               pv_node));
  3311                               p2i(pv_node)));
  3314         // For debugging purposes.
  3312         // For debugging purposes.
  3315         pv_node->set_is_scratch_class();
  3313         pv_node->set_is_scratch_class();
  3316         pv_node->class_loader_data()->add_to_deallocate_list(pv_node);
  3314         pv_node->class_loader_data()->add_to_deallocate_list(pv_node);
  3317         pv_node = pv_node->previous_versions();
  3315         pv_node = pv_node->previous_versions();
  3318         last->link_previous_versions(pv_node);
  3316         last->link_previous_versions(pv_node);
  3319         deleted_count++;
  3317         deleted_count++;
  3320         version++;
  3318         version++;
  3321         continue;
  3319         continue;
  3322       } else {
  3320       } else {
  3323         RC_TRACE(0x00000200, ("purge: previous version " INTPTR_FORMAT " is alive",
  3321         RC_TRACE(0x00000200, ("purge: previous version " INTPTR_FORMAT " is alive",
  3324                               pv_node));
  3322                               p2i(pv_node)));
  3325         assert(pvcp->pool_holder() != NULL, "Constant pool with no holder");
  3323         assert(pvcp->pool_holder() != NULL, "Constant pool with no holder");
  3326         guarantee (!loader_data->is_unloading(), "unloaded classes can't be on the stack");
  3324         guarantee (!loader_data->is_unloading(), "unloaded classes can't be on the stack");
  3327         live_count++;
  3325         live_count++;
  3328       }
  3326       }
  3329 
  3327 
  3470         // After the safepoint, the on_stack bit is cleared and the running emcp
  3468         // After the safepoint, the on_stack bit is cleared and the running emcp
  3471         // method may exit.   If so, we would set a breakpoint in a method that
  3469         // method may exit.   If so, we would set a breakpoint in a method that
  3472         // is never reached, but this won't be noticeable to the programmer.
  3470         // is never reached, but this won't be noticeable to the programmer.
  3473         old_method->set_running_emcp(true);
  3471         old_method->set_running_emcp(true);
  3474         RC_TRACE(0x00000400, ("add: EMCP method %s is on_stack " INTPTR_FORMAT,
  3472         RC_TRACE(0x00000400, ("add: EMCP method %s is on_stack " INTPTR_FORMAT,
  3475                               old_method->name_and_sig_as_C_string(), old_method));
  3473                               old_method->name_and_sig_as_C_string(), p2i(old_method)));
  3476       } else if (!old_method->is_obsolete()) {
  3474       } else if (!old_method->is_obsolete()) {
  3477         RC_TRACE(0x00000400, ("add: EMCP method %s is NOT on_stack " INTPTR_FORMAT,
  3475         RC_TRACE(0x00000400, ("add: EMCP method %s is NOT on_stack " INTPTR_FORMAT,
  3478                               old_method->name_and_sig_as_C_string(), old_method));
  3476                               old_method->name_and_sig_as_C_string(), p2i(old_method)));
  3479       }
  3477       }
  3480     }
  3478     }
  3481   }
  3479   }
  3482 
  3480 
  3483   // Add previous version if any methods are still running.
  3481   // Add previous version if any methods are still running.