hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp
changeset 11580 05e16a45f0f3
parent 11578 fc6f77eca886
child 11581 b1afc51ad34e
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Thu Jan 19 09:13:58 2012 -0500
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Fri Jan 20 18:01:32 2012 +0100
@@ -1059,8 +1059,14 @@
 
     if (result != NULL) {
       if (g1_policy()->need_to_start_conc_mark("concurrent humongous allocation")) {
-        // We need to release the Heap_lock before we try to call collect
+        // We need to release the Heap_lock before we try to call collect().
+        // The result will not be stored in any object before this method
+        // returns, so the GC might miss it. Thus, we create a handle to the result
+        // and fake an object at that place.
+        CollectedHeap::fill_with_object(result, word_size, false);
+        Handle h((oop)result);
         collect(GCCause::_g1_humongous_allocation);
+        assert(result == (HeapWord*)h(), "Humongous objects should not be moved by collections");
       }
       return result;
     }