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

changeset 435
a61af66fc99e
child 777
37f87013dfd8
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/oops/markOop.inline.hpp	Sat Dec 01 00:00:00 2007 +0000
     1.3 @@ -0,0 +1,80 @@
     1.4 +/*
     1.5 + * Copyright 2006 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
    1.24 + * have any questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +// Should this header be preserved during GC?
    1.29 +inline bool markOopDesc::must_be_preserved_with_bias(oop obj_containing_mark) const {
    1.30 +  assert(UseBiasedLocking, "unexpected");
    1.31 +  if (has_bias_pattern()) {
    1.32 +    // Will reset bias at end of collection
    1.33 +    // Mark words of biased and currently locked objects are preserved separately
    1.34 +    return false;
    1.35 +  }
    1.36 +  markOop prototype_header = prototype_for_object(obj_containing_mark);
    1.37 +  if (prototype_header->has_bias_pattern()) {
    1.38 +    // Individual instance which has its bias revoked; must return
    1.39 +    // true for correctness
    1.40 +    return true;
    1.41 +  }
    1.42 +  return (!is_unlocked() || !has_no_hash());
    1.43 +}
    1.44 +
    1.45 +// Should this header (including its age bits) be preserved in the
    1.46 +// case of a promotion failure during scavenge?
    1.47 +inline bool markOopDesc::must_be_preserved_with_bias_for_promotion_failure(oop obj_containing_mark) const {
    1.48 +  assert(UseBiasedLocking, "unexpected");
    1.49 +  // We don't explicitly save off the mark words of biased and
    1.50 +  // currently-locked objects during scavenges, so if during a
    1.51 +  // promotion failure we encounter either a biased mark word or a
    1.52 +  // klass which still has a biasable prototype header, we have to
    1.53 +  // preserve the mark word. This results in oversaving, but promotion
    1.54 +  // failures are rare, and this avoids adding more complex logic to
    1.55 +  // the scavengers to call new variants of
    1.56 +  // BiasedLocking::preserve_marks() / restore_marks() in the middle
    1.57 +  // of a scavenge when a promotion failure has first been detected.
    1.58 +  if (has_bias_pattern() ||
    1.59 +      prototype_for_object(obj_containing_mark)->has_bias_pattern()) {
    1.60 +    return true;
    1.61 +  }
    1.62 +  return (this != prototype());
    1.63 +}
    1.64 +
    1.65 +// Should this header (including its age bits) be preserved in the
    1.66 +// case of a scavenge in which CMS is the old generation?
    1.67 +inline bool markOopDesc::must_be_preserved_with_bias_for_cms_scavenge(klassOop klass_of_obj_containing_mark) const {
    1.68 +  assert(UseBiasedLocking, "unexpected");
    1.69 +  // CMS scavenges preserve mark words in similar fashion to promotion failures; see above
    1.70 +  if (has_bias_pattern() ||
    1.71 +      klass_of_obj_containing_mark->klass_part()->prototype_header()->has_bias_pattern()) {
    1.72 +    return true;
    1.73 +  }
    1.74 +  return (this != prototype());
    1.75 +}
    1.76 +
    1.77 +inline markOop markOopDesc::prototype_for_object(oop obj) {
    1.78 +#ifdef ASSERT
    1.79 +  markOop prototype_header = obj->klass()->klass_part()->prototype_header();
    1.80 +  assert(prototype_header == prototype() || prototype_header->has_bias_pattern(), "corrupt prototype header");
    1.81 +#endif
    1.82 +  return obj->klass()->klass_part()->prototype_header();
    1.83 +}

mercurial