1 #ifdef USE_PRAGMA_IDENT_HDR 2 #pragma ident "@(#)instanceRefKlass.hpp 1.62 07/05/29 09:44:21 JVM" 3 #endif 4 /* 5 * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved. 6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7 * 8 * This code is free software; you can redistribute it and/or modify it 9 * under the terms of the GNU General Public License version 2 only, as 10 * published by the Free Software Foundation. 11 * 12 * This code is distributed in the hope that it will be useful, but WITHOUT 13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 * version 2 for more details (a copy is included in the LICENSE file that 16 * accompanied this code). 17 * 18 * You should have received a copy of the GNU General Public License version 19 * 2 along with this work; if not, write to the Free Software Foundation, 20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 21 * 22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 23 * CA 95054 USA or visit www.sun.com if you need additional information or 24 * have any questions. 25 * 26 */ 27 28 // An instanceRefKlass is a specialized instanceKlass for Java 29 // classes that are subclasses of java/lang/ref/Reference. 30 // 31 // These classes are used to implement soft/weak/final/phantom 32 // references and finalization, and need special treatment by the 33 // garbage collector. 34 // 35 // During GC discovered reference objects are added (chained) to one 36 // of the four lists below, depending on the type of reference. 37 // The linked occurs through the next field in class java/lang/ref/Reference. 38 // 39 // Afterwards, the discovered references are processed in decreasing 40 // order of reachability. Reference objects eligible for notification 41 // are linked to the static pending_list in class java/lang/ref/Reference, 42 // and the pending list lock object in the same class is notified. 43 44 45 class instanceRefKlass: public instanceKlass { 46 public: 47 // Type testing 48 bool oop_is_instanceRef() const { return true; } 49 50 // Casting from klassOop 51 static instanceRefKlass* cast(klassOop k) { 52 assert(k->klass_part()->oop_is_instanceRef(), "cast to instanceRefKlass"); 53 return (instanceRefKlass*) k->klass_part(); 54 } 55 56 // allocation 57 DEFINE_ALLOCATE_PERMANENT(instanceRefKlass); 58 59 // Garbage collection 60 int oop_adjust_pointers(oop obj); 61 void oop_follow_contents(oop obj); 62 63 // Parallel Scavenge and Parallel Old 64 PARALLEL_GC_DECLS 65 66 int oop_oop_iterate(oop obj, OopClosure* blk) { 67 return oop_oop_iterate_v(obj, blk); 68 } 69 int oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) { 70 return oop_oop_iterate_v_m(obj, blk, mr); 71 } 72 73 #define InstanceRefKlass_OOP_OOP_ITERATE_DECL(OopClosureType, nv_suffix) \ 74 int oop_oop_iterate##nv_suffix(oop obj, OopClosureType* blk); \ 75 int oop_oop_iterate##nv_suffix##_m(oop obj, OopClosureType* blk, MemRegion mr); 76 77 ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceRefKlass_OOP_OOP_ITERATE_DECL) 78 ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceRefKlass_OOP_OOP_ITERATE_DECL) 79 80 #ifndef SERIALGC 81 #define InstanceRefKlass_OOP_OOP_ITERATE_BACKWARDS_DECL(OopClosureType, nv_suffix) \ 82 int oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* blk); 83 84 ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceRefKlass_OOP_OOP_ITERATE_BACKWARDS_DECL) 85 ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceRefKlass_OOP_OOP_ITERATE_BACKWARDS_DECL) 86 #endif // !SERIALGC 87 88 static void release_and_notify_pending_list_lock(BasicLock *pending_list_basic_lock); 89 static void acquire_pending_list_lock(BasicLock *pending_list_basic_lock); 90 91 // Update non-static oop maps so 'referent', 'nextPending' and 92 // 'discovered' will look like non-oops 93 static void update_nonstatic_oop_maps(klassOop k); 94 95 public: 96 // Verification 97 void oop_verify_on(oop obj, outputStream* st); 98 };