< prev index next >

src/share/vm/gc/g1/vm_operations_g1.cpp

Print this page




  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "gc/g1/concurrentMarkThread.inline.hpp"
  27 #include "gc/g1/g1CollectedHeap.inline.hpp"
  28 #include "gc/g1/g1CollectorPolicy.hpp"
  29 #include "gc/shared/gcId.hpp"
  30 #include "gc/g1/g1Log.hpp"
  31 #include "gc/g1/vm_operations_g1.hpp"
  32 #include "gc/shared/gcTimer.hpp"
  33 #include "gc/shared/gcTraceTime.hpp"
  34 #include "gc/shared/isGCActiveMark.hpp"
  35 #include "runtime/interfaceSupport.hpp"
  36 
  37 VM_G1CollectForAllocation::VM_G1CollectForAllocation(uint gc_count_before,
  38                                                      size_t word_size)
  39   : VM_G1OperationWithAllocRequest(gc_count_before, word_size,
  40                                    GCCause::_allocation_failure) {
  41   guarantee(word_size != 0, "An allocation should always be requested with this operation.");
  42 }
  43 
  44 void VM_G1CollectForAllocation::doit() {
  45   G1CollectedHeap* g1h = G1CollectedHeap::heap();
  46   GCCauseSetter x(g1h, _gc_cause);
  47 
  48   _result = g1h->satisfy_failed_allocation(_word_size, allocation_context(), &_pause_succeeded);
  49   assert(_result == NULL || _pause_succeeded,
  50          "if we get back a result, the pause should have succeeded");


 209   assert(_needs_pll, "don't call this otherwise");
 210   // The caller may block while communicating
 211   // with the SLT thread in order to acquire/release the PLL.
 212   SurrogateLockerThread* slt = ConcurrentMarkThread::slt();
 213   if (slt != NULL) {
 214     slt->manipulatePLL(SurrogateLockerThread::acquirePLL);
 215   } else {
 216     SurrogateLockerThread::report_missing_slt();
 217   }
 218 }
 219 
 220 void VM_CGC_Operation::release_and_notify_pending_list_lock() {
 221   assert(_needs_pll, "don't call this otherwise");
 222   // The caller may block while communicating
 223   // with the SLT thread in order to acquire/release the PLL.
 224   ConcurrentMarkThread::slt()->
 225     manipulatePLL(SurrogateLockerThread::releaseAndNotifyPLL);
 226 }
 227 
 228 void VM_CGC_Operation::doit() {
 229   TraceCPUTime tcpu(G1Log::finer(), true, gclog_or_tty);
 230   G1CollectedHeap* g1h = G1CollectedHeap::heap();
 231   GCIdMark gc_id_mark(_gc_id);
 232   GCTraceTime t(_printGCMessage, G1Log::fine(), true, g1h->gc_timer_cm());


 233   IsGCActiveMark x;
 234   _cl->do_void();
 235 }
 236 
 237 bool VM_CGC_Operation::doit_prologue() {
 238   // Note the relative order of the locks must match that in
 239   // VM_GC_Operation::doit_prologue() or deadlocks can occur
 240   if (_needs_pll) {
 241     acquire_pending_list_lock();
 242   }
 243 
 244   Heap_lock->lock();
 245   return true;
 246 }
 247 
 248 void VM_CGC_Operation::doit_epilogue() {
 249   // Note the relative order of the unlocks must match that in
 250   // VM_GC_Operation::doit_epilogue()
 251   Heap_lock->unlock();
 252   if (_needs_pll) {


  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "gc/g1/concurrentMarkThread.inline.hpp"
  27 #include "gc/g1/g1CollectedHeap.inline.hpp"
  28 #include "gc/g1/g1CollectorPolicy.hpp"
  29 #include "gc/shared/gcId.hpp"

  30 #include "gc/g1/vm_operations_g1.hpp"
  31 #include "gc/shared/gcTimer.hpp"
  32 #include "gc/shared/gcTraceTime.hpp"
  33 #include "gc/shared/isGCActiveMark.hpp"
  34 #include "runtime/interfaceSupport.hpp"
  35 
  36 VM_G1CollectForAllocation::VM_G1CollectForAllocation(uint gc_count_before,
  37                                                      size_t word_size)
  38   : VM_G1OperationWithAllocRequest(gc_count_before, word_size,
  39                                    GCCause::_allocation_failure) {
  40   guarantee(word_size != 0, "An allocation should always be requested with this operation.");
  41 }
  42 
  43 void VM_G1CollectForAllocation::doit() {
  44   G1CollectedHeap* g1h = G1CollectedHeap::heap();
  45   GCCauseSetter x(g1h, _gc_cause);
  46 
  47   _result = g1h->satisfy_failed_allocation(_word_size, allocation_context(), &_pause_succeeded);
  48   assert(_result == NULL || _pause_succeeded,
  49          "if we get back a result, the pause should have succeeded");


 208   assert(_needs_pll, "don't call this otherwise");
 209   // The caller may block while communicating
 210   // with the SLT thread in order to acquire/release the PLL.
 211   SurrogateLockerThread* slt = ConcurrentMarkThread::slt();
 212   if (slt != NULL) {
 213     slt->manipulatePLL(SurrogateLockerThread::acquirePLL);
 214   } else {
 215     SurrogateLockerThread::report_missing_slt();
 216   }
 217 }
 218 
 219 void VM_CGC_Operation::release_and_notify_pending_list_lock() {
 220   assert(_needs_pll, "don't call this otherwise");
 221   // The caller may block while communicating
 222   // with the SLT thread in order to acquire/release the PLL.
 223   ConcurrentMarkThread::slt()->
 224     manipulatePLL(SurrogateLockerThread::releaseAndNotifyPLL);
 225 }
 226 
 227 void VM_CGC_Operation::doit() {


 228   GCIdMark gc_id_mark(_gc_id);
 229   GCTraceCPUTime tcpu;
 230   G1CollectedHeap* g1h = G1CollectedHeap::heap();
 231   GCTraceTime(Info, gc) t(_printGCMessage, g1h->gc_timer_cm(), GCCause::_no_gc, true);
 232   IsGCActiveMark x;
 233   _cl->do_void();
 234 }
 235 
 236 bool VM_CGC_Operation::doit_prologue() {
 237   // Note the relative order of the locks must match that in
 238   // VM_GC_Operation::doit_prologue() or deadlocks can occur
 239   if (_needs_pll) {
 240     acquire_pending_list_lock();
 241   }
 242 
 243   Heap_lock->lock();
 244   return true;
 245 }
 246 
 247 void VM_CGC_Operation::doit_epilogue() {
 248   // Note the relative order of the unlocks must match that in
 249   // VM_GC_Operation::doit_epilogue()
 250   Heap_lock->unlock();
 251   if (_needs_pll) {
< prev index next >