src/share/vm/gc_implementation/g1/satbQueue.hpp

Print this page


   1 /*
   2  * Copyright (c) 2001, 2007, 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 class ObjectClosure;
  26 class JavaThread;
  27 
  28 // A ptrQueue whose elements are "oops", pointers to object heads.
  29 class ObjPtrQueue: public PtrQueue {
  30 public:
  31   ObjPtrQueue(PtrQueueSet* qset_, bool perm = false) :
  32     // SATB queues are only active during marking cycles. We create
  33     // them with their active field set to false. If a thread is
  34     // created during a cycle and its SATB queue needs to be activated
  35     // before the thread starts running, we'll need to set its active
  36     // field to true. This is done in JavaThread::initialize_queues().
  37     PtrQueue(qset_, perm, false /* active */) { }
  38   // Apply the closure to all elements, and reset the index to make the
  39   // buffer empty.
  40   void apply_closure(ObjectClosure* cl);
  41 
  42   // Apply the closure to all elements of "buf", down to "index" (inclusive.)
  43   static void apply_closure_to_buffer(ObjectClosure* cl,
  44                                       void** buf, size_t index, size_t sz);


  96   // Parallel version of the above.
  97   void par_iterate_closure_all_threads(int worker);
  98 
  99   // If there exists some completed buffer, pop it, then apply the
 100   // registered closure to all its elements, and return true.  If no
 101   // completed buffers exist, return false.
 102   bool apply_closure_to_completed_buffer() {
 103     return apply_closure_to_completed_buffer_work(false, 0);
 104   }
 105   // Parallel version of the above.
 106   bool par_apply_closure_to_completed_buffer(int worker) {
 107     return apply_closure_to_completed_buffer_work(true, worker);
 108   }
 109 
 110   ObjPtrQueue* shared_satb_queue() { return &_shared_satb_queue; }
 111 
 112   // If a marking is being abandoned, reset any unprocessed log buffers.
 113   void abandon_partial_marking();
 114 
 115 };


   1 /*
   2  * Copyright (c) 2001, 2010, 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 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_SATBQUEUE_HPP
  26 #define SHARE_VM_GC_IMPLEMENTATION_G1_SATBQUEUE_HPP
  27 
  28 #include "gc_implementation/g1/ptrQueue.hpp"
  29 
  30 class ObjectClosure;
  31 class JavaThread;
  32 
  33 // A ptrQueue whose elements are "oops", pointers to object heads.
  34 class ObjPtrQueue: public PtrQueue {
  35 public:
  36   ObjPtrQueue(PtrQueueSet* qset_, bool perm = false) :
  37     // SATB queues are only active during marking cycles. We create
  38     // them with their active field set to false. If a thread is
  39     // created during a cycle and its SATB queue needs to be activated
  40     // before the thread starts running, we'll need to set its active
  41     // field to true. This is done in JavaThread::initialize_queues().
  42     PtrQueue(qset_, perm, false /* active */) { }
  43   // Apply the closure to all elements, and reset the index to make the
  44   // buffer empty.
  45   void apply_closure(ObjectClosure* cl);
  46 
  47   // Apply the closure to all elements of "buf", down to "index" (inclusive.)
  48   static void apply_closure_to_buffer(ObjectClosure* cl,
  49                                       void** buf, size_t index, size_t sz);


 101   // Parallel version of the above.
 102   void par_iterate_closure_all_threads(int worker);
 103 
 104   // If there exists some completed buffer, pop it, then apply the
 105   // registered closure to all its elements, and return true.  If no
 106   // completed buffers exist, return false.
 107   bool apply_closure_to_completed_buffer() {
 108     return apply_closure_to_completed_buffer_work(false, 0);
 109   }
 110   // Parallel version of the above.
 111   bool par_apply_closure_to_completed_buffer(int worker) {
 112     return apply_closure_to_completed_buffer_work(true, worker);
 113   }
 114 
 115   ObjPtrQueue* shared_satb_queue() { return &_shared_satb_queue; }
 116 
 117   // If a marking is being abandoned, reset any unprocessed log buffers.
 118   void abandon_partial_marking();
 119 
 120 };
 121 
 122 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_SATBQUEUE_HPP