Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/memory/defNewGeneration.inline.hpp
32285 views
/*1* Copyright (c) 2001, 2010, 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_MEMORY_DEFNEWGENERATION_INLINE_HPP25#define SHARE_VM_MEMORY_DEFNEWGENERATION_INLINE_HPP2627#include "memory/cardTableRS.hpp"28#include "memory/defNewGeneration.hpp"29#include "memory/space.hpp"3031// Methods of protected closure types3233template <class T>34inline void DefNewGeneration::KeepAliveClosure::do_oop_work(T* p) {35#ifdef ASSERT36{37// We never expect to see a null reference being processed38// as a weak reference.39assert (!oopDesc::is_null(*p), "expected non-null ref");40oop obj = oopDesc::load_decode_heap_oop_not_null(p);41assert (obj->is_oop(), "expected an oop while scanning weak refs");42}43#endif // ASSERT4445_cl->do_oop_nv(p);4647// Card marking is trickier for weak refs.48// This oop is a 'next' field which was filled in while we49// were discovering weak references. While we might not need50// to take a special action to keep this reference alive, we51// will need to dirty a card as the field was modified.52//53// Alternatively, we could create a method which iterates through54// each generation, allowing them in turn to examine the modified55// field.56//57// We could check that p is also in an older generation, but58// dirty cards in the youngest gen are never scanned, so the59// extra check probably isn't worthwhile.60if (Universe::heap()->is_in_reserved(p)) {61oop obj = oopDesc::load_decode_heap_oop_not_null(p);62_rs->inline_write_ref_field_gc(p, obj);63}64}6566template <class T>67inline void DefNewGeneration::FastKeepAliveClosure::do_oop_work(T* p) {68#ifdef ASSERT69{70// We never expect to see a null reference being processed71// as a weak reference.72assert (!oopDesc::is_null(*p), "expected non-null ref");73oop obj = oopDesc::load_decode_heap_oop_not_null(p);74assert (obj->is_oop(), "expected an oop while scanning weak refs");75}76#endif // ASSERT7778_cl->do_oop_nv(p);7980// Optimized for Defnew generation if it's the youngest generation:81// we set a younger_gen card if we have an older->youngest82// generation pointer.83oop obj = oopDesc::load_decode_heap_oop_not_null(p);84if (((HeapWord*)obj < _boundary) && Universe::heap()->is_in_reserved(p)) {85_rs->inline_write_ref_field_gc(p, obj);86}87}8889#endif // SHARE_VM_MEMORY_DEFNEWGENERATION_INLINE_HPP909192