src/share/vm/classfile/dictionary.hpp

Print this page
rev 5310 : imported patch ioi_original_patch
rev 5311 : imported patch cleanup

@@ -133,12 +133,16 @@
 // The following classes can be in dictionary.cpp, but we need these
 // to be in header file so that SA's vmStructs can access them.
 class ProtectionDomainCacheEntry : public HashtableEntry<oop, mtClass> {
   friend class VMStructs;
  private:
+  // the number of system dictionary entries referring to this entry
   int _refcount;
-  int _scan_generation;
+  // flag indicating whether this protection domain entry is strongly reachable.
+  // Used during iterating over the system dictionary to remember oops that need
+  // to be updated.
+  bool _strongly_reachable;
  public:
   oop protection_domain() { return literal(); }
 
   void increment_refcount() {
     assert(_refcount >= 0, "sanity");

@@ -152,11 +156,11 @@
     return _refcount;
   }
 
   void init() {
     _refcount = 0;
-    _scan_generation = 0;
+    _strongly_reachable = false;
   }
 
   ProtectionDomainCacheEntry* next() {
     return (ProtectionDomainCacheEntry*)HashtableEntry<oop, mtClass>::next();
   }

@@ -167,15 +171,29 @@
 
   void oops_do(OopClosure* f) {
     f->do_oop(literal_addr());
   }
 
-  void set_strongly_reachable(int gen) { _scan_generation = gen; }
+  void set_strongly_reachable() { _strongly_reachable = true; }
 
-  bool is_strongly_reachable(int gen) { return _scan_generation == gen; }
+  bool is_strongly_reachable() { return _strongly_reachable; }
+
+  void reset_strongly_reachable() { _strongly_reachable = false; }
+
+  void print() PRODUCT_RETURN;
+  void verify();
 };
 
+// the ProtectionDomainCacheTable contains all protection domain oops. The system
+// dictionary entries reference its entries instead of having references to oops
+// directly.
+// This is used to speed up system dictionary iteration: the oops in the
+// protection domain are the only ones referring the Java heap. So when there is
+// need to update these, instead of going over every entry of the system dictionary,
+// we only need to iterate over this set.
+// The amount of different protection domains used is typically magnitudes smaller
+// than the number of system dictionary entries (loaded classes).
 class ProtectionDomainCacheTable : public Hashtable<oop, mtClass> {
   friend class VMStructs;
 private:
   ProtectionDomainCacheEntry* bucket(int i) {
     return (ProtectionDomainCacheEntry*) Hashtable<oop, mtClass>::bucket(i);

@@ -190,11 +208,11 @@
     ProtectionDomainCacheEntry* entry = (ProtectionDomainCacheEntry*) Hashtable<oop, mtClass>::new_entry(hash, protection_domain);
     entry->init();
     return entry;
   }
 
-  unsigned int compute_hash(oop protection_domain) {
+  static unsigned int compute_hash(oop protection_domain) {
     return (unsigned int)(protection_domain->identity_hash());
   }
 
   int index_for(oop protection_domain) {
     return hash_to_index(compute_hash(protection_domain));

@@ -210,15 +228,15 @@
   ProtectionDomainCacheEntry* get(oop protection_domain);
   void free(ProtectionDomainCacheEntry* entry);
 
   // GC support
   void oops_do(OopClosure* f);
-  void always_strong_oops_do(OopClosure* f, int gen);
+  void always_strong_oops_do(OopClosure* f);
 
-#ifndef PRODUCT
-  void print();
-#endif
+  static uint bucket_size();
+
+  void print() PRODUCT_RETURN;
   void verify();
 };
 
 
 class ProtectionDomainEntry :public CHeapObj<mtClass> {

@@ -233,10 +251,11 @@
     _pd_cache->increment_refcount();
   }
 
   ProtectionDomainEntry* next() { return _next; }
   oop protection_domain() { return _pd_cache->protection_domain(); }
+
   ProtectionDomainCacheEntry * release_pd_cache() {
     if (_pd_cache->decrement_refcount() == 0) {
       return _pd_cache;
     } else {
       return NULL;

@@ -288,15 +307,15 @@
     return protection_domain() == NULL
          ? true
          : contains_protection_domain(protection_domain());
   }
 
-  void set_strongly_reachable(int gen) {
+  void set_strongly_reachable() {
     for (ProtectionDomainEntry* current = _pd_set;
                                 current != NULL;
                                 current = current->_next) {
-      current->_pd_cache->set_strongly_reachable(gen);
+      current->_pd_cache->set_strongly_reachable();
     }
   }
 
   void verify_protection_domain_set() {
     for (ProtectionDomainEntry* current = _pd_set;