src/share/vm/oops/oop.inline.hpp
Print this page
rev 5729 : 8029396: PPC64 (part 212): Several memory ordering fixes in C-code.
@@ -488,13 +488,13 @@
inline int oopDesc::size() {
return size_given_klass(klass());
}
-inline void update_barrier_set(void* p, oop v) {
+inline void update_barrier_set(void* p, oop v, bool release = false) {
assert(oopDesc::bs() != NULL, "Uninitialized bs in oop!");
- oopDesc::bs()->write_ref_field(p, v);
+ oopDesc::bs()->write_ref_field(p, v, release);
}
template <class T> inline void update_barrier_set_pre(T* p, oop v) {
oopDesc::bs()->write_ref_field_pre(p, v);
}
@@ -503,19 +503,27 @@
if (always_do_update_barrier) {
oop_store((volatile T*)p, v);
} else {
update_barrier_set_pre(p, v);
oopDesc::encode_store_heap_oop(p, v);
- update_barrier_set((void*)p, v); // cast away type
+ // always_do_update_barrier == false =>
+ // Either we are at a safepoint (in GC) or CMS is not used. In both
+ // cases it's unnecessary to mark the card as dirty with release sematics.
+ update_barrier_set((void*)p, v, false /* release */); // cast away type
}
}
template <class T> inline void oop_store(volatile T* p, oop v) {
update_barrier_set_pre((T*)p, v); // cast away volatile
// Used by release_obj_field_put, so use release_store_ptr.
oopDesc::release_encode_store_heap_oop(p, v);
- update_barrier_set((void*)p, v); // cast away type
+ // When using CMS we must mark the card corresponding to p as dirty
+ // with release sematics to prevent that CMS sees the dirty card but
+ // not the new value v at p due to reordering of the two
+ // stores. Note that CMS has a concurrent precleaning phase, where
+ // it reads the card table while the Java threads are running.
+ update_barrier_set((void*)p, v, true /* release */); // cast away type
}
// Should replace *addr = oop assignments where addr type depends on UseCompressedOops
// (without having to remember the function name this calls).
inline void oop_store_raw(HeapWord* addr, oop value) {