duke@435: /* stefank@2314: * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. duke@435: * duke@435: */ duke@435: stefank@2314: #ifndef SHARE_VM_MEMORY_DEFNEWGENERATION_INLINE_HPP stefank@2314: #define SHARE_VM_MEMORY_DEFNEWGENERATION_INLINE_HPP stefank@2314: stefank@2314: #include "memory/cardTableRS.hpp" stefank@2314: #include "memory/defNewGeneration.hpp" stefank@2314: #include "memory/space.hpp" stefank@2314: coleenp@548: // Methods of protected closure types coleenp@548: coleenp@548: template coleenp@548: inline void DefNewGeneration::KeepAliveClosure::do_oop_work(T* p) { coleenp@548: #ifdef ASSERT coleenp@548: { coleenp@548: // We never expect to see a null reference being processed coleenp@548: // as a weak reference. coleenp@548: assert (!oopDesc::is_null(*p), "expected non-null ref"); coleenp@548: oop obj = oopDesc::load_decode_heap_oop_not_null(p); coleenp@548: assert (obj->is_oop(), "expected an oop while scanning weak refs"); coleenp@548: } coleenp@548: #endif // ASSERT coleenp@548: coleenp@548: _cl->do_oop_nv(p); coleenp@548: coleenp@548: // Card marking is trickier for weak refs. coleenp@548: // This oop is a 'next' field which was filled in while we coleenp@548: // were discovering weak references. While we might not need coleenp@548: // to take a special action to keep this reference alive, we coleenp@548: // will need to dirty a card as the field was modified. coleenp@548: // coleenp@548: // Alternatively, we could create a method which iterates through coleenp@548: // each generation, allowing them in turn to examine the modified coleenp@548: // field. coleenp@548: // coleenp@548: // We could check that p is also in an older generation, but coleenp@548: // dirty cards in the youngest gen are never scanned, so the coleenp@548: // extra check probably isn't worthwhile. coleenp@548: if (Universe::heap()->is_in_reserved(p)) { coleenp@548: oop obj = oopDesc::load_decode_heap_oop_not_null(p); coleenp@548: _rs->inline_write_ref_field_gc(p, obj); coleenp@548: } duke@435: } duke@435: coleenp@548: template coleenp@548: inline void DefNewGeneration::FastKeepAliveClosure::do_oop_work(T* p) { coleenp@548: #ifdef ASSERT coleenp@548: { coleenp@548: // We never expect to see a null reference being processed coleenp@548: // as a weak reference. coleenp@548: assert (!oopDesc::is_null(*p), "expected non-null ref"); coleenp@548: oop obj = oopDesc::load_decode_heap_oop_not_null(p); coleenp@548: assert (obj->is_oop(), "expected an oop while scanning weak refs"); duke@435: } coleenp@548: #endif // ASSERT duke@435: coleenp@548: _cl->do_oop_nv(p); coleenp@548: coleenp@548: // Optimized for Defnew generation if it's the youngest generation: coleenp@548: // we set a younger_gen card if we have an older->youngest coleenp@548: // generation pointer. coleenp@548: oop obj = oopDesc::load_decode_heap_oop_not_null(p); coleenp@548: if (((HeapWord*)obj < _boundary) && Universe::heap()->is_in_reserved(p)) { coleenp@548: _rs->inline_write_ref_field_gc(p, obj); duke@435: } duke@435: } stefank@2314: stefank@2314: #endif // SHARE_VM_MEMORY_DEFNEWGENERATION_INLINE_HPP