7 * published by the Free Software Foundation.
8 *
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/vmSymbols.hpp"
27 #include "memory/padded.hpp"
28 #include "memory/resourceArea.hpp"
29 #include "oops/markOop.hpp"
30 #include "oops/oop.inline.hpp"
31 #include "runtime/atomic.inline.hpp"
32 #include "runtime/biasedLocking.hpp"
33 #include "runtime/handles.inline.hpp"
34 #include "runtime/interfaceSupport.hpp"
35 #include "runtime/mutexLocker.hpp"
36 #include "runtime/objectMonitor.hpp"
37 #include "runtime/objectMonitor.inline.hpp"
38 #include "runtime/osThread.hpp"
39 #include "runtime/stubRoutines.hpp"
40 #include "runtime/synchronizer.hpp"
41 #include "runtime/thread.inline.hpp"
42 #include "utilities/dtrace.hpp"
43 #include "utilities/events.hpp"
44 #include "utilities/preserveException.hpp"
45
46 #if defined(__GNUC__) && !defined(PPC64)
621 // objects. However, we only ever bias Java instances and all of
622 // the call sites of identity_hash that might revoke biases have
623 // been checked to make sure they can handle a safepoint. The
624 // added check of the bias pattern is to avoid useless calls to
625 // thread-local storage.
626 if (obj->mark()->has_bias_pattern()) {
627 // Handle for oop obj in case of STW safepoint
628 Handle hobj(Self, obj);
629 // Relaxing assertion for bug 6320749.
630 assert(Universe::verify_in_progress() ||
631 !SafepointSynchronize::is_at_safepoint(),
632 "biases should not be seen by VM thread here");
633 BiasedLocking::revoke_and_rebias(hobj, false, JavaThread::current());
634 obj = hobj();
635 assert(!obj->mark()->has_bias_pattern(), "biases should be revoked by now");
636 }
637 }
638
639 // hashCode() is a heap mutator ...
640 // Relaxing assertion for bug 6320749.
641 assert(Universe::verify_in_progress() ||
642 !SafepointSynchronize::is_at_safepoint(), "invariant");
643 assert(Universe::verify_in_progress() ||
644 Self->is_Java_thread() , "invariant");
645 assert(Universe::verify_in_progress() ||
646 ((JavaThread *)Self)->thread_state() != _thread_blocked, "invariant");
647
648 ObjectMonitor* monitor = NULL;
649 markOop temp, test;
650 intptr_t hash;
651 markOop mark = ReadStableMark(obj);
652
653 // object should remain ineligible for biased locking
654 assert(!mark->has_bias_pattern(), "invariant");
655
656 if (mark->is_neutral()) {
657 hash = mark->hash(); // this is a normal header
658 if (hash) { // if it has hash, just return it
659 return hash;
660 }
661 hash = get_next_hash(Self, obj); // allocate a new hash code
662 temp = mark->copy_set_hash(hash); // merge the hash code into header
663 // use (machine word version) atomic operation to install the hash
664 test = (markOop) Atomic::cmpxchg_ptr(temp, obj->mark_addr(), mark);
665 if (test == mark) {
|
7 * published by the Free Software Foundation.
8 *
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/vmSymbols.hpp"
27 #include "memory/metaspaceShared.hpp"
28 #include "memory/padded.hpp"
29 #include "memory/resourceArea.hpp"
30 #include "oops/markOop.hpp"
31 #include "oops/oop.inline.hpp"
32 #include "runtime/atomic.inline.hpp"
33 #include "runtime/biasedLocking.hpp"
34 #include "runtime/handles.inline.hpp"
35 #include "runtime/interfaceSupport.hpp"
36 #include "runtime/mutexLocker.hpp"
37 #include "runtime/objectMonitor.hpp"
38 #include "runtime/objectMonitor.inline.hpp"
39 #include "runtime/osThread.hpp"
40 #include "runtime/stubRoutines.hpp"
41 #include "runtime/synchronizer.hpp"
42 #include "runtime/thread.inline.hpp"
43 #include "utilities/dtrace.hpp"
44 #include "utilities/events.hpp"
45 #include "utilities/preserveException.hpp"
46
47 #if defined(__GNUC__) && !defined(PPC64)
622 // objects. However, we only ever bias Java instances and all of
623 // the call sites of identity_hash that might revoke biases have
624 // been checked to make sure they can handle a safepoint. The
625 // added check of the bias pattern is to avoid useless calls to
626 // thread-local storage.
627 if (obj->mark()->has_bias_pattern()) {
628 // Handle for oop obj in case of STW safepoint
629 Handle hobj(Self, obj);
630 // Relaxing assertion for bug 6320749.
631 assert(Universe::verify_in_progress() ||
632 !SafepointSynchronize::is_at_safepoint(),
633 "biases should not be seen by VM thread here");
634 BiasedLocking::revoke_and_rebias(hobj, false, JavaThread::current());
635 obj = hobj();
636 assert(!obj->mark()->has_bias_pattern(), "biases should be revoked by now");
637 }
638 }
639
640 // hashCode() is a heap mutator ...
641 // Relaxing assertion for bug 6320749.
642 assert(Universe::verify_in_progress() || DumpSharedSpaces ||
643 !SafepointSynchronize::is_at_safepoint(), "invariant");
644 assert(Universe::verify_in_progress() || DumpSharedSpaces ||
645 Self->is_Java_thread() , "invariant");
646 assert(Universe::verify_in_progress() || DumpSharedSpaces ||
647 ((JavaThread *)Self)->thread_state() != _thread_blocked, "invariant");
648
649 ObjectMonitor* monitor = NULL;
650 markOop temp, test;
651 intptr_t hash;
652 markOop mark = ReadStableMark(obj);
653
654 // object should remain ineligible for biased locking
655 assert(!mark->has_bias_pattern(), "invariant");
656
657 if (mark->is_neutral()) {
658 hash = mark->hash(); // this is a normal header
659 if (hash) { // if it has hash, just return it
660 return hash;
661 }
662 hash = get_next_hash(Self, obj); // allocate a new hash code
663 temp = mark->copy_set_hash(hash); // merge the hash code into header
664 // use (machine word version) atomic operation to install the hash
665 test = (markOop) Atomic::cmpxchg_ptr(temp, obj->mark_addr(), mark);
666 if (test == mark) {
|