author | coleenp |
Sat, 29 Sep 2012 06:40:00 -0400 | |
changeset 13952 | e3cf184080bc |
parent 13728 | 882756847a04 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5547
diff
changeset
|
2 |
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
25 |
package sun.jvm.hotspot.oops; |
|
26 |
||
27 |
import java.io.*; |
|
28 |
import java.util.*; |
|
29 |
import sun.jvm.hotspot.debugger.*; |
|
30 |
import sun.jvm.hotspot.runtime.*; |
|
31 |
import sun.jvm.hotspot.types.*; |
|
32 |
import sun.jvm.hotspot.utilities.*; |
|
33 |
||
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
34 |
// TypeArrayKlass is a proxy for TypeArrayKlass in the JVM |
1 | 35 |
|
36 |
public class TypeArrayKlass extends ArrayKlass { |
|
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) throws WrongTypeException { |
|
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
46 |
Type t = db.lookupType("TypeArrayKlass"); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5547
diff
changeset
|
47 |
maxLength = new CIntField(t.getCIntegerField("_max_length"), 0); |
1 | 48 |
} |
49 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5547
diff
changeset
|
50 |
public TypeArrayKlass(Address addr) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5547
diff
changeset
|
51 |
super(addr); |
1 | 52 |
} |
53 |
||
54 |
private static CIntField maxLength; |
|
55 |
||
56 |
public long getMaxLength() { return maxLength.getValue(this); } |
|
57 |
||
58 |
public static final int T_BOOLEAN = 4; |
|
59 |
public static final int T_CHAR = 5; |
|
60 |
public static final int T_FLOAT = 6; |
|
61 |
public static final int T_DOUBLE = 7; |
|
62 |
public static final int T_BYTE = 8; |
|
63 |
public static final int T_SHORT = 9; |
|
64 |
public static final int T_INT = 10; |
|
65 |
public static final int T_LONG = 11; |
|
66 |
||
67 |
public String getTypeName() { |
|
68 |
switch ((int) getElementType()) { |
|
69 |
case T_BOOLEAN: return "[Z"; |
|
70 |
case T_CHAR: return "[C"; |
|
71 |
case T_FLOAT: return "[F"; |
|
72 |
case T_DOUBLE: return "[D"; |
|
73 |
case T_BYTE: return "[B"; |
|
74 |
case T_SHORT: return "[S"; |
|
75 |
case T_INT: return "[I"; |
|
76 |
case T_LONG: return "[J"; |
|
77 |
} |
|
78 |
return "Unknown TypeArray"; |
|
79 |
} |
|
80 |
||
81 |
public String getElementTypeName() { |
|
82 |
switch ((int) getElementType()) { |
|
83 |
case T_BOOLEAN: return "boolean"; |
|
84 |
case T_CHAR: return "char"; |
|
85 |
case T_FLOAT: return "float"; |
|
86 |
case T_DOUBLE: return "double"; |
|
87 |
case T_BYTE: return "byte"; |
|
88 |
case T_SHORT: return "short"; |
|
89 |
case T_INT: return "int"; |
|
90 |
case T_LONG: return "long"; |
|
91 |
} |
|
92 |
throw new RuntimeException("should not reach here"); |
|
93 |
} |
|
94 |
||
95 |
public void printValueOn(PrintStream tty) { |
|
96 |
tty.print("TypeArrayKlass for " + getTypeName()); |
|
97 |
} |
|
98 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5547
diff
changeset
|
99 |
public void iterateFields(MetadataVisitor visitor) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5547
diff
changeset
|
100 |
super.iterateFields(visitor); |
1 | 101 |
visitor.doCInt(maxLength, true); |
102 |
} |
|
103 |
||
104 |
public Klass arrayKlassImpl(boolean orNull, int n) { |
|
105 |
int dimension = (int) getDimension(); |
|
106 |
if (Assert.ASSERTS_ENABLED) { |
|
107 |
Assert.that(dimension <= n, "check order of chain"); |
|
108 |
} |
|
109 |
if (dimension == n) |
|
110 |
return this; |
|
111 |
ObjArrayKlass ak = (ObjArrayKlass) getHigherDimension(); |
|
112 |
if (ak == null) { |
|
113 |
if (orNull) return null; |
|
114 |
// FIXME: would need to change in reflective system to actually |
|
115 |
// allocate klass |
|
116 |
throw new RuntimeException("Can not allocate array klasses in debugging system"); |
|
117 |
} |
|
118 |
if (orNull) { |
|
119 |
return ak.arrayKlassOrNull(n); |
|
120 |
} |
|
121 |
return ak.arrayKlass(n); |
|
122 |
} |
|
123 |
||
124 |
public Klass arrayKlassImpl(boolean orNull) { |
|
125 |
return arrayKlassImpl(orNull, (int) (getDimension() + 1)); |
|
126 |
} |
|
127 |
} |