src/share/vm/memory/dump.cpp

changeset 2777
8ce625481709
parent 2700
352622fd140a
child 3368
52b5d32fbfaf
     1.1 --- a/src/share/vm/memory/dump.cpp	Thu Apr 14 23:06:33 2011 -0400
     1.2 +++ b/src/share/vm/memory/dump.cpp	Fri Apr 15 09:36:28 2011 -0400
     1.3 @@ -623,24 +623,48 @@
     1.4    }
     1.5  };
     1.6  
     1.7 -// Itable indices are calculated based on methods array order
     1.8 -// (see klassItable::compute_itable_index()).  Must reinitialize
     1.9 +// Vtable and Itable indices are calculated based on methods array
    1.10 +// order (see klassItable::compute_itable_index()).  Must reinitialize
    1.11  // after ALL methods of ALL classes have been reordered.
    1.12  // We assume that since checkconstraints is false, this method
    1.13  // cannot throw an exception.  An exception here would be
    1.14  // problematic since this is the VMThread, not a JavaThread.
    1.15  
    1.16 -class ReinitializeItables: public ObjectClosure {
    1.17 +class ReinitializeTables: public ObjectClosure {
    1.18  private:
    1.19    Thread* _thread;
    1.20  
    1.21  public:
    1.22 -  ReinitializeItables(Thread* thread) : _thread(thread) {}
    1.23 +  ReinitializeTables(Thread* thread) : _thread(thread) {}
    1.24 +
    1.25 +  // Initialize super vtable first, check if already initialized to avoid
    1.26 +  // quadradic behavior.  The vtable is cleared in remove_unshareable_info.
    1.27 +  void reinitialize_vtables(klassOop k) {
    1.28 +    if (k->blueprint()->oop_is_instanceKlass()) {
    1.29 +      instanceKlass* ik = instanceKlass::cast(k);
    1.30 +      if (ik->vtable()->is_initialized()) return;
    1.31 +      if (ik->super() != NULL) {
    1.32 +        reinitialize_vtables(ik->super());
    1.33 +      }
    1.34 +      ik->vtable()->initialize_vtable(false, _thread);
    1.35 +    }
    1.36 +  }
    1.37  
    1.38    void do_object(oop obj) {
    1.39      if (obj->blueprint()->oop_is_instanceKlass()) {
    1.40        instanceKlass* ik = instanceKlass::cast((klassOop)obj);
    1.41 +      ResourceMark rm(_thread);
    1.42        ik->itable()->initialize_itable(false, _thread);
    1.43 +      reinitialize_vtables((klassOop)obj);
    1.44 +#ifdef ASSERT
    1.45 +      ik->vtable()->verify(tty, true);
    1.46 +#endif // ASSERT
    1.47 +    } else if (obj->blueprint()->oop_is_arrayKlass()) {
    1.48 +      // The vtable for array klasses are that of its super class,
    1.49 +      // ie. java.lang.Object.
    1.50 +      arrayKlass* ak = arrayKlass::cast((klassOop)obj);
    1.51 +      if (ak->vtable()->is_initialized()) return;
    1.52 +      ak->vtable()->initialize_vtable(false, _thread);
    1.53      }
    1.54    }
    1.55  };
    1.56 @@ -1205,9 +1229,9 @@
    1.57      gen->ro_space()->object_iterate(&sort);
    1.58      gen->rw_space()->object_iterate(&sort);
    1.59  
    1.60 -    ReinitializeItables reinit_itables(THREAD);
    1.61 -    gen->ro_space()->object_iterate(&reinit_itables);
    1.62 -    gen->rw_space()->object_iterate(&reinit_itables);
    1.63 +    ReinitializeTables reinit_tables(THREAD);
    1.64 +    gen->ro_space()->object_iterate(&reinit_tables);
    1.65 +    gen->rw_space()->object_iterate(&reinit_tables);
    1.66      tty->print_cr("done. ");
    1.67      tty->cr();
    1.68  

mercurial