comparison agent/src/share/classes/sun/jvm/hotspot/memory/DefNewGeneration.java @ 0:a61af66fc99e jdk7-b24

Initial load
author duke
date Sat, 01 Dec 2007 00:00:00 +0000
parents
children c70a245cad3a
comparison
equal deleted inserted replaced
-1:000000000000 0:a61af66fc99e
1 /*
2 * Copyright 2000-2005 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 *
23 */
24
25 package sun.jvm.hotspot.memory;
26
27 import java.io.*;
28 import java.util.*;
29
30 import sun.jvm.hotspot.debugger.*;
31 import sun.jvm.hotspot.runtime.*;
32 import sun.jvm.hotspot.types.*;
33
34 /** DefNewGeneration is a young generation containing eden, from- and
35 to-space. */
36
37 public class DefNewGeneration extends Generation {
38 protected static AddressField edenSpaceField;
39 protected static AddressField fromSpaceField;
40 protected static AddressField toSpaceField;
41
42 static {
43 VM.registerVMInitializedObserver(new Observer() {
44 public void update(Observable o, Object data) {
45 initialize(VM.getVM().getTypeDataBase());
46 }
47 });
48 }
49
50 private static synchronized void initialize(TypeDataBase db) {
51 Type type = db.lookupType("DefNewGeneration");
52
53 edenSpaceField = type.getAddressField("_eden_space");
54 fromSpaceField = type.getAddressField("_from_space");
55 toSpaceField = type.getAddressField("_to_space");
56 }
57
58 public DefNewGeneration(Address addr) {
59 super(addr);
60 }
61
62 public Generation.Name kind() {
63 return Generation.Name.DEF_NEW;
64 }
65
66 // Accessing spaces
67 public EdenSpace eden() {
68 return (EdenSpace) VMObjectFactory.newObject(EdenSpace.class, edenSpaceField.getValue(addr));
69 }
70
71 public ContiguousSpace from() {
72 return (ContiguousSpace) VMObjectFactory.newObject(ContiguousSpace.class, fromSpaceField.getValue(addr));
73 }
74
75 public ContiguousSpace to() {
76 return (ContiguousSpace) VMObjectFactory.newObject(ContiguousSpace.class, toSpaceField.getValue(addr));
77 }
78
79 public long capacity() { return eden().capacity() + from().capacity(); /* to() is only used during scavenge */ }
80 public long used() { return eden().used() + from().used(); /* to() is only used during scavenge */ }
81 public long free() { return eden().free() + from().free(); /* to() is only used during scavenge */ }
82 public long contiguousAvailable() { return eden().free(); }
83
84 public String name() {
85 return "default new generation";
86 }
87
88 public void spaceIterate(SpaceClosure blk, boolean usedOnly) {
89 blk.doSpace(eden());
90 blk.doSpace(from());
91 if (!usedOnly) {
92 blk.doSpace(to());
93 }
94 }
95
96 public void printOn(PrintStream tty) {
97 tty.print(" eden");
98 eden().printOn(tty);
99 tty.print(" from");
100 from().printOn(tty);
101 tty.print(" to ");
102 to().printOn(tty);
103 }
104 }