Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/gc_implementation/shenandoah/preservedMarks.inline.hpp
38920 views
/*1* Copyright (c) 2016, 2018 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_GC_SHARED_PRESERVEDMARKS_INLINE_HPP25#define SHARE_VM_GC_SHARED_PRESERVEDMARKS_INLINE_HPP2627#include "gc_implementation/shenandoah/preservedMarks.hpp"28#include "gc_implementation/shenandoah/shenandoahLogging.hpp"29#include "oops/oop.inline.hpp"30#include "utilities/stack.inline.hpp"3132inline bool PreservedMarks::should_preserve_mark(oop obj, markOop m) const {33return m->must_be_preserved_for_promotion_failure(obj);34}3536inline void PreservedMarks::push(oop obj, markOop m) {37assert(should_preserve_mark(obj, m), "pre-condition");38OopAndMarkOop elem(obj, m);39_stack.push(elem);40}4142inline void PreservedMarks::push_if_necessary(oop obj, markOop m) {43if (should_preserve_mark(obj, m)) {44push(obj, m);45}46}4748inline void PreservedMarks::init_forwarded_mark(oop obj) {49obj->init_mark();50}5152inline void PreservedMarksSet::restore(RestorePreservedMarksTaskExecutor* executor) {53volatile size_t total_size = 0;5455#ifdef ASSERT56// This is to make sure the total_size we'll calculate below is correct.57size_t total_size_before = 0;58for (uint i = 0; i < _num; i += 1) {59total_size_before += get(i)->size();60}61#endif // def ASSERT6263executor->restore(this, &total_size);64assert_empty();6566assert(total_size == total_size_before,67err_msg("total_size = " SIZE_FORMAT " before = " SIZE_FORMAT,68total_size, total_size_before));6970log_trace(gc)("Restored " SIZE_FORMAT " marks", total_size);71}7273inline PreservedMarks::PreservedMarks()74: _stack(OopAndMarkOopStack::default_segment_size(),75// This stack should be used very infrequently so there's76// no point in caching stack segments (there will be a77// waste of space most of the time). So we set the max78// cache size to 0.790 /* max_cache_size */) { }8081void PreservedMarks::OopAndMarkOop::set_mark() const {82_o->set_mark(_m);83}8485#endif // SHARE_VM_GC_SHARED_PRESERVEDMARKS_INLINE_HPP868788