src/share/vm/classfile/dictionary.cpp

changeset 4037
da91efe96a93
parent 3900
d2a62e0f25eb
child 4278
070d523b96a7
     1.1 --- a/src/share/vm/classfile/dictionary.cpp	Fri Aug 31 16:39:35 2012 -0700
     1.2 +++ b/src/share/vm/classfile/dictionary.cpp	Sat Sep 01 13:25:18 2012 -0400
     1.3 @@ -36,7 +36,7 @@
     1.4  
     1.5  
     1.6  Dictionary::Dictionary(int table_size)
     1.7 -  : TwoOopHashtable<klassOop, mtClass>(table_size, sizeof(DictionaryEntry)) {
     1.8 +  : TwoOopHashtable<Klass*, mtClass>(table_size, sizeof(DictionaryEntry)) {
     1.9    _current_class_index = 0;
    1.10    _current_class_entry = NULL;
    1.11  };
    1.12 @@ -45,26 +45,18 @@
    1.13  
    1.14  Dictionary::Dictionary(int table_size, HashtableBucket<mtClass>* t,
    1.15                         int number_of_entries)
    1.16 -  : TwoOopHashtable<klassOop, mtClass>(table_size, sizeof(DictionaryEntry), t, number_of_entries) {
    1.17 +  : TwoOopHashtable<Klass*, mtClass>(table_size, sizeof(DictionaryEntry), t, number_of_entries) {
    1.18    _current_class_index = 0;
    1.19    _current_class_entry = NULL;
    1.20  };
    1.21  
    1.22  
    1.23 -DictionaryEntry* Dictionary::new_entry(unsigned int hash, klassOop klass,
    1.24 -                                       oop loader) {
    1.25 -  DictionaryEntry* entry;
    1.26 -  entry = (DictionaryEntry*)Hashtable<klassOop, mtClass>::new_entry(hash, klass);
    1.27 -  entry->set_loader(loader);
    1.28 +DictionaryEntry* Dictionary::new_entry(unsigned int hash, Klass* klass,
    1.29 +                                       ClassLoaderData* loader_data) {
    1.30 +  DictionaryEntry* entry = (DictionaryEntry*)Hashtable<Klass*, mtClass>::new_entry(hash, klass);
    1.31 +  entry->set_loader_data(loader_data);
    1.32    entry->set_pd_set(NULL);
    1.33 -  return entry;
    1.34 -}
    1.35 -
    1.36 -
    1.37 -DictionaryEntry* Dictionary::new_entry() {
    1.38 -  DictionaryEntry* entry = (DictionaryEntry*)Hashtable<klassOop, mtClass>::new_entry(0L, NULL);
    1.39 -  entry->set_loader(NULL);
    1.40 -  entry->set_pd_set(NULL);
    1.41 +  assert(klass->oop_is_instance(), "Must be");
    1.42    return entry;
    1.43  }
    1.44  
    1.45 @@ -76,13 +68,13 @@
    1.46      entry->set_pd_set(to_delete->next());
    1.47      delete to_delete;
    1.48    }
    1.49 -  Hashtable<klassOop, mtClass>::free_entry(entry);
    1.50 +  Hashtable<Klass*, mtClass>::free_entry(entry);
    1.51  }
    1.52  
    1.53  
    1.54  bool DictionaryEntry::contains_protection_domain(oop protection_domain) const {
    1.55  #ifdef ASSERT
    1.56 -  if (protection_domain == instanceKlass::cast(klass())->protection_domain()) {
    1.57 +  if (protection_domain == InstanceKlass::cast(klass())->protection_domain()) {
    1.58      // Ensure this doesn't show up in the pd_set (invariant)
    1.59      bool in_pd_set = false;
    1.60      for (ProtectionDomainEntry* current = _pd_set;
    1.61 @@ -100,7 +92,7 @@
    1.62    }
    1.63  #endif /* ASSERT */
    1.64  
    1.65 -  if (protection_domain == instanceKlass::cast(klass())->protection_domain()) {
    1.66 +  if (protection_domain == InstanceKlass::cast(klass())->protection_domain()) {
    1.67      // Succeeds trivially
    1.68      return true;
    1.69    }
    1.70 @@ -131,7 +123,7 @@
    1.71  }
    1.72  
    1.73  
    1.74 -bool Dictionary::do_unloading(BoolObjectClosure* is_alive) {
    1.75 +bool Dictionary::do_unloading() {
    1.76    assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
    1.77    bool class_was_unloaded = false;
    1.78    int  index = 0; // Defined here for portability! Do not move
    1.79 @@ -142,111 +134,33 @@
    1.80    for (index = 0; index < table_size(); index++) {
    1.81      for (DictionaryEntry** p = bucket_addr(index); *p != NULL; ) {
    1.82        probe = *p;
    1.83 -      klassOop e = probe->klass();
    1.84 -      oop class_loader = probe->loader();
    1.85 +      Klass* e = probe->klass();
    1.86 +      ClassLoaderData* loader_data = probe->loader_data();
    1.87  
    1.88 -      instanceKlass* ik = instanceKlass::cast(e);
    1.89 -      if (ik->previous_versions() != NULL) {
    1.90 -        // This klass has previous versions so see what we can cleanup
    1.91 -        // while it is safe to do so.
    1.92 -
    1.93 -        int gc_count = 0;    // leave debugging breadcrumbs
    1.94 -        int live_count = 0;
    1.95 -
    1.96 -        // RC_TRACE macro has an embedded ResourceMark
    1.97 -        RC_TRACE(0x00000200, ("unload: %s: previous version length=%d",
    1.98 -          ik->external_name(), ik->previous_versions()->length()));
    1.99 -
   1.100 -        for (int i = ik->previous_versions()->length() - 1; i >= 0; i--) {
   1.101 -          // check the previous versions array for GC'ed weak refs
   1.102 -          PreviousVersionNode * pv_node = ik->previous_versions()->at(i);
   1.103 -          jobject cp_ref = pv_node->prev_constant_pool();
   1.104 -          assert(cp_ref != NULL, "cp ref was unexpectedly cleared");
   1.105 -          if (cp_ref == NULL) {
   1.106 -            delete pv_node;
   1.107 -            ik->previous_versions()->remove_at(i);
   1.108 -            // Since we are traversing the array backwards, we don't have to
   1.109 -            // do anything special with the index.
   1.110 -            continue;  // robustness
   1.111 -          }
   1.112 -
   1.113 -          constantPoolOop pvcp = (constantPoolOop)JNIHandles::resolve(cp_ref);
   1.114 -          if (pvcp == NULL) {
   1.115 -            // this entry has been GC'ed so remove it
   1.116 -            delete pv_node;
   1.117 -            ik->previous_versions()->remove_at(i);
   1.118 -            // Since we are traversing the array backwards, we don't have to
   1.119 -            // do anything special with the index.
   1.120 -            gc_count++;
   1.121 -            continue;
   1.122 -          } else {
   1.123 -            RC_TRACE(0x00000200, ("unload: previous version @%d is alive", i));
   1.124 -            if (is_alive->do_object_b(pvcp)) {
   1.125 -              live_count++;
   1.126 -            } else {
   1.127 -              guarantee(false, "sanity check");
   1.128 -            }
   1.129 -          }
   1.130 -
   1.131 -          GrowableArray<jweak>* method_refs = pv_node->prev_EMCP_methods();
   1.132 -          if (method_refs != NULL) {
   1.133 -            RC_TRACE(0x00000200, ("unload: previous methods length=%d",
   1.134 -              method_refs->length()));
   1.135 -            for (int j = method_refs->length() - 1; j >= 0; j--) {
   1.136 -              jweak method_ref = method_refs->at(j);
   1.137 -              assert(method_ref != NULL, "weak method ref was unexpectedly cleared");
   1.138 -              if (method_ref == NULL) {
   1.139 -                method_refs->remove_at(j);
   1.140 -                // Since we are traversing the array backwards, we don't have to
   1.141 -                // do anything special with the index.
   1.142 -                continue;  // robustness
   1.143 -              }
   1.144 -
   1.145 -              methodOop method = (methodOop)JNIHandles::resolve(method_ref);
   1.146 -              if (method == NULL) {
   1.147 -                // this method entry has been GC'ed so remove it
   1.148 -                JNIHandles::destroy_weak_global(method_ref);
   1.149 -                method_refs->remove_at(j);
   1.150 -              } else {
   1.151 -                // RC_TRACE macro has an embedded ResourceMark
   1.152 -                RC_TRACE(0x00000200,
   1.153 -                  ("unload: %s(%s): prev method @%d in version @%d is alive",
   1.154 -                  method->name()->as_C_string(),
   1.155 -                  method->signature()->as_C_string(), j, i));
   1.156 -              }
   1.157 -            }
   1.158 -          }
   1.159 -        }
   1.160 -        assert(ik->previous_versions()->length() == live_count, "sanity check");
   1.161 -        RC_TRACE(0x00000200,
   1.162 -          ("unload: previous version stats: live=%d, GC'ed=%d", live_count,
   1.163 -          gc_count));
   1.164 -      }
   1.165 +      InstanceKlass* ik = InstanceKlass::cast(e);
   1.166  
   1.167        // Non-unloadable classes were handled in always_strong_oops_do
   1.168 -      if (!is_strongly_reachable(class_loader, e)) {
   1.169 +      if (!is_strongly_reachable(loader_data, e)) {
   1.170          // Entry was not visited in phase1 (negated test from phase1)
   1.171 -        assert(class_loader != NULL, "unloading entry with null class loader");
   1.172 -        oop k_def_class_loader = ik->class_loader();
   1.173 +        assert(!loader_data->is_the_null_class_loader_data(), "unloading entry with null class loader");
   1.174 +        ClassLoaderData* k_def_class_loader_data = ik->class_loader_data();
   1.175  
   1.176          // Do we need to delete this system dictionary entry?
   1.177          bool purge_entry = false;
   1.178  
   1.179          // Do we need to delete this system dictionary entry?
   1.180 -        if (!is_alive->do_object_b(class_loader)) {
   1.181 +        if (loader_data->is_unloading()) {
   1.182            // If the loader is not live this entry should always be
   1.183            // removed (will never be looked up again). Note that this is
   1.184            // not the same as unloading the referred class.
   1.185 -          if (k_def_class_loader == class_loader) {
   1.186 +          if (k_def_class_loader_data == loader_data) {
   1.187              // This is the defining entry, so the referred class is about
   1.188              // to be unloaded.
   1.189              // Notify the debugger and clean up the class.
   1.190 -            guarantee(!is_alive->do_object_b(e),
   1.191 -                      "klass should not be live if defining loader is not");
   1.192              class_was_unloaded = true;
   1.193              // notify the debugger
   1.194              if (JvmtiExport::should_post_class_unload()) {
   1.195 -              JvmtiExport::post_class_unload(ik->as_klassOop());
   1.196 +              JvmtiExport::post_class_unload(ik);
   1.197              }
   1.198  
   1.199              // notify ClassLoadingService of class unload
   1.200 @@ -254,22 +168,21 @@
   1.201  
   1.202              // Clean up C heap
   1.203              ik->release_C_heap_structures();
   1.204 +            ik->constants()->release_C_heap_structures();
   1.205            }
   1.206            // Also remove this system dictionary entry.
   1.207            purge_entry = true;
   1.208  
   1.209          } else {
   1.210            // The loader in this entry is alive. If the klass is dead,
   1.211 +          // (determined by checking the defining class loader)
   1.212            // the loader must be an initiating loader (rather than the
   1.213            // defining loader). Remove this entry.
   1.214 -          if (!is_alive->do_object_b(e)) {
   1.215 -            guarantee(!is_alive->do_object_b(k_def_class_loader),
   1.216 -                      "defining loader should not be live if klass is not");
   1.217 -            // If we get here, the class_loader must not be the defining
   1.218 +          if (k_def_class_loader_data->is_unloading()) {
   1.219 +            // If we get here, the class_loader_data must not be the defining
   1.220              // loader, it must be an initiating one.
   1.221 -            assert(k_def_class_loader != class_loader,
   1.222 +            assert(k_def_class_loader_data != loader_data,
   1.223                     "cannot have live defining loader and unreachable klass");
   1.224 -
   1.225              // Loader is live, but class and its defining loader are dead.
   1.226              // Remove the entry. The class is going away.
   1.227              purge_entry = true;
   1.228 @@ -292,19 +205,15 @@
   1.229  }
   1.230  
   1.231  
   1.232 -void Dictionary::always_strong_classes_do(OopClosure* blk) {
   1.233 +void Dictionary::always_strong_oops_do(OopClosure* blk) {
   1.234    // Follow all system classes and temporary placeholders in dictionary
   1.235    for (int index = 0; index < table_size(); index++) {
   1.236      for (DictionaryEntry *probe = bucket(index);
   1.237                            probe != NULL;
   1.238                            probe = probe->next()) {
   1.239 -      klassOop e = probe->klass();
   1.240 -      oop class_loader = probe->loader();
   1.241 -      if (is_strongly_reachable(class_loader, e)) {
   1.242 -        blk->do_oop((oop*)probe->klass_addr());
   1.243 -        if (class_loader != NULL) {
   1.244 -          blk->do_oop(probe->loader_addr());
   1.245 -        }
   1.246 +      Klass* e = probe->klass();
   1.247 +      ClassLoaderData* loader_data = probe->loader_data();
   1.248 +      if (is_strongly_reachable(loader_data, e)) {
   1.249          probe->protection_domain_set_oops_do(blk);
   1.250        }
   1.251      }
   1.252 @@ -312,14 +221,30 @@
   1.253  }
   1.254  
   1.255  
   1.256 -//   Just the classes from defining class loaders
   1.257 -void Dictionary::classes_do(void f(klassOop)) {
   1.258 +void Dictionary::always_strong_classes_do(KlassClosure* closure) {
   1.259 +  // Follow all system classes and temporary placeholders in dictionary
   1.260    for (int index = 0; index < table_size(); index++) {
   1.261      for (DictionaryEntry* probe = bucket(index);
   1.262                            probe != NULL;
   1.263                            probe = probe->next()) {
   1.264 -      klassOop k = probe->klass();
   1.265 -      if (probe->loader() == instanceKlass::cast(k)->class_loader()) {
   1.266 +      Klass* e = probe->klass();
   1.267 +      ClassLoaderData* loader_data = probe->loader_data();
   1.268 +      if (is_strongly_reachable(loader_data, e)) {
   1.269 +        closure->do_klass(e);
   1.270 +      }
   1.271 +    }
   1.272 +  }
   1.273 +}
   1.274 +
   1.275 +
   1.276 +//   Just the classes from defining class loaders
   1.277 +void Dictionary::classes_do(void f(Klass*)) {
   1.278 +  for (int index = 0; index < table_size(); index++) {
   1.279 +    for (DictionaryEntry* probe = bucket(index);
   1.280 +                          probe != NULL;
   1.281 +                          probe = probe->next()) {
   1.282 +      Klass* k = probe->klass();
   1.283 +      if (probe->loader_data() == InstanceKlass::cast(k)->class_loader_data()) {
   1.284          f(k);
   1.285        }
   1.286      }
   1.287 @@ -328,13 +253,13 @@
   1.288  
   1.289  // Added for initialize_itable_for_klass to handle exceptions
   1.290  //   Just the classes from defining class loaders
   1.291 -void Dictionary::classes_do(void f(klassOop, TRAPS), TRAPS) {
   1.292 +void Dictionary::classes_do(void f(Klass*, TRAPS), TRAPS) {
   1.293    for (int index = 0; index < table_size(); index++) {
   1.294      for (DictionaryEntry* probe = bucket(index);
   1.295                            probe != NULL;
   1.296                            probe = probe->next()) {
   1.297 -      klassOop k = probe->klass();
   1.298 -      if (probe->loader() == instanceKlass::cast(k)->class_loader()) {
   1.299 +      Klass* k = probe->klass();
   1.300 +      if (probe->loader_data() == InstanceKlass::cast(k)->class_loader_data()) {
   1.301          f(k, CHECK);
   1.302        }
   1.303      }
   1.304 @@ -345,13 +270,13 @@
   1.305  //   All classes, and their class loaders
   1.306  //   (added for helpers that use HandleMarks and ResourceMarks)
   1.307  // Don't iterate over placeholders
   1.308 -void Dictionary::classes_do(void f(klassOop, oop, TRAPS), TRAPS) {
   1.309 +void Dictionary::classes_do(void f(Klass*, ClassLoaderData*, TRAPS), TRAPS) {
   1.310    for (int index = 0; index < table_size(); index++) {
   1.311      for (DictionaryEntry* probe = bucket(index);
   1.312                            probe != NULL;
   1.313                            probe = probe->next()) {
   1.314 -      klassOop k = probe->klass();
   1.315 -      f(k, probe->loader(), CHECK);
   1.316 +      Klass* k = probe->klass();
   1.317 +      f(k, probe->loader_data(), CHECK);
   1.318      }
   1.319    }
   1.320  }
   1.321 @@ -359,13 +284,13 @@
   1.322  
   1.323  //   All classes, and their class loaders
   1.324  // Don't iterate over placeholders
   1.325 -void Dictionary::classes_do(void f(klassOop, oop)) {
   1.326 +void Dictionary::classes_do(void f(Klass*, ClassLoaderData*)) {
   1.327    for (int index = 0; index < table_size(); index++) {
   1.328      for (DictionaryEntry* probe = bucket(index);
   1.329                            probe != NULL;
   1.330                            probe = probe->next()) {
   1.331 -      klassOop k = probe->klass();
   1.332 -      f(k, probe->loader());
   1.333 +      Klass* k = probe->klass();
   1.334 +      f(k, probe->loader_data());
   1.335      }
   1.336    }
   1.337  }
   1.338 @@ -376,35 +301,31 @@
   1.339      for (DictionaryEntry* probe = bucket(index);
   1.340                            probe != NULL;
   1.341                            probe = probe->next()) {
   1.342 -      f->do_oop((oop*)probe->klass_addr());
   1.343 -      if (probe->loader() != NULL) {
   1.344 -        f->do_oop(probe->loader_addr());
   1.345 -      }
   1.346        probe->protection_domain_set_oops_do(f);
   1.347      }
   1.348    }
   1.349  }
   1.350  
   1.351  
   1.352 -void Dictionary::methods_do(void f(methodOop)) {
   1.353 +void Dictionary::methods_do(void f(Method*)) {
   1.354    for (int index = 0; index < table_size(); index++) {
   1.355      for (DictionaryEntry* probe = bucket(index);
   1.356                            probe != NULL;
   1.357                            probe = probe->next()) {
   1.358 -      klassOop k = probe->klass();
   1.359 -      if (probe->loader() == instanceKlass::cast(k)->class_loader()) {
   1.360 +      Klass* k = probe->klass();
   1.361 +      if (probe->loader_data() == InstanceKlass::cast(k)->class_loader_data()) {
   1.362          // only take klass is we have the entry with the defining class loader
   1.363 -        instanceKlass::cast(k)->methods_do(f);
   1.364 +        InstanceKlass::cast(k)->methods_do(f);
   1.365        }
   1.366      }
   1.367    }
   1.368  }
   1.369  
   1.370  
   1.371 -klassOop Dictionary::try_get_next_class() {
   1.372 +Klass* Dictionary::try_get_next_class() {
   1.373    while (true) {
   1.374      if (_current_class_entry != NULL) {
   1.375 -      klassOop k = _current_class_entry->klass();
   1.376 +      Klass* k = _current_class_entry->klass();
   1.377        _current_class_entry = _current_class_entry->next();
   1.378        return k;
   1.379      }
   1.380 @@ -421,15 +342,15 @@
   1.381  // also cast to volatile;  we do this to ensure store order is maintained
   1.382  // by the compilers.
   1.383  
   1.384 -void Dictionary::add_klass(Symbol* class_name, Handle class_loader,
   1.385 +void Dictionary::add_klass(Symbol* class_name, ClassLoaderData* loader_data,
   1.386                             KlassHandle obj) {
   1.387    assert_locked_or_safepoint(SystemDictionary_lock);
   1.388    assert(obj() != NULL, "adding NULL obj");
   1.389    assert(Klass::cast(obj())->name() == class_name, "sanity check on name");
   1.390  
   1.391 -  unsigned int hash = compute_hash(class_name, class_loader);
   1.392 +  unsigned int hash = compute_hash(class_name, loader_data);
   1.393    int index = hash_to_index(hash);
   1.394 -  DictionaryEntry* entry = new_entry(hash, obj(), class_loader());
   1.395 +  DictionaryEntry* entry = new_entry(hash, obj(), loader_data);
   1.396    add_entry(index, entry);
   1.397  }
   1.398  
   1.399 @@ -445,13 +366,12 @@
   1.400  // _buckets[index] is read here, so the caller will not see the new entry.
   1.401  DictionaryEntry* Dictionary::get_entry(int index, unsigned int hash,
   1.402                                         Symbol* class_name,
   1.403 -                                       Handle class_loader) {
   1.404 -  oop loader = class_loader();
   1.405 +                                       ClassLoaderData* loader_data) {
   1.406    debug_only(_lookup_count++);
   1.407    for (DictionaryEntry* entry = bucket(index);
   1.408                          entry != NULL;
   1.409                          entry = entry->next()) {
   1.410 -    if (entry->hash() == hash && entry->equals(class_name, loader)) {
   1.411 +    if (entry->hash() == hash && entry->equals(class_name, loader_data)) {
   1.412        return entry;
   1.413      }
   1.414      debug_only(_lookup_length++);
   1.415 @@ -460,9 +380,9 @@
   1.416  }
   1.417  
   1.418  
   1.419 -klassOop Dictionary::find(int index, unsigned int hash, Symbol* name,
   1.420 -                          Handle loader, Handle protection_domain, TRAPS) {
   1.421 -  DictionaryEntry* entry = get_entry(index, hash, name, loader);
   1.422 +Klass* Dictionary::find(int index, unsigned int hash, Symbol* name,
   1.423 +                          ClassLoaderData* loader_data, Handle protection_domain, TRAPS) {
   1.424 +  DictionaryEntry* entry = get_entry(index, hash, name, loader_data);
   1.425    if (entry != NULL && entry->is_valid_protection_domain(protection_domain)) {
   1.426      return entry->klass();
   1.427    } else {
   1.428 @@ -471,34 +391,34 @@
   1.429  }
   1.430  
   1.431  
   1.432 -klassOop Dictionary::find_class(int index, unsigned int hash,
   1.433 -                                Symbol* name, Handle loader) {
   1.434 +Klass* Dictionary::find_class(int index, unsigned int hash,
   1.435 +                                Symbol* name, ClassLoaderData* loader_data) {
   1.436    assert_locked_or_safepoint(SystemDictionary_lock);
   1.437 -  assert (index == index_for(name, loader), "incorrect index?");
   1.438 +  assert (index == index_for(name, loader_data), "incorrect index?");
   1.439  
   1.440 -  DictionaryEntry* entry = get_entry(index, hash, name, loader);
   1.441 -  return (entry != NULL) ? entry->klass() : (klassOop)NULL;
   1.442 +  DictionaryEntry* entry = get_entry(index, hash, name, loader_data);
   1.443 +  return (entry != NULL) ? entry->klass() : (Klass*)NULL;
   1.444  }
   1.445  
   1.446  
   1.447  // Variant of find_class for shared classes.  No locking required, as
   1.448  // that table is static.
   1.449  
   1.450 -klassOop Dictionary::find_shared_class(int index, unsigned int hash,
   1.451 +Klass* Dictionary::find_shared_class(int index, unsigned int hash,
   1.452                                         Symbol* name) {
   1.453 -  assert (index == index_for(name, Handle()), "incorrect index?");
   1.454 +  assert (index == index_for(name, NULL), "incorrect index?");
   1.455  
   1.456 -  DictionaryEntry* entry = get_entry(index, hash, name, Handle());
   1.457 -  return (entry != NULL) ? entry->klass() : (klassOop)NULL;
   1.458 +  DictionaryEntry* entry = get_entry(index, hash, name, NULL);
   1.459 +  return (entry != NULL) ? entry->klass() : (Klass*)NULL;
   1.460  }
   1.461  
   1.462  
   1.463  void Dictionary::add_protection_domain(int index, unsigned int hash,
   1.464                                         instanceKlassHandle klass,
   1.465 -                                       Handle loader, Handle protection_domain,
   1.466 +                                       ClassLoaderData* loader_data, Handle protection_domain,
   1.467                                         TRAPS) {
   1.468    Symbol*  klass_name = klass->name();
   1.469 -  DictionaryEntry* entry = get_entry(index, hash, klass_name, loader);
   1.470 +  DictionaryEntry* entry = get_entry(index, hash, klass_name, loader_data);
   1.471  
   1.472    assert(entry != NULL,"entry must be present, we just created it");
   1.473    assert(protection_domain() != NULL,
   1.474 @@ -513,9 +433,9 @@
   1.475  
   1.476  bool Dictionary::is_valid_protection_domain(int index, unsigned int hash,
   1.477                                              Symbol* name,
   1.478 -                                            Handle loader,
   1.479 +                                            ClassLoaderData* loader_data,
   1.480                                              Handle protection_domain) {
   1.481 -  DictionaryEntry* entry = get_entry(index, hash, name, loader);
   1.482 +  DictionaryEntry* entry = get_entry(index, hash, name, loader_data);
   1.483    return entry->is_valid_protection_domain(protection_domain);
   1.484  }
   1.485  
   1.486 @@ -538,16 +458,17 @@
   1.487    }
   1.488  
   1.489    // Add the dictionary entries back to the list in the correct buckets.
   1.490 -  Thread *thread = Thread::current();
   1.491 -
   1.492    while (master_list != NULL) {
   1.493      DictionaryEntry* p = master_list;
   1.494      master_list = master_list->next();
   1.495      p->set_next(NULL);
   1.496 -    Symbol* class_name = instanceKlass::cast((klassOop)(p->klass()))->name();
   1.497 -    unsigned int hash = compute_hash(class_name, Handle(thread, p->loader()));
   1.498 +    Symbol* class_name = InstanceKlass::cast((Klass*)(p->klass()))->name();
   1.499 +    // Since the null class loader data isn't copied to the CDS archive,
   1.500 +    // compute the hash with NULL for loader data.
   1.501 +    unsigned int hash = compute_hash(class_name, NULL);
   1.502      int index = hash_to_index(hash);
   1.503      p->set_hash(hash);
   1.504 +    p->set_loader_data(NULL);   // loader_data isn't copied to CDS
   1.505      p->set_next(bucket(index));
   1.506      set_entry(index, p);
   1.507    }
   1.508 @@ -588,23 +509,22 @@
   1.509    return p;
   1.510  }
   1.511  
   1.512 -
   1.513  void SymbolPropertyTable::oops_do(OopClosure* f) {
   1.514    for (int index = 0; index < table_size(); index++) {
   1.515      for (SymbolPropertyEntry* p = bucket(index); p != NULL; p = p->next()) {
   1.516 -      if (p->property_oop() != NULL) {
   1.517 -        f->do_oop(p->property_oop_addr());
   1.518 +      if (p->method_type() != NULL) {
   1.519 +        f->do_oop(p->method_type_addr());
   1.520        }
   1.521      }
   1.522    }
   1.523  }
   1.524  
   1.525 -void SymbolPropertyTable::methods_do(void f(methodOop)) {
   1.526 +void SymbolPropertyTable::methods_do(void f(Method*)) {
   1.527    for (int index = 0; index < table_size(); index++) {
   1.528      for (SymbolPropertyEntry* p = bucket(index); p != NULL; p = p->next()) {
   1.529 -      oop prop = p->property_oop();
   1.530 -      if (prop != NULL && prop->is_method()) {
   1.531 -        f((methodOop)prop);
   1.532 +      Method* prop = p->method();
   1.533 +      if (prop != NULL) {
   1.534 +        f((Method*)prop);
   1.535        }
   1.536      }
   1.537    }
   1.538 @@ -628,16 +548,15 @@
   1.539                            probe != NULL;
   1.540                            probe = probe->next()) {
   1.541        if (Verbose) tty->print("%4d: ", index);
   1.542 -      klassOop e = probe->klass();
   1.543 -      oop class_loader =  probe->loader();
   1.544 +      Klass* e = probe->klass();
   1.545 +      ClassLoaderData* loader_data =  probe->loader_data();
   1.546        bool is_defining_class =
   1.547 -         (class_loader == instanceKlass::cast(e)->class_loader());
   1.548 +         (loader_data == InstanceKlass::cast(e)->class_loader_data());
   1.549        tty->print("%s%s", is_defining_class ? " " : "^",
   1.550                     Klass::cast(e)->external_name());
   1.551 -      if (class_loader != NULL) {
   1.552 +
   1.553          tty->print(", loader ");
   1.554 -        class_loader->print_value();
   1.555 -      }
   1.556 +      loader_data->print_value();
   1.557        tty->cr();
   1.558      }
   1.559    }
   1.560 @@ -645,20 +564,24 @@
   1.561  
   1.562  #endif
   1.563  
   1.564 +
   1.565  void Dictionary::verify() {
   1.566    guarantee(number_of_entries() >= 0, "Verify of system dictionary failed");
   1.567 +
   1.568    int element_count = 0;
   1.569    for (int index = 0; index < table_size(); index++) {
   1.570      for (DictionaryEntry* probe = bucket(index);
   1.571                            probe != NULL;
   1.572                            probe = probe->next()) {
   1.573 -      klassOop e = probe->klass();
   1.574 -      oop class_loader = probe->loader();
   1.575 +      Klass* e = probe->klass();
   1.576 +      ClassLoaderData* loader_data = probe->loader_data();
   1.577        guarantee(Klass::cast(e)->oop_is_instance(),
   1.578                                "Verify of system dictionary failed");
   1.579        // class loader must be present;  a null class loader is the
   1.580        // boostrap loader
   1.581 -      guarantee(class_loader == NULL || class_loader->is_instance(),
   1.582 +      guarantee(loader_data != NULL || DumpSharedSpaces ||
   1.583 +                loader_data->is_the_null_class_loader_data() ||
   1.584 +                loader_data->class_loader()->is_instance(),
   1.585                  "checking type of class_loader");
   1.586        e->verify();
   1.587        probe->verify_protection_domain_set();
   1.588 @@ -669,3 +592,4 @@
   1.589              "Verify of system dictionary failed");
   1.590    debug_only(verify_lookup_length((double)number_of_entries() / table_size()));
   1.591  }
   1.592 +

mercurial