annotate agent/src/share/classes/sun/jvm/hotspot/debugger/cdbg/basic/BasicType.java @ 113:ba764ed4b6f2

6420645: Create a vm that uses compressed oops for up to 32gb heapsizes Summary: Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
author coleenp
date Sun, 13 Apr 2008 17:43:42 -0400
parents a61af66fc99e
children c18cbe5936b8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved.
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 package sun.jvm.hotspot.debugger.cdbg.basic;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import java.util.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import sun.jvm.hotspot.debugger.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import sun.jvm.hotspot.debugger.cdbg.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
30
a61af66fc99e Initial load
duke
parents:
diff changeset
31 public abstract class BasicType implements Type, CVAttributes {
a61af66fc99e Initial load
duke
parents:
diff changeset
32 private String name;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 private int size;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 private int cvAttributes;
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // Types keep a list of const/volatile qualified variants of themselves
a61af66fc99e Initial load
duke
parents:
diff changeset
36 private List cvVariants;
a61af66fc99e Initial load
duke
parents:
diff changeset
37
a61af66fc99e Initial load
duke
parents:
diff changeset
38 protected BasicType(String name, int size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
39 this(name, size, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
40 }
a61af66fc99e Initial load
duke
parents:
diff changeset
41
a61af66fc99e Initial load
duke
parents:
diff changeset
42 protected BasicType(String name, int size, int cvAttributes) {
a61af66fc99e Initial load
duke
parents:
diff changeset
43 this.name = name;
a61af66fc99e Initial load
duke
parents:
diff changeset
44 this.size = size;
a61af66fc99e Initial load
duke
parents:
diff changeset
45 this.cvAttributes = cvAttributes;
a61af66fc99e Initial load
duke
parents:
diff changeset
46 }
a61af66fc99e Initial load
duke
parents:
diff changeset
47
a61af66fc99e Initial load
duke
parents:
diff changeset
48 public String getName() { return name; }
a61af66fc99e Initial load
duke
parents:
diff changeset
49
a61af66fc99e Initial load
duke
parents:
diff changeset
50 /** For use during resolution only */
a61af66fc99e Initial load
duke
parents:
diff changeset
51 protected void setName(String name) { this.name = name; }
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 public int getSize() { return size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55 public BitType asBit() { return null; }
a61af66fc99e Initial load
duke
parents:
diff changeset
56 public IntType asInt() { return null; }
a61af66fc99e Initial load
duke
parents:
diff changeset
57 public EnumType asEnum() { return null; }
a61af66fc99e Initial load
duke
parents:
diff changeset
58 public FloatType asFloat() { return null; }
a61af66fc99e Initial load
duke
parents:
diff changeset
59 public DoubleType asDouble() { return null; }
a61af66fc99e Initial load
duke
parents:
diff changeset
60 public PointerType asPointer() { return null; }
a61af66fc99e Initial load
duke
parents:
diff changeset
61 public ArrayType asArray() { return null; }
a61af66fc99e Initial load
duke
parents:
diff changeset
62 public RefType asRef() { return null; }
a61af66fc99e Initial load
duke
parents:
diff changeset
63 public CompoundType asCompound() { return null; }
a61af66fc99e Initial load
duke
parents:
diff changeset
64 public FunctionType asFunction() { return null; }
a61af66fc99e Initial load
duke
parents:
diff changeset
65 public MemberFunctionType asMemberFunction() { return null; }
a61af66fc99e Initial load
duke
parents:
diff changeset
66 public VoidType asVoid() { return null; }
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68 public boolean isBit() { return (asBit() != null); }
a61af66fc99e Initial load
duke
parents:
diff changeset
69 public boolean isInt() { return (asInt() != null); }
a61af66fc99e Initial load
duke
parents:
diff changeset
70 public boolean isEnum() { return (asEnum() != null); }
a61af66fc99e Initial load
duke
parents:
diff changeset
71 public boolean isFloat() { return (asFloat() != null); }
a61af66fc99e Initial load
duke
parents:
diff changeset
72 public boolean isDouble() { return (asDouble() != null); }
a61af66fc99e Initial load
duke
parents:
diff changeset
73 public boolean isPointer() { return (asPointer() != null); }
a61af66fc99e Initial load
duke
parents:
diff changeset
74 public boolean isArray() { return (asArray() != null); }
a61af66fc99e Initial load
duke
parents:
diff changeset
75 public boolean isRef() { return (asRef() != null); }
a61af66fc99e Initial load
duke
parents:
diff changeset
76 public boolean isCompound() { return (asCompound() != null); }
a61af66fc99e Initial load
duke
parents:
diff changeset
77 public boolean isFunction() { return (asFunction() != null); }
a61af66fc99e Initial load
duke
parents:
diff changeset
78 public boolean isMemberFunction() { return (asMemberFunction() != null); }
a61af66fc99e Initial load
duke
parents:
diff changeset
79 public boolean isVoid() { return (asVoid() != null); }
a61af66fc99e Initial load
duke
parents:
diff changeset
80
a61af66fc99e Initial load
duke
parents:
diff changeset
81 public boolean isConst() { return ((cvAttributes & CONST) != 0); }
a61af66fc99e Initial load
duke
parents:
diff changeset
82 public boolean isVolatile() { return ((cvAttributes & VOLATILE) != 0); }
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84 Type resolveTypes(BasicCDebugInfoDataBase db, ResolveListener listener) {
a61af66fc99e Initial load
duke
parents:
diff changeset
85 if (cvVariants != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
86 for (ListIterator iter = cvVariants.listIterator(); iter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
87 iter.set(db.resolveType(this, (BasicType) iter.next(), listener, "resolving const/var variants"));
a61af66fc99e Initial load
duke
parents:
diff changeset
88 }
a61af66fc99e Initial load
duke
parents:
diff changeset
89 }
a61af66fc99e Initial load
duke
parents:
diff changeset
90 return this;
a61af66fc99e Initial load
duke
parents:
diff changeset
91 }
a61af66fc99e Initial load
duke
parents:
diff changeset
92 public boolean isLazy() { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
93 public void iterateObject(Address a, ObjectVisitor v) {
a61af66fc99e Initial load
duke
parents:
diff changeset
94 iterateObject(a, v, null);
a61af66fc99e Initial load
duke
parents:
diff changeset
95 }
a61af66fc99e Initial load
duke
parents:
diff changeset
96 public abstract void iterateObject(Address a, ObjectVisitor v, FieldIdentifier f);
a61af66fc99e Initial load
duke
parents:
diff changeset
97 public Type getCVVariant(int cvAttributes) {
a61af66fc99e Initial load
duke
parents:
diff changeset
98 Type t = findCVVariant(cvAttributes);
a61af66fc99e Initial load
duke
parents:
diff changeset
99 if (t != null) return t;
a61af66fc99e Initial load
duke
parents:
diff changeset
100 t = createCVVariant(cvAttributes);
a61af66fc99e Initial load
duke
parents:
diff changeset
101 addCVVariant(t);
a61af66fc99e Initial load
duke
parents:
diff changeset
102 return t;
a61af66fc99e Initial load
duke
parents:
diff changeset
103 }
a61af66fc99e Initial load
duke
parents:
diff changeset
104
a61af66fc99e Initial load
duke
parents:
diff changeset
105 public String toString() {
a61af66fc99e Initial load
duke
parents:
diff changeset
106 return getName();
a61af66fc99e Initial load
duke
parents:
diff changeset
107 }
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 private int getCVAttributes() { return cvAttributes; }
a61af66fc99e Initial load
duke
parents:
diff changeset
110 protected abstract Type createCVVariant(int cvAttributes);
a61af66fc99e Initial load
duke
parents:
diff changeset
111 protected Type findCVVariant(int cvAttributes) {
a61af66fc99e Initial load
duke
parents:
diff changeset
112 if (cvVariants != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
113 for (Iterator iter = cvVariants.iterator(); iter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
114 BasicType t = (BasicType) iter.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
115 if (t.getCVAttributes() == cvAttributes) return t;
a61af66fc99e Initial load
duke
parents:
diff changeset
116 }
a61af66fc99e Initial load
duke
parents:
diff changeset
117 }
a61af66fc99e Initial load
duke
parents:
diff changeset
118 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
119 }
a61af66fc99e Initial load
duke
parents:
diff changeset
120 protected void addCVVariant(Type t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
121 if (cvVariants == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
122 cvVariants = new ArrayList();
a61af66fc99e Initial load
duke
parents:
diff changeset
123 }
a61af66fc99e Initial load
duke
parents:
diff changeset
124 cvVariants.add(t);
a61af66fc99e Initial load
duke
parents:
diff changeset
125 }
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127 public abstract void visit(TypeVisitor v);
a61af66fc99e Initial load
duke
parents:
diff changeset
128 }