< prev index next >

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java

Print this page
rev 52710 : Upstream/backport Shenandoah to JDK11u
   1 /*
   2  * Copyright (c) 2000, 2015, 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 //
  26 // The ObjectHeap is an abstraction over all generations in the VM
  27 // It gives access to all present objects and classes.
  28 //
  29 
  30 package sun.jvm.hotspot.oops;
  31 
  32 import java.util.*;
  33 
  34 import sun.jvm.hotspot.debugger.*;
  35 import sun.jvm.hotspot.gc.cms.*;
  36 import sun.jvm.hotspot.gc.shared.*;
  37 import sun.jvm.hotspot.gc.epsilon.*;
  38 import sun.jvm.hotspot.gc.g1.*;

  39 import sun.jvm.hotspot.gc.parallel.*;
  40 import sun.jvm.hotspot.memory.*;
  41 import sun.jvm.hotspot.runtime.*;
  42 import sun.jvm.hotspot.types.*;
  43 import sun.jvm.hotspot.utilities.*;
  44 
  45 public class ObjectHeap {
  46 
  47   private static final boolean DEBUG;
  48 
  49   static {
  50     DEBUG = System.getProperty("sun.jvm.hotspot.oops.ObjectHeap.DEBUG") != null;
  51   }
  52 
  53   private Address              boolArrayKlassHandle;
  54   private Address              byteArrayKlassHandle;
  55   private Address              charArrayKlassHandle;
  56   private Address              intArrayKlassHandle;
  57   private Address              shortArrayKlassHandle;
  58   private Address              longArrayKlassHandle;


 422 
 423     if (heap instanceof GenCollectedHeap) {
 424        GenCollectedHeap genHeap = (GenCollectedHeap) heap;
 425        // Run through all generations, obtaining bottom-top pairs.
 426        for (int i = 0; i < genHeap.nGens(); i++) {
 427          Generation gen = genHeap.getGen(i);
 428          gen.spaceIterate(lrc, true);
 429        }
 430     } else if (heap instanceof ParallelScavengeHeap) {
 431        ParallelScavengeHeap psh = (ParallelScavengeHeap) heap;
 432        PSYoungGen youngGen = psh.youngGen();
 433        // Add eden space
 434        addLiveRegions("eden", youngGen.edenSpace().getLiveRegions(), liveRegions);
 435        // Add from-space but not to-space
 436        addLiveRegions("from", youngGen.fromSpace().getLiveRegions(), liveRegions);
 437        PSOldGen oldGen = psh.oldGen();
 438        addLiveRegions("old ", oldGen.objectSpace().getLiveRegions(), liveRegions);
 439     } else if (heap instanceof G1CollectedHeap) {
 440         G1CollectedHeap g1h = (G1CollectedHeap) heap;
 441         g1h.heapRegionIterate(lrc);




 442     } else if (heap instanceof EpsilonHeap) {
 443        EpsilonHeap eh = (EpsilonHeap) heap;
 444        liveRegions.add(eh.space().top());
 445        liveRegions.add(eh.space().bottom());
 446     } else {
 447        if (Assert.ASSERTS_ENABLED) {
 448           Assert.that(false, "Unexpected CollectedHeap type: " + heap.getClass().getName());
 449        }
 450     }
 451 
 452     // If UseTLAB is enabled, snip out regions associated with TLABs'
 453     // dead regions. Note that TLABs can be present in any generation.
 454 
 455     // FIXME: consider adding fewer boundaries to live region list.
 456     // Theoretically only need to stop at TLAB's top and resume at its
 457     // end.
 458 
 459     if (VM.getVM().getUseTLAB()) {
 460       for (JavaThread thread = VM.getVM().getThreads().first(); thread != null; thread = thread.next()) {
 461         ThreadLocalAllocBuffer tlab = thread.tlab();


   1 /*
   2  * Copyright (c) 2000, 2018, 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 //
  26 // The ObjectHeap is an abstraction over all generations in the VM
  27 // It gives access to all present objects and classes.
  28 //
  29 
  30 package sun.jvm.hotspot.oops;
  31 
  32 import java.util.*;
  33 
  34 import sun.jvm.hotspot.debugger.*;
  35 import sun.jvm.hotspot.gc.cms.*;
  36 import sun.jvm.hotspot.gc.shared.*;
  37 import sun.jvm.hotspot.gc.epsilon.*;
  38 import sun.jvm.hotspot.gc.g1.*;
  39 import sun.jvm.hotspot.gc.shenandoah.*;
  40 import sun.jvm.hotspot.gc.parallel.*;
  41 import sun.jvm.hotspot.memory.*;
  42 import sun.jvm.hotspot.runtime.*;
  43 import sun.jvm.hotspot.types.*;
  44 import sun.jvm.hotspot.utilities.*;
  45 
  46 public class ObjectHeap {
  47 
  48   private static final boolean DEBUG;
  49 
  50   static {
  51     DEBUG = System.getProperty("sun.jvm.hotspot.oops.ObjectHeap.DEBUG") != null;
  52   }
  53 
  54   private Address              boolArrayKlassHandle;
  55   private Address              byteArrayKlassHandle;
  56   private Address              charArrayKlassHandle;
  57   private Address              intArrayKlassHandle;
  58   private Address              shortArrayKlassHandle;
  59   private Address              longArrayKlassHandle;


 423 
 424     if (heap instanceof GenCollectedHeap) {
 425        GenCollectedHeap genHeap = (GenCollectedHeap) heap;
 426        // Run through all generations, obtaining bottom-top pairs.
 427        for (int i = 0; i < genHeap.nGens(); i++) {
 428          Generation gen = genHeap.getGen(i);
 429          gen.spaceIterate(lrc, true);
 430        }
 431     } else if (heap instanceof ParallelScavengeHeap) {
 432        ParallelScavengeHeap psh = (ParallelScavengeHeap) heap;
 433        PSYoungGen youngGen = psh.youngGen();
 434        // Add eden space
 435        addLiveRegions("eden", youngGen.edenSpace().getLiveRegions(), liveRegions);
 436        // Add from-space but not to-space
 437        addLiveRegions("from", youngGen.fromSpace().getLiveRegions(), liveRegions);
 438        PSOldGen oldGen = psh.oldGen();
 439        addLiveRegions("old ", oldGen.objectSpace().getLiveRegions(), liveRegions);
 440     } else if (heap instanceof G1CollectedHeap) {
 441         G1CollectedHeap g1h = (G1CollectedHeap) heap;
 442         g1h.heapRegionIterate(lrc);
 443     } else if (heap instanceof ShenandoahHeap) {
 444        // Operation (currently) not supported with Shenandoah GC. Print
 445        // a warning and leave the list of live regions empty.
 446        System.err.println("Warning: Operation not supported with Shenandoah GC");
 447     } else if (heap instanceof EpsilonHeap) {
 448        EpsilonHeap eh = (EpsilonHeap) heap;
 449        liveRegions.add(eh.space().top());
 450        liveRegions.add(eh.space().bottom());
 451     } else {
 452        if (Assert.ASSERTS_ENABLED) {
 453           Assert.that(false, "Unexpected CollectedHeap type: " + heap.getClass().getName());
 454        }
 455     }
 456 
 457     // If UseTLAB is enabled, snip out regions associated with TLABs'
 458     // dead regions. Note that TLABs can be present in any generation.
 459 
 460     // FIXME: consider adding fewer boundaries to live region list.
 461     // Theoretically only need to stop at TLAB's top and resume at its
 462     // end.
 463 
 464     if (VM.getVM().getUseTLAB()) {
 465       for (JavaThread thread = VM.getVM().getThreads().first(); thread != null; thread = thread.next()) {
 466         ThreadLocalAllocBuffer tlab = thread.tlab();


< prev index next >