src/share/vm/runtime/biasedLocking.cpp

changeset 882
2b42b31e7928
parent 631
d1605aabd0a1
child 1253
b109e761e927
     1.1 --- a/src/share/vm/runtime/biasedLocking.cpp	Wed Nov 12 11:23:13 2008 -0500
     1.2 +++ b/src/share/vm/runtime/biasedLocking.cpp	Fri Nov 21 08:09:11 2008 -0800
     1.3 @@ -582,13 +582,19 @@
     1.4    if (heuristics == HR_NOT_BIASED) {
     1.5      return NOT_BIASED;
     1.6    } else if (heuristics == HR_SINGLE_REVOKE) {
     1.7 -    if (mark->biased_locker() == THREAD) {
     1.8 +    Klass *k = Klass::cast(obj->klass());
     1.9 +    markOop prototype_header = k->prototype_header();
    1.10 +    if (mark->biased_locker() == THREAD &&
    1.11 +        prototype_header->bias_epoch() == mark->bias_epoch()) {
    1.12        // A thread is trying to revoke the bias of an object biased
    1.13        // toward it, again likely due to an identity hash code
    1.14        // computation. We can again avoid a safepoint in this case
    1.15        // since we are only going to walk our own stack. There are no
    1.16        // races with revocations occurring in other threads because we
    1.17        // reach no safepoints in the revocation path.
    1.18 +      // Also check the epoch because even if threads match, another thread
    1.19 +      // can come in with a CAS to steal the bias of an object that has a
    1.20 +      // stale epoch.
    1.21        ResourceMark rm;
    1.22        if (TraceBiasedLocking) {
    1.23          tty->print_cr("Revoking bias by walking my own stack:");

mercurial