src/share/vm/oops/instanceMirrorKlass.hpp

Print this page
rev 6796 : [mq]: templateOopIterate


  29 #include "oops/instanceKlass.hpp"
  30 #include "runtime/handles.hpp"
  31 #include "utilities/macros.hpp"
  32 
  33 // An InstanceMirrorKlass is a specialized InstanceKlass for
  34 // java.lang.Class instances.  These instances are special because
  35 // they contain the static fields of the class in addition to the
  36 // normal fields of Class.  This means they are variable sized
  37 // instances and need special logic for computing their size and for
  38 // iteration of their oops.
  39 
  40 
  41 class InstanceMirrorKlass: public InstanceKlass {
  42   friend class VMStructs;
  43   friend class InstanceKlass;
  44 
  45  private:
  46   static int _offset_of_static_fields;
  47 
  48   // Constructor
  49   InstanceMirrorKlass(int vtable_len, int itable_len, int static_field_size, int nonstatic_oop_map_size, ReferenceType rt, AccessFlags access_flags,  bool is_anonymous)
  50     : InstanceKlass(vtable_len, itable_len, static_field_size, nonstatic_oop_map_size, rt, access_flags, is_anonymous) {}
  51 
  52  public:
  53   InstanceMirrorKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for CDS"); }
  54   // Type testing
  55   bool oop_is_instanceMirror() const             { return true; }
  56 
  57   // Casting from Klass*
  58   static InstanceMirrorKlass* cast(Klass* k) {
  59     assert(k->oop_is_instanceMirror(), "cast to InstanceMirrorKlass");
  60     return (InstanceMirrorKlass*) k;
  61   }
  62 
  63   // Returns the size of the instance including the extra static fields.
  64   virtual int oop_size(oop obj) const;
  65 
  66   // Static field offset is an offset into the Heap, should be converted by
  67   // based on UseCompressedOop for traversal
  68   static HeapWord* start_of_static_fields(oop obj) {
  69     return (HeapWord*)(cast_from_oop<intptr_t>(obj) + offset_of_static_fields());
  70   }


  77 
  78   static int offset_of_static_fields() {
  79     return _offset_of_static_fields;
  80   }
  81 
  82   int compute_static_oop_field_count(oop obj);
  83 
  84   // Given a Klass return the size of the instance
  85   int instance_size(KlassHandle k);
  86 
  87   // allocation
  88   instanceOop allocate_instance(KlassHandle k, TRAPS);
  89 
  90   // Garbage collection
  91   int  oop_adjust_pointers(oop obj);
  92   void oop_follow_contents(oop obj);
  93 
  94   // Parallel Scavenge and Parallel Old
  95   PARALLEL_GC_DECLS
  96 
  97   int oop_oop_iterate(oop obj, ExtendedOopClosure* blk) {
  98     return oop_oop_iterate_v(obj, blk);
  99   }
 100   int oop_oop_iterate_m(oop obj, ExtendedOopClosure* blk, MemRegion mr) {
 101     return oop_oop_iterate_v_m(obj, blk, mr);
 102   }
 103 
 104 #define InstanceMirrorKlass_OOP_OOP_ITERATE_DECL(OopClosureType, nv_suffix)           \
 105   int oop_oop_iterate##nv_suffix(oop obj, OopClosureType* blk);                       \
 106   int oop_oop_iterate##nv_suffix##_m(oop obj, OopClosureType* blk, MemRegion mr);
 107 
 108   ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceMirrorKlass_OOP_OOP_ITERATE_DECL)
 109   ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceMirrorKlass_OOP_OOP_ITERATE_DECL)
 110 
 111 #if INCLUDE_ALL_GCS
 112 #define InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DECL(OopClosureType, nv_suffix) \
 113   int oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* blk);
 114 
 115   ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DECL)
 116   ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DECL)
 117 #endif // INCLUDE_ALL_GCS
 118 };
 119 
 120 #endif // SHARE_VM_OOPS_INSTANCEMIRRORKLASS_HPP


  29 #include "oops/instanceKlass.hpp"
  30 #include "runtime/handles.hpp"
  31 #include "utilities/macros.hpp"
  32 
  33 // An InstanceMirrorKlass is a specialized InstanceKlass for
  34 // java.lang.Class instances.  These instances are special because
  35 // they contain the static fields of the class in addition to the
  36 // normal fields of Class.  This means they are variable sized
  37 // instances and need special logic for computing their size and for
  38 // iteration of their oops.
  39 
  40 
  41 class InstanceMirrorKlass: public InstanceKlass {
  42   friend class VMStructs;
  43   friend class InstanceKlass;
  44 
  45  private:
  46   static int _offset_of_static_fields;
  47 
  48   // Constructor
  49   InstanceMirrorKlass(int vtable_len, int itable_len, int static_field_size, int nonstatic_oop_map_size, ReferenceType rt, AccessFlags access_flags,  bool is_anonymous);

  50 
  51  public:
  52   InstanceMirrorKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for CDS"); }
  53   // Type testing
  54   bool oop_is_instanceMirror() const             { return true; }
  55 
  56   // Casting from Klass*
  57   static InstanceMirrorKlass* cast(Klass* k) {
  58     assert(k->oop_is_instanceMirror(), "cast to InstanceMirrorKlass");
  59     return (InstanceMirrorKlass*) k;
  60   }
  61 
  62   // Returns the size of the instance including the extra static fields.
  63   virtual int oop_size(oop obj) const;
  64 
  65   // Static field offset is an offset into the Heap, should be converted by
  66   // based on UseCompressedOop for traversal
  67   static HeapWord* start_of_static_fields(oop obj) {
  68     return (HeapWord*)(cast_from_oop<intptr_t>(obj) + offset_of_static_fields());
  69   }


  76 
  77   static int offset_of_static_fields() {
  78     return _offset_of_static_fields;
  79   }
  80 
  81   int compute_static_oop_field_count(oop obj);
  82 
  83   // Given a Klass return the size of the instance
  84   int instance_size(KlassHandle k);
  85 
  86   // allocation
  87   instanceOop allocate_instance(KlassHandle k, TRAPS);
  88 
  89   // Garbage collection
  90   int  oop_adjust_pointers(oop obj);
  91   void oop_follow_contents(oop obj);
  92 
  93   // Parallel Scavenge and Parallel Old
  94   PARALLEL_GC_DECLS
  95 
  96  template <bool nv, typename OopClosureType>
  97  int oop_oop_iterate(oop obj, OopClosureType* blk);




  98 
  99  template <bool nv, typename OopClosureType>
 100  int oop_oop_iterate_m(oop obj, OopClosureType* blk, MemRegion mr);




 101 
 102 #if INCLUDE_ALL_GCS
 103  template <bool nv, typename OopClosureType>
 104  int oop_oop_iterate_backwards(oop obj, OopClosureType* blk);



 105 #endif // INCLUDE_ALL_GCS
 106 };
 107 
 108 #endif // SHARE_VM_OOPS_INSTANCEMIRRORKLASS_HPP