src/share/vm/classfile/javaClasses.hpp

changeset 3865
e9140bf80b4a
parent 3760
8f972594effc
child 3869
58ad5f22317e
     1.1 --- a/src/share/vm/classfile/javaClasses.hpp	Mon Jun 11 13:10:14 2012 -0400
     1.2 +++ b/src/share/vm/classfile/javaClasses.hpp	Wed Jun 13 19:52:59 2012 -0400
     1.3 @@ -158,20 +158,16 @@
     1.4    static jchar* as_unicode_string(oop java_string, int& length);
     1.5  
     1.6    // Compute the hash value for a java.lang.String object which would
     1.7 -  // contain the characters passed in. This hash value is used for at
     1.8 -  // least two purposes.
     1.9 +  // contain the characters passed in.
    1.10    //
    1.11 -  // (a) As the hash value used by the StringTable for bucket selection
    1.12 -  //     and comparison (stored in the HashtableEntry structures).  This
    1.13 -  //     is used in the String.intern() method.
    1.14 +  // As the hash value used by the String object itself, in
    1.15 +  // String.hashCode().  This value is normally calculated in Java code
    1.16 +  // in the String.hashCode method(), but is precomputed for String
    1.17 +  // objects in the shared archive file.
    1.18 +  // hash P(31) from Kernighan & Ritchie
    1.19    //
    1.20 -  // (b) As the hash value used by the String object itself, in
    1.21 -  //     String.hashCode().  This value is normally calculate in Java code
    1.22 -  //     in the String.hashCode method(), but is precomputed for String
    1.23 -  //     objects in the shared archive file.
    1.24 -  //
    1.25 -  //     For this reason, THIS ALGORITHM MUST MATCH String.hashCode().
    1.26 -  static unsigned int hash_string(jchar* s, int len) {
    1.27 +  // For this reason, THIS ALGORITHM MUST MATCH String.toHash().
    1.28 +  template <typename T> static unsigned int to_hash(T* s, int len) {
    1.29      unsigned int h = 0;
    1.30      while (len-- > 0) {
    1.31        h = 31*h + (unsigned int) *s;
    1.32 @@ -179,6 +175,10 @@
    1.33      }
    1.34      return h;
    1.35    }
    1.36 +  static unsigned int to_hash(oop java_string);
    1.37 +
    1.38 +  // This is the string hash code used by the StringTable, which may be
    1.39 +  // the same as String.toHash or an alternate hash code.
    1.40    static unsigned int hash_string(oop java_string);
    1.41  
    1.42    static bool equals(oop java_string, jchar* chars, int len);

mercurial