1 /* 2 * Copyright (c) 2000, 2019, 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 package sun.jvm.hotspot.gc.serial; 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 /** <P> TenuredGeneration models a heap of old objects contained 36 in a single contiguous space. </P> 37 38 <P> Garbage collection is performed using mark-compact. </P> */ 39 40 public class TenuredGeneration extends CardGeneration { 41 private static AddressField theSpaceField; 42 43 static { 44 VM.registerVMInitializedObserver(new Observer() { 45 public void update(Observable o, Object data) { 46 initialize(VM.getVM().getTypeDataBase()); 47 } 48 }); 49 } 50 51 private static synchronized void initialize(TypeDataBase db) { 52 Type type = db.lookupType("TenuredGeneration"); 53 54 theSpaceField = type.getAddressField("_the_space"); 55 } 56 57 public TenuredGeneration(Address addr) { 58 super(addr); 59 } 60 61 public ContiguousSpace theSpace() { 62 return (ContiguousSpace) VMObjectFactory.newObject(ContiguousSpace.class, theSpaceField.getValue(addr)); 63 } 64 65 public boolean isIn(Address p) { 66 return theSpace().contains(p); 67 } 68 69 /** Space queries */ 70 public long capacity() { return theSpace().capacity(); } 71 public long used() { return theSpace().used(); } 72 public long free() { return theSpace().free(); } 73 public long contiguousAvailable() { return theSpace().free() + virtualSpace().uncommittedSize(); } 74 75 public void spaceIterate(SpaceClosure blk, boolean usedOnly) { 76 blk.doSpace(theSpace()); 77 } 78 79 public void liveRegionsIterate(LiveRegionsClosure closure) { 80 closure.doLiveRegions(theSpace()); 81 } 82 83 public void printOn(PrintStream tty) { 84 tty.print(" old "); 85 theSpace().printOn(tty); 86 } 87 88 public Generation.Name kind() { 89 return Generation.Name.MARK_SWEEP_COMPACT; 90 } 91 92 public String name() { 93 return "tenured generation"; 94 } 95 }