src/share/vm/classfile/placeholders.cpp

changeset 2497
3582bf76420e
parent 2314
f95d63e2154a
child 2708
1d1603768966
     1.1 --- a/src/share/vm/classfile/placeholders.cpp	Thu Jan 27 13:42:28 2011 -0800
     1.2 +++ b/src/share/vm/classfile/placeholders.cpp	Thu Jan 27 16:11:27 2011 -0800
     1.3 @@ -31,10 +31,12 @@
     1.4  
     1.5  // Placeholder methods
     1.6  
     1.7 -PlaceholderEntry* PlaceholderTable::new_entry(int hash, symbolOop name,
     1.8 +PlaceholderEntry* PlaceholderTable::new_entry(int hash, Symbol* name,
     1.9                                                oop loader, bool havesupername,
    1.10 -                                              symbolOop supername) {
    1.11 -  PlaceholderEntry* entry = (PlaceholderEntry*)Hashtable::new_entry(hash, name);
    1.12 +                                              Symbol* supername) {
    1.13 +  PlaceholderEntry* entry = (PlaceholderEntry*)Hashtable<Symbol*>::new_entry(hash, name);
    1.14 +  // Hashtable with Symbol* literal must increment and decrement refcount.
    1.15 +  name->increment_refcount();
    1.16    entry->set_loader(loader);
    1.17    entry->set_havesupername(havesupername);
    1.18    entry->set_supername(supername);
    1.19 @@ -46,33 +48,40 @@
    1.20    return entry;
    1.21  }
    1.22  
    1.23 +void PlaceholderTable::free_entry(PlaceholderEntry* entry) {
    1.24 +  // decrement Symbol refcount here because Hashtable doesn't.
    1.25 +  entry->literal()->decrement_refcount();
    1.26 +  if (entry->supername() != NULL) entry->supername()->decrement_refcount();
    1.27 +  Hashtable<Symbol*>::free_entry(entry);
    1.28 +}
    1.29 +
    1.30  
    1.31  // Placeholder objects represent classes currently being loaded.
    1.32  // All threads examining the placeholder table must hold the
    1.33  // SystemDictionary_lock, so we don't need special precautions
    1.34  // on store ordering here.
    1.35  void PlaceholderTable::add_entry(int index, unsigned int hash,
    1.36 -                                 symbolHandle class_name, Handle class_loader,
    1.37 -                                 bool havesupername, symbolHandle supername){
    1.38 +                                 Symbol* class_name, Handle class_loader,
    1.39 +                                 bool havesupername, Symbol* supername){
    1.40    assert_locked_or_safepoint(SystemDictionary_lock);
    1.41 -  assert(!class_name.is_null(), "adding NULL obj");
    1.42 +  assert(class_name != NULL, "adding NULL obj");
    1.43  
    1.44    // Both readers and writers are locked so it's safe to just
    1.45    // create the placeholder and insert it in the list without a membar.
    1.46 -  PlaceholderEntry* entry = new_entry(hash, class_name(), class_loader(), havesupername, supername());
    1.47 +  PlaceholderEntry* entry = new_entry(hash, class_name, class_loader(), havesupername, supername);
    1.48    add_entry(index, entry);
    1.49  }
    1.50  
    1.51  
    1.52  // Remove a placeholder object.
    1.53  void PlaceholderTable::remove_entry(int index, unsigned int hash,
    1.54 -                                    symbolHandle class_name,
    1.55 +                                    Symbol* class_name,
    1.56                                      Handle class_loader) {
    1.57    assert_locked_or_safepoint(SystemDictionary_lock);
    1.58    PlaceholderEntry** p = bucket_addr(index);
    1.59    while (*p) {
    1.60      PlaceholderEntry *probe = *p;
    1.61 -    if (probe->hash() == hash && probe->equals(class_name(), class_loader())) {
    1.62 +    if (probe->hash() == hash && probe->equals(class_name, class_loader())) {
    1.63        // Delete entry
    1.64        *p = probe->next();
    1.65        free_entry(probe);
    1.66 @@ -83,29 +92,28 @@
    1.67  }
    1.68  
    1.69  PlaceholderEntry* PlaceholderTable::get_entry(int index, unsigned int hash,
    1.70 -                                       symbolHandle class_name,
    1.71 +                                       Symbol* class_name,
    1.72                                         Handle class_loader) {
    1.73    assert_locked_or_safepoint(SystemDictionary_lock);
    1.74  
    1.75 -  symbolOop class_name_ = class_name();
    1.76    oop class_loader_ = class_loader();
    1.77  
    1.78    for (PlaceholderEntry *place_probe = bucket(index);
    1.79                           place_probe != NULL;
    1.80                           place_probe = place_probe->next()) {
    1.81      if (place_probe->hash() == hash &&
    1.82 -        place_probe->equals(class_name_, class_loader_)) {
    1.83 +        place_probe->equals(class_name, class_loader_)) {
    1.84        return place_probe;
    1.85      }
    1.86    }
    1.87    return NULL;
    1.88  }
    1.89  
    1.90 -symbolOop PlaceholderTable::find_entry(int index, unsigned int hash,
    1.91 -                                       symbolHandle class_name,
    1.92 +Symbol* PlaceholderTable::find_entry(int index, unsigned int hash,
    1.93 +                                       Symbol* class_name,
    1.94                                         Handle class_loader) {
    1.95    PlaceholderEntry* probe = get_entry(index, hash, class_name, class_loader);
    1.96 -  return (probe? probe->klass(): symbolOop(NULL));
    1.97 +  return (probe? probe->klassname(): (Symbol*)NULL);
    1.98  }
    1.99  
   1.100    // find_and_add returns probe pointer - old or new
   1.101 @@ -113,7 +121,7 @@
   1.102    // If entry exists, reuse entry
   1.103    // For both, push SeenThread for classloadAction
   1.104    // if havesupername: this is used for circularity for instanceklass loading
   1.105 -PlaceholderEntry* PlaceholderTable::find_and_add(int index, unsigned int hash, symbolHandle name, Handle loader, classloadAction action, symbolHandle supername, Thread* thread) {
   1.106 +PlaceholderEntry* PlaceholderTable::find_and_add(int index, unsigned int hash, Symbol* name, Handle loader, classloadAction action, Symbol* supername, Thread* thread) {
   1.107    PlaceholderEntry* probe = get_entry(index, hash, name, loader);
   1.108    if (probe == NULL) {
   1.109      // Nothing found, add place holder
   1.110 @@ -122,7 +130,7 @@
   1.111    } else {
   1.112      if (action == LOAD_SUPER) {
   1.113        probe->set_havesupername(true);
   1.114 -      probe->set_supername(supername());
   1.115 +      probe->set_supername(supername);
   1.116      }
   1.117    }
   1.118    if (probe) probe->add_seen_thread(thread, action);
   1.119 @@ -145,7 +153,7 @@
   1.120  // Therefore - must always check SD first
   1.121  // Ignores the case where entry is not found
   1.122  void PlaceholderTable::find_and_remove(int index, unsigned int hash,
   1.123 -                       symbolHandle name, Handle loader, Thread* thread) {
   1.124 +                       Symbol* name, Handle loader, Thread* thread) {
   1.125      assert_locked_or_safepoint(SystemDictionary_lock);
   1.126      PlaceholderEntry *probe = get_entry(index, hash, name, loader);
   1.127      if (probe != NULL) {
   1.128 @@ -158,7 +166,7 @@
   1.129    }
   1.130  
   1.131  PlaceholderTable::PlaceholderTable(int table_size)
   1.132 -    : TwoOopHashtable(table_size, sizeof(PlaceholderEntry)) {
   1.133 +    : TwoOopHashtable<Symbol*>(table_size, sizeof(PlaceholderEntry)) {
   1.134  }
   1.135  
   1.136  
   1.137 @@ -174,26 +182,22 @@
   1.138  
   1.139  
   1.140  void PlaceholderEntry::oops_do(OopClosure* blk) {
   1.141 -  assert(klass() != NULL, "should have a non-null klass");
   1.142 -  blk->do_oop((oop*)klass_addr());
   1.143 +  assert(klassname() != NULL, "should have a non-null klass");
   1.144    if (_loader != NULL) {
   1.145      blk->do_oop(loader_addr());
   1.146    }
   1.147 -  if (_supername != NULL) {
   1.148 -    blk->do_oop((oop*)supername_addr());
   1.149 -  }
   1.150    if (_instanceKlass != NULL) {
   1.151      blk->do_oop((oop*)instanceKlass_addr());
   1.152    }
   1.153  }
   1.154  
   1.155  // do all entries in the placeholder table
   1.156 -void PlaceholderTable::entries_do(void f(symbolOop, oop)) {
   1.157 +void PlaceholderTable::entries_do(void f(Symbol*, oop)) {
   1.158    for (int index = 0; index < table_size(); index++) {
   1.159      for (PlaceholderEntry* probe = bucket(index);
   1.160                             probe != NULL;
   1.161                             probe = probe->next()) {
   1.162 -      f(probe->klass(), probe->loader());
   1.163 +      f(probe->klassname(), probe->loader());
   1.164      }
   1.165    }
   1.166  }
   1.167 @@ -202,7 +206,7 @@
   1.168  #ifndef PRODUCT
   1.169  // Note, doesn't append a cr
   1.170  void PlaceholderEntry::print() const {
   1.171 -  klass()->print_value();
   1.172 +  klassname()->print_value();
   1.173    if (loader() != NULL) {
   1.174      tty->print(", loader ");
   1.175      loader()->print_value();
   1.176 @@ -238,7 +242,6 @@
   1.177    guarantee(instanceKlass() == NULL
   1.178              || Klass::cast(instanceKlass())->oop_is_instance(),
   1.179              "checking type of instanceKlass result");
   1.180 -  klass()->verify();
   1.181  }
   1.182  
   1.183  void PlaceholderTable::verify() {

mercurial