hotspot/src/share/vm/gc_implementation/shared/mutableSpace.hpp

Print this page
rev 611 : Merge

@@ -1,10 +1,10 @@
 #ifdef USE_PRAGMA_IDENT_HDR
 #pragma ident "@(#)mutableSpace.hpp     1.22 07/05/05 17:05:35 JVM"
 #endif
 /*
- * Copyright 2001-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2001-2008 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -31,18 +31,27 @@
 // an assumption.
 //
 // Invariant: (ImmutableSpace +) bottom() <= top() <= end() 
 // top() is inclusive and end() is exclusive.
 
+class MutableSpaceMangler;
+
 class MutableSpace: public ImmutableSpace {
   friend class VMStructs;
+
+  // Helper for mangling unused space in debug builds
+  MutableSpaceMangler* _mangler;
+
  protected:
   HeapWord* _top;
 
+  MutableSpaceMangler* mangler() { return _mangler; }
+
  public:
-  virtual ~MutableSpace()                  {}
-  MutableSpace()                           { _top = NULL;    }
+  virtual ~MutableSpace();
+  MutableSpace();
+
   // Accessors
   HeapWord* top() const                    { return _top;    }
   virtual void set_top(HeapWord* value)    { _top = value;   }
 
   HeapWord** top_addr()                    { return &_top; }

@@ -53,25 +62,34 @@
 
   // Returns a subregion containing all objects in this space.
   MemRegion used_region() { return MemRegion(bottom(), top()); }
 
   // Initialization
-  virtual void initialize(MemRegion mr, bool clear_space);
-  virtual void clear();
+  virtual void initialize(MemRegion mr,
+                          bool clear_space,
+                          bool mangle_space);
+  virtual void clear(bool mangle_space);
+  // Does the usual initialization but optionally resets top to bottom.
+#if 0  // MANGLE_SPACE
+  void initialize(MemRegion mr, bool clear_space, bool reset_top);
+#endif
   virtual void update() { }
   virtual void accumulate_statistics() { }
 
-  // Overwrites the unused portion of this space. Note that some collectors
-  // may use this "scratch" space during collections.
-  virtual void mangle_unused_area() {
-    mangle_region(MemRegion(_top, _end));
-  }
+  // Methods used in mangling.  See descriptions under SpaceMangler.
+  virtual void mangle_unused_area() PRODUCT_RETURN;
+  virtual void mangle_unused_area_complete() PRODUCT_RETURN;
+  virtual void check_mangled_unused_area(HeapWord* limit) PRODUCT_RETURN;
+  virtual void check_mangled_unused_area_complete() PRODUCT_RETURN;
+  virtual void set_top_for_allocations(HeapWord* v) PRODUCT_RETURN;
+
+  // Used to save the space's current top for later use during mangling.
+  virtual void set_top_for_allocations() PRODUCT_RETURN;
+
   virtual void ensure_parsability() { }
 
-  void mangle_region(MemRegion mr) {
-    debug_only(Copy::fill_to_words(mr.start(), mr.word_size(), badHeapWord));
-  }
+  virtual void mangle_region(MemRegion mr) PRODUCT_RETURN;
 
   // Boolean querries.
   bool is_empty() const              { return used_in_words() == 0; }
   bool not_empty() const             { return used_in_words() > 0; }
   bool contains(const void* p) const { return _bottom <= p && p < _end; }

@@ -99,7 +117,7 @@
   // Debugging
   virtual void print() const;
   virtual void print_on(outputStream* st) const;
   virtual void print_short() const;
   virtual void print_short_on(outputStream* st) const;
-  virtual void verify(bool allow_dirty) const;
+  virtual void verify(bool allow_dirty);
 };