< prev index next >

src/share/vm/classfile/stringTable.hpp

Print this page




  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_CLASSFILE_STRINGTABLE_HPP
  26 #define SHARE_VM_CLASSFILE_STRINGTABLE_HPP
  27 
  28 #include "memory/allocation.inline.hpp"
  29 #include "utilities/hashtable.hpp"
  30 




  31 class StringTable : public RehashableHashtable<oop, mtSymbol> {
  32   friend class VMStructs;
  33   friend class Symbol;
  34 
  35 private:
  36   // The string table
  37   static StringTable* _the_table;
  38 




  39   // Set if one bucket is out of balance due to hash algorithm deficiency
  40   static bool _needs_rehashing;
  41 
  42   // Claimed high water mark for parallel chunked scanning
  43   static volatile int _parallel_claimed_idx;
  44 
  45   static oop intern(Handle string_or_null, jchar* chars, int length, TRAPS);
  46   oop basic_add(int index, Handle string_or_null, jchar* name, int len,
  47                 unsigned int hashValue, TRAPS);
  48 
  49   oop lookup(int index, jchar* chars, int length, unsigned int hashValue);

  50 
  51   // Apply the give oop closure to the entries to the buckets
  52   // in the range [start_idx, end_idx).
  53   static void buckets_oops_do(OopClosure* f, int start_idx, int end_idx);
  54   // Unlink or apply the give oop closure to the entries to the buckets
  55   // in the range [start_idx, end_idx).
  56   static void buckets_unlink_or_oops_do(BoolObjectClosure* is_alive, OopClosure* f, int start_idx, int end_idx, int* processed, int* removed);
  57 
  58   StringTable() : RehashableHashtable<oop, mtSymbol>((int)StringTableSize,
  59                               sizeof (HashtableEntry<oop, mtSymbol>)) {}
  60 
  61   StringTable(HashtableBucket<mtSymbol>* t, int number_of_entries)
  62     : RehashableHashtable<oop, mtSymbol>((int)StringTableSize, sizeof (HashtableEntry<oop, mtSymbol>), t,
  63                      number_of_entries) {}
  64 public:
  65   // The string table
  66   static StringTable* the_table() { return _the_table; }
  67 
  68   // Size of one bucket in the string table.  Used when checking for rollover.
  69   static uint bucket_size() { return sizeof(HashtableBucket<mtSymbol>); }


 124     _verify_quietly    = 0,
 125     _verify_with_mesgs = 1
 126   };
 127 
 128   enum VerifyRetTypes {
 129     _verify_pass          = 0,
 130     _verify_fail_continue = 1,
 131     _verify_fail_done     = 2
 132   };
 133 
 134   static VerifyRetTypes compare_entries(int bkt1, int e_cnt1,
 135                                         HashtableEntry<oop, mtSymbol>* e_ptr1,
 136                                         int bkt2, int e_cnt2,
 137                                         HashtableEntry<oop, mtSymbol>* e_ptr2);
 138   static VerifyRetTypes verify_entry(int bkt, int e_cnt,
 139                                      HashtableEntry<oop, mtSymbol>* e_ptr,
 140                                      VerifyMesgModes mesg_mode);
 141   static int verify_and_compare_entries();
 142 
 143   // Sharing
 144   static void copy_buckets(char** top, char*end) {
 145     the_table()->Hashtable<oop, mtSymbol>::copy_buckets(top, end);
 146   }
 147   static void copy_table(char** top, char*end) {
 148     the_table()->Hashtable<oop, mtSymbol>::copy_table(top, end);
 149   }


 150   static void reverse() {
 151     the_table()->Hashtable<oop, mtSymbol>::reverse();
 152   }
 153 
 154   // Rehash the symbol table if it gets out of balance
 155   static void rehash_table();
 156   static bool needs_rehashing() { return _needs_rehashing; }
 157 
 158   // Parallel chunked scanning
 159   static void clear_parallel_claimed_index() { _parallel_claimed_idx = 0; }
 160   static int parallel_claimed_index() { return _parallel_claimed_idx; }
 161 };
 162 #endif // SHARE_VM_CLASSFILE_STRINGTABLE_HPP


  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_CLASSFILE_STRINGTABLE_HPP
  26 #define SHARE_VM_CLASSFILE_STRINGTABLE_HPP
  27 
  28 #include "memory/allocation.inline.hpp"
  29 #include "utilities/hashtable.hpp"
  30 
  31 template <class T, class N> class CompactHashtable;
  32 class CompactHashtableWriter;
  33 class FileMapInfo;
  34 
  35 class StringTable : public RehashableHashtable<oop, mtSymbol> {
  36   friend class VMStructs;
  37   friend class Symbol;
  38 
  39 private:
  40   // The string table
  41   static StringTable* _the_table;
  42 
  43   // Shared string table
  44   static CompactHashtable<oop, char> _shared_table;
  45   static bool _ignore_shared_strings;
  46 
  47   // Set if one bucket is out of balance due to hash algorithm deficiency
  48   static bool _needs_rehashing;
  49 
  50   // Claimed high water mark for parallel chunked scanning
  51   static volatile int _parallel_claimed_idx;
  52   
  53   static oop intern(Handle string_or_null, jchar* chars, int length, TRAPS);
  54   oop basic_add(int index, Handle string_or_null, jchar* name, int len,
  55                 unsigned int hashValue, TRAPS);
  56 
  57   oop lookup_dynamic(int index, jchar* chars, int length, unsigned int hashValue);
  58   static oop lookup_shared(jchar* name, int len);
  59 
  60   // Apply the give oop closure to the entries to the buckets
  61   // in the range [start_idx, end_idx).
  62   static void buckets_oops_do(OopClosure* f, int start_idx, int end_idx);
  63   // Unlink or apply the give oop closure to the entries to the buckets
  64   // in the range [start_idx, end_idx).
  65   static void buckets_unlink_or_oops_do(BoolObjectClosure* is_alive, OopClosure* f, int start_idx, int end_idx, int* processed, int* removed);
  66 
  67   StringTable() : RehashableHashtable<oop, mtSymbol>((int)StringTableSize,
  68                               sizeof (HashtableEntry<oop, mtSymbol>)) {}
  69 
  70   StringTable(HashtableBucket<mtSymbol>* t, int number_of_entries)
  71     : RehashableHashtable<oop, mtSymbol>((int)StringTableSize, sizeof (HashtableEntry<oop, mtSymbol>), t,
  72                      number_of_entries) {}
  73 public:
  74   // The string table
  75   static StringTable* the_table() { return _the_table; }
  76 
  77   // Size of one bucket in the string table.  Used when checking for rollover.
  78   static uint bucket_size() { return sizeof(HashtableBucket<mtSymbol>); }


 133     _verify_quietly    = 0,
 134     _verify_with_mesgs = 1
 135   };
 136 
 137   enum VerifyRetTypes {
 138     _verify_pass          = 0,
 139     _verify_fail_continue = 1,
 140     _verify_fail_done     = 2
 141   };
 142 
 143   static VerifyRetTypes compare_entries(int bkt1, int e_cnt1,
 144                                         HashtableEntry<oop, mtSymbol>* e_ptr1,
 145                                         int bkt2, int e_cnt2,
 146                                         HashtableEntry<oop, mtSymbol>* e_ptr2);
 147   static VerifyRetTypes verify_entry(int bkt, int e_cnt,
 148                                      HashtableEntry<oop, mtSymbol>* e_ptr,
 149                                      VerifyMesgModes mesg_mode);
 150   static int verify_and_compare_entries();
 151 
 152   // Sharing
 153   static void ignore_shared_strings(bool v) { _ignore_shared_strings = v; }
 154   static bool shared_string_ignored()       { return _ignore_shared_strings; }
 155   static void shared_oops_do(OopClosure* f);
 156   static bool copy_shared_string(GrowableArray<MemRegion> *string_space,
 157                                  CompactHashtableWriter* ch_table);
 158   static bool copy_compact_table(char** top, char* end, GrowableArray<MemRegion> *string_space,
 159                                  size_t* space_size);
 160   static const char* init_shared_table(FileMapInfo *mapinfo, char* buffer);
 161   static void reverse() {
 162     the_table()->Hashtable<oop, mtSymbol>::reverse();
 163   }
 164 
 165   // Rehash the symbol table if it gets out of balance
 166   static void rehash_table();
 167   static bool needs_rehashing() { return _needs_rehashing; }
 168 
 169   // Parallel chunked scanning
 170   static void clear_parallel_claimed_index() { _parallel_claimed_idx = 0; }
 171   static int parallel_claimed_index() { return _parallel_claimed_idx; }
 172 };
 173 #endif // SHARE_VM_CLASSFILE_STRINGTABLE_HPP
< prev index next >