< prev index next >

src/share/vm/gc/parallel/psPromotionManager.inline.hpp

Print this page

        

@@ -209,11 +209,11 @@
 
     // Copy obj
     Copy::aligned_disjoint_words((HeapWord*)o, (HeapWord*)new_obj, new_obj_size);
 
     // Now we have to CAS in the header.
-    if (o->cas_forward_to(new_obj, test_mark)) {
+    if (o->cas_forward_to(new_obj, test_mark, memory_order_relaxed)) {
       // We won any races, we "own" this object.
       assert(new_obj == o->forwardee(), "Sanity");
 
       // Increment age if obj still in new generation. Now that
       // we're dealing with a markOop that cannot change, it is

@@ -236,10 +236,19 @@
         TASKQUEUE_STATS_ONLY(++_arrays_chunked; ++_masked_pushes);
       } else {
         // we'll just push its contents
         push_contents(new_obj);
       }
+
+      // This code must come after the CAS test, or it will print incorrect
+      // information.
+      if (log_develop_is_enabled(Trace, gc, scavenge)) {
+        log_develop_trace(gc, scavenge)("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}",
+                                        should_scavenge(&new_obj) ? "copying" : "tenuring",
+                                        new_obj->klass()->internal_name(), p2i((void *)o), p2i((void *)new_obj),
+                                        new_obj->size())
+      }
     }  else {
       // We lost, someone else "owns" this object
       guarantee(o->is_forwarded(), "Object must be forwarded if the cas failed.");
 
       // Try to deallocate the space.  If it was directly allocated we cannot

@@ -253,21 +262,28 @@
         CollectedHeap::fill_with_object((HeapWord*) new_obj, new_obj_size);
       }
 
       // don't update this before the unallocation!
       new_obj = o->forwardee();
+
+      // fields in new_obj may not be synchronized.
+      if (log_develop_is_enabled(Trace, gc, scavenge)) {
+        log_develop_trace(gc, scavenge)("{%s %s " PTR_FORMAT " -> " PTR_FORMAT "}",
+                                        should_scavenge(&new_obj) ? "copying" : "tenuring",
+                                        o->klass()->internal_name(), p2i((void *)o), p2i((void *)new_obj));
+      }
     }
   } else {
     assert(o->is_forwarded(), "Sanity");
     new_obj = o->forwardee();
-  }
-
-  // This code must come after the CAS test, or it will print incorrect
-  // information.
-  log_develop_trace(gc, scavenge)("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}",
+    // fields in new_obj may not be synchronized.
+    if (log_develop_is_enabled(Trace, gc, scavenge)) {
+      log_develop_trace(gc, scavenge)("{%s %s " PTR_FORMAT " -> " PTR_FORMAT "}",
                                   should_scavenge(&new_obj) ? "copying" : "tenuring",
-                                  new_obj->klass()->internal_name(), p2i((void *)o), p2i((void *)new_obj), new_obj->size());
+                                      o->klass()->internal_name(), p2i((void *)o), p2i((void *)new_obj));
+    }
+  }
 
   return new_obj;
 }
 
 // Attempt to "claim" oop at p via CAS, push the new obj if successful

@@ -276,20 +292,20 @@
 template <class T, bool promote_immediately>
 inline void PSPromotionManager::copy_and_push_safe_barrier(T* p) {
   assert(should_scavenge(p, true), "revisiting object?");
 
   oop o = oopDesc::load_decode_heap_oop_not_null(p);
-  oop new_obj = o->is_forwarded()
-        ? o->forwardee()
-        : copy_to_survivor_space<promote_immediately>(o);
 
-  // This code must come after the CAS test, or it will print incorrect
-  // information.
-  if (log_develop_is_enabled(Trace, gc, scavenge) && o->is_forwarded()) {
-    log_develop_trace(gc, scavenge)("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}",
-                      "forwarding",
-                      new_obj->klass()->internal_name(), p2i((void *)o), p2i((void *)new_obj), new_obj->size());
+  if (!o->is_forwarded()) {
+    copy_to_survivor_space<promote_immediately>(o);
+  }
+  oop new_obj = o->forwardee();
+  assert(forwardee != NULL, "forwardee should not be NULL");
+  // This code must come after the CAS test, or it will print incorrect information.
+  if (log_develop_is_enabled(Trace, gc, scavenge)) {
+    log_develop_trace(gc, scavenge)("{forwarding %s " PTR_FORMAT " -> " PTR_FORMAT "}",
+                      o->klass()->internal_name(), p2i((void *)o), p2i((void *)new_obj));
   }
 
   oopDesc::encode_store_heap_oop_not_null(p, new_obj);
 
   // We cannot mark without test, as some code passes us pointers
< prev index next >