< prev index next >

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/parallel/ParallelScavengeHeap.java

Print this page




  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 package sun.jvm.hotspot.gc.parallel;
  26 
  27 import java.io.*;
  28 import java.util.*;
  29 
  30 import sun.jvm.hotspot.debugger.*;
  31 import sun.jvm.hotspot.gc.shared.*;

  32 import sun.jvm.hotspot.runtime.*;
  33 import sun.jvm.hotspot.types.*;
  34 
  35 public class ParallelScavengeHeap extends CollectedHeap {
  36    static {
  37       VM.registerVMInitializedObserver(new Observer() {
  38          public void update(Observable o, Object data) {
  39             initialize(VM.getVM().getTypeDataBase());
  40          }
  41       });
  42    }
  43 
  44    private static synchronized void initialize(TypeDataBase db) {
  45       Type type = db.lookupType("ParallelScavengeHeap");
  46       youngGenField = type.getAddressField("_young_gen");
  47       oldGenField    = type.getAddressField("_old_gen");
  48    }
  49 
  50    public ParallelScavengeHeap(Address addr) {
  51       super(addr);


  69    }
  70 
  71    public long used() {
  72       return youngGen().used() + oldGen().used();
  73    }
  74 
  75    public boolean isIn(Address a) {
  76       if (youngGen().isIn(a)) {
  77          return true;
  78       }
  79 
  80       if (oldGen().isIn(a)) {
  81          return true;
  82       }
  83 
  84       return false;
  85    }
  86 
  87    public CollectedHeapName kind() {
  88       return CollectedHeapName.PARALLEL;





























  89    }
  90 
  91    public void printOn(PrintStream tty) {
  92       tty.print("ParallelScavengeHeap [ ");
  93       youngGen().printOn(tty);
  94       oldGen().printOn(tty);
  95       tty.print(" ] ");
  96    }
  97 }


  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 package sun.jvm.hotspot.gc.parallel;
  26 
  27 import java.io.*;
  28 import java.util.*;
  29 
  30 import sun.jvm.hotspot.debugger.*;
  31 import sun.jvm.hotspot.gc.shared.*;
  32 import sun.jvm.hotspot.memory.MemRegion;
  33 import sun.jvm.hotspot.runtime.*;
  34 import sun.jvm.hotspot.types.*;
  35 
  36 public class ParallelScavengeHeap extends CollectedHeap {
  37    static {
  38       VM.registerVMInitializedObserver(new Observer() {
  39          public void update(Observable o, Object data) {
  40             initialize(VM.getVM().getTypeDataBase());
  41          }
  42       });
  43    }
  44 
  45    private static synchronized void initialize(TypeDataBase db) {
  46       Type type = db.lookupType("ParallelScavengeHeap");
  47       youngGenField = type.getAddressField("_young_gen");
  48       oldGenField    = type.getAddressField("_old_gen");
  49    }
  50 
  51    public ParallelScavengeHeap(Address addr) {
  52       super(addr);


  70    }
  71 
  72    public long used() {
  73       return youngGen().used() + oldGen().used();
  74    }
  75 
  76    public boolean isIn(Address a) {
  77       if (youngGen().isIn(a)) {
  78          return true;
  79       }
  80 
  81       if (oldGen().isIn(a)) {
  82          return true;
  83       }
  84 
  85       return false;
  86    }
  87 
  88    public CollectedHeapName kind() {
  89       return CollectedHeapName.PARALLEL;
  90    }
  91 
  92    // Simple wrapper to provide toString() usable for debugging.
  93    private class LiveRegionProviderImpl implements LiveRegionsProvider {
  94       private String name;
  95       private MutableSpace space;
  96 
  97       public LiveRegionProviderImpl(String name, MutableSpace space) {
  98          this.name = name;
  99          this.space = space;
 100       }
 101 
 102       @Override
 103       public List<MemRegion> getLiveRegions() {
 104          return space.getLiveRegions();
 105       }
 106       @Override
 107       public String toString() {
 108          return name;
 109       }
 110    }
 111 
 112    public void liveRegionsIterate(LiveRegionsClosure closure) {
 113       // Add eden space
 114       closure.doLiveRegions(new LiveRegionProviderImpl("eden", youngGen().edenSpace()));
 115       // Add from-space but not to-space
 116       closure.doLiveRegions(new LiveRegionProviderImpl("from", youngGen().fromSpace()));
 117 
 118       closure.doLiveRegions(new LiveRegionProviderImpl("old ", oldGen().objectSpace()));
 119    }
 120 
 121    public void printOn(PrintStream tty) {
 122       tty.print("ParallelScavengeHeap [ ");
 123       youngGen().printOn(tty);
 124       oldGen().printOn(tty);
 125       tty.print(" ] ");
 126    }
 127 }
< prev index next >