< prev index next >

src/hotspot/share/gc/shared/preservedMarks.hpp

Print this page

 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_GC_SHARED_PRESERVEDMARKS_HPP
 26 #define SHARE_GC_SHARED_PRESERVEDMARKS_HPP
 27 
 28 #include "memory/allocation.hpp"
 29 #include "memory/padded.hpp"
 30 #include "oops/oop.hpp"
 31 #include "utilities/stack.hpp"
 32 
 33 class AbstractGangTask;
 34 class PreservedMarksSet;

 35 class WorkGang;
 36 
 37 class PreservedMarks {
 38 private:
 39   class OopAndMarkWord {
 40   private:
 41     oop _o;
 42     markWord _m;
 43 
 44   public:
 45     OopAndMarkWord(oop obj, markWord m) : _o(obj), _m(m) { }
 46 
 47     oop get_oop() { return _o; }
 48     inline void set_mark() const;
 49     void set_oop(oop obj) { _o = obj; }
 50   };
 51   typedef Stack<OopAndMarkWord, mtGC> OopAndMarkWordStack;
 52 
 53   OopAndMarkWordStack _stack;
 54 
 55   inline bool should_preserve_mark(oop obj, markWord m) const;
 56 
 57 public:
 58   size_t size() const { return _stack.size(); }
 59   inline void push(oop obj, markWord m);
 60   inline void push_if_necessary(oop obj, markWord m);
 61   // Iterate over the stack, restore all preserved marks, and
 62   // reclaim the memory taken up by the stack segments.
 63   void restore();
 64   // Iterate over the stack, adjust all preserved marks according
 65   // to their forwarding location stored in the mark.


 66   void adjust_during_full_gc();
 67 


 68   void restore_and_increment(volatile size_t* const _total_size_addr);
 69   inline static void init_forwarded_mark(oop obj);
 70 
 71   // Assert the stack is empty and has no cached segments.
 72   void assert_empty() PRODUCT_RETURN;
 73 
 74   inline PreservedMarks();
 75   ~PreservedMarks() { assert_empty(); }
 76 };
 77 
 78 class RemoveForwardedPointerClosure: public ObjectClosure {
 79 public:
 80   virtual void do_object(oop obj);
 81 };
 82 
 83 class PreservedMarksSet : public CHeapObj<mtGC> {
 84 private:
 85   // true -> _stacks will be allocated in the C heap
 86   // false -> _stacks will be allocated in the resource arena
 87   const bool _in_c_heap;

 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_GC_SHARED_PRESERVEDMARKS_HPP
 26 #define SHARE_GC_SHARED_PRESERVEDMARKS_HPP
 27 
 28 #include "memory/allocation.hpp"
 29 #include "memory/padded.hpp"
 30 #include "oops/oop.hpp"
 31 #include "utilities/stack.hpp"
 32 
 33 class AbstractGangTask;
 34 class PreservedMarksSet;
 35 class SlidingForwarding;
 36 class WorkGang;
 37 
 38 class PreservedMarks {
 39 private:
 40   class OopAndMarkWord {
 41   private:
 42     oop _o;
 43     markWord _m;
 44 
 45   public:
 46     OopAndMarkWord(oop obj, markWord m) : _o(obj), _m(m) { }
 47 
 48     oop get_oop() { return _o; }
 49     inline void set_mark() const;
 50     void set_oop(oop obj) { _o = obj; }
 51   };
 52   typedef Stack<OopAndMarkWord, mtGC> OopAndMarkWordStack;
 53 
 54   OopAndMarkWordStack _stack;
 55 
 56   inline bool should_preserve_mark(oop obj, markWord m) const;
 57 
 58 public:
 59   size_t size() const { return _stack.size(); }
 60   inline void push(oop obj, markWord m);
 61   inline void push_if_necessary(oop obj, markWord m);
 62   // Iterate over the stack, restore all preserved marks, and
 63   // reclaim the memory taken up by the stack segments.
 64   void restore();
 65   // Iterate over the stack, adjust all preserved marks according
 66   // to their forwarding location stored in the mark.
 67   // TODO: This method is unused, except in the gunit test. Change the test
 68   // to exercise the updated method below instead, and remove this one.
 69   void adjust_during_full_gc();
 70 
 71   void adjust_during_full_gc(const SlidingForwarding* const forwarding);
 72 
 73   void restore_and_increment(volatile size_t* const _total_size_addr);
 74   inline static void init_forwarded_mark(oop obj);
 75 
 76   // Assert the stack is empty and has no cached segments.
 77   void assert_empty() PRODUCT_RETURN;
 78 
 79   inline PreservedMarks();
 80   ~PreservedMarks() { assert_empty(); }
 81 };
 82 
 83 class RemoveForwardedPointerClosure: public ObjectClosure {
 84 public:
 85   virtual void do_object(oop obj);
 86 };
 87 
 88 class PreservedMarksSet : public CHeapObj<mtGC> {
 89 private:
 90   // true -> _stacks will be allocated in the C heap
 91   // false -> _stacks will be allocated in the resource arena
 92   const bool _in_c_heap;
< prev index next >