src/share/vm/classfile/symbolTable.cpp

changeset 2700
352622fd140a
parent 2661
b099aaf51bf8
child 3427
94ec88ca68e2
     1.1 --- a/src/share/vm/classfile/symbolTable.cpp	Thu Mar 31 02:31:57 2011 -0700
     1.2 +++ b/src/share/vm/classfile/symbolTable.cpp	Thu Mar 31 14:00:41 2011 -0700
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -480,33 +480,6 @@
    1.11  
    1.12  
    1.13  // --------------------------------------------------------------------------
    1.14 -
    1.15 -
    1.16 -// Compute the hash value for a java.lang.String object which would
    1.17 -// contain the characters passed in. This hash value is used for at
    1.18 -// least two purposes.
    1.19 -//
    1.20 -// (a) As the hash value used by the StringTable for bucket selection
    1.21 -//     and comparison (stored in the HashtableEntry structures).  This
    1.22 -//     is used in the String.intern() method.
    1.23 -//
    1.24 -// (b) As the hash value used by the String object itself, in
    1.25 -//     String.hashCode().  This value is normally calculate in Java code
    1.26 -//     in the String.hashCode method(), but is precomputed for String
    1.27 -//     objects in the shared archive file.
    1.28 -//
    1.29 -//     For this reason, THIS ALGORITHM MUST MATCH String.hashCode().
    1.30 -
    1.31 -int StringTable::hash_string(jchar* s, int len) {
    1.32 -  unsigned h = 0;
    1.33 -  while (len-- > 0) {
    1.34 -    h = 31*h + (unsigned) *s;
    1.35 -    s++;
    1.36 -  }
    1.37 -  return h;
    1.38 -}
    1.39 -
    1.40 -
    1.41  StringTable* StringTable::_the_table = NULL;
    1.42  
    1.43  oop StringTable::lookup(int index, jchar* name,
    1.44 @@ -561,7 +534,7 @@
    1.45    ResourceMark rm;
    1.46    int length;
    1.47    jchar* chars = symbol->as_unicode(length);
    1.48 -  unsigned int hashValue = hash_string(chars, length);
    1.49 +  unsigned int hashValue = java_lang_String::hash_string(chars, length);
    1.50    int index = the_table()->hash_to_index(hashValue);
    1.51    return the_table()->lookup(index, chars, length, hashValue);
    1.52  }
    1.53 @@ -569,7 +542,7 @@
    1.54  
    1.55  oop StringTable::intern(Handle string_or_null, jchar* name,
    1.56                          int len, TRAPS) {
    1.57 -  unsigned int hashValue = hash_string(name, len);
    1.58 +  unsigned int hashValue = java_lang_String::hash_string(name, len);
    1.59    int index = the_table()->hash_to_index(hashValue);
    1.60    oop string = the_table()->lookup(index, name, len, hashValue);
    1.61  
    1.62 @@ -663,10 +636,7 @@
    1.63        oop s = p->literal();
    1.64        guarantee(s != NULL, "interned string is NULL");
    1.65        guarantee(s->is_perm() || !JavaObjectsInPerm, "interned string not in permspace");
    1.66 -
    1.67 -      int length;
    1.68 -      jchar* chars = java_lang_String::as_unicode_string(s, length);
    1.69 -      unsigned int h = hash_string(chars, length);
    1.70 +      unsigned int h = java_lang_String::hash_string(s);
    1.71        guarantee(p->hash() == h, "broken hash in string table entry");
    1.72        guarantee(the_table()->hash_to_index(h) == i,
    1.73                  "wrong index in string table");

mercurial