src/share/vm/classfile/loaderConstraints.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/classfile

src/share/vm/classfile/loaderConstraints.cpp

Print this page




  68       }
  69         }
  70       }
  71     }
  72 
  73 // The loaderConstraintTable must always be accessed with the
  74 // SystemDictionary lock held. This is true even for readers as
  75 // entries in the table could be being dynamically resized.
  76 
  77 LoaderConstraintEntry** LoaderConstraintTable::find_loader_constraint(
  78                                     Symbol* name, Handle loader) {
  79 
  80   unsigned int hash = compute_hash(name);
  81   int index = hash_to_index(hash);
  82   LoaderConstraintEntry** pp = bucket_addr(index);
  83   ClassLoaderData* loader_data = ClassLoaderData::class_loader_data(loader());
  84 
  85   while (*pp) {
  86     LoaderConstraintEntry* p = *pp;
  87     if (p->hash() == hash) {
  88       if (p->name() == name) {
  89         for (int i = p->num_loaders() - 1; i >= 0; i--) {
  90           if (p->loader_data(i) == loader_data) {
  91             return pp;
  92           }
  93         }
  94       }
  95     }
  96     pp = p->next_addr();
  97   }
  98   return pp;
  99 }
 100 
 101 
 102 void LoaderConstraintTable::purge_loader_constraints() {
 103   assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
 104   // Remove unloaded entries from constraint table
 105   for (int index = 0; index < table_size(); index++) {
 106     LoaderConstraintEntry** p = bucket_addr(index);
 107     while(*p) {
 108       LoaderConstraintEntry* probe = *p;


 420   } else {
 421     assert(p1->klass() == klass, "constraints corrupted");
 422   }
 423 
 424   *pp2 = p2->next();
 425   FREE_C_HEAP_ARRAY(oop, p2->loaders());
 426   free_entry(p2);
 427   return;
 428 }
 429 
 430 
 431 void LoaderConstraintTable::verify(Dictionary* dictionary,
 432                                    PlaceholderTable* placeholders) {
 433   Thread *thread = Thread::current();
 434   for (int cindex = 0; cindex < _loader_constraint_size; cindex++) {
 435     for (LoaderConstraintEntry* probe = bucket(cindex);
 436                                 probe != NULL;
 437                                 probe = probe->next()) {
 438       if (probe->klass() != NULL) {
 439         InstanceKlass* ik = InstanceKlass::cast(probe->klass());
 440         guarantee(ik->name() == probe->name(), "name should match");
 441         Symbol* name = ik->name();
 442         ClassLoaderData* loader_data = ik->class_loader_data();
 443         unsigned int d_hash = dictionary->compute_hash(name, loader_data);
 444         int d_index = dictionary->hash_to_index(d_hash);
 445         Klass* k = dictionary->find_class(d_index, d_hash, name, loader_data);
 446         if (k != NULL) {
 447           // We found the class in the system dictionary, so we should
 448           // make sure that the Klass* matches what we already have.
 449           guarantee(k == probe->klass(), "klass should be in dictionary");
 450         } else {
 451           // If we don't find the class in the system dictionary, it
 452           // has to be in the placeholders table.
 453           unsigned int p_hash = placeholders->compute_hash(name, loader_data);
 454           int p_index = placeholders->hash_to_index(p_hash);
 455           PlaceholderEntry* entry = placeholders->get_entry(p_index, p_hash,
 456                                                             name, loader_data);
 457 
 458           // The InstanceKlass might not be on the entry, so the only
 459           // thing we can check here is whether we were successful in
 460           // finding the class in the placeholders table.




  68       }
  69         }
  70       }
  71     }
  72 
  73 // The loaderConstraintTable must always be accessed with the
  74 // SystemDictionary lock held. This is true even for readers as
  75 // entries in the table could be being dynamically resized.
  76 
  77 LoaderConstraintEntry** LoaderConstraintTable::find_loader_constraint(
  78                                     Symbol* name, Handle loader) {
  79 
  80   unsigned int hash = compute_hash(name);
  81   int index = hash_to_index(hash);
  82   LoaderConstraintEntry** pp = bucket_addr(index);
  83   ClassLoaderData* loader_data = ClassLoaderData::class_loader_data(loader());
  84 
  85   while (*pp) {
  86     LoaderConstraintEntry* p = *pp;
  87     if (p->hash() == hash) {
  88       if (p->name()->equals(name)) {
  89         for (int i = p->num_loaders() - 1; i >= 0; i--) {
  90           if (p->loader_data(i) == loader_data) {
  91             return pp;
  92           }
  93         }
  94       }
  95     }
  96     pp = p->next_addr();
  97   }
  98   return pp;
  99 }
 100 
 101 
 102 void LoaderConstraintTable::purge_loader_constraints() {
 103   assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
 104   // Remove unloaded entries from constraint table
 105   for (int index = 0; index < table_size(); index++) {
 106     LoaderConstraintEntry** p = bucket_addr(index);
 107     while(*p) {
 108       LoaderConstraintEntry* probe = *p;


 420   } else {
 421     assert(p1->klass() == klass, "constraints corrupted");
 422   }
 423 
 424   *pp2 = p2->next();
 425   FREE_C_HEAP_ARRAY(oop, p2->loaders());
 426   free_entry(p2);
 427   return;
 428 }
 429 
 430 
 431 void LoaderConstraintTable::verify(Dictionary* dictionary,
 432                                    PlaceholderTable* placeholders) {
 433   Thread *thread = Thread::current();
 434   for (int cindex = 0; cindex < _loader_constraint_size; cindex++) {
 435     for (LoaderConstraintEntry* probe = bucket(cindex);
 436                                 probe != NULL;
 437                                 probe = probe->next()) {
 438       if (probe->klass() != NULL) {
 439         InstanceKlass* ik = InstanceKlass::cast(probe->klass());
 440         guarantee(ik->name()->equals(probe->name()), "name should match");
 441         Symbol* name = ik->name();
 442         ClassLoaderData* loader_data = ik->class_loader_data();
 443         unsigned int d_hash = dictionary->compute_hash(name, loader_data);
 444         int d_index = dictionary->hash_to_index(d_hash);
 445         Klass* k = dictionary->find_class(d_index, d_hash, name, loader_data);
 446         if (k != NULL) {
 447           // We found the class in the system dictionary, so we should
 448           // make sure that the Klass* matches what we already have.
 449           guarantee(k == probe->klass(), "klass should be in dictionary");
 450         } else {
 451           // If we don't find the class in the system dictionary, it
 452           // has to be in the placeholders table.
 453           unsigned int p_hash = placeholders->compute_hash(name, loader_data);
 454           int p_index = placeholders->hash_to_index(p_hash);
 455           PlaceholderEntry* entry = placeholders->get_entry(p_index, p_hash,
 456                                                             name, loader_data);
 457 
 458           // The InstanceKlass might not be on the entry, so the only
 459           // thing we can check here is whether we were successful in
 460           // finding the class in the placeholders table.


src/share/vm/classfile/loaderConstraints.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File