Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/oops/ArrayKlass.java @ 7587:4a916f2ce331
8003985: Support @Contended Annotation - JEP 142
Summary: HotSpot changes to support @Contended annotation.
Reviewed-by: coleenp, kvn, jrose
Contributed-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
author | jwilhelm |
---|---|
date | Mon, 14 Jan 2013 15:17:47 +0100 |
parents | d8ce2825b193 |
children | 71180a6e5080 |
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.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 { | |
6831
d8ce2825b193
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
6725
diff
changeset
|
47 Type type = db.lookupType("ArrayKlass"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
48 dimension = new CIntField(type.getCIntegerField("_dimension"), 0); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
49 higherDimension = new MetadataField(type.getAddressField("_higher_dimension"), 0); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
50 lowerDimension = new MetadataField(type.getAddressField("_lower_dimension"), 0); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
51 vtableLen = new CIntField(type.getCIntegerField("_vtable_len"), 0); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
52 allocSize = new CIntField(type.getCIntegerField("_alloc_size"), 0); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
53 componentMirror = new OopField(type.getOopField("_component_mirror"), 0); |
0 | 54 javaLangCloneableName = null; |
55 javaLangObjectName = null; | |
56 javaIoSerializableName = null; | |
57 } | |
58 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
59 public ArrayKlass(Address addr) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
60 super(addr); |
0 | 61 } |
62 | |
63 private static CIntField dimension; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
64 private static MetadataField higherDimension; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
65 private static MetadataField lowerDimension; |
0 | 66 private static CIntField vtableLen; |
67 private static CIntField allocSize; | |
68 private static OopField componentMirror; | |
69 | |
70 public Klass getJavaSuper() { | |
71 SystemDictionary sysDict = VM.getVM().getSystemDictionary(); | |
72 return sysDict.getObjectKlass(); | |
73 } | |
74 | |
75 public long getDimension() { return dimension.getValue(this); } | |
76 public Klass getHigherDimension() { return (Klass) higherDimension.getValue(this); } | |
77 public Klass getLowerDimension() { return (Klass) lowerDimension.getValue(this); } | |
78 public long getVtableLen() { return vtableLen.getValue(this); } | |
79 public long getAllocSize() { return allocSize.getValue(this); } | |
80 public Oop getComponentMirror() { return componentMirror.getValue(this); } | |
81 | |
82 // constant class names - javaLangCloneable, javaIoSerializable, javaLangObject | |
83 // Initialized lazily to avoid initialization ordering dependencies between ArrayKlass and SymbolTable | |
84 private static Symbol javaLangCloneableName; | |
85 private static Symbol javaLangObjectName; | |
86 private static Symbol javaIoSerializableName; | |
87 private static Symbol javaLangCloneableName() { | |
88 if (javaLangCloneableName == null) { | |
89 javaLangCloneableName = VM.getVM().getSymbolTable().probe("java/lang/Cloneable"); | |
90 } | |
91 return javaLangCloneableName; | |
92 } | |
93 | |
94 private static Symbol javaLangObjectName() { | |
95 if (javaLangObjectName == null) { | |
96 javaLangObjectName = VM.getVM().getSymbolTable().probe("java/lang/Object"); | |
97 } | |
98 return javaLangObjectName; | |
99 } | |
100 | |
101 private static Symbol javaIoSerializableName() { | |
102 if (javaIoSerializableName == null) { | |
103 javaIoSerializableName = VM.getVM().getSymbolTable().probe("java/io/Serializable"); | |
104 } | |
105 return javaIoSerializableName; | |
106 } | |
107 | |
108 public int getClassStatus() { | |
109 return JVMDIClassStatus.VERIFIED | JVMDIClassStatus.PREPARED | JVMDIClassStatus.INITIALIZED; | |
110 } | |
111 | |
112 public long computeModifierFlags() { | |
113 return JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC; | |
114 } | |
115 | |
116 public long getArrayHeaderInBytes() { | |
117 return Bits.maskBits(getLayoutHelper() >> LH_HEADER_SIZE_SHIFT, 0xFF); | |
118 } | |
119 | |
120 public int getLog2ElementSize() { | |
121 return Bits.maskBits(getLayoutHelper() >> LH_LOG2_ELEMENT_SIZE_SHIFT, 0xFF); | |
122 } | |
123 | |
124 public int getElementType() { | |
125 return Bits.maskBits(getLayoutHelper() >> LH_ELEMENT_TYPE_SHIFT, 0xFF); | |
126 } | |
127 | |
128 boolean computeSubtypeOf(Klass k) { | |
129 // An array is a subtype of Serializable, Clonable, and Object | |
130 Symbol name = k.getName(); | |
131 if (name != null && (name.equals(javaIoSerializableName()) || | |
132 name.equals(javaLangCloneableName()) || | |
133 name.equals(javaLangObjectName()))) { | |
134 return true; | |
135 } else { | |
136 return false; | |
137 } | |
138 } | |
139 | |
140 public void printValueOn(PrintStream tty) { | |
141 tty.print("ArrayKlass"); | |
142 } | |
143 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
144 public void iterateFields(MetadataVisitor visitor) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
145 super.iterateFields(visitor); |
0 | 146 visitor.doCInt(dimension, true); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
147 visitor.doMetadata(higherDimension, true); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
148 visitor.doMetadata(lowerDimension, true); |
0 | 149 visitor.doCInt(vtableLen, true); |
150 visitor.doCInt(allocSize, true); | |
151 visitor.doOop(componentMirror, true); | |
152 } | |
153 } |