< prev index next >

src/hotspot/share/oops/oop.hpp

Print this page




  29 #include "memory/memRegion.hpp"
  30 #include "oops/access.hpp"
  31 #include "oops/metadata.hpp"
  32 #include "runtime/atomic.hpp"
  33 #include "utilities/macros.hpp"
  34 
  35 // oopDesc is the top baseclass for objects classes. The {name}Desc classes describe
  36 // the format of Java objects so the fields can be accessed from C++.
  37 // oopDesc is abstract.
  38 // (see oopHierarchy for complete oop class hierarchy)
  39 //
  40 // no virtual functions allowed
  41 
  42 extern bool always_do_update_barrier;
  43 
  44 // Forward declarations.
  45 class OopClosure;
  46 class ScanClosure;
  47 class FastScanClosure;
  48 class FilteringClosure;
  49 class BarrierSet;
  50 class CMSIsAliveClosure;
  51 
  52 class PSPromotionManager;
  53 class ParCompactionManager;
  54 
  55 class oopDesc {
  56   friend class VMStructs;
  57   friend class JVMCIVMStructs;
  58  private:
  59   volatile markOop _mark;
  60   union _metadata {
  61     Klass*      _klass;
  62     narrowKlass _compressed_klass;
  63   } _metadata;
  64 
  65  public:
  66   inline markOop  mark()          const;
  67   inline markOop  mark_raw()      const;
  68   inline markOop* mark_addr_raw() const;
  69 


 136   template <class T> inline T* obj_field_addr_raw(int offset) const;
 137 
 138   template <typename T> inline size_t field_offset(T* p) const;
 139 
 140   // Standard compare function returns negative value if o1 < o2
 141   //                                   0              if o1 == o2
 142   //                                   positive value if o1 > o2
 143   inline static int  compare(oop o1, oop o2) {
 144     void* o1_addr = (void*)o1;
 145     void* o2_addr = (void*)o2;
 146     if (o1_addr < o2_addr) {
 147       return -1;
 148     } else if (o1_addr > o2_addr) {
 149       return 1;
 150     } else {
 151       return 0;
 152     }
 153   }
 154 
 155   inline static bool equals(oop o1, oop o2) { return Access<>::equals(o1, o2); }








 156 
 157   // Access to fields in a instanceOop through these methods.
 158   template <DecoratorSet decorator>
 159   oop obj_field_access(int offset) const;
 160   oop obj_field(int offset) const;
 161   void obj_field_put(int offset, oop value);
 162   void obj_field_put_raw(int offset, oop value);
 163   void obj_field_put_volatile(int offset, oop value);
 164 
 165   Metadata* metadata_field(int offset) const;
 166   void metadata_field_put(int offset, Metadata* value);
 167 
 168   Metadata* metadata_field_acquire(int offset) const;
 169   void release_metadata_field_put(int offset, Metadata* value);
 170 
 171   jbyte byte_field(int offset) const;
 172   void byte_field_put(int offset, jbyte contents);
 173 
 174   jchar char_field(int offset) const;
 175   void char_field_put(int offset, jchar contents);




  29 #include "memory/memRegion.hpp"
  30 #include "oops/access.hpp"
  31 #include "oops/metadata.hpp"
  32 #include "runtime/atomic.hpp"
  33 #include "utilities/macros.hpp"
  34 
  35 // oopDesc is the top baseclass for objects classes. The {name}Desc classes describe
  36 // the format of Java objects so the fields can be accessed from C++.
  37 // oopDesc is abstract.
  38 // (see oopHierarchy for complete oop class hierarchy)
  39 //
  40 // no virtual functions allowed
  41 
  42 extern bool always_do_update_barrier;
  43 
  44 // Forward declarations.
  45 class OopClosure;
  46 class ScanClosure;
  47 class FastScanClosure;
  48 class FilteringClosure;

  49 class CMSIsAliveClosure;
  50 
  51 class PSPromotionManager;
  52 class ParCompactionManager;
  53 
  54 class oopDesc {
  55   friend class VMStructs;
  56   friend class JVMCIVMStructs;
  57  private:
  58   volatile markOop _mark;
  59   union _metadata {
  60     Klass*      _klass;
  61     narrowKlass _compressed_klass;
  62   } _metadata;
  63 
  64  public:
  65   inline markOop  mark()          const;
  66   inline markOop  mark_raw()      const;
  67   inline markOop* mark_addr_raw() const;
  68 


 135   template <class T> inline T* obj_field_addr_raw(int offset) const;
 136 
 137   template <typename T> inline size_t field_offset(T* p) const;
 138 
 139   // Standard compare function returns negative value if o1 < o2
 140   //                                   0              if o1 == o2
 141   //                                   positive value if o1 > o2
 142   inline static int  compare(oop o1, oop o2) {
 143     void* o1_addr = (void*)o1;
 144     void* o2_addr = (void*)o2;
 145     if (o1_addr < o2_addr) {
 146       return -1;
 147     } else if (o1_addr > o2_addr) {
 148       return 1;
 149     } else {
 150       return 0;
 151     }
 152   }
 153 
 154   inline static bool equals(oop o1, oop o2) { return Access<>::equals(o1, o2); }
 155 
 156   inline static bool unsafe_equals(oop o1, oop o2) {
 157 #ifdef CHECK_UNHANDLED_OOPS
 158     return o1.obj() == o2.obj();
 159 #else
 160     return o1 == o2;
 161 #endif
 162   }
 163 
 164   // Access to fields in a instanceOop through these methods.
 165   template <DecoratorSet decorator>
 166   oop obj_field_access(int offset) const;
 167   oop obj_field(int offset) const;
 168   void obj_field_put(int offset, oop value);
 169   void obj_field_put_raw(int offset, oop value);
 170   void obj_field_put_volatile(int offset, oop value);
 171 
 172   Metadata* metadata_field(int offset) const;
 173   void metadata_field_put(int offset, Metadata* value);
 174 
 175   Metadata* metadata_field_acquire(int offset) const;
 176   void release_metadata_field_put(int offset, Metadata* value);
 177 
 178   jbyte byte_field(int offset) const;
 179   void byte_field_put(int offset, jbyte contents);
 180 
 181   jchar char_field(int offset) const;
 182   void char_field_put(int offset, jchar contents);


< prev index next >