< prev index next >

src/share/vm/oops/oop.inline.hpp

Print this page

        

@@ -63,15 +63,17 @@
 
 // Implementation of all inlined member functions defined in oop.hpp
 // We need a separate file to avoid circular references
 
 inline void oopDesc::release_set_mark(markOop m) {
-  OrderAccess::release_store_ptr(&_mark, m);
+  oop p = bs()->write_barrier(this);
+  OrderAccess::release_store_ptr(&p->_mark, m);
 }
 
 inline markOop oopDesc::cas_set_mark(markOop new_mark, markOop old_mark) {
-  return (markOop) Atomic::cmpxchg_ptr(new_mark, &_mark, old_mark);
+  oop p = bs()->write_barrier(this);
+  return (markOop) Atomic::cmpxchg_ptr(new_mark, &p->_mark, old_mark);
 }
 
 inline Klass* oopDesc::klass() const {
   if (UseCompressedClassPointers) {
     return Klass::decode_klass_not_null(_metadata._compressed_klass);

@@ -199,11 +201,11 @@
   int    shift = Universe::narrow_oop_shift();
   uint64_t  pd = (uint64_t)(pointer_delta((void*)v, (void*)base, 1));
   assert(OopEncodingHeapMax > pd, "change encoding max if new encoding");
   uint64_t result = pd >> shift;
   assert((result & CONST64(0xffffffff00000000)) == 0, "narrow oop overflow");
-  assert(decode_heap_oop(result) == v, "reversibility");
+  assert(oopDesc::unsafe_equals(decode_heap_oop(result), v), "reversibility");
   return (narrowOop)result;
 }
 
 inline narrowOop oopDesc::encode_heap_oop(oop v) {
   return (is_null(v)) ? (narrowOop)0 : encode_heap_oop_not_null(v);

@@ -303,109 +305,230 @@
 }
 
 // In order to put or get a field out of an instance, must first check
 // if the field has been compressed and uncompress it.
 inline oop oopDesc::obj_field(int offset) const {
+  oop p = bs()->read_barrier((oop) this);
   return UseCompressedOops ?
-    load_decode_heap_oop(obj_field_addr<narrowOop>(offset)) :
-    load_decode_heap_oop(obj_field_addr<oop>(offset));
+    load_decode_heap_oop(p->obj_field_addr<narrowOop>(offset)) :
+    load_decode_heap_oop(p->obj_field_addr<oop>(offset));
 }
 inline volatile oop oopDesc::obj_field_volatile(int offset) const {
   volatile oop value = obj_field(offset);
   OrderAccess::acquire();
   return value;
 }
 inline void oopDesc::obj_field_put(int offset, oop value) {
-  UseCompressedOops ? oop_store(obj_field_addr<narrowOop>(offset), value) :
-                      oop_store(obj_field_addr<oop>(offset),       value);
+  oop p = bs()->write_barrier(this);
+  value = bs()->read_barrier(value);
+  UseCompressedOops ? oop_store(p->obj_field_addr<narrowOop>(offset), value) :
+                      oop_store(p->obj_field_addr<oop>(offset),       value);
 }
 
 inline Metadata* oopDesc::metadata_field(int offset) const {
-  return *metadata_field_addr(offset);
+  oop p = bs()->read_barrier((oop) this);
+  return *p->metadata_field_addr(offset);
 }
 
 inline void oopDesc::metadata_field_put(int offset, Metadata* value) {
-  *metadata_field_addr(offset) = value;
+  oop p = bs()->write_barrier(this);
+  *p->metadata_field_addr(offset) = value;
 }
 
 inline void oopDesc::obj_field_put_raw(int offset, oop value) {
+  oop p = bs()->write_barrier(this);
+  value = bs()->read_barrier(value);
   UseCompressedOops ?
-    encode_store_heap_oop(obj_field_addr<narrowOop>(offset), value) :
-    encode_store_heap_oop(obj_field_addr<oop>(offset),       value);
+    encode_store_heap_oop(p->obj_field_addr<narrowOop>(offset), value) :
+    encode_store_heap_oop(p->obj_field_addr<oop>(offset),       value);
 }
 inline void oopDesc::obj_field_put_volatile(int offset, oop value) {
   OrderAccess::release();
   obj_field_put(offset, value);
   OrderAccess::fence();
 }
 
-inline jbyte oopDesc::byte_field(int offset) const                  { return (jbyte) *byte_field_addr(offset);    }
-inline void oopDesc::byte_field_put(int offset, jbyte contents)     { *byte_field_addr(offset) = (jint) contents; }
+inline jbyte oopDesc::byte_field(int offset) const                  {
+  oop p = bs()->read_barrier((oop) this);
+  return (jbyte) *p->byte_field_addr(offset);
+}
+inline void oopDesc::byte_field_put(int offset, jbyte contents)     {
+  oop p = bs()->write_barrier(this);
+  *p->byte_field_addr(offset) = (jint) contents;
+}
 
-inline jboolean oopDesc::bool_field(int offset) const               { return (jboolean) *bool_field_addr(offset); }
-inline void oopDesc::bool_field_put(int offset, jboolean contents)  { *bool_field_addr(offset) = (( (jint) contents) & 1); }
+inline jboolean oopDesc::bool_field(int offset) const               {
+  oop p = bs()->read_barrier((oop) this);
+  return (jboolean) *p->bool_field_addr(offset);
+}
+inline void oopDesc::bool_field_put(int offset, jboolean contents)  {
+  oop p = bs()->write_barrier(this);
+  *p->bool_field_addr(offset) =  (( (jint) contents) & 1);
+}
 
-inline jchar oopDesc::char_field(int offset) const                  { return (jchar) *char_field_addr(offset);    }
-inline void oopDesc::char_field_put(int offset, jchar contents)     { *char_field_addr(offset) = (jint) contents; }
+inline jchar oopDesc::char_field(int offset) const                  {
+  oop p = bs()->read_barrier((oop) this);
+  return (jchar) *p->char_field_addr(offset);
+}
+inline void oopDesc::char_field_put(int offset, jchar contents)     {
+  oop p = bs()->write_barrier(this);
+  *p->char_field_addr(offset) = (jint) contents;
+}
 
-inline jint oopDesc::int_field(int offset) const                    { return *int_field_addr(offset);        }
-inline void oopDesc::int_field_put(int offset, jint contents)       { *int_field_addr(offset) = contents;    }
+inline jint oopDesc::int_field(int offset) const                    {
+  oop p = bs()->read_barrier((oop) this);
+  return *p->int_field_addr(offset);
+}
+inline void oopDesc::int_field_put(int offset, jint contents)       {
+  oop p = bs()->write_barrier(this);
+  *p->int_field_addr(offset) = contents;
+}
+inline void oopDesc::int_field_put_raw(int offset, jint contents)   {
+  *int_field_addr(offset) = contents;
+}
 
-inline jshort oopDesc::short_field(int offset) const                { return (jshort) *short_field_addr(offset);  }
-inline void oopDesc::short_field_put(int offset, jshort contents)   { *short_field_addr(offset) = (jint) contents;}
+inline jshort oopDesc::short_field(int offset) const                {
+  oop p = bs()->read_barrier((oop) this);
+  return (jshort) *p->short_field_addr(offset);
+}
+inline void oopDesc::short_field_put(int offset, jshort contents)   {
+  oop p = bs()->write_barrier(this);
+  *p->short_field_addr(offset) = (jint) contents;
+}
 
-inline jlong oopDesc::long_field(int offset) const                  { return *long_field_addr(offset);       }
-inline void oopDesc::long_field_put(int offset, jlong contents)     { *long_field_addr(offset) = contents;   }
+inline jlong oopDesc::long_field(int offset) const                  {
+  oop p = bs()->read_barrier((oop) this);
+  return *p->long_field_addr(offset);
+}
+inline void oopDesc::long_field_put(int offset, jlong contents)     {
+  oop p = bs()->write_barrier(this);
+  *p->long_field_addr(offset) = contents;
+}
 
-inline jfloat oopDesc::float_field(int offset) const                { return *float_field_addr(offset);      }
-inline void oopDesc::float_field_put(int offset, jfloat contents)   { *float_field_addr(offset) = contents;  }
+inline jfloat oopDesc::float_field(int offset) const                {
+  oop p = bs()->read_barrier((oop) this);
+  return *p->float_field_addr(offset);
+}
+inline void oopDesc::float_field_put(int offset, jfloat contents)   {
+  oop p = bs()->write_barrier(this);
+  *p->float_field_addr(offset) = contents;
+}
 
-inline jdouble oopDesc::double_field(int offset) const              { return *double_field_addr(offset);     }
-inline void oopDesc::double_field_put(int offset, jdouble contents) { *double_field_addr(offset) = contents; }
+inline jdouble oopDesc::double_field(int offset) const              {
+  oop p = bs()->read_barrier((oop) this);
+  return *p->double_field_addr(offset);
+}
+inline void oopDesc::double_field_put(int offset, jdouble contents) {
+  oop p = bs()->write_barrier(this);
+  *p->double_field_addr(offset) = contents;
+}
 
-inline address oopDesc::address_field(int offset) const              { return *address_field_addr(offset);     }
-inline void oopDesc::address_field_put(int offset, address contents) { *address_field_addr(offset) = contents; }
+inline address oopDesc::address_field(int offset) const              {
+  oop p = bs()->read_barrier((oop) this);
+  return *p->address_field_addr(offset);
+}
+inline void oopDesc::address_field_put(int offset, address contents) {
+  oop p = bs()->write_barrier(this);
+  *p->address_field_addr(offset) = contents;
+}
 
 inline oop oopDesc::obj_field_acquire(int offset) const {
+  oop p = bs()->read_barrier((oop) this);
   return UseCompressedOops ?
              decode_heap_oop((narrowOop)
-               OrderAccess::load_acquire(obj_field_addr<narrowOop>(offset)))
+               OrderAccess::load_acquire(p->obj_field_addr<narrowOop>(offset)))
            : decode_heap_oop((oop)
-               OrderAccess::load_ptr_acquire(obj_field_addr<oop>(offset)));
+               OrderAccess::load_ptr_acquire(p->obj_field_addr<oop>(offset)));
 }
 inline void oopDesc::release_obj_field_put(int offset, oop value) {
+  oop p = bs()->write_barrier(this);
+  value = bs()->read_barrier(value);
   UseCompressedOops ?
-    oop_store((volatile narrowOop*)obj_field_addr<narrowOop>(offset), value) :
-    oop_store((volatile oop*)      obj_field_addr<oop>(offset),       value);
+    oop_store((volatile narrowOop*)p->obj_field_addr<narrowOop>(offset), value) :
+    oop_store((volatile oop*)      p->obj_field_addr<oop>(offset),       value);
 }
 
-inline jbyte oopDesc::byte_field_acquire(int offset) const                  { return OrderAccess::load_acquire(byte_field_addr(offset));     }
-inline void oopDesc::release_byte_field_put(int offset, jbyte contents)     { OrderAccess::release_store(byte_field_addr(offset), contents); }
+inline jbyte oopDesc::byte_field_acquire(int offset) const                  {
+  oop p = bs()->read_barrier((oop) this);
+  return OrderAccess::load_acquire(p->byte_field_addr(offset));
+}
+inline void oopDesc::release_byte_field_put(int offset, jbyte contents)     {
+  oop p = bs()->write_barrier(this);
+  OrderAccess::release_store(p->byte_field_addr(offset), contents);
+}
 
-inline jboolean oopDesc::bool_field_acquire(int offset) const               { return OrderAccess::load_acquire(bool_field_addr(offset));     }
-inline void oopDesc::release_bool_field_put(int offset, jboolean contents)  { OrderAccess::release_store(bool_field_addr(offset), (contents & 1)); }
+inline jboolean oopDesc::bool_field_acquire(int offset) const               {
+  oop p = bs()->read_barrier((oop) this);
+  return OrderAccess::load_acquire(p->bool_field_addr(offset));
+}
+inline void oopDesc::release_bool_field_put(int offset, jboolean contents)  {
+  oop p = bs()->write_barrier(this);
+  OrderAccess::release_store(p->bool_field_addr(offset), (contents & 1));
+}
 
-inline jchar oopDesc::char_field_acquire(int offset) const                  { return OrderAccess::load_acquire(char_field_addr(offset));     }
-inline void oopDesc::release_char_field_put(int offset, jchar contents)     { OrderAccess::release_store(char_field_addr(offset), contents); }
+inline jchar oopDesc::char_field_acquire(int offset) const                  {
+  oop p = bs()->read_barrier((oop) this);
+  return OrderAccess::load_acquire(p->char_field_addr(offset));
+}
+inline void oopDesc::release_char_field_put(int offset, jchar contents)     {
+  oop p = bs()->write_barrier(this);
+  OrderAccess::release_store(p->char_field_addr(offset), contents);
+}
 
-inline jint oopDesc::int_field_acquire(int offset) const                    { return OrderAccess::load_acquire(int_field_addr(offset));      }
-inline void oopDesc::release_int_field_put(int offset, jint contents)       { OrderAccess::release_store(int_field_addr(offset), contents);  }
+inline jint oopDesc::int_field_acquire(int offset) const                    {
+  oop p = bs()->read_barrier((oop) this);
+  return OrderAccess::load_acquire(p->int_field_addr(offset));
+}
+inline void oopDesc::release_int_field_put(int offset, jint contents)       {
+  oop p = bs()->write_barrier(this);
+  OrderAccess::release_store(p->int_field_addr(offset), contents);
+}
 
-inline jshort oopDesc::short_field_acquire(int offset) const                { return (jshort)OrderAccess::load_acquire(short_field_addr(offset)); }
-inline void oopDesc::release_short_field_put(int offset, jshort contents)   { OrderAccess::release_store(short_field_addr(offset), contents);     }
+inline jshort oopDesc::short_field_acquire(int offset) const                {
+  oop p = bs()->read_barrier((oop) this);
+  return (jshort)OrderAccess::load_acquire(p->short_field_addr(offset));
+}
+inline void oopDesc::release_short_field_put(int offset, jshort contents)   {
+  oop p = bs()->write_barrier(this);
+  OrderAccess::release_store(p->short_field_addr(offset), contents);
+}
 
-inline jlong oopDesc::long_field_acquire(int offset) const                  { return OrderAccess::load_acquire(long_field_addr(offset));       }
-inline void oopDesc::release_long_field_put(int offset, jlong contents)     { OrderAccess::release_store(long_field_addr(offset), contents);   }
+inline jlong oopDesc::long_field_acquire(int offset) const                  {
+  oop p = bs()->read_barrier((oop) this);
+  return OrderAccess::load_acquire(p->long_field_addr(offset));
+}
+inline void oopDesc::release_long_field_put(int offset, jlong contents)     {
+  oop p = bs()->write_barrier(this);
+  OrderAccess::release_store(p->long_field_addr(offset), contents);
+}
 
-inline jfloat oopDesc::float_field_acquire(int offset) const                { return OrderAccess::load_acquire(float_field_addr(offset));      }
-inline void oopDesc::release_float_field_put(int offset, jfloat contents)   { OrderAccess::release_store(float_field_addr(offset), contents);  }
+inline jfloat oopDesc::float_field_acquire(int offset) const                {
+  oop p = bs()->read_barrier((oop) this);
+  return OrderAccess::load_acquire(p->float_field_addr(offset));
+}
+inline void oopDesc::release_float_field_put(int offset, jfloat contents)   {
+  oop p = bs()->write_barrier(this);
+  OrderAccess::release_store(p->float_field_addr(offset), contents);
+}
 
-inline jdouble oopDesc::double_field_acquire(int offset) const              { return OrderAccess::load_acquire(double_field_addr(offset));     }
-inline void oopDesc::release_double_field_put(int offset, jdouble contents) { OrderAccess::release_store(double_field_addr(offset), contents); }
+inline jdouble oopDesc::double_field_acquire(int offset) const              {
+  oop p = bs()->read_barrier((oop) this);
+  return OrderAccess::load_acquire(p->double_field_addr(offset));
+}
+inline void oopDesc::release_double_field_put(int offset, jdouble contents) {
+  oop p = bs()->write_barrier(this);
+  OrderAccess::release_store(p->double_field_addr(offset), contents);
+}
 
-inline address oopDesc::address_field_acquire(int offset) const             { return (address) OrderAccess::load_ptr_acquire(address_field_addr(offset)); }
-inline void oopDesc::release_address_field_put(int offset, address contents) { OrderAccess::release_store_ptr(address_field_addr(offset), contents); }
+inline address oopDesc::address_field_acquire(int offset) const             {
+  oop p = bs()->read_barrier((oop) this);
+  return (address) OrderAccess::load_ptr_acquire(p->address_field_addr(offset));
+}
+inline void oopDesc::release_address_field_put(int offset, address contents) {
+  oop p = bs()->write_barrier(this);
+  OrderAccess::release_store_ptr(p->address_field_addr(offset), contents);
+}
 
 inline int oopDesc::size_given_klass(Klass* klass)  {
   int lh = klass->layout_helper();
   int s;
 
< prev index next >