Mercurial > hg > graal-jvmci-8
annotate agent/src/share/classes/sun/jvm/hotspot/oops/TypeArray.java @ 8059:49618582fc5b
8004840: Jstack seems to output unnecessary information in 7u9
Reviewed-by: dholmes, coleenp, sspitsyn, rbackman
author | sla |
---|---|
date | Thu, 14 Feb 2013 13:08:15 +0100 |
parents | da91efe96a93 |
children |
rev | line source |
---|---|
0 | 1 /* |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3838
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 | |
33 // A TypeArray is an array containing basic types (non oop elements). | |
34 // It is used for arrays of {characters, singles, doubles, bytes, shorts, integers, longs} | |
35 | |
36 public class TypeArray extends Array { | |
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 { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3838
diff
changeset
|
46 Type type = db.lookupType("typeArrayOop"); |
0 | 47 } |
48 | |
49 TypeArray(OopHandle handle, ObjectHeap heap) { | |
50 super(handle, heap); | |
51 } | |
52 | |
53 public boolean isTypeArray() { return true; } | |
54 | |
55 public byte getByteAt(long index) { | |
3838
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
56 if (index < 0 || index >= getLength()) { |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
57 throw new ArrayIndexOutOfBoundsException(index + " " + getLength()); |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
58 } |
0 | 59 long offset = baseOffsetInBytes(BasicType.T_BYTE) + index * getHeap().getByteSize(); |
60 return getHandle().getJByteAt(offset); | |
61 } | |
62 | |
63 public boolean getBooleanAt(long index) { | |
64 long offset = baseOffsetInBytes(BasicType.T_BOOLEAN) + index * getHeap().getBooleanSize(); | |
65 return getHandle().getJBooleanAt(offset); | |
66 } | |
67 | |
68 public char getCharAt(long index) { | |
69 long offset = baseOffsetInBytes(BasicType.T_CHAR) + index * getHeap().getCharSize(); | |
70 return getHandle().getJCharAt(offset); | |
71 } | |
72 | |
73 public int getIntAt(long index) { | |
74 long offset = baseOffsetInBytes(BasicType.T_INT) + index * getHeap().getIntSize(); | |
75 return getHandle().getJIntAt(offset); | |
76 } | |
77 | |
78 public short getShortAt(long index) { | |
79 long offset = baseOffsetInBytes(BasicType.T_SHORT) + index * getHeap().getShortSize(); | |
80 return getHandle().getJShortAt(offset); | |
81 } | |
82 | |
83 public long getLongAt(long index) { | |
84 long offset = baseOffsetInBytes(BasicType.T_LONG) + index * getHeap().getLongSize(); | |
85 return getHandle().getJLongAt(offset); | |
86 } | |
87 | |
88 public float getFloatAt(long index) { | |
89 long offset = baseOffsetInBytes(BasicType.T_FLOAT) + index * getHeap().getFloatSize(); | |
90 return getHandle().getJFloatAt(offset); | |
91 } | |
92 | |
93 public double getDoubleAt(long index) { | |
94 long offset = baseOffsetInBytes(BasicType.T_DOUBLE) + index * getHeap().getDoubleSize(); | |
95 return getHandle().getJDoubleAt(offset); | |
96 } | |
97 | |
98 public void printValueOn(PrintStream tty) { | |
99 TypeArrayKlass klass = (TypeArrayKlass) getKlass(); | |
100 tty.print(klass.getTypeName()); | |
101 } | |
102 | |
103 public void iterateFields(OopVisitor visitor, boolean doVMFields) { | |
104 super.iterateFields(visitor, doVMFields); | |
105 TypeArrayKlass klass = (TypeArrayKlass) getKlass(); | |
106 int length = (int) getLength(); | |
107 int type = (int) klass.getElementType(); | |
108 for (int index = 0; index < length; index++) { | |
109 FieldIdentifier id = new IndexableFieldIdentifier(index); | |
110 switch (type) { | |
111 case TypeArrayKlass.T_BOOLEAN: { | |
112 long offset = baseOffsetInBytes(BasicType.T_BOOLEAN) + index * getHeap().getBooleanSize(); | |
113 visitor.doBoolean(new BooleanField(id, offset, false), false); | |
114 break; | |
115 } | |
116 case TypeArrayKlass.T_CHAR: { | |
117 long offset = baseOffsetInBytes(BasicType.T_CHAR) + index * getHeap().getCharSize(); | |
118 visitor.doChar(new CharField(id, offset, false), false); | |
119 break; | |
120 } | |
121 case TypeArrayKlass.T_FLOAT: { | |
122 long offset = baseOffsetInBytes(BasicType.T_FLOAT) + index * getHeap().getFloatSize(); | |
123 visitor.doFloat(new FloatField(id, offset, false), false); | |
124 break; | |
125 } | |
126 case TypeArrayKlass.T_DOUBLE: { | |
127 long offset = baseOffsetInBytes(BasicType.T_DOUBLE) + index * getHeap().getDoubleSize(); | |
128 visitor.doDouble(new DoubleField(id, offset, false), false); | |
129 break; | |
130 } | |
131 case TypeArrayKlass.T_BYTE: { | |
132 long offset = baseOffsetInBytes(BasicType.T_BYTE) + index * getHeap().getByteSize(); | |
133 visitor.doByte(new ByteField(id, offset, false), false); | |
134 break; | |
135 } | |
136 case TypeArrayKlass.T_SHORT: { | |
137 long offset = baseOffsetInBytes(BasicType.T_SHORT) + index * getHeap().getShortSize(); | |
138 visitor.doShort(new ShortField(id, offset, false), false); | |
139 break; | |
140 } | |
141 case TypeArrayKlass.T_INT: { | |
142 long offset = baseOffsetInBytes(BasicType.T_INT) + index * getHeap().getIntSize(); | |
143 visitor.doInt(new IntField(id, offset, false), false); | |
144 break; | |
145 } | |
146 case TypeArrayKlass.T_LONG: { | |
147 long offset = baseOffsetInBytes(BasicType.T_LONG) + index * getHeap().getLongSize(); | |
148 visitor.doLong(new LongField(id, offset, false), false); | |
149 break; | |
150 } | |
151 } | |
152 } | |
153 } | |
154 } |