Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/oops/markOop.inline.hpp
32285 views
/*1* Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_VM_OOPS_MARKOOP_INLINE_HPP25#define SHARE_VM_OOPS_MARKOOP_INLINE_HPP2627#include "oops/klass.hpp"28#include "oops/markOop.hpp"29#include "runtime/globals.hpp"3031// Should this header be preserved during GC (when biased locking is enabled)?32inline bool markOopDesc::must_be_preserved_with_bias(oop obj_containing_mark) const {33assert(UseBiasedLocking, "unexpected");34if (has_bias_pattern()) {35// Will reset bias at end of collection36// Mark words of biased and currently locked objects are preserved separately37return false;38}39markOop prototype_header = prototype_for_object(obj_containing_mark);40if (prototype_header->has_bias_pattern()) {41// Individual instance which has its bias revoked; must return42// true for correctness43return true;44}45return (!is_unlocked() || !has_no_hash());46}4748// Should this header be preserved during GC?49inline bool markOopDesc::must_be_preserved(oop obj_containing_mark) const {50if (!UseBiasedLocking)51return (!is_unlocked() || !has_no_hash());52return must_be_preserved_with_bias(obj_containing_mark);53}5455// Should this header be preserved in the case of a promotion failure56// during scavenge (when biased locking is enabled)?57inline bool markOopDesc::must_be_preserved_with_bias_for_promotion_failure(oop obj_containing_mark) const {58assert(UseBiasedLocking, "unexpected");59// We don't explicitly save off the mark words of biased and60// currently-locked objects during scavenges, so if during a61// promotion failure we encounter either a biased mark word or a62// klass which still has a biasable prototype header, we have to63// preserve the mark word. This results in oversaving, but promotion64// failures are rare, and this avoids adding more complex logic to65// the scavengers to call new variants of66// BiasedLocking::preserve_marks() / restore_marks() in the middle67// of a scavenge when a promotion failure has first been detected.68if (has_bias_pattern() ||69prototype_for_object(obj_containing_mark)->has_bias_pattern()) {70return true;71}72return (!is_unlocked() || !has_no_hash());73}7475// Should this header be preserved in the case of a promotion failure76// during scavenge?77inline bool markOopDesc::must_be_preserved_for_promotion_failure(oop obj_containing_mark) const {78if (!UseBiasedLocking)79return (!is_unlocked() || !has_no_hash());80return must_be_preserved_with_bias_for_promotion_failure(obj_containing_mark);81}828384// Same as must_be_preserved_with_bias_for_promotion_failure() except that85// it takes a Klass* argument, instead of the object of which this is the mark word.86inline bool markOopDesc::must_be_preserved_with_bias_for_cms_scavenge(Klass* klass_of_obj_containing_mark) const {87assert(UseBiasedLocking, "unexpected");88// CMS scavenges preserve mark words in similar fashion to promotion failures; see above89if (has_bias_pattern() ||90klass_of_obj_containing_mark->prototype_header()->has_bias_pattern()) {91return true;92}93return (!is_unlocked() || !has_no_hash());94}9596// Same as must_be_preserved_for_promotion_failure() except that97// it takes a Klass* argument, instead of the object of which this is the mark word.98inline bool markOopDesc::must_be_preserved_for_cms_scavenge(Klass* klass_of_obj_containing_mark) const {99if (!UseBiasedLocking)100return (!is_unlocked() || !has_no_hash());101return must_be_preserved_with_bias_for_cms_scavenge(klass_of_obj_containing_mark);102}103104inline markOop markOopDesc::prototype_for_object(oop obj) {105#ifdef ASSERT106markOop prototype_header = obj->klass()->prototype_header();107assert(prototype_header == prototype() || prototype_header->has_bias_pattern(), "corrupt prototype header");108#endif109return obj->klass()->prototype_header();110}111112#endif // SHARE_VM_OOPS_MARKOOP_INLINE_HPP113114115