0
|
1 /*
|
|
2 * Copyright 2003 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.gc_implementation.parallelScavenge;
|
|
26
|
|
27 import java.io.*;
|
|
28 import java.util.*;
|
|
29
|
|
30 import sun.jvm.hotspot.debugger.*;
|
|
31 import sun.jvm.hotspot.gc_implementation.shared.*;
|
|
32 import sun.jvm.hotspot.memory.*;
|
|
33 import sun.jvm.hotspot.runtime.*;
|
|
34 import sun.jvm.hotspot.types.*;
|
|
35
|
|
36 public class PSYoungGen extends VMObject {
|
|
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("PSYoungGen");
|
|
47 edenSpaceField = type.getAddressField("_eden_space");
|
|
48 fromSpaceField = type.getAddressField("_from_space");
|
|
49 toSpaceField = type.getAddressField("_to_space");
|
|
50 }
|
|
51
|
|
52 public PSYoungGen(Address addr) {
|
|
53 super(addr);
|
|
54 }
|
|
55
|
|
56 // Fields
|
|
57 private static AddressField edenSpaceField;
|
|
58 private static AddressField fromSpaceField;
|
|
59 private static AddressField toSpaceField;
|
|
60
|
|
61 // Accessors
|
|
62 public MutableSpace edenSpace() {
|
|
63 return (MutableSpace) VMObjectFactory.newObject(MutableSpace.class, edenSpaceField.getValue(addr));
|
|
64 }
|
|
65
|
|
66 public MutableSpace fromSpace() {
|
|
67 return (MutableSpace) VMObjectFactory.newObject(MutableSpace.class, fromSpaceField.getValue(addr));
|
|
68 }
|
|
69
|
|
70 public MutableSpace toSpace() {
|
|
71 return (MutableSpace) VMObjectFactory.newObject(MutableSpace.class, toSpaceField.getValue(addr));
|
|
72 }
|
|
73
|
|
74 public long capacity() {
|
|
75 return edenSpace().capacity() + fromSpace().capacity();
|
|
76 }
|
|
77
|
|
78 public long used() {
|
|
79 return edenSpace().used() + fromSpace().used();
|
|
80 }
|
|
81
|
|
82 public boolean isIn(Address a) {
|
|
83 if (edenSpace().contains(a)) {
|
|
84 return true;
|
|
85 }
|
|
86
|
|
87 if (fromSpace().contains(a)) {
|
|
88 return true;
|
|
89 }
|
|
90 return false;
|
|
91 }
|
|
92
|
|
93 public void printOn(PrintStream tty) {
|
|
94 tty.print("PSYoungGen [ ");
|
|
95 tty.print("eden = ");
|
|
96 edenSpace().printOn(tty);
|
|
97 tty.print(", from = ");
|
|
98 fromSpace().printOn(tty);
|
|
99 tty.print(", to = ");
|
|
100 toSpace().printOn(tty);
|
|
101 tty.print(" ] ");
|
|
102 }
|
|
103 }
|