src/share/vm/oops/markOop.inline.hpp

changeset 0
f90c822e73f8
child 6876
710a3c8b516e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/oops/markOop.inline.hpp	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,113 @@
     1.4 +/*
     1.5 + * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#ifndef SHARE_VM_OOPS_MARKOOP_INLINE_HPP
    1.29 +#define SHARE_VM_OOPS_MARKOOP_INLINE_HPP
    1.30 +
    1.31 +#include "oops/klass.hpp"
    1.32 +#include "oops/markOop.hpp"
    1.33 +#include "runtime/globals.hpp"
    1.34 +
    1.35 +// Should this header be preserved during GC (when biased locking is enabled)?
    1.36 +inline bool markOopDesc::must_be_preserved_with_bias(oop obj_containing_mark) const {
    1.37 +  assert(UseBiasedLocking, "unexpected");
    1.38 +  if (has_bias_pattern()) {
    1.39 +    // Will reset bias at end of collection
    1.40 +    // Mark words of biased and currently locked objects are preserved separately
    1.41 +    return false;
    1.42 +  }
    1.43 +  markOop prototype_header = prototype_for_object(obj_containing_mark);
    1.44 +  if (prototype_header->has_bias_pattern()) {
    1.45 +    // Individual instance which has its bias revoked; must return
    1.46 +    // true for correctness
    1.47 +    return true;
    1.48 +  }
    1.49 +  return (!is_unlocked() || !has_no_hash());
    1.50 +}
    1.51 +
    1.52 +// Should this header be preserved during GC?
    1.53 +inline bool markOopDesc::must_be_preserved(oop obj_containing_mark) const {
    1.54 +  if (!UseBiasedLocking)
    1.55 +    return (!is_unlocked() || !has_no_hash());
    1.56 +  return must_be_preserved_with_bias(obj_containing_mark);
    1.57 +}
    1.58 +
    1.59 +// Should this header be preserved in the case of a promotion failure
    1.60 +// during scavenge (when biased locking is enabled)?
    1.61 +inline bool markOopDesc::must_be_preserved_with_bias_for_promotion_failure(oop obj_containing_mark) const {
    1.62 +  assert(UseBiasedLocking, "unexpected");
    1.63 +  // We don't explicitly save off the mark words of biased and
    1.64 +  // currently-locked objects during scavenges, so if during a
    1.65 +  // promotion failure we encounter either a biased mark word or a
    1.66 +  // klass which still has a biasable prototype header, we have to
    1.67 +  // preserve the mark word. This results in oversaving, but promotion
    1.68 +  // failures are rare, and this avoids adding more complex logic to
    1.69 +  // the scavengers to call new variants of
    1.70 +  // BiasedLocking::preserve_marks() / restore_marks() in the middle
    1.71 +  // of a scavenge when a promotion failure has first been detected.
    1.72 +  if (has_bias_pattern() ||
    1.73 +      prototype_for_object(obj_containing_mark)->has_bias_pattern()) {
    1.74 +    return true;
    1.75 +  }
    1.76 +  return (!is_unlocked() || !has_no_hash());
    1.77 +}
    1.78 +
    1.79 +// Should this header be preserved in the case of a promotion failure
    1.80 +// during scavenge?
    1.81 +inline bool markOopDesc::must_be_preserved_for_promotion_failure(oop obj_containing_mark) const {
    1.82 +  if (!UseBiasedLocking)
    1.83 +    return (!is_unlocked() || !has_no_hash());
    1.84 +  return must_be_preserved_with_bias_for_promotion_failure(obj_containing_mark);
    1.85 +}
    1.86 +
    1.87 +
    1.88 +// Same as must_be_preserved_with_bias_for_promotion_failure() except that
    1.89 +// it takes a Klass* argument, instead of the object of which this is the mark word.
    1.90 +inline bool markOopDesc::must_be_preserved_with_bias_for_cms_scavenge(Klass* klass_of_obj_containing_mark) const {
    1.91 +  assert(UseBiasedLocking, "unexpected");
    1.92 +  // CMS scavenges preserve mark words in similar fashion to promotion failures; see above
    1.93 +  if (has_bias_pattern() ||
    1.94 +      klass_of_obj_containing_mark->prototype_header()->has_bias_pattern()) {
    1.95 +    return true;
    1.96 +  }
    1.97 +  return (!is_unlocked() || !has_no_hash());
    1.98 +}
    1.99 +
   1.100 +// Same as must_be_preserved_for_promotion_failure() except that
   1.101 +// it takes a Klass* argument, instead of the object of which this is the mark word.
   1.102 +inline bool markOopDesc::must_be_preserved_for_cms_scavenge(Klass* klass_of_obj_containing_mark) const {
   1.103 +  if (!UseBiasedLocking)
   1.104 +    return (!is_unlocked() || !has_no_hash());
   1.105 +  return must_be_preserved_with_bias_for_cms_scavenge(klass_of_obj_containing_mark);
   1.106 +}
   1.107 +
   1.108 +inline markOop markOopDesc::prototype_for_object(oop obj) {
   1.109 +#ifdef ASSERT
   1.110 +  markOop prototype_header = obj->klass()->prototype_header();
   1.111 +  assert(prototype_header == prototype() || prototype_header->has_bias_pattern(), "corrupt prototype header");
   1.112 +#endif
   1.113 +  return obj->klass()->prototype_header();
   1.114 +}
   1.115 +
   1.116 +#endif // SHARE_VM_OOPS_MARKOOP_INLINE_HPP

mercurial