author | coleenp |
Thu, 28 Aug 2014 11:29:09 -0400 | |
changeset 26412 | 80741eb33ba2 |
parent 22234 | da823d78ad65 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
26412
80741eb33ba2
8049105: Move array component mirror to instance of java/lang/Class (hotspot part 2)
coleenp
parents:
22234
diff
changeset
|
2 |
* Copyright (c) 2000, 2014, 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.utilities.*; |
|
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 |
// ArrayKlass is the abstract class for all array classes |
|
36 |
||
37 |
public class ArrayKlass extends Klass { |
|
38 |
static { |
|
39 |
VM.registerVMInitializedObserver(new Observer() { |
|
40 |
public void update(Observable o, Object data) { |
|
41 |
initialize(VM.getVM().getTypeDataBase()); |
|
42 |
} |
|
43 |
}); |
|
44 |
} |
|
45 |
||
46 |
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { |
|
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
47 |
Type type = db.lookupType("ArrayKlass"); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5547
diff
changeset
|
48 |
dimension = new CIntField(type.getCIntegerField("_dimension"), 0); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5547
diff
changeset
|
49 |
higherDimension = new MetadataField(type.getAddressField("_higher_dimension"), 0); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5547
diff
changeset
|
50 |
lowerDimension = new MetadataField(type.getAddressField("_lower_dimension"), 0); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5547
diff
changeset
|
51 |
vtableLen = new CIntField(type.getCIntegerField("_vtable_len"), 0); |
1 | 52 |
javaLangCloneableName = null; |
53 |
javaLangObjectName = null; |
|
54 |
javaIoSerializableName = null; |
|
55 |
} |
|
56 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5547
diff
changeset
|
57 |
public ArrayKlass(Address addr) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5547
diff
changeset
|
58 |
super(addr); |
1 | 59 |
} |
60 |
||
61 |
private static CIntField dimension; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5547
diff
changeset
|
62 |
private static MetadataField higherDimension; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5547
diff
changeset
|
63 |
private static MetadataField lowerDimension; |
1 | 64 |
private static CIntField vtableLen; |
65 |
||
66 |
public Klass getJavaSuper() { |
|
67 |
SystemDictionary sysDict = VM.getVM().getSystemDictionary(); |
|
68 |
return sysDict.getObjectKlass(); |
|
69 |
} |
|
70 |
||
71 |
public long getDimension() { return dimension.getValue(this); } |
|
72 |
public Klass getHigherDimension() { return (Klass) higherDimension.getValue(this); } |
|
73 |
public Klass getLowerDimension() { return (Klass) lowerDimension.getValue(this); } |
|
74 |
public long getVtableLen() { return vtableLen.getValue(this); } |
|
75 |
||
76 |
// constant class names - javaLangCloneable, javaIoSerializable, javaLangObject |
|
77 |
// Initialized lazily to avoid initialization ordering dependencies between ArrayKlass and SymbolTable |
|
78 |
private static Symbol javaLangCloneableName; |
|
79 |
private static Symbol javaLangObjectName; |
|
80 |
private static Symbol javaIoSerializableName; |
|
81 |
private static Symbol javaLangCloneableName() { |
|
82 |
if (javaLangCloneableName == null) { |
|
83 |
javaLangCloneableName = VM.getVM().getSymbolTable().probe("java/lang/Cloneable"); |
|
84 |
} |
|
85 |
return javaLangCloneableName; |
|
86 |
} |
|
87 |
||
88 |
private static Symbol javaLangObjectName() { |
|
89 |
if (javaLangObjectName == null) { |
|
90 |
javaLangObjectName = VM.getVM().getSymbolTable().probe("java/lang/Object"); |
|
91 |
} |
|
92 |
return javaLangObjectName; |
|
93 |
} |
|
94 |
||
95 |
private static Symbol javaIoSerializableName() { |
|
96 |
if (javaIoSerializableName == null) { |
|
97 |
javaIoSerializableName = VM.getVM().getSymbolTable().probe("java/io/Serializable"); |
|
98 |
} |
|
99 |
return javaIoSerializableName; |
|
100 |
} |
|
101 |
||
102 |
public int getClassStatus() { |
|
103 |
return JVMDIClassStatus.VERIFIED | JVMDIClassStatus.PREPARED | JVMDIClassStatus.INITIALIZED; |
|
104 |
} |
|
105 |
||
106 |
public long computeModifierFlags() { |
|
107 |
return JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC; |
|
108 |
} |
|
109 |
||
110 |
public long getArrayHeaderInBytes() { |
|
111 |
return Bits.maskBits(getLayoutHelper() >> LH_HEADER_SIZE_SHIFT, 0xFF); |
|
112 |
} |
|
113 |
||
114 |
public int getLog2ElementSize() { |
|
115 |
return Bits.maskBits(getLayoutHelper() >> LH_LOG2_ELEMENT_SIZE_SHIFT, 0xFF); |
|
116 |
} |
|
117 |
||
118 |
public int getElementType() { |
|
119 |
return Bits.maskBits(getLayoutHelper() >> LH_ELEMENT_TYPE_SHIFT, 0xFF); |
|
120 |
} |
|
121 |
||
122 |
boolean computeSubtypeOf(Klass k) { |
|
123 |
// An array is a subtype of Serializable, Clonable, and Object |
|
124 |
Symbol name = k.getName(); |
|
125 |
if (name != null && (name.equals(javaIoSerializableName()) || |
|
126 |
name.equals(javaLangCloneableName()) || |
|
127 |
name.equals(javaLangObjectName()))) { |
|
128 |
return true; |
|
129 |
} else { |
|
130 |
return false; |
|
131 |
} |
|
132 |
} |
|
133 |
||
134 |
public void printValueOn(PrintStream tty) { |
|
135 |
tty.print("ArrayKlass"); |
|
136 |
} |
|
137 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5547
diff
changeset
|
138 |
public void iterateFields(MetadataVisitor visitor) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5547
diff
changeset
|
139 |
super.iterateFields(visitor); |
1 | 140 |
visitor.doCInt(dimension, true); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5547
diff
changeset
|
141 |
visitor.doMetadata(higherDimension, true); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5547
diff
changeset
|
142 |
visitor.doMetadata(lowerDimension, true); |
1 | 143 |
visitor.doCInt(vtableLen, true); |
144 |
} |
|
145 |
} |