Path: blob/jdk8u272-b10-aarch32-20201026/hotspot/src/share/vm/gc_implementation/shared/markSweep.inline.hpp
48726 views
/*1* Copyright (c) 2000, 2014, 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_IMPLEMENTATION_SHARED_MARKSWEEP_INLINE_HPP25#define SHARE_VM_GC_IMPLEMENTATION_SHARED_MARKSWEEP_INLINE_HPP2627#include "gc_implementation/shared/markSweep.hpp"28#include "gc_interface/collectedHeap.hpp"29#include "utilities/stack.inline.hpp"30#include "utilities/macros.hpp"31#if INCLUDE_ALL_GCS32#include "gc_implementation/g1/g1StringDedup.hpp"33#include "gc_implementation/parallelScavenge/psParallelCompact.hpp"34#endif // INCLUDE_ALL_GCS3536inline void MarkSweep::mark_object(oop obj) {37#if INCLUDE_ALL_GCS38if (G1StringDedup::is_enabled()) {39// We must enqueue the object before it is marked40// as we otherwise can't read the object's age.41G1StringDedup::enqueue_from_mark(obj);42}43#endif44// some marks may contain information we need to preserve so we store them away45// and overwrite the mark. We'll restore it at the end of markSweep.46markOop mark = obj->mark();47obj->set_mark(markOopDesc::prototype()->set_marked());4849if (mark->must_be_preserved(obj)) {50preserve_mark(obj, mark);51}52}5354inline void MarkSweep::follow_klass(Klass* klass) {55oop op = klass->klass_holder();56MarkSweep::mark_and_push(&op);57}5859template <class T> inline void MarkSweep::follow_root(T* p) {60assert(!Universe::heap()->is_in_reserved(p),61"roots shouldn't be things within the heap");62T heap_oop = oopDesc::load_heap_oop(p);63if (!oopDesc::is_null(heap_oop)) {64oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);65if (!obj->mark()->is_marked()) {66mark_object(obj);67obj->follow_contents();68}69}70follow_stack();71}7273template <class T> inline void MarkSweep::mark_and_push(T* p) {74// assert(Universe::heap()->is_in_reserved(p), "should be in object space");75T heap_oop = oopDesc::load_heap_oop(p);76if (!oopDesc::is_null(heap_oop)) {77oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);78if (!obj->mark()->is_marked()) {79mark_object(obj);80_marking_stack.push(obj);81}82}83}8485void MarkSweep::push_objarray(oop obj, size_t index) {86ObjArrayTask task(obj, index);87assert(task.is_valid(), "bad ObjArrayTask");88_objarray_stack.push(task);89}9091template <class T> inline void MarkSweep::adjust_pointer(T* p) {92T heap_oop = oopDesc::load_heap_oop(p);93if (!oopDesc::is_null(heap_oop)) {94oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);95oop new_obj = oop(obj->mark()->decode_pointer());96assert(new_obj != NULL || // is forwarding ptr?97obj->mark() == markOopDesc::prototype() || // not gc marked?98(UseBiasedLocking && obj->mark()->has_bias_pattern()),99// not gc marked?100"should be forwarded");101if (new_obj != NULL) {102assert(Universe::heap()->is_in_reserved(new_obj),103"should be in object space");104oopDesc::encode_store_heap_oop_not_null(p, new_obj);105}106}107}108109template <class T> inline void MarkSweep::KeepAliveClosure::do_oop_work(T* p) {110mark_and_push(p);111}112113#endif // SHARE_VM_GC_IMPLEMENTATION_SHARED_MARKSWEEP_INLINE_HPP114115116