src/share/vm/oops/instanceKlass.cpp

changeset 5732
b2e698d2276c
parent 5535
e22ee8e7ae62
child 5755
0f37d1badced
     1.1 --- a/src/share/vm/oops/instanceKlass.cpp	Tue Sep 17 23:12:27 2013 +0200
     1.2 +++ b/src/share/vm/oops/instanceKlass.cpp	Fri Sep 13 22:38:02 2013 -0400
     1.3 @@ -286,7 +286,6 @@
     1.4    init_previous_versions();
     1.5    set_generic_signature_index(0);
     1.6    release_set_methods_jmethod_ids(NULL);
     1.7 -  release_set_methods_cached_itable_indices(NULL);
     1.8    set_annotations(NULL);
     1.9    set_jvmti_cached_class_field_map(NULL);
    1.10    set_initial_method_idnum(0);
    1.11 @@ -1149,7 +1148,7 @@
    1.12      Symbol* f_name = fs.name();
    1.13      Symbol* f_sig  = fs.signature();
    1.14      if (f_name == name && f_sig == sig) {
    1.15 -      fd->initialize(const_cast<InstanceKlass*>(this), fs.index());
    1.16 +      fd->reinitialize(const_cast<InstanceKlass*>(this), fs.index());
    1.17        return true;
    1.18      }
    1.19    }
    1.20 @@ -1218,7 +1217,7 @@
    1.21  bool InstanceKlass::find_local_field_from_offset(int offset, bool is_static, fieldDescriptor* fd) const {
    1.22    for (JavaFieldStream fs(this); !fs.done(); fs.next()) {
    1.23      if (fs.offset() == offset) {
    1.24 -      fd->initialize(const_cast<InstanceKlass*>(this), fs.index());
    1.25 +      fd->reinitialize(const_cast<InstanceKlass*>(this), fs.index());
    1.26        if (fd->is_static() == is_static) return true;
    1.27      }
    1.28    }
    1.29 @@ -1251,8 +1250,7 @@
    1.30  void InstanceKlass::do_local_static_fields(FieldClosure* cl) {
    1.31    for (JavaFieldStream fs(this); !fs.done(); fs.next()) {
    1.32      if (fs.access_flags().is_static()) {
    1.33 -      fieldDescriptor fd;
    1.34 -      fd.initialize(this, fs.index());
    1.35 +      fieldDescriptor& fd = fs.field_descriptor();
    1.36        cl->do_field(&fd);
    1.37      }
    1.38    }
    1.39 @@ -1268,8 +1266,7 @@
    1.40  void InstanceKlass::do_local_static_fields_impl(instanceKlassHandle this_oop, void f(fieldDescriptor* fd, TRAPS), TRAPS) {
    1.41    for (JavaFieldStream fs(this_oop()); !fs.done(); fs.next()) {
    1.42      if (fs.access_flags().is_static()) {
    1.43 -      fieldDescriptor fd;
    1.44 -      fd.initialize(this_oop(), fs.index());
    1.45 +      fieldDescriptor& fd = fs.field_descriptor();
    1.46        f(&fd, CHECK);
    1.47      }
    1.48    }
    1.49 @@ -1291,7 +1288,7 @@
    1.50    int* fields_sorted = NEW_C_HEAP_ARRAY(int, 2*(length+1), mtClass);
    1.51    int j = 0;
    1.52    for (int i = 0; i < length; i += 1) {
    1.53 -    fd.initialize(this, i);
    1.54 +    fd.reinitialize(this, i);
    1.55      if (!fd.is_static()) {
    1.56        fields_sorted[j + 0] = fd.offset();
    1.57        fields_sorted[j + 1] = i;
    1.58 @@ -1303,7 +1300,7 @@
    1.59      // _sort_Fn is defined in growableArray.hpp.
    1.60      qsort(fields_sorted, length/2, 2*sizeof(int), (_sort_Fn)compare_fields_by_offset);
    1.61      for (int i = 0; i < length; i += 2) {
    1.62 -      fd.initialize(this, fields_sorted[i + 1]);
    1.63 +      fd.reinitialize(this, fields_sorted[i + 1]);
    1.64        assert(!fd.is_static() && fd.offset() == fields_sorted[i], "only nonstatic fields");
    1.65        cl->do_field(&fd);
    1.66      }
    1.67 @@ -1686,87 +1683,6 @@
    1.68  }
    1.69  
    1.70  
    1.71 -// Cache an itable index
    1.72 -void InstanceKlass::set_cached_itable_index(size_t idnum, int index) {
    1.73 -  int* indices = methods_cached_itable_indices_acquire();
    1.74 -  int* to_dealloc_indices = NULL;
    1.75 -
    1.76 -  // We use a double-check locking idiom here because this cache is
    1.77 -  // performance sensitive. In the normal system, this cache only
    1.78 -  // transitions from NULL to non-NULL which is safe because we use
    1.79 -  // release_set_methods_cached_itable_indices() to advertise the
    1.80 -  // new cache. A partially constructed cache should never be seen
    1.81 -  // by a racing thread. Cache reads and writes proceed without a
    1.82 -  // lock, but creation of the cache itself requires no leaks so a
    1.83 -  // lock is generally acquired in that case.
    1.84 -  //
    1.85 -  // If the RedefineClasses() API has been used, then this cache can
    1.86 -  // grow and we'll have transitions from non-NULL to bigger non-NULL.
    1.87 -  // Cache creation requires no leaks and we require safety between all
    1.88 -  // cache accesses and freeing of the old cache so a lock is generally
    1.89 -  // acquired when the RedefineClasses() API has been used.
    1.90 -
    1.91 -  if (indices == NULL || idnum_can_increment()) {
    1.92 -    // we need a cache or the cache can grow
    1.93 -    MutexLocker ml(JNICachedItableIndex_lock);
    1.94 -    // reacquire the cache to see if another thread already did the work
    1.95 -    indices = methods_cached_itable_indices_acquire();
    1.96 -    size_t length = 0;
    1.97 -    // cache size is stored in element[0], other elements offset by one
    1.98 -    if (indices == NULL || (length = (size_t)indices[0]) <= idnum) {
    1.99 -      size_t size = MAX2(idnum+1, (size_t)idnum_allocated_count());
   1.100 -      int* new_indices = NEW_C_HEAP_ARRAY(int, size+1, mtClass);
   1.101 -      new_indices[0] = (int)size;
   1.102 -      // copy any existing entries
   1.103 -      size_t i;
   1.104 -      for (i = 0; i < length; i++) {
   1.105 -        new_indices[i+1] = indices[i+1];
   1.106 -      }
   1.107 -      // Set all the rest to -1
   1.108 -      for (i = length; i < size; i++) {
   1.109 -        new_indices[i+1] = -1;
   1.110 -      }
   1.111 -      if (indices != NULL) {
   1.112 -        // We have an old cache to delete so save it for after we
   1.113 -        // drop the lock.
   1.114 -        to_dealloc_indices = indices;
   1.115 -      }
   1.116 -      release_set_methods_cached_itable_indices(indices = new_indices);
   1.117 -    }
   1.118 -
   1.119 -    if (idnum_can_increment()) {
   1.120 -      // this cache can grow so we have to write to it safely
   1.121 -      indices[idnum+1] = index;
   1.122 -    }
   1.123 -  } else {
   1.124 -    CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops());
   1.125 -  }
   1.126 -
   1.127 -  if (!idnum_can_increment()) {
   1.128 -    // The cache cannot grow and this JNI itable index value does not
   1.129 -    // have to be unique like a jmethodID. If there is a race to set it,
   1.130 -    // it doesn't matter.
   1.131 -    indices[idnum+1] = index;
   1.132 -  }
   1.133 -
   1.134 -  if (to_dealloc_indices != NULL) {
   1.135 -    // we allocated a new cache so free the old one
   1.136 -    FreeHeap(to_dealloc_indices);
   1.137 -  }
   1.138 -}
   1.139 -
   1.140 -
   1.141 -// Retrieve a cached itable index
   1.142 -int InstanceKlass::cached_itable_index(size_t idnum) {
   1.143 -  int* indices = methods_cached_itable_indices_acquire();
   1.144 -  if (indices != NULL && ((size_t)indices[0]) > idnum) {
   1.145 -     // indices exist and are long enough, retrieve possible cached
   1.146 -    return indices[idnum+1];
   1.147 -  }
   1.148 -  return -1;
   1.149 -}
   1.150 -
   1.151 -
   1.152  //
   1.153  // Walk the list of dependent nmethods searching for nmethods which
   1.154  // are dependent on the changes that were passed in and mark them for
   1.155 @@ -2326,12 +2242,6 @@
   1.156      }
   1.157    }
   1.158  
   1.159 -  int* indices = methods_cached_itable_indices_acquire();
   1.160 -  if (indices != (int*)NULL) {
   1.161 -    release_set_methods_cached_itable_indices(NULL);
   1.162 -    FreeHeap(indices);
   1.163 -  }
   1.164 -
   1.165    // release dependencies
   1.166    nmethodBucket* b = _dependencies;
   1.167    _dependencies = NULL;
   1.168 @@ -2782,6 +2692,18 @@
   1.169    "allocated", "loaded", "linked", "being_initialized", "fully_initialized", "initialization_error"
   1.170  };
   1.171  
   1.172 +static void print_vtable(intptr_t* start, int len, outputStream* st) {
   1.173 +  for (int i = 0; i < len; i++) {
   1.174 +    intptr_t e = start[i];
   1.175 +    st->print("%d : " INTPTR_FORMAT, i, e);
   1.176 +    if (e != 0 && ((Metadata*)e)->is_metaspace_object()) {
   1.177 +      st->print(" ");
   1.178 +      ((Metadata*)e)->print_value_on(st);
   1.179 +    }
   1.180 +    st->cr();
   1.181 +  }
   1.182 +}
   1.183 +
   1.184  void InstanceKlass::print_on(outputStream* st) const {
   1.185    assert(is_klass(), "must be klass");
   1.186    Klass::print_on(st);
   1.187 @@ -2816,7 +2738,7 @@
   1.188  
   1.189    st->print(BULLET"arrays:            "); array_klasses()->print_value_on_maybe_null(st); st->cr();
   1.190    st->print(BULLET"methods:           "); methods()->print_value_on(st);                  st->cr();
   1.191 -  if (Verbose) {
   1.192 +  if (Verbose || WizardMode) {
   1.193      Array<Method*>* method_array = methods();
   1.194      for(int i = 0; i < method_array->length(); i++) {
   1.195        st->print("%d : ", i); method_array->at(i)->print_value(); st->cr();
   1.196 @@ -2874,7 +2796,9 @@
   1.197    st->print(BULLET"inner classes:     "); inner_classes()->print_value_on(st);     st->cr();
   1.198    st->print(BULLET"java mirror:       "); java_mirror()->print_value_on(st);       st->cr();
   1.199    st->print(BULLET"vtable length      %d  (start addr: " INTPTR_FORMAT ")", vtable_length(), start_of_vtable());  st->cr();
   1.200 +  if (vtable_length() > 0 && (Verbose || WizardMode))  print_vtable(start_of_vtable(), vtable_length(), st);
   1.201    st->print(BULLET"itable length      %d (start addr: " INTPTR_FORMAT ")", itable_length(), start_of_itable()); st->cr();
   1.202 +  if (itable_length() > 0 && (Verbose || WizardMode))  print_vtable(start_of_itable(), itable_length(), st);
   1.203    st->print_cr(BULLET"---- static fields (%d words):", static_field_size());
   1.204    FieldPrinter print_static_field(st);
   1.205    ((InstanceKlass*)this)->do_local_static_fields(&print_static_field);
   1.206 @@ -2896,6 +2820,7 @@
   1.207  
   1.208  void InstanceKlass::print_value_on(outputStream* st) const {
   1.209    assert(is_klass(), "must be klass");
   1.210 +  if (Verbose || WizardMode)  access_flags().print_on(st);
   1.211    name()->print_value_on(st);
   1.212  }
   1.213  

mercurial