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

Print this page
rev 4773 : 8005849: JEP 167: Event-Based JVM Tracing
Reviewed-by: acorn, coleenp, sla
Contributed-by: Karen Kinnear <karen.kinnear@oracle.com>, Bengt Rutisson <bengt.rutisson@oracle.com>, Calvin Cheung <calvin.cheung@oracle.com>, Erik Gahlin <erik.gahlin@oracle.com>, Erik Helin <erik.helin@oracle.com>, Jesper Wilhelmsson <jesper.wilhelmsson@oracle.com>, Keith McGuigan <keith.mcguigan@oracle.com>, Mattias Tobiasson <mattias.tobiasson@oracle.com>, Markus Gronlund <markus.gronlund@oracle.com>, Mikael Auno <mikael.auno@oracle.com>, Nils Eliasson <nils.eliasson@oracle.com>, Nils Loodin <nils.loodin@oracle.com>, Rickard Backman <rickard.backman@oracle.com>, Staffan Larsen <staffan.larsen@oracle.com>, Stefan Karlsson <stefan.karlsson@oracle.com>, Yekaterina Kantserova <yekaterina.kantserova@oracle.com>
   1 /*
   2  * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  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_implementation/g1/concurrentMarkThread.inline.hpp"
  27 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
  28 #include "gc_implementation/g1/g1CollectorPolicy.hpp"
  29 #include "gc_implementation/g1/g1Log.hpp"
  30 #include "gc_implementation/g1/vm_operations_g1.hpp"


  31 #include "gc_implementation/shared/isGCActiveMark.hpp"
  32 #include "gc_implementation/g1/vm_operations_g1.hpp"
  33 #include "runtime/interfaceSupport.hpp"
  34 
  35 VM_G1CollectForAllocation::VM_G1CollectForAllocation(
  36                                                   unsigned int 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");
  41 }
  42 
  43 void VM_G1CollectForAllocation::doit() {
  44   G1CollectedHeap* g1h = G1CollectedHeap::heap();
  45   GCCauseSetter x(g1h, _gc_cause);
  46   _result = g1h->satisfy_failed_allocation(_word_size, &_pause_succeeded);
  47   assert(_result == NULL || _pause_succeeded,
  48          "if we get back a result, the pause should have succeeded");
  49 }
  50 


 210 
 211 void VM_CGC_Operation::acquire_pending_list_lock() {
 212   assert(_needs_pll, "don't call this otherwise");
 213   // The caller may block while communicating
 214   // with the SLT thread in order to acquire/release the PLL.
 215   ConcurrentMarkThread::slt()->
 216     manipulatePLL(SurrogateLockerThread::acquirePLL);
 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   gclog_or_tty->date_stamp(G1Log::fine() && PrintGCDateStamps);
 229   TraceCPUTime tcpu(G1Log::finer(), true, gclog_or_tty);
 230   TraceTime t(_printGCMessage, G1Log::fine(), true, gclog_or_tty);
 231   SharedHeap* sh = SharedHeap::heap();
 232   // This could go away if CollectedHeap gave access to _gc_is_active...
 233   if (sh != NULL) {
 234     IsGCActiveMark x;
 235     _cl->do_void();
 236   } else {
 237     _cl->do_void();
 238   }
 239 }
 240 
 241 bool VM_CGC_Operation::doit_prologue() {
 242   // Note the relative order of the locks must match that in
 243   // VM_GC_Operation::doit_prologue() or deadlocks can occur
 244   if (_needs_pll) {
 245     acquire_pending_list_lock();
 246   }
 247 
 248   Heap_lock->lock();
 249   SharedHeap::heap()->_thread_holds_heap_lock_for_gc = true;
 250   return true;
   1 /*
   2  * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  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_implementation/g1/concurrentMarkThread.inline.hpp"
  27 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
  28 #include "gc_implementation/g1/g1CollectorPolicy.hpp"
  29 #include "gc_implementation/g1/g1Log.hpp"
  30 #include "gc_implementation/g1/vm_operations_g1.hpp"
  31 #include "gc_implementation/shared/gcTimer.hpp"
  32 #include "gc_implementation/shared/gcTraceTime.hpp"
  33 #include "gc_implementation/shared/isGCActiveMark.hpp"
  34 #include "gc_implementation/g1/vm_operations_g1.hpp"
  35 #include "runtime/interfaceSupport.hpp"
  36 
  37 VM_G1CollectForAllocation::VM_G1CollectForAllocation(
  38                                                   unsigned int gc_count_before,
  39                                                   size_t word_size)
  40   : VM_G1OperationWithAllocRequest(gc_count_before, word_size,
  41                                    GCCause::_allocation_failure) {
  42   guarantee(word_size > 0, "an allocation should always be requested");
  43 }
  44 
  45 void VM_G1CollectForAllocation::doit() {
  46   G1CollectedHeap* g1h = G1CollectedHeap::heap();
  47   GCCauseSetter x(g1h, _gc_cause);
  48   _result = g1h->satisfy_failed_allocation(_word_size, &_pause_succeeded);
  49   assert(_result == NULL || _pause_succeeded,
  50          "if we get back a result, the pause should have succeeded");
  51 }
  52 


 212 
 213 void VM_CGC_Operation::acquire_pending_list_lock() {
 214   assert(_needs_pll, "don't call this otherwise");
 215   // The caller may block while communicating
 216   // with the SLT thread in order to acquire/release the PLL.
 217   ConcurrentMarkThread::slt()->
 218     manipulatePLL(SurrogateLockerThread::acquirePLL);
 219 }
 220 
 221 void VM_CGC_Operation::release_and_notify_pending_list_lock() {
 222   assert(_needs_pll, "don't call this otherwise");
 223   // The caller may block while communicating
 224   // with the SLT thread in order to acquire/release the PLL.
 225   ConcurrentMarkThread::slt()->
 226     manipulatePLL(SurrogateLockerThread::releaseAndNotifyPLL);
 227 }
 228 
 229 void VM_CGC_Operation::doit() {
 230   gclog_or_tty->date_stamp(G1Log::fine() && PrintGCDateStamps);
 231   TraceCPUTime tcpu(G1Log::finer(), true, gclog_or_tty);
 232   GCTraceTime t(_printGCMessage, G1Log::fine(), true, G1CollectedHeap::heap()->gc_timer_cm());
 233   SharedHeap* sh = SharedHeap::heap();
 234   // This could go away if CollectedHeap gave access to _gc_is_active...
 235   if (sh != NULL) {
 236     IsGCActiveMark x;
 237     _cl->do_void();
 238   } else {
 239     _cl->do_void();
 240   }
 241 }
 242 
 243 bool VM_CGC_Operation::doit_prologue() {
 244   // Note the relative order of the locks must match that in
 245   // VM_GC_Operation::doit_prologue() or deadlocks can occur
 246   if (_needs_pll) {
 247     acquire_pending_list_lock();
 248   }
 249 
 250   Heap_lock->lock();
 251   SharedHeap::heap()->_thread_holds_heap_lock_for_gc = true;
 252   return true;