< prev index next >

src/hotspot/share/classfile/altHashing.cpp

Print this page




   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  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 #include "precompiled.hpp"
  26 #include "classfile/altHashing.hpp"
  27 #include "classfile/symbolTable.hpp"
  28 #include "classfile/systemDictionary.hpp"
  29 #include "oops/markWord.hpp"
  30 #include "oops/oop.inline.hpp"
  31 #include "runtime/thread.hpp"
  32 
  33 // Get the hash code of the classes mirror if it exists, otherwise just
  34 // return a random number, which is one of the possible hash code used for
  35 // objects.  We don't want to call the synchronizer hash code to install
  36 // this value because it may safepoint.
  37 static intptr_t object_hash(Klass* k) {
  38   intptr_t hc = k->java_mirror()->mark().hash();
  39   return hc != markWord::no_hash ? hc : os::random();
  40 }
  41 
  42 // Seed value used for each alternative hash calculated.
  43 juint AltHashing::compute_seed() {
  44   jlong nanos = os::javaTimeNanos();
  45   jlong now = os::javaTimeMillis();
  46   jint SEED_MATERIAL[8] = {
  47             (jint) object_hash(SystemDictionary::String_klass()),
  48             (jint) object_hash(SystemDictionary::System_klass()),
  49             (jint) os::random(),  // current thread isn't a java thread
  50             (jint) (((julong)nanos) >> 32),
  51             (jint) nanos,
  52             (jint) (((julong)now) >> 32),
  53             (jint) now,
  54             (jint) (os::javaTimeNanos() >> 2)
  55   };
  56 
  57   return murmur3_32(SEED_MATERIAL, 8);
  58 }
  59 




   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  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 #include "precompiled.hpp"
  26 #include "classfile/altHashing.hpp"
  27 #include "classfile/symbolTable.hpp"
  28 #include "classfile/systemDictionary.hpp"
  29 #include "oops/markOop.hpp"
  30 #include "oops/oop.inline.hpp"
  31 #include "runtime/thread.hpp"
  32 
  33 // Get the hash code of the classes mirror if it exists, otherwise just
  34 // return a random number, which is one of the possible hash code used for
  35 // objects.  We don't want to call the synchronizer hash code to install
  36 // this value because it may safepoint.
  37 static intptr_t object_hash(Klass* k) {
  38   intptr_t hc = k->java_mirror()->mark()->hash();
  39   return hc != markOopDesc::no_hash ? hc : os::random();
  40 }
  41 
  42 // Seed value used for each alternative hash calculated.
  43 juint AltHashing::compute_seed() {
  44   jlong nanos = os::javaTimeNanos();
  45   jlong now = os::javaTimeMillis();
  46   jint SEED_MATERIAL[8] = {
  47             (jint) object_hash(SystemDictionary::String_klass()),
  48             (jint) object_hash(SystemDictionary::System_klass()),
  49             (jint) os::random(),  // current thread isn't a java thread
  50             (jint) (((julong)nanos) >> 32),
  51             (jint) nanos,
  52             (jint) (((julong)now) >> 32),
  53             (jint) now,
  54             (jint) (os::javaTimeNanos() >> 2)
  55   };
  56 
  57   return murmur3_32(SEED_MATERIAL, 8);
  58 }
  59 


< prev index next >