Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/oops/TypeArrayKlass.java @ 18665:96861e3f8cc5
made CFGPrinterObserver reset (upon close) properly
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 11 Dec 2014 22:14:30 +0100 |
parents | d8ce2825b193 |
children |
rev | line source |
---|---|
0 | 1 /* |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
21 * questions. |
0 | 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 | |
6831
d8ce2825b193
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
6725
diff
changeset
|
34 // TypeArrayKlass is a proxy for TypeArrayKlass in the JVM |
0 | 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 { | |
6831
d8ce2825b193
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
6725
diff
changeset
|
46 Type t = db.lookupType("TypeArrayKlass"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
47 maxLength = new CIntField(t.getCIntegerField("_max_length"), 0); |
0 | 48 } |
49 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
50 public TypeArrayKlass(Address addr) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
51 super(addr); |
0 | 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 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
99 public void iterateFields(MetadataVisitor visitor) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
100 super.iterateFields(visitor); |
0 | 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 } |