src/hotspot/share/oops/oop.hpp
changeset 47998 fb0275c320a0
parent 47216 71c04702a3d5
child 48618 688e5cbd0b91
equal deleted inserted replaced
47997:55c43e677ded 47998:fb0275c320a0
    35 // the format of Java objects so the fields can be accessed from C++.
    35 // the format of Java objects so the fields can be accessed from C++.
    36 // oopDesc is abstract.
    36 // oopDesc is abstract.
    37 // (see oopHierarchy for complete oop class hierarchy)
    37 // (see oopHierarchy for complete oop class hierarchy)
    38 //
    38 //
    39 // no virtual functions allowed
    39 // no virtual functions allowed
    40 
       
    41 // store into oop with store check
       
    42 template <class T> inline void oop_store(T* p, oop v);
       
    43 template <class T> inline void oop_store(volatile T* p, oop v);
       
    44 
    40 
    45 extern bool always_do_update_barrier;
    41 extern bool always_do_update_barrier;
    46 
    42 
    47 // Forward declarations.
    43 // Forward declarations.
    48 class OopClosure;
    44 class OopClosure;
    63   union _metadata {
    59   union _metadata {
    64     Klass*      _klass;
    60     Klass*      _klass;
    65     narrowKlass _compressed_klass;
    61     narrowKlass _compressed_klass;
    66   } _metadata;
    62   } _metadata;
    67 
    63 
    68   // Fast access to barrier set. Must be initialized.
       
    69   static BarrierSet* _bs;
       
    70 
       
    71  public:
    64  public:
    72   markOop  mark()      const { return _mark; }
    65   markOop  mark()      const { return _mark; }
    73   markOop* mark_addr() const { return (markOop*) &_mark; }
    66   markOop* mark_addr() const { return (markOop*) &_mark; }
    74 
    67 
    75   void set_mark(volatile markOop m) { _mark = m; }
    68   void set_mark(volatile markOop m) { _mark = m; }
   119   // type test operations that don't require inclusion of oop.inline.hpp.
   112   // type test operations that don't require inclusion of oop.inline.hpp.
   120   bool is_instance_noinline()          const;
   113   bool is_instance_noinline()          const;
   121   bool is_array_noinline()             const;
   114   bool is_array_noinline()             const;
   122   bool is_objArray_noinline()          const;
   115   bool is_objArray_noinline()          const;
   123   bool is_typeArray_noinline()         const;
   116   bool is_typeArray_noinline()         const;
       
   117 
       
   118  protected:
       
   119   inline oop        as_oop() const { return const_cast<oopDesc*>(this); }
   124 
   120 
   125  private:
   121  private:
   126   // field addresses in oop
   122   // field addresses in oop
   127   inline void*      field_base(int offset)          const;
   123   inline void*      field_base(int offset)          const;
   128 
   124 
   160   static inline narrowOop encode_heap_oop_not_null(oop v);
   156   static inline narrowOop encode_heap_oop_not_null(oop v);
   161   static inline narrowOop encode_heap_oop(oop v);
   157   static inline narrowOop encode_heap_oop(oop v);
   162 
   158 
   163   // Load an oop out of the Java heap as is without decoding.
   159   // Load an oop out of the Java heap as is without decoding.
   164   // Called by GC to check for null before decoding.
   160   // Called by GC to check for null before decoding.
   165   static inline narrowOop load_heap_oop(narrowOop* p) { return *p; }
   161   static inline narrowOop load_heap_oop(narrowOop* p);
   166   static inline oop       load_heap_oop(oop* p)       { return *p; }
   162   static inline oop       load_heap_oop(oop* p);
   167 
   163 
   168   // Load an oop out of Java heap and decode it to an uncompressed oop.
   164   // Load an oop out of Java heap and decode it to an uncompressed oop.
   169   static inline oop load_decode_heap_oop_not_null(narrowOop* p);
   165   static inline oop load_decode_heap_oop_not_null(narrowOop* p);
   170   static inline oop load_decode_heap_oop_not_null(oop* p) { return *p; }
   166   static inline oop load_decode_heap_oop_not_null(oop* p);
   171   static inline oop load_decode_heap_oop(narrowOop* p);
   167   static inline oop load_decode_heap_oop(narrowOop* p);
   172   static inline oop load_decode_heap_oop(oop* p) { return *p; }
   168   static inline oop load_decode_heap_oop(oop* p);
   173 
   169 
   174   // Store already encoded heap oop into the heap.
   170   // Store already encoded heap oop into the heap.
   175   static inline void store_heap_oop(narrowOop* p, narrowOop v) { *p = v; }
   171   static inline void store_heap_oop(narrowOop* p, narrowOop v);
   176   static inline void store_heap_oop(oop* p, oop v)             { *p = v; }
   172   static inline void store_heap_oop(oop* p, oop v);
   177 
   173 
   178   // Encode oop if UseCompressedOops and store into the heap.
   174   // Encode oop if UseCompressedOops and store into the heap.
   179   static inline void encode_store_heap_oop_not_null(narrowOop* p, oop v);
   175   static inline void encode_store_heap_oop_not_null(narrowOop* p, oop v);
   180   static inline void encode_store_heap_oop_not_null(oop* p, oop v) { *p = v; }
   176   static inline void encode_store_heap_oop_not_null(oop* p, oop v);
   181   static inline void encode_store_heap_oop(narrowOop* p, oop v);
   177   static inline void encode_store_heap_oop(narrowOop* p, oop v);
   182   static inline void encode_store_heap_oop(oop* p, oop v) { *p = v; }
   178   static inline void encode_store_heap_oop(oop* p, oop v);
   183 
       
   184   static inline void release_store_heap_oop(volatile narrowOop* p, narrowOop v);
       
   185   static inline void release_store_heap_oop(volatile oop* p, oop v);
       
   186 
       
   187   static inline void release_encode_store_heap_oop_not_null(volatile narrowOop* p, oop v);
       
   188   static inline void release_encode_store_heap_oop_not_null(volatile oop* p, oop v);
       
   189   static inline void release_encode_store_heap_oop(volatile narrowOop* p, oop v);
       
   190   static inline void release_encode_store_heap_oop(volatile oop* p, oop v);
       
   191 
       
   192   static inline oop atomic_exchange_oop(oop exchange_value, volatile HeapWord *dest);
       
   193   static inline oop atomic_compare_exchange_oop(oop exchange_value,
       
   194                                                 volatile HeapWord *dest,
       
   195                                                 oop compare_value,
       
   196                                                 bool prebarrier = false);
       
   197 
   179 
   198   // Access to fields in a instanceOop through these methods.
   180   // Access to fields in a instanceOop through these methods.
   199   inline oop obj_field(int offset) const;
   181   oop obj_field(int offset) const;
   200   inline void obj_field_put(int offset, oop value);
   182   void obj_field_put(int offset, oop value);
   201   inline void obj_field_put_raw(int offset, oop value);
   183   void obj_field_put_raw(int offset, oop value);
   202   inline void obj_field_put_volatile(int offset, oop value);
   184   void obj_field_put_volatile(int offset, oop value);
   203 
   185 
   204   inline Metadata* metadata_field(int offset) const;
   186   Metadata* metadata_field(int offset) const;
   205   inline void metadata_field_put(int offset, Metadata* value);
   187   void metadata_field_put(int offset, Metadata* value);
   206 
   188 
   207   inline Metadata* metadata_field_acquire(int offset) const;
   189   Metadata* metadata_field_acquire(int offset) const;
   208   inline void release_metadata_field_put(int offset, Metadata* value);
   190   void release_metadata_field_put(int offset, Metadata* value);
   209 
   191 
   210   inline jbyte byte_field(int offset) const;
   192   jbyte byte_field(int offset) const;
   211   inline void byte_field_put(int offset, jbyte contents);
   193   void byte_field_put(int offset, jbyte contents);
   212 
   194 
   213   inline jchar char_field(int offset) const;
   195   jchar char_field(int offset) const;
   214   inline void char_field_put(int offset, jchar contents);
   196   void char_field_put(int offset, jchar contents);
   215 
   197 
   216   inline jboolean bool_field(int offset) const;
   198   jboolean bool_field(int offset) const;
   217   inline void bool_field_put(int offset, jboolean contents);
   199   void bool_field_put(int offset, jboolean contents);
   218 
   200 
   219   inline jint int_field(int offset) const;
   201   jint int_field(int offset) const;
   220   inline void int_field_put(int offset, jint contents);
   202   void int_field_put(int offset, jint contents);
   221 
   203 
   222   inline jshort short_field(int offset) const;
   204   jshort short_field(int offset) const;
   223   inline void short_field_put(int offset, jshort contents);
   205   void short_field_put(int offset, jshort contents);
   224 
   206 
   225   inline jlong long_field(int offset) const;
   207   jlong long_field(int offset) const;
   226   inline void long_field_put(int offset, jlong contents);
   208   void long_field_put(int offset, jlong contents);
   227 
   209 
   228   inline jfloat float_field(int offset) const;
   210   jfloat float_field(int offset) const;
   229   inline void float_field_put(int offset, jfloat contents);
   211   void float_field_put(int offset, jfloat contents);
   230 
   212 
   231   inline jdouble double_field(int offset) const;
   213   jdouble double_field(int offset) const;
   232   inline void double_field_put(int offset, jdouble contents);
   214   void double_field_put(int offset, jdouble contents);
   233 
   215 
   234   inline address address_field(int offset) const;
   216   address address_field(int offset) const;
   235   inline void address_field_put(int offset, address contents);
   217   void address_field_put(int offset, address contents);
   236 
   218 
   237   inline oop obj_field_acquire(int offset) const;
   219   oop obj_field_acquire(int offset) const;
   238   inline void release_obj_field_put(int offset, oop value);
   220   void release_obj_field_put(int offset, oop value);
   239 
   221 
   240   inline jbyte byte_field_acquire(int offset) const;
   222   jbyte byte_field_acquire(int offset) const;
   241   inline void release_byte_field_put(int offset, jbyte contents);
   223   void release_byte_field_put(int offset, jbyte contents);
   242 
   224 
   243   inline jchar char_field_acquire(int offset) const;
   225   jchar char_field_acquire(int offset) const;
   244   inline void release_char_field_put(int offset, jchar contents);
   226   void release_char_field_put(int offset, jchar contents);
   245 
   227 
   246   inline jboolean bool_field_acquire(int offset) const;
   228   jboolean bool_field_acquire(int offset) const;
   247   inline void release_bool_field_put(int offset, jboolean contents);
   229   void release_bool_field_put(int offset, jboolean contents);
   248 
   230 
   249   inline jint int_field_acquire(int offset) const;
   231   jint int_field_acquire(int offset) const;
   250   inline void release_int_field_put(int offset, jint contents);
   232   void release_int_field_put(int offset, jint contents);
   251 
   233 
   252   inline jshort short_field_acquire(int offset) const;
   234   jshort short_field_acquire(int offset) const;
   253   inline void release_short_field_put(int offset, jshort contents);
   235   void release_short_field_put(int offset, jshort contents);
   254 
   236 
   255   inline jlong long_field_acquire(int offset) const;
   237   jlong long_field_acquire(int offset) const;
   256   inline void release_long_field_put(int offset, jlong contents);
   238   void release_long_field_put(int offset, jlong contents);
   257 
   239 
   258   inline jfloat float_field_acquire(int offset) const;
   240   jfloat float_field_acquire(int offset) const;
   259   inline void release_float_field_put(int offset, jfloat contents);
   241   void release_float_field_put(int offset, jfloat contents);
   260 
   242 
   261   inline jdouble double_field_acquire(int offset) const;
   243   jdouble double_field_acquire(int offset) const;
   262   inline void release_double_field_put(int offset, jdouble contents);
   244   void release_double_field_put(int offset, jdouble contents);
   263 
   245 
   264   inline address address_field_acquire(int offset) const;
   246   address address_field_acquire(int offset) const;
   265   inline void release_address_field_put(int offset, address contents);
   247   void release_address_field_put(int offset, address contents);
   266 
   248 
   267   // printing functions for VM debugging
   249   // printing functions for VM debugging
   268   void print_on(outputStream* st) const;         // First level print
   250   void print_on(outputStream* st) const;         // First level print
   269   void print_value_on(outputStream* st) const;   // Second level print.
   251   void print_value_on(outputStream* st) const;   // Second level print.
   270   void print_address_on(outputStream* st) const; // Address printing
   252   void print_address_on(outputStream* st) const; // Address printing
   320   inline void incr_age();
   302   inline void incr_age();
   321 
   303 
   322   // mark-sweep support
   304   // mark-sweep support
   323   void follow_body(int begin, int end);
   305   void follow_body(int begin, int end);
   324 
   306 
   325   // Fast access to barrier set
       
   326   static BarrierSet* bs()            { return _bs; }
       
   327   static void set_bs(BarrierSet* bs) { _bs = bs; }
       
   328 
       
   329   // Garbage Collection support
   307   // Garbage Collection support
   330 
   308 
   331 #if INCLUDE_ALL_GCS
   309 #if INCLUDE_ALL_GCS
   332   // Parallel Compact
   310   // Parallel Compact
   333   inline void pc_follow_contents(ParCompactionManager* cm);
   311   inline void pc_follow_contents(ParCompactionManager* cm);