Path: blob/master/src/hotspot/share/gc/serial/defNewGeneration.inline.hpp
41152 views
/*1* Copyright (c) 2001, 2019, 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_GC_SERIAL_DEFNEWGENERATION_INLINE_HPP25#define SHARE_GC_SERIAL_DEFNEWGENERATION_INLINE_HPP2627#include "gc/serial/defNewGeneration.hpp"2829#include "gc/shared/cardTableRS.hpp"30#include "gc/shared/genCollectedHeap.hpp"31#include "gc/shared/genOopClosures.inline.hpp"32#include "gc/shared/space.inline.hpp"33#include "oops/access.inline.hpp"3435// Methods of protected closure types3637template <class T>38inline void DefNewGeneration::KeepAliveClosure::do_oop_work(T* p) {39#ifdef ASSERT40{41// We never expect to see a null reference being processed42// as a weak reference.43oop obj = RawAccess<IS_NOT_NULL>::oop_load(p);44assert (oopDesc::is_oop(obj), "expected an oop while scanning weak refs");45}46#endif // ASSERT4748Devirtualizer::do_oop(_cl, p);4950// Card marking is trickier for weak refs.51// This oop is a 'next' field which was filled in while we52// were discovering weak references. While we might not need53// to take a special action to keep this reference alive, we54// will need to dirty a card as the field was modified.55//56// Alternatively, we could create a method which iterates through57// each generation, allowing them in turn to examine the modified58// field.59//60// We could check that p is also in the old generation, but61// dirty cards in the young gen are never scanned, so the62// extra check probably isn't worthwhile.63if (GenCollectedHeap::heap()->is_in_reserved(p)) {64_rs->inline_write_ref_field_gc(p);65}66}6768template <class T>69inline void DefNewGeneration::FastKeepAliveClosure::do_oop_work(T* p) {70#ifdef ASSERT71{72// We never expect to see a null reference being processed73// as a weak reference.74oop obj = RawAccess<IS_NOT_NULL>::oop_load(p);75assert (oopDesc::is_oop(obj), "expected an oop while scanning weak refs");76}77#endif // ASSERT7879Devirtualizer::do_oop(_cl, p);8081// Optimized for Defnew generation if it's the youngest generation:82// we set a younger_gen card if we have an older->youngest83// generation pointer.84oop obj = RawAccess<IS_NOT_NULL>::oop_load(p);85if ((cast_from_oop<HeapWord*>(obj) < _boundary) && GenCollectedHeap::heap()->is_in_reserved(p)) {86_rs->inline_write_ref_field_gc(p);87}88}8990template <typename OopClosureType>91void DefNewGeneration::oop_since_save_marks_iterate(OopClosureType* cl) {92eden()->oop_since_save_marks_iterate(cl);93to()->oop_since_save_marks_iterate(cl);94from()->oop_since_save_marks_iterate(cl);9596save_marks();97}9899#endif // SHARE_GC_SERIAL_DEFNEWGENERATION_INLINE_HPP100101102