hotspot/src/share/vm/oops/instanceRefKlass.hpp
changeset 13728 882756847a04
parent 7446 9193aa209467
child 13738 d67be49a5beb
equal deleted inserted replaced
13727:caf5eb7dd4a7 13728:882756847a04
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    25 #ifndef SHARE_VM_OOPS_INSTANCEREFKLASS_HPP
    25 #ifndef SHARE_VM_OOPS_INSTANCEREFKLASS_HPP
    26 #define SHARE_VM_OOPS_INSTANCEREFKLASS_HPP
    26 #define SHARE_VM_OOPS_INSTANCEREFKLASS_HPP
    27 
    27 
    28 #include "oops/instanceKlass.hpp"
    28 #include "oops/instanceKlass.hpp"
    29 
    29 
    30 // An instanceRefKlass is a specialized instanceKlass for Java
    30 // An instanceRefKlass is a specialized InstanceKlass for Java
    31 // classes that are subclasses of java/lang/ref/Reference.
    31 // classes that are subclasses of java/lang/ref/Reference.
    32 //
    32 //
    33 // These classes are used to implement soft/weak/final/phantom
    33 // These classes are used to implement soft/weak/final/phantom
    34 // references and finalization, and need special treatment by the
    34 // references and finalization, and need special treatment by the
    35 // garbage collector.
    35 // garbage collector.
    42 // order of reachability. Reference objects eligible for notification
    42 // order of reachability. Reference objects eligible for notification
    43 // are linked to the static pending_list in class java/lang/ref/Reference,
    43 // are linked to the static pending_list in class java/lang/ref/Reference,
    44 // and the pending list lock object in the same class is notified.
    44 // and the pending list lock object in the same class is notified.
    45 
    45 
    46 
    46 
    47 class instanceRefKlass: public instanceKlass {
    47 class instanceRefKlass: public InstanceKlass {
       
    48   friend class InstanceKlass;
       
    49 
       
    50   // Constructor
       
    51   instanceRefKlass(int vtable_len, int itable_len, int static_field_size, int nonstatic_oop_map_size, ReferenceType rt, AccessFlags access_flags, bool is_anonymous)
       
    52     : InstanceKlass(vtable_len, itable_len, static_field_size, nonstatic_oop_map_size, rt, access_flags, is_anonymous) {}
       
    53 
    48  public:
    54  public:
       
    55   instanceRefKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for CDS"); }
    49   // Type testing
    56   // Type testing
    50   bool oop_is_instanceRef() const             { return true; }
    57   bool oop_is_instanceRef() const             { return true; }
    51 
    58 
    52   // Casting from klassOop
    59   // Casting from Klass*
    53   static instanceRefKlass* cast(klassOop k) {
    60   static instanceRefKlass* cast(Klass* k) {
    54     assert(k->klass_part()->oop_is_instanceRef(), "cast to instanceRefKlass");
    61     assert(k->oop_is_instanceRef(), "cast to instanceRefKlass");
    55     return (instanceRefKlass*) k->klass_part();
    62     return (instanceRefKlass*) k;
    56   }
    63   }
    57 
       
    58   // allocation
       
    59   DEFINE_ALLOCATE_PERMANENT(instanceRefKlass);
       
    60 
    64 
    61   // Garbage collection
    65   // Garbage collection
    62   int  oop_adjust_pointers(oop obj);
    66   int  oop_adjust_pointers(oop obj);
    63   void oop_follow_contents(oop obj);
    67   void oop_follow_contents(oop obj);
    64 
    68 
    65   // Parallel Scavenge and Parallel Old
    69   // Parallel Scavenge and Parallel Old
    66   PARALLEL_GC_DECLS
    70   PARALLEL_GC_DECLS
    67 
    71 
    68   int oop_oop_iterate(oop obj, OopClosure* blk) {
    72   int oop_oop_iterate(oop obj, ExtendedOopClosure* blk) {
    69     return oop_oop_iterate_v(obj, blk);
    73     return oop_oop_iterate_v(obj, blk);
    70   }
    74   }
    71   int oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) {
    75   int oop_oop_iterate_m(oop obj, ExtendedOopClosure* blk, MemRegion mr) {
    72     return oop_oop_iterate_v_m(obj, blk, mr);
    76     return oop_oop_iterate_v_m(obj, blk, mr);
    73   }
    77   }
    74 
    78 
    75 #define InstanceRefKlass_OOP_OOP_ITERATE_DECL(OopClosureType, nv_suffix)                \
    79 #define InstanceRefKlass_OOP_OOP_ITERATE_DECL(OopClosureType, nv_suffix)                \
    76   int oop_oop_iterate##nv_suffix(oop obj, OopClosureType* blk);                         \
    80   int oop_oop_iterate##nv_suffix(oop obj, OopClosureType* blk);                         \
    91   static void acquire_pending_list_lock(BasicLock *pending_list_basic_lock);
    95   static void acquire_pending_list_lock(BasicLock *pending_list_basic_lock);
    92   static bool owns_pending_list_lock(JavaThread* thread);
    96   static bool owns_pending_list_lock(JavaThread* thread);
    93 
    97 
    94   // Update non-static oop maps so 'referent', 'nextPending' and
    98   // Update non-static oop maps so 'referent', 'nextPending' and
    95   // 'discovered' will look like non-oops
    99   // 'discovered' will look like non-oops
    96   static void update_nonstatic_oop_maps(klassOop k);
   100   static void update_nonstatic_oop_maps(Klass* k);
    97 
   101 
    98  public:
   102  public:
    99   // Verification
   103   // Verification
   100   void oop_verify_on(oop obj, outputStream* st);
   104   void oop_verify_on(oop obj, outputStream* st);
   101 };
   105 };