src/share/vm/oops/instanceRefKlass.hpp

Thu, 04 Apr 2019 17:56:29 +0800

author
aoqi
date
Thu, 04 Apr 2019 17:56:29 +0800
changeset 9572
624a0741915c
parent 6876
710a3c8b516e
permissions
-rw-r--r--

Merge

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

mercurial