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.shared;
|
|
26
|
|
27 import java.io.*;
|
|
28 import java.util.*;
|
|
29
|
|
30 import sun.jvm.hotspot.debugger.*;
|
|
31 import sun.jvm.hotspot.memory.*;
|
|
32 import sun.jvm.hotspot.runtime.*;
|
|
33 import sun.jvm.hotspot.types.*;
|
|
34
|
|
35 public abstract class ImmutableSpace extends VMObject {
|
|
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("ImmutableSpace");
|
|
46 bottomField = type.getAddressField("_bottom");
|
|
47 endField = type.getAddressField("_end");
|
|
48 }
|
|
49
|
|
50 public ImmutableSpace(Address addr) {
|
|
51 super(addr);
|
|
52 }
|
|
53
|
|
54 // Fields
|
|
55 private static AddressField bottomField;
|
|
56 private static AddressField endField;
|
|
57
|
|
58 // Accessors
|
|
59 public Address bottom() { return bottomField.getValue(addr); }
|
|
60 public Address end() { return endField.getValue(addr); }
|
|
61
|
|
62 /** Returns a subregion of the space containing all the objects in
|
|
63 the space. */
|
|
64 public MemRegion usedRegion() {
|
|
65 return new MemRegion(bottom(), end());
|
|
66 }
|
|
67
|
|
68 /** Support for iteration over heap -- not sure how this will
|
|
69 interact with GC in reflective system, but necessary for the
|
|
70 debugging mechanism */
|
|
71 public OopHandle bottomAsOopHandle() {
|
|
72 return bottomField.getOopHandle(addr);
|
|
73 }
|
|
74
|
|
75 /** returns all MemRegions where live objects are */
|
|
76 public abstract List/*<MemRegion>*/ getLiveRegions();
|
|
77
|
|
78 /** Returned value is in bytes */
|
|
79 public long capacity() { return end().minus(bottom()); }
|
|
80
|
|
81 public abstract long used();
|
|
82
|
|
83 /** Testers */
|
|
84 public boolean contains(Address p) {
|
|
85 return (bottom().lessThanOrEqual(p) && end().greaterThan(p));
|
|
86 }
|
|
87
|
|
88 public void print() { printOn(System.out); }
|
|
89 public abstract void printOn(PrintStream tty);
|
|
90 }
|