hotspot/src/share/vm/classfile/javaClasses.hpp
changeset 13087 673ea6efaf18
parent 12623 09fcb0dc71ad
child 13091 e2c2f5de7e6a
equal deleted inserted replaced
12943:5ebbcf0cb20f 13087:673ea6efaf18
   156   static char*  as_utf8_string(oop java_string, int start, int len);
   156   static char*  as_utf8_string(oop java_string, int start, int len);
   157   static char*  as_platform_dependent_str(Handle java_string, TRAPS);
   157   static char*  as_platform_dependent_str(Handle java_string, TRAPS);
   158   static jchar* as_unicode_string(oop java_string, int& length);
   158   static jchar* as_unicode_string(oop java_string, int& length);
   159 
   159 
   160   // Compute the hash value for a java.lang.String object which would
   160   // Compute the hash value for a java.lang.String object which would
   161   // contain the characters passed in. This hash value is used for at
   161   // contain the characters passed in.
   162   // least two purposes.
       
   163   //
   162   //
   164   // (a) As the hash value used by the StringTable for bucket selection
   163   // As the hash value used by the String object itself, in
   165   //     and comparison (stored in the HashtableEntry structures).  This
   164   // String.hashCode().  This value is normally calculated in Java code
   166   //     is used in the String.intern() method.
   165   // in the String.hashCode method(), but is precomputed for String
       
   166   // objects in the shared archive file.
       
   167   // hash P(31) from Kernighan & Ritchie
   167   //
   168   //
   168   // (b) As the hash value used by the String object itself, in
   169   // For this reason, THIS ALGORITHM MUST MATCH String.toHash().
   169   //     String.hashCode().  This value is normally calculate in Java code
   170   template <typename T> static unsigned int to_hash(T* s, int len) {
   170   //     in the String.hashCode method(), but is precomputed for String
       
   171   //     objects in the shared archive file.
       
   172   //
       
   173   //     For this reason, THIS ALGORITHM MUST MATCH String.hashCode().
       
   174   static unsigned int hash_string(jchar* s, int len) {
       
   175     unsigned int h = 0;
   171     unsigned int h = 0;
   176     while (len-- > 0) {
   172     while (len-- > 0) {
   177       h = 31*h + (unsigned int) *s;
   173       h = 31*h + (unsigned int) *s;
   178       s++;
   174       s++;
   179     }
   175     }
   180     return h;
   176     return h;
   181   }
   177   }
       
   178   static unsigned int to_hash(oop java_string);
       
   179 
       
   180   // This is the string hash code used by the StringTable, which may be
       
   181   // the same as String.toHash or an alternate hash code.
   182   static unsigned int hash_string(oop java_string);
   182   static unsigned int hash_string(oop java_string);
   183 
   183 
   184   static bool equals(oop java_string, jchar* chars, int len);
   184   static bool equals(oop java_string, jchar* chars, int len);
   185 
   185 
   186   // Conversion between '.' and '/' formats
   186   // Conversion between '.' and '/' formats