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

changeset 3416
2ace1c4ee8da
parent 2469
7e37af9d69ef
child 6396
f99e331f6ef6
     1.1 --- a/src/share/vm/gc_implementation/g1/satbQueue.hpp	Tue Jan 10 20:02:41 2012 +0100
     1.2 +++ b/src/share/vm/gc_implementation/g1/satbQueue.hpp	Tue Jan 10 18:58:13 2012 -0500
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -29,9 +29,26 @@
    1.11  
    1.12  class ObjectClosure;
    1.13  class JavaThread;
    1.14 +class SATBMarkQueueSet;
    1.15  
    1.16  // A ptrQueue whose elements are "oops", pointers to object heads.
    1.17  class ObjPtrQueue: public PtrQueue {
    1.18 +  friend class SATBMarkQueueSet;
    1.19 +
    1.20 +private:
    1.21 +  // Filter out unwanted entries from the buffer.
    1.22 +  void filter();
    1.23 +
    1.24 +  // Apply the closure to all elements.
    1.25 +  void apply_closure(ObjectClosure* cl);
    1.26 +
    1.27 +  // Apply the closure to all elements and empty the buffer;
    1.28 +  void apply_closure_and_empty(ObjectClosure* cl);
    1.29 +
    1.30 +  // Apply the closure to all elements of "buf", down to "index" (inclusive.)
    1.31 +  static void apply_closure_to_buffer(ObjectClosure* cl,
    1.32 +                                      void** buf, size_t index, size_t sz);
    1.33 +
    1.34  public:
    1.35    ObjPtrQueue(PtrQueueSet* qset, bool perm = false) :
    1.36      // SATB queues are only active during marking cycles. We create
    1.37 @@ -41,23 +58,23 @@
    1.38      // field to true. This is done in JavaThread::initialize_queues().
    1.39      PtrQueue(qset, perm, false /* active */) { }
    1.40  
    1.41 +  // Overrides PtrQueue::flush() so that it can filter the buffer
    1.42 +  // before it is flushed.
    1.43 +  virtual void flush();
    1.44 +
    1.45    // Overrides PtrQueue::should_enqueue_buffer(). See the method's
    1.46    // definition for more information.
    1.47    virtual bool should_enqueue_buffer();
    1.48  
    1.49 -  // Apply the closure to all elements, and reset the index to make the
    1.50 -  // buffer empty.
    1.51 -  void apply_closure(ObjectClosure* cl);
    1.52 -
    1.53 -  // Apply the closure to all elements of "buf", down to "index" (inclusive.)
    1.54 -  static void apply_closure_to_buffer(ObjectClosure* cl,
    1.55 -                                      void** buf, size_t index, size_t sz);
    1.56 +#ifndef PRODUCT
    1.57 +  // Helpful for debugging
    1.58 +  void print(const char* name);
    1.59 +  static void print(const char* name, void** buf, size_t index, size_t sz);
    1.60 +#endif // PRODUCT
    1.61  
    1.62    void verify_oops_in_buffer() NOT_DEBUG_RETURN;
    1.63  };
    1.64  
    1.65 -
    1.66 -
    1.67  class SATBMarkQueueSet: public PtrQueueSet {
    1.68    ObjectClosure* _closure;
    1.69    ObjectClosure** _par_closures;  // One per ParGCThread.
    1.70 @@ -88,6 +105,9 @@
    1.71    // set itself, has an active value same as expected_active.
    1.72    void set_active_all_threads(bool b, bool expected_active);
    1.73  
    1.74 +  // Filter all the currently-active SATB buffers.
    1.75 +  void filter_thread_buffers();
    1.76 +
    1.77    // Register "blk" as "the closure" for all queues.  Only one such closure
    1.78    // is allowed.  The "apply_closure_to_completed_buffer" method will apply
    1.79    // this closure to a completed buffer, and "iterate_closure_all_threads"
    1.80 @@ -98,10 +118,9 @@
    1.81    // closures, one for each parallel GC thread.
    1.82    void set_par_closure(int i, ObjectClosure* closure);
    1.83  
    1.84 -  // If there is a registered closure for buffers, apply it to all entries
    1.85 -  // in all currently-active buffers.  This should only be applied at a
    1.86 -  // safepoint.  (Currently must not be called in parallel; this should
    1.87 -  // change in the future.)
    1.88 +  // Apply the registered closure to all entries on each
    1.89 +  // currently-active buffer and then empty the buffer. It should only
    1.90 +  // be called serially and at a safepoint.
    1.91    void iterate_closure_all_threads();
    1.92    // Parallel version of the above.
    1.93    void par_iterate_closure_all_threads(int worker);
    1.94 @@ -117,11 +136,21 @@
    1.95      return apply_closure_to_completed_buffer_work(true, worker);
    1.96    }
    1.97  
    1.98 +  // Apply the given closure on enqueued and currently-active buffers
    1.99 +  // respectively. Both methods are read-only, i.e., they do not
   1.100 +  // modify any of the buffers.
   1.101 +  void iterate_completed_buffers_read_only(ObjectClosure* cl);
   1.102 +  void iterate_thread_buffers_read_only(ObjectClosure* cl);
   1.103 +
   1.104 +#ifndef PRODUCT
   1.105 +  // Helpful for debugging
   1.106 +  void print_all(const char* msg);
   1.107 +#endif // PRODUCT
   1.108 +
   1.109    ObjPtrQueue* shared_satb_queue() { return &_shared_satb_queue; }
   1.110  
   1.111    // If a marking is being abandoned, reset any unprocessed log buffers.
   1.112    void abandon_partial_marking();
   1.113 -
   1.114  };
   1.115  
   1.116  #endif // SHARE_VM_GC_IMPLEMENTATION_G1_SATBQUEUE_HPP

mercurial