Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPoolCacheEntry.java @ 3945:8ed53447f690
Merge
author | iveresov |
---|---|
date | Thu, 15 Sep 2011 12:44:09 -0700 |
parents | 0a8e0d4345b3 |
children | da91efe96a93 |
rev | line source |
---|---|
0 | 1 /* |
2042
0a8e0d4345b3
7010068: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - first pass
trims
parents:
1602
diff
changeset
|
2 * Copyright (c) 2001, 2010, 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.util.*; | |
28 import sun.jvm.hotspot.debugger.*; | |
29 import sun.jvm.hotspot.runtime.*; | |
30 import sun.jvm.hotspot.types.*; | |
1602 | 31 import sun.jvm.hotspot.utilities.*; |
0 | 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() { | |
1602 | 71 if (Assert.ASSERTS_ENABLED) { |
72 Assert.that(!isSecondaryEntry(), "must not be a secondary CP entry"); | |
73 } | |
0 | 74 return (int) (getIndices() & 0xFFFF); |
75 } | |
76 | |
1602 | 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 | |
0 | 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 } |