hotspot/src/share/vm/gc/g1/g1StringDedupTable.hpp
changeset 33628 09241459a8b8
parent 30764 fec48bf5a827
child 35061 be6025ebffea
equal deleted inserted replaced
33627:c5b7455f846e 33628:09241459a8b8
    38 //
    38 //
    39 class G1StringDedupEntry : public CHeapObj<mtGC> {
    39 class G1StringDedupEntry : public CHeapObj<mtGC> {
    40 private:
    40 private:
    41   G1StringDedupEntry* _next;
    41   G1StringDedupEntry* _next;
    42   unsigned int      _hash;
    42   unsigned int      _hash;
       
    43   bool              _latin1;
    43   typeArrayOop      _obj;
    44   typeArrayOop      _obj;
    44 
    45 
    45 public:
    46 public:
    46   G1StringDedupEntry() :
    47   G1StringDedupEntry() :
    47     _next(NULL),
    48     _next(NULL),
    48     _hash(0),
    49     _hash(0),
       
    50     _latin1(false),
    49     _obj(NULL) {
    51     _obj(NULL) {
    50   }
    52   }
    51 
    53 
    52   G1StringDedupEntry* next() {
    54   G1StringDedupEntry* next() {
    53     return _next;
    55     return _next;
    65     return _hash;
    67     return _hash;
    66   }
    68   }
    67 
    69 
    68   void set_hash(unsigned int hash) {
    70   void set_hash(unsigned int hash) {
    69     _hash = hash;
    71     _hash = hash;
       
    72   }
       
    73 
       
    74   bool latin1() {
       
    75     return _latin1;
       
    76   }
       
    77 
       
    78   void set_latin1(bool latin1) {
       
    79     _latin1 = latin1;
    70   }
    80   }
    71 
    81 
    72   typeArrayOop obj() {
    82   typeArrayOop obj() {
    73     return _obj;
    83     return _obj;
    74   }
    84   }
   150   size_t hash_to_index(unsigned int hash) {
   160   size_t hash_to_index(unsigned int hash) {
   151     return (size_t)hash & (_size - 1);
   161     return (size_t)hash & (_size - 1);
   152   }
   162   }
   153 
   163 
   154   // Adds a new table entry to the given hash bucket.
   164   // Adds a new table entry to the given hash bucket.
   155   void add(typeArrayOop value, unsigned int hash, G1StringDedupEntry** list);
   165   void add(typeArrayOop value, bool latin1, unsigned int hash, G1StringDedupEntry** list);
   156 
   166 
   157   // Removes the given table entry from the table.
   167   // Removes the given table entry from the table.
   158   void remove(G1StringDedupEntry** pentry, uint worker_id);
   168   void remove(G1StringDedupEntry** pentry, uint worker_id);
   159 
   169 
   160   // Transfers a table entry from the current table to the destination table.
   170   // Transfers a table entry from the current table to the destination table.
   161   void transfer(G1StringDedupEntry** pentry, G1StringDedupTable* dest);
   171   void transfer(G1StringDedupEntry** pentry, G1StringDedupTable* dest);
   162 
   172 
   163   // Returns an existing character array in the given hash bucket, or NULL
   173   // Returns an existing character array in the given hash bucket, or NULL
   164   // if no matching character array exists.
   174   // if no matching character array exists.
   165   typeArrayOop lookup(typeArrayOop value, unsigned int hash,
   175   typeArrayOop lookup(typeArrayOop value, bool latin1, unsigned int hash,
   166                       G1StringDedupEntry** list, uintx &count);
   176                       G1StringDedupEntry** list, uintx &count);
   167 
   177 
   168   // Returns an existing character array in the table, or inserts a new
   178   // Returns an existing character array in the table, or inserts a new
   169   // table entry if no matching character array exists.
   179   // table entry if no matching character array exists.
   170   typeArrayOop lookup_or_add_inner(typeArrayOop value, unsigned int hash);
   180   typeArrayOop lookup_or_add_inner(typeArrayOop value, bool latin1, unsigned int hash);
   171 
   181 
   172   // Thread safe lookup or add of table entry
   182   // Thread safe lookup or add of table entry
   173   static typeArrayOop lookup_or_add(typeArrayOop value, unsigned int hash) {
   183   static typeArrayOop lookup_or_add(typeArrayOop value, bool latin1, unsigned int hash) {
   174     // Protect the table from concurrent access. Also note that this lock
   184     // Protect the table from concurrent access. Also note that this lock
   175     // acts as a fence for _table, which could have been replaced by a new
   185     // acts as a fence for _table, which could have been replaced by a new
   176     // instance if the table was resized or rehashed.
   186     // instance if the table was resized or rehashed.
   177     MutexLockerEx ml(StringDedupTable_lock, Mutex::_no_safepoint_check_flag);
   187     MutexLockerEx ml(StringDedupTable_lock, Mutex::_no_safepoint_check_flag);
   178     return _table->lookup_or_add_inner(value, hash);
   188     return _table->lookup_or_add_inner(value, latin1, hash);
   179   }
   189   }
   180 
   190 
   181   // Returns true if the hashtable is currently using a Java compatible
   191   // Returns true if the hashtable is currently using a Java compatible
   182   // hash function.
   192   // hash function.
   183   static bool use_java_hash() {
   193   static bool use_java_hash() {
   186 
   196 
   187   static bool equals(typeArrayOop value1, typeArrayOop value2);
   197   static bool equals(typeArrayOop value1, typeArrayOop value2);
   188 
   198 
   189   // Computes the hash code for the given character array, using the
   199   // Computes the hash code for the given character array, using the
   190   // currently active hash function and hash seed.
   200   // currently active hash function and hash seed.
   191   static unsigned int hash_code(typeArrayOop value);
   201   static unsigned int hash_code(typeArrayOop value, bool latin1);
   192 
   202 
   193   static uintx unlink_or_oops_do(G1StringDedupUnlinkOrOopsDoClosure* cl,
   203   static uintx unlink_or_oops_do(G1StringDedupUnlinkOrOopsDoClosure* cl,
   194                                  size_t partition_begin,
   204                                  size_t partition_begin,
   195                                  size_t partition_end,
   205                                  size_t partition_end,
   196                                  uint worker_id);
   206                                  uint worker_id);