# HG changeset patch # User iklam # Date 1392141902 28800 # Node ID d2c32004414fda0ee7cc21274315679243c3ad5a # Parent c6b6abb73544b1e54896f6252533fe8e45bbdbe8# Parent b2cbb3680b4f5b8a0784ecee032e31e7d64a19e1 Merge diff -r c6b6abb73544 -r d2c32004414f hotspot/make/bsd/makefiles/optimized.make --- a/hotspot/make/bsd/makefiles/optimized.make Tue Feb 11 08:43:17 2014 -0800 +++ b/hotspot/make/bsd/makefiles/optimized.make Tue Feb 11 10:05:02 2014 -0800 @@ -22,7 +22,7 @@ # # -# Sets make macros for making optimized version of Gamma VM +# Sets make macros for making optimized version of HotSpot VM # (This is the "product", not the "release" version.) # Compiler specific OPT_CFLAGS are passed in from gcc.make, sparcWorks.make diff -r c6b6abb73544 -r d2c32004414f hotspot/make/bsd/makefiles/product.make --- a/hotspot/make/bsd/makefiles/product.make Tue Feb 11 08:43:17 2014 -0800 +++ b/hotspot/make/bsd/makefiles/product.make Tue Feb 11 10:05:02 2014 -0800 @@ -22,7 +22,7 @@ # # -# Sets make macros for making optimized version of Gamma VM +# Sets make macros for making optimized version of HotSpot VM # (This is the "product", not the "release" version.) # Compiler specific OPT_CFLAGS are passed in from gcc.make, sparcWorks.make diff -r c6b6abb73544 -r d2c32004414f hotspot/make/bsd/makefiles/top.make --- a/hotspot/make/bsd/makefiles/top.make Tue Feb 11 08:43:17 2014 -0800 +++ b/hotspot/make/bsd/makefiles/top.make Tue Feb 11 10:05:02 2014 -0800 @@ -128,7 +128,7 @@ @$(UpdatePCH) @$(MAKE) -f vm.make $(MFLAGS-adjusted) -install gamma: the_vm +install : the_vm @$(MAKE) -f vm.make $@ # next rules support "make foo.[ois]" diff -r c6b6abb73544 -r d2c32004414f hotspot/make/linux/makefiles/optimized.make --- a/hotspot/make/linux/makefiles/optimized.make Tue Feb 11 08:43:17 2014 -0800 +++ b/hotspot/make/linux/makefiles/optimized.make Tue Feb 11 10:05:02 2014 -0800 @@ -22,7 +22,7 @@ # # -# Sets make macros for making optimized version of Gamma VM +# Sets make macros for making optimized version of HotSpot VM # (This is the "product", not the "release" version.) # Compiler specific OPT_CFLAGS are passed in from gcc.make, sparcWorks.make diff -r c6b6abb73544 -r d2c32004414f hotspot/make/linux/makefiles/product.make --- a/hotspot/make/linux/makefiles/product.make Tue Feb 11 08:43:17 2014 -0800 +++ b/hotspot/make/linux/makefiles/product.make Tue Feb 11 10:05:02 2014 -0800 @@ -22,7 +22,7 @@ # # -# Sets make macros for making optimized version of Gamma VM +# Sets make macros for making optimized version of HotSpot VM # (This is the "product", not the "release" version.) # Compiler specific OPT_CFLAGS are passed in from gcc.make, sparcWorks.make diff -r c6b6abb73544 -r d2c32004414f hotspot/make/linux/makefiles/top.make --- a/hotspot/make/linux/makefiles/top.make Tue Feb 11 08:43:17 2014 -0800 +++ b/hotspot/make/linux/makefiles/top.make Tue Feb 11 10:05:02 2014 -0800 @@ -122,7 +122,7 @@ @$(UpdatePCH) @$(MAKE) -f vm.make $(MFLAGS-adjusted) -install gamma: the_vm +install: the_vm @$(MAKE) -f vm.make $@ # next rules support "make foo.[ois]" diff -r c6b6abb73544 -r d2c32004414f hotspot/make/solaris/makefiles/optimized.make --- a/hotspot/make/solaris/makefiles/optimized.make Tue Feb 11 08:43:17 2014 -0800 +++ b/hotspot/make/solaris/makefiles/optimized.make Tue Feb 11 10:05:02 2014 -0800 @@ -22,7 +22,7 @@ # # -# Sets make macros for making optimized version of Gamma VM +# Sets make macros for making optimized version of HotSpot VM # (This is the "product", not the "release" version.) # Compiler specific OPT_CFLAGS are passed in from gcc.make, sparcWorks.make diff -r c6b6abb73544 -r d2c32004414f hotspot/make/solaris/makefiles/product.make --- a/hotspot/make/solaris/makefiles/product.make Tue Feb 11 08:43:17 2014 -0800 +++ b/hotspot/make/solaris/makefiles/product.make Tue Feb 11 10:05:02 2014 -0800 @@ -22,7 +22,7 @@ # # -# Sets make macros for making optimized version of Gamma VM +# Sets make macros for making optimized version of HotSpot VM # (This is the "product", not the "release" version.) # Compiler specific OPT_CFLAGS are passed in from gcc.make, sparcWorks.make diff -r c6b6abb73544 -r d2c32004414f hotspot/make/solaris/makefiles/top.make --- a/hotspot/make/solaris/makefiles/top.make Tue Feb 11 08:43:17 2014 -0800 +++ b/hotspot/make/solaris/makefiles/top.make Tue Feb 11 10:05:02 2014 -0800 @@ -114,7 +114,7 @@ the_vm: vm_build_preliminaries $(adjust-mflags) @$(MAKE) -f vm.make $(MFLAGS-adjusted) -install gamma: the_vm +install: the_vm @$(MAKE) -f vm.make $@ # next rules support "make foo.[oi]" diff -r c6b6abb73544 -r d2c32004414f hotspot/src/share/vm/classfile/altHashing.cpp --- a/hotspot/src/share/vm/classfile/altHashing.cpp Tue Feb 11 08:43:17 2014 -0800 +++ b/hotspot/src/share/vm/classfile/altHashing.cpp Tue Feb 11 10:05:02 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,18 +39,18 @@ } // Seed value used for each alternative hash calculated. -jint AltHashing::compute_seed() { +juint AltHashing::compute_seed() { jlong nanos = os::javaTimeNanos(); jlong now = os::javaTimeMillis(); - jint SEED_MATERIAL[8] = { - (jint) object_hash(SystemDictionary::String_klass()), - (jint) object_hash(SystemDictionary::System_klass()), - (jint) os::random(), // current thread isn't a java thread - (jint) (((julong)nanos) >> 32), - (jint) nanos, - (jint) (((julong)now) >> 32), - (jint) now, - (jint) (os::javaTimeNanos() >> 2) + int SEED_MATERIAL[8] = { + (int) object_hash(SystemDictionary::String_klass()), + (int) object_hash(SystemDictionary::System_klass()), + (int) os::random(), // current thread isn't a java thread + (int) (((julong)nanos) >> 32), + (int) nanos, + (int) (((julong)now) >> 32), + (int) now, + (int) (os::javaTimeNanos() >> 2) }; return murmur3_32(SEED_MATERIAL, 8); @@ -58,14 +58,14 @@ // Murmur3 hashing for Symbol -jint AltHashing::murmur3_32(jint seed, const jbyte* data, int len) { - jint h1 = seed; +juint AltHashing::murmur3_32(juint seed, const jbyte* data, int len) { + juint h1 = seed; int count = len; int offset = 0; // body while (count >= 4) { - jint k1 = (data[offset] & 0x0FF) + juint k1 = (data[offset] & 0x0FF) | (data[offset + 1] & 0x0FF) << 8 | (data[offset + 2] & 0x0FF) << 16 | data[offset + 3] << 24; @@ -85,7 +85,7 @@ // tail if (count > 0) { - jint k1 = 0; + juint k1 = 0; switch (count) { case 3: @@ -109,18 +109,18 @@ h1 ^= len; // finalization mix force all bits of a hash block to avalanche - h1 ^= ((unsigned int)h1) >> 16; + h1 ^= h1 >> 16; h1 *= 0x85ebca6b; - h1 ^= ((unsigned int)h1) >> 13; + h1 ^= h1 >> 13; h1 *= 0xc2b2ae35; - h1 ^= ((unsigned int)h1) >> 16; + h1 ^= h1 >> 16; return h1; } // Murmur3 hashing for Strings -jint AltHashing::murmur3_32(jint seed, const jchar* data, int len) { - jint h1 = seed; +juint AltHashing::murmur3_32(juint seed, const jchar* data, int len) { + juint h1 = seed; int off = 0; int count = len; @@ -129,7 +129,7 @@ while (count >= 2) { jchar d1 = data[off++] & 0xFFFF; jchar d2 = data[off++]; - jint k1 = (d1 | d2 << 16); + juint k1 = (d1 | d2 << 16); count -= 2; @@ -145,7 +145,7 @@ // tail if (count > 0) { - int k1 = data[off]; + juint k1 = (juint)data[off]; k1 *= 0xcc9e2d51; k1 = Integer_rotateLeft(k1, 15); @@ -157,25 +157,25 @@ h1 ^= len * 2; // (Character.SIZE / Byte.SIZE); // finalization mix force all bits of a hash block to avalanche - h1 ^= ((unsigned int)h1) >> 16; + h1 ^= h1 >> 16; h1 *= 0x85ebca6b; - h1 ^= ((unsigned int)h1) >> 13; + h1 ^= h1 >> 13; h1 *= 0xc2b2ae35; - h1 ^= ((unsigned int)h1) >> 16; + h1 ^= h1 >> 16; return h1; } // Hash used for the seed. -jint AltHashing::murmur3_32(jint seed, const int* data, int len) { - jint h1 = seed; +juint AltHashing::murmur3_32(juint seed, const int* data, int len) { + juint h1 = seed; int off = 0; int end = len; // body while (off < end) { - jint k1 = data[off++]; + juint k1 = (juint)data[off++]; k1 *= 0xcc9e2d51; k1 = Integer_rotateLeft(k1, 15); @@ -193,26 +193,26 @@ h1 ^= len * 4; // (Integer.SIZE / Byte.SIZE); // finalization mix force all bits of a hash block to avalanche - h1 ^= ((juint)h1) >> 16; + h1 ^= h1 >> 16; h1 *= 0x85ebca6b; - h1 ^= ((juint)h1) >> 13; + h1 ^= h1 >> 13; h1 *= 0xc2b2ae35; - h1 ^= ((juint)h1) >> 16; + h1 ^= h1 >> 16; return h1; } -jint AltHashing::murmur3_32(const int* data, int len) { +juint AltHashing::murmur3_32(const int* data, int len) { return murmur3_32(0, data, len); } #ifndef PRODUCT // Overloaded versions for internal test. -jint AltHashing::murmur3_32(const jbyte* data, int len) { +juint AltHashing::murmur3_32(const jbyte* data, int len) { return murmur3_32(0, data, len); } -jint AltHashing::murmur3_32(const jchar* data, int len) { +juint AltHashing::murmur3_32(const jchar* data, int len) { return murmur3_32(0, data, len); } @@ -251,11 +251,11 @@ // Hash subranges {}, {0}, {0,1}, {0,1,2}, ..., {0,...,255} for (int i = 0; i < 256; i++) { - jint hash = murmur3_32(256 - i, vector, i); + juint hash = murmur3_32(256 - i, vector, i); hashes[i * 4] = (jbyte) hash; - hashes[i * 4 + 1] = (jbyte) (((juint)hash) >> 8); - hashes[i * 4 + 2] = (jbyte) (((juint)hash) >> 16); - hashes[i * 4 + 3] = (jbyte) (((juint)hash) >> 24); + hashes[i * 4 + 1] = (jbyte)(hash >> 8); + hashes[i * 4 + 2] = (jbyte)(hash >> 16); + hashes[i * 4 + 3] = (jbyte)(hash >> 24); } // hash to get const result. @@ -269,7 +269,7 @@ } void AltHashing::testEquivalentHashes() { - jint jbytes, jchars, ints; + juint jbytes, jchars, ints; // printf("testEquivalentHashes\n"); diff -r c6b6abb73544 -r d2c32004414f hotspot/src/share/vm/classfile/altHashing.hpp --- a/hotspot/src/share/vm/classfile/altHashing.hpp Tue Feb 11 08:43:17 2014 -0800 +++ b/hotspot/src/share/vm/classfile/altHashing.hpp Tue Feb 11 10:05:02 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,24 +39,24 @@ class AltHashing : AllStatic { // utility function copied from java/lang/Integer - static jint Integer_rotateLeft(jint i, int distance) { - return (i << distance) | (((juint)i) >> (32-distance)); + static juint Integer_rotateLeft(juint i, int distance) { + return (i << distance) | (i >> (32-distance)); } - static jint murmur3_32(const int* data, int len); - static jint murmur3_32(jint seed, const int* data, int len); + static juint murmur3_32(const int* data, int len); + static juint murmur3_32(juint seed, const int* data, int len); #ifndef PRODUCT // Hashing functions used for internal testing - static jint murmur3_32(const jbyte* data, int len); - static jint murmur3_32(const jchar* data, int len); + static juint murmur3_32(const jbyte* data, int len); + static juint murmur3_32(const jchar* data, int len); static void testMurmur3_32_ByteArray(); static void testEquivalentHashes(); #endif // PRODUCT public: - static jint compute_seed(); - static jint murmur3_32(jint seed, const jbyte* data, int len); - static jint murmur3_32(jint seed, const jchar* data, int len); + static juint compute_seed(); + static juint murmur3_32(juint seed, const jbyte* data, int len); + static juint murmur3_32(juint seed, const jchar* data, int len); NOT_PRODUCT(static void test_alt_hash();) }; #endif // SHARE_VM_CLASSFILE_ALTHASHING_HPP diff -r c6b6abb73544 -r d2c32004414f hotspot/src/share/vm/oops/instanceKlass.hpp --- a/hotspot/src/share/vm/oops/instanceKlass.hpp Tue Feb 11 08:43:17 2014 -0800 +++ b/hotspot/src/share/vm/oops/instanceKlass.hpp Tue Feb 11 10:05:02 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -554,6 +554,7 @@ if (hk == NULL) { return NULL; } else { + assert(*hk != NULL, "host klass should always be set if the address is not null"); return *hk; } } diff -r c6b6abb73544 -r d2c32004414f hotspot/src/share/vm/oops/metadata.hpp --- a/hotspot/src/share/vm/oops/metadata.hpp Tue Feb 11 08:43:17 2014 -0800 +++ b/hotspot/src/share/vm/oops/metadata.hpp Tue Feb 11 10:05:02 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,7 @@ int identity_hash() { return (int)(uintptr_t)this; } // Rehashing support for tables containing pointers to this - unsigned int new_hash(jint seed) { ShouldNotReachHere(); return 0; } + unsigned int new_hash(juint seed) { ShouldNotReachHere(); return 0; } virtual bool is_klass() const volatile { return false; } virtual bool is_method() const volatile { return false; } diff -r c6b6abb73544 -r d2c32004414f hotspot/src/share/vm/oops/oop.cpp --- a/hotspot/src/share/vm/oops/oop.cpp Tue Feb 11 08:43:17 2014 -0800 +++ b/hotspot/src/share/vm/oops/oop.cpp Tue Feb 11 10:05:02 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -102,7 +102,7 @@ } // When String table needs to rehash -unsigned int oopDesc::new_hash(jint seed) { +unsigned int oopDesc::new_hash(juint seed) { EXCEPTION_MARK; ResourceMark rm; int length; diff -r c6b6abb73544 -r d2c32004414f hotspot/src/share/vm/oops/oop.hpp --- a/hotspot/src/share/vm/oops/oop.hpp Tue Feb 11 08:43:17 2014 -0800 +++ b/hotspot/src/share/vm/oops/oop.hpp Tue Feb 11 10:05:02 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -362,7 +362,7 @@ intptr_t slow_identity_hash(); // Alternate hashing code if string table is rehashed - unsigned int new_hash(jint seed); + unsigned int new_hash(juint seed); // marks are forwarded to stack when object is locked bool has_displaced_mark() const; diff -r c6b6abb73544 -r d2c32004414f hotspot/src/share/vm/oops/symbol.cpp --- a/hotspot/src/share/vm/oops/symbol.cpp Tue Feb 11 08:43:17 2014 -0800 +++ b/hotspot/src/share/vm/oops/symbol.cpp Tue Feb 11 10:05:02 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -207,7 +207,7 @@ } // Alternate hashing for unbalanced symbol tables. -unsigned int Symbol::new_hash(jint seed) { +unsigned int Symbol::new_hash(juint seed) { ResourceMark rm; // Use alternate hashing algorithm on this symbol. return AltHashing::murmur3_32(seed, (const jbyte*)as_C_string(), utf8_length()); diff -r c6b6abb73544 -r d2c32004414f hotspot/src/share/vm/oops/symbol.hpp --- a/hotspot/src/share/vm/oops/symbol.hpp Tue Feb 11 08:43:17 2014 -0800 +++ b/hotspot/src/share/vm/oops/symbol.hpp Tue Feb 11 10:05:02 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -154,7 +154,7 @@ int identity_hash() { return _identity_hash; } // For symbol table alternate hashing - unsigned int new_hash(jint seed); + unsigned int new_hash(juint seed); // Reference counting. See comments above this class for when to use. int refcount() const { return _refcount; } diff -r c6b6abb73544 -r d2c32004414f hotspot/src/share/vm/prims/jvm.cpp --- a/hotspot/src/share/vm/prims/jvm.cpp Tue Feb 11 08:43:17 2014 -0800 +++ b/hotspot/src/share/vm/prims/jvm.cpp Tue Feb 11 10:05:02 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -518,6 +518,12 @@ JavaThreadInObjectWaitState jtiows(thread, ms != 0); if (JvmtiExport::should_post_monitor_wait()) { JvmtiExport::post_monitor_wait((JavaThread *)THREAD, (oop)obj(), ms); + + // The current thread already owns the monitor and it has not yet + // been added to the wait queue so the current thread cannot be + // made the successor. This means that the JVMTI_EVENT_MONITOR_WAIT + // event handler cannot accidentally consume an unpark() meant for + // the ParkEvent associated with this ObjectMonitor. } ObjectSynchronizer::wait(obj, ms, CHECK); JVM_END diff -r c6b6abb73544 -r d2c32004414f hotspot/src/share/vm/runtime/objectMonitor.cpp --- a/hotspot/src/share/vm/runtime/objectMonitor.cpp Tue Feb 11 08:43:17 2014 -0800 +++ b/hotspot/src/share/vm/runtime/objectMonitor.cpp Tue Feb 11 10:05:02 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -382,6 +382,12 @@ DTRACE_MONITOR_PROBE(contended__enter, this, object(), jt); if (JvmtiExport::should_post_monitor_contended_enter()) { JvmtiExport::post_monitor_contended_enter(jt, this); + + // The current thread does not yet own the monitor and does not + // yet appear on any queues that would get it made the successor. + // This means that the JVMTI_EVENT_MONITOR_CONTENDED_ENTER event + // handler cannot accidentally consume an unpark() meant for the + // ParkEvent associated with this ObjectMonitor. } OSThreadContendState osts(Self->osthread()); @@ -439,6 +445,12 @@ DTRACE_MONITOR_PROBE(contended__entered, this, object(), jt); if (JvmtiExport::should_post_monitor_contended_entered()) { JvmtiExport::post_monitor_contended_entered(jt, this); + + // The current thread already owns the monitor and is not going to + // call park() for the remainder of the monitor enter protocol. So + // it doesn't matter if the JVMTI_EVENT_MONITOR_CONTENDED_ENTERED + // event handler consumed an unpark() issued by the thread that + // just exited the monitor. } if (event.should_commit()) { @@ -1456,6 +1468,14 @@ // Note: 'false' parameter is passed here because the // wait was not timed out due to thread interrupt. JvmtiExport::post_monitor_waited(jt, this, false); + + // In this short circuit of the monitor wait protocol, the + // current thread never drops ownership of the monitor and + // never gets added to the wait queue so the current thread + // cannot be made the successor. This means that the + // JVMTI_EVENT_MONITOR_WAITED event handler cannot accidentally + // consume an unpark() meant for the ParkEvent associated with + // this ObjectMonitor. } if (event.should_commit()) { post_monitor_wait_event(&event, 0, millis, false); @@ -1499,21 +1519,6 @@ exit (true, Self) ; // exit the monitor guarantee (_owner != Self, "invariant") ; - // As soon as the ObjectMonitor's ownership is dropped in the exit() - // call above, another thread can enter() the ObjectMonitor, do the - // notify(), and exit() the ObjectMonitor. If the other thread's - // exit() call chooses this thread as the successor and the unpark() - // call happens to occur while this thread is posting a - // MONITOR_CONTENDED_EXIT event, then we run the risk of the event - // handler using RawMonitors and consuming the unpark(). - // - // To avoid the problem, we re-post the event. This does no harm - // even if the original unpark() was not consumed because we are the - // chosen successor for this monitor. - if (node._notified != 0 && _succ == Self) { - node._event->unpark(); - } - // The thread is on the WaitSet list - now park() it. // On MP systems it's conceivable that a brief spin before we park // could be profitable. @@ -1595,6 +1600,25 @@ // post monitor waited event. Note that this is past-tense, we are done waiting. if (JvmtiExport::should_post_monitor_waited()) { JvmtiExport::post_monitor_waited(jt, this, ret == OS_TIMEOUT); + + if (node._notified != 0 && _succ == Self) { + // In this part of the monitor wait-notify-reenter protocol it + // is possible (and normal) for another thread to do a fastpath + // monitor enter-exit while this thread is still trying to get + // to the reenter portion of the protocol. + // + // The ObjectMonitor was notified and the current thread is + // the successor which also means that an unpark() has already + // been done. The JVMTI_EVENT_MONITOR_WAITED event handler can + // consume the unpark() that was done when the successor was + // set because the same ParkEvent is shared between Java + // monitors and JVM/TI RawMonitors (for now). + // + // We redo the unpark() to ensure forward progress, i.e., we + // don't want all pending threads hanging (parked) with none + // entering the unlocked monitor. + node._event->unpark(); + } } if (event.should_commit()) { diff -r c6b6abb73544 -r d2c32004414f hotspot/src/share/vm/utilities/hashtable.cpp --- a/hotspot/src/share/vm/utilities/hashtable.cpp Tue Feb 11 08:43:17 2014 -0800 +++ b/hotspot/src/share/vm/utilities/hashtable.cpp Tue Feb 11 10:05:02 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -93,7 +93,7 @@ return false; } -template jint Hashtable::_seed = 0; +template juint Hashtable::_seed = 0; // Create a new table and using alternate hash code, populate the new table // with the existing elements. This can be used to change the hash code diff -r c6b6abb73544 -r d2c32004414f hotspot/src/share/vm/utilities/hashtable.hpp --- a/hotspot/src/share/vm/utilities/hashtable.hpp Tue Feb 11 08:43:17 2014 -0800 +++ b/hotspot/src/share/vm/utilities/hashtable.hpp Tue Feb 11 10:05:02 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -280,7 +280,7 @@ // Function to move these elements into the new table. void move_to(Hashtable* new_table); static bool use_alternate_hashcode() { return _seed != 0; } - static jint seed() { return _seed; } + static juint seed() { return _seed; } static int literal_size(Symbol *symbol); static int literal_size(oop oop); @@ -296,7 +296,7 @@ void dump_table(outputStream* st, const char *table_name); private: - static jint _seed; + static juint _seed; };