author | jrose |
Wed, 09 Jun 2010 18:50:45 -0700 | |
changeset 5882 | 6b2aecc4f7d8 |
parent 5547 | f4b087cbb361 |
child 7662 | 5f31baaff55b |
permissions | -rw-r--r-- |
1 | 1 |
/* |
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
2 |
* Copyright (c) 2001, 2005, 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.util.*; |
|
28 |
import sun.jvm.hotspot.debugger.*; |
|
29 |
import sun.jvm.hotspot.runtime.*; |
|
30 |
import sun.jvm.hotspot.types.*; |
|
5882 | 31 |
import sun.jvm.hotspot.utilities.*; |
1 | 32 |
|
33 |
public class ConstantPoolCacheEntry { |
|
34 |
private static long size; |
|
35 |
private static long baseOffset; |
|
36 |
private static CIntegerField indices; |
|
37 |
private static sun.jvm.hotspot.types.OopField f1; |
|
38 |
private static CIntegerField f2; |
|
39 |
private static CIntegerField flags; |
|
40 |
||
41 |
private ConstantPoolCache cp; |
|
42 |
private long offset; |
|
43 |
||
44 |
static { |
|
45 |
VM.registerVMInitializedObserver(new Observer() { |
|
46 |
public void update(Observable o, Object data) { |
|
47 |
initialize(VM.getVM().getTypeDataBase()); |
|
48 |
} |
|
49 |
}); |
|
50 |
} |
|
51 |
||
52 |
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { |
|
53 |
Type type = db.lookupType("ConstantPoolCacheEntry"); |
|
54 |
size = type.getSize(); |
|
55 |
||
56 |
indices = type.getCIntegerField("_indices"); |
|
57 |
f1 = type.getOopField ("_f1"); |
|
58 |
f2 = type.getCIntegerField("_f2"); |
|
59 |
flags = type.getCIntegerField("_flags"); |
|
60 |
||
61 |
type = db.lookupType("constantPoolCacheOopDesc"); |
|
62 |
baseOffset = type.getSize(); |
|
63 |
} |
|
64 |
||
65 |
ConstantPoolCacheEntry(ConstantPoolCache cp, int index) { |
|
66 |
this.cp = cp; |
|
67 |
offset = baseOffset + index * size; |
|
68 |
} |
|
69 |
||
70 |
public int getConstantPoolIndex() { |
|
5882 | 71 |
if (Assert.ASSERTS_ENABLED) { |
72 |
Assert.that(!isSecondaryEntry(), "must not be a secondary CP entry"); |
|
73 |
} |
|
1 | 74 |
return (int) (getIndices() & 0xFFFF); |
75 |
} |
|
76 |
||
5882 | 77 |
public boolean isSecondaryEntry() { |
78 |
return (getIndices() & 0xFFFF) == 0; |
|
79 |
} |
|
80 |
||
81 |
public int getMainEntryIndex() { |
|
82 |
if (Assert.ASSERTS_ENABLED) { |
|
83 |
Assert.that(isSecondaryEntry(), "must be a secondary CP entry"); |
|
84 |
} |
|
85 |
return (int) (getIndices() >>> 16); |
|
86 |
} |
|
87 |
||
1 | 88 |
private long getIndices() { |
89 |
return cp.getHandle().getCIntegerAt(indices.getOffset() + offset, indices.getSize(), indices.isUnsigned()); |
|
90 |
} |
|
91 |
||
92 |
public Oop getF1() { |
|
93 |
return cp.getHeap().newOop(cp.getHandle().getOopHandleAt(f1.getOffset() + offset)); |
|
94 |
} |
|
95 |
||
96 |
public int getF2() { |
|
97 |
return cp.getHandle().getJIntAt(f1.getOffset() + offset); |
|
98 |
} |
|
99 |
||
100 |
public int getFlags() { |
|
101 |
return cp.getHandle().getJIntAt(flags.getOffset() + offset); |
|
102 |
} |
|
103 |
||
104 |
static NamedFieldIdentifier f1FieldName = new NamedFieldIdentifier("_f1"); |
|
105 |
static NamedFieldIdentifier f2FieldName = new NamedFieldIdentifier("_f2"); |
|
106 |
static NamedFieldIdentifier flagsFieldName = new NamedFieldIdentifier("_flags"); |
|
107 |
||
108 |
public void iterateFields(OopVisitor visitor) { |
|
109 |
visitor.doOop(new OopField(f1FieldName, f1.getOffset() + offset, true), true); |
|
110 |
visitor.doInt(new IntField(f2FieldName, f2.getOffset() + offset, true), true); |
|
111 |
visitor.doInt(new IntField(flagsFieldName, flags.getOffset() + offset, true), true); |
|
112 |
} |
|
113 |
} |