annotate agent/src/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaMethod.java @ 6725:da91efe96a93

6964458: Reimplement class meta-data storage to use native memory Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author coleenp
date Sat, 01 Sep 2012 13:25:18 -0400
parents c18cbe5936b8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
2 * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
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
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 package sun.jvm.hotspot.utilities.soql;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import java.util.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import sun.jvm.hotspot.oops.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import sun.jvm.hotspot.runtime.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
30
a61af66fc99e Initial load
duke
parents:
diff changeset
31 /**
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
32 * Wraps a Method* from the debuggee VM.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
33 */
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
34 public class JSJavaMethod extends JSMetadata {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
35 private static final int FIELD_NAME = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
36 private static final int FIELD_SIGNATURE = 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 private static final int FIELD_HOLDER = 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 private static final int FIELD_IS_PRIVATE = 3;
a61af66fc99e Initial load
duke
parents:
diff changeset
39 private static final int FIELD_IS_PUBLIC = 4;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 private static final int FIELD_IS_PROTECTED = 5;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 private static final int FIELD_IS_PACKAGE_PRIVATE = 6;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 private static final int FIELD_IS_STATIC = 7;
a61af66fc99e Initial load
duke
parents:
diff changeset
43 private static final int FIELD_IS_FINAL = 8;
a61af66fc99e Initial load
duke
parents:
diff changeset
44 private static final int FIELD_IS_SYNCHRONIZED = 9;
a61af66fc99e Initial load
duke
parents:
diff changeset
45 private static final int FIELD_IS_NATIVE = 10;
a61af66fc99e Initial load
duke
parents:
diff changeset
46 private static final int FIELD_IS_ABSTRACT = 11;
a61af66fc99e Initial load
duke
parents:
diff changeset
47 private static final int FIELD_IS_STRICT = 12;
a61af66fc99e Initial load
duke
parents:
diff changeset
48 private static final int FIELD_IS_SYNTHETIC = 13;
a61af66fc99e Initial load
duke
parents:
diff changeset
49 private static final int FIELD_IS_OBSOLETE = 14;
a61af66fc99e Initial load
duke
parents:
diff changeset
50 private static final int FIELD_UNDEFINED = -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
51
a61af66fc99e Initial load
duke
parents:
diff changeset
52 public JSJavaMethod(Method m, JSJavaFactory fac) {
a61af66fc99e Initial load
duke
parents:
diff changeset
53 super(m, fac);
a61af66fc99e Initial load
duke
parents:
diff changeset
54 }
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 public final Method getMethod() {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
57 return (Method) getMetadata();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
58 }
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 public Object get(String name) {
a61af66fc99e Initial load
duke
parents:
diff changeset
61 int fieldID = getFieldID(name);
a61af66fc99e Initial load
duke
parents:
diff changeset
62 Method method = getMethod();
a61af66fc99e Initial load
duke
parents:
diff changeset
63 switch (fieldID) {
a61af66fc99e Initial load
duke
parents:
diff changeset
64 case FIELD_NAME:
a61af66fc99e Initial load
duke
parents:
diff changeset
65 return method.getName().asString();
a61af66fc99e Initial load
duke
parents:
diff changeset
66 case FIELD_SIGNATURE:
a61af66fc99e Initial load
duke
parents:
diff changeset
67 return method.getSignature().asString();
a61af66fc99e Initial load
duke
parents:
diff changeset
68 case FIELD_HOLDER:
a61af66fc99e Initial load
duke
parents:
diff changeset
69 return getMethodHolder();
a61af66fc99e Initial load
duke
parents:
diff changeset
70 case FIELD_IS_PRIVATE:
a61af66fc99e Initial load
duke
parents:
diff changeset
71 return Boolean.valueOf(method.isPrivate());
a61af66fc99e Initial load
duke
parents:
diff changeset
72 case FIELD_IS_PUBLIC:
a61af66fc99e Initial load
duke
parents:
diff changeset
73 return Boolean.valueOf(method.isPublic());
a61af66fc99e Initial load
duke
parents:
diff changeset
74 case FIELD_IS_PROTECTED:
a61af66fc99e Initial load
duke
parents:
diff changeset
75 return Boolean.valueOf(method.isProtected());
a61af66fc99e Initial load
duke
parents:
diff changeset
76 case FIELD_IS_PACKAGE_PRIVATE:
a61af66fc99e Initial load
duke
parents:
diff changeset
77 return Boolean.valueOf(method.isPackagePrivate());
a61af66fc99e Initial load
duke
parents:
diff changeset
78 case FIELD_IS_STATIC:
a61af66fc99e Initial load
duke
parents:
diff changeset
79 return Boolean.valueOf(method.isStatic());
a61af66fc99e Initial load
duke
parents:
diff changeset
80 case FIELD_IS_FINAL:
a61af66fc99e Initial load
duke
parents:
diff changeset
81 return Boolean.valueOf(method.isFinal());
a61af66fc99e Initial load
duke
parents:
diff changeset
82 case FIELD_IS_SYNCHRONIZED:
a61af66fc99e Initial load
duke
parents:
diff changeset
83 return Boolean.valueOf(method.isSynchronized());
a61af66fc99e Initial load
duke
parents:
diff changeset
84 case FIELD_IS_NATIVE:
a61af66fc99e Initial load
duke
parents:
diff changeset
85 return Boolean.valueOf(method.isNative());
a61af66fc99e Initial load
duke
parents:
diff changeset
86 case FIELD_IS_ABSTRACT:
a61af66fc99e Initial load
duke
parents:
diff changeset
87 return Boolean.valueOf(method.isAbstract());
a61af66fc99e Initial load
duke
parents:
diff changeset
88 case FIELD_IS_STRICT:
a61af66fc99e Initial load
duke
parents:
diff changeset
89 return Boolean.valueOf(method.isStrict());
a61af66fc99e Initial load
duke
parents:
diff changeset
90 case FIELD_IS_SYNTHETIC:
a61af66fc99e Initial load
duke
parents:
diff changeset
91 return Boolean.valueOf(method.isSynthetic());
a61af66fc99e Initial load
duke
parents:
diff changeset
92 case FIELD_IS_OBSOLETE:
a61af66fc99e Initial load
duke
parents:
diff changeset
93 return Boolean.valueOf(method.isObsolete());
a61af66fc99e Initial load
duke
parents:
diff changeset
94 case FIELD_UNDEFINED:
a61af66fc99e Initial load
duke
parents:
diff changeset
95 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
96 return super.get(name);
a61af66fc99e Initial load
duke
parents:
diff changeset
97 }
a61af66fc99e Initial load
duke
parents:
diff changeset
98 }
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 public Object[] getIds() {
a61af66fc99e Initial load
duke
parents:
diff changeset
101 Object[] fieldNames = fields.keySet().toArray();
a61af66fc99e Initial load
duke
parents:
diff changeset
102 Object[] superFields = super.getIds();
a61af66fc99e Initial load
duke
parents:
diff changeset
103 Object[] res = new Object[fieldNames.length + superFields.length];
a61af66fc99e Initial load
duke
parents:
diff changeset
104 System.arraycopy(fieldNames, 0, res, 0, fieldNames.length);
a61af66fc99e Initial load
duke
parents:
diff changeset
105 System.arraycopy(superFields, 0, res, fieldNames.length, superFields.length);
a61af66fc99e Initial load
duke
parents:
diff changeset
106 return res;
a61af66fc99e Initial load
duke
parents:
diff changeset
107 }
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 public boolean has(String name) {
a61af66fc99e Initial load
duke
parents:
diff changeset
110 if (getFieldID(name) != FIELD_UNDEFINED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
111 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
112 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
113 return super.has(name);
a61af66fc99e Initial load
duke
parents:
diff changeset
114 }
a61af66fc99e Initial load
duke
parents:
diff changeset
115 }
a61af66fc99e Initial load
duke
parents:
diff changeset
116
a61af66fc99e Initial load
duke
parents:
diff changeset
117 public void put(String name, Object value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
118 if (getFieldID(name) != FIELD_UNDEFINED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
119 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
120 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
121 super.put(name, value);
a61af66fc99e Initial load
duke
parents:
diff changeset
122 }
a61af66fc99e Initial load
duke
parents:
diff changeset
123 }
a61af66fc99e Initial load
duke
parents:
diff changeset
124
a61af66fc99e Initial load
duke
parents:
diff changeset
125 public String toString() {
a61af66fc99e Initial load
duke
parents:
diff changeset
126 StringBuffer buf = new StringBuffer();
a61af66fc99e Initial load
duke
parents:
diff changeset
127 buf.append("Method ");
a61af66fc99e Initial load
duke
parents:
diff changeset
128 buf.append(getMethod().externalNameAndSignature());
a61af66fc99e Initial load
duke
parents:
diff changeset
129 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
130 }
a61af66fc99e Initial load
duke
parents:
diff changeset
131
a61af66fc99e Initial load
duke
parents:
diff changeset
132 //-- Internals only below this point
a61af66fc99e Initial load
duke
parents:
diff changeset
133 private JSJavaObject getMethodHolder() {
a61af66fc99e Initial load
duke
parents:
diff changeset
134 Klass k = getMethod().getMethodHolder();
a61af66fc99e Initial load
duke
parents:
diff changeset
135 return factory.newJSJavaKlass(k).getJSJavaClass();
a61af66fc99e Initial load
duke
parents:
diff changeset
136 }
a61af66fc99e Initial load
duke
parents:
diff changeset
137
a61af66fc99e Initial load
duke
parents:
diff changeset
138 private static Map fields = new HashMap();
a61af66fc99e Initial load
duke
parents:
diff changeset
139 private static void addField(String name, int fieldId) {
a61af66fc99e Initial load
duke
parents:
diff changeset
140 fields.put(name, new Integer(fieldId));
a61af66fc99e Initial load
duke
parents:
diff changeset
141 }
a61af66fc99e Initial load
duke
parents:
diff changeset
142
a61af66fc99e Initial load
duke
parents:
diff changeset
143 private static int getFieldID(String name) {
a61af66fc99e Initial load
duke
parents:
diff changeset
144 Integer res = (Integer) fields.get(name);
a61af66fc99e Initial load
duke
parents:
diff changeset
145 return (res != null)? res.intValue() : FIELD_UNDEFINED;
a61af66fc99e Initial load
duke
parents:
diff changeset
146 }
a61af66fc99e Initial load
duke
parents:
diff changeset
147
a61af66fc99e Initial load
duke
parents:
diff changeset
148 static {
a61af66fc99e Initial load
duke
parents:
diff changeset
149 addField("name", FIELD_NAME);
a61af66fc99e Initial load
duke
parents:
diff changeset
150 addField("signature", FIELD_SIGNATURE);
a61af66fc99e Initial load
duke
parents:
diff changeset
151 addField("holder", FIELD_HOLDER);
a61af66fc99e Initial load
duke
parents:
diff changeset
152 addField("isPrivate", FIELD_IS_PRIVATE);
a61af66fc99e Initial load
duke
parents:
diff changeset
153 addField("isPublic", FIELD_IS_PUBLIC);
a61af66fc99e Initial load
duke
parents:
diff changeset
154 addField("isProtected", FIELD_IS_PROTECTED);
a61af66fc99e Initial load
duke
parents:
diff changeset
155 addField("isPackagePrivate", FIELD_IS_PACKAGE_PRIVATE);
a61af66fc99e Initial load
duke
parents:
diff changeset
156 addField("isStatic", FIELD_IS_STATIC);
a61af66fc99e Initial load
duke
parents:
diff changeset
157 addField("isFinal", FIELD_IS_FINAL);
a61af66fc99e Initial load
duke
parents:
diff changeset
158 addField("isSynchronized", FIELD_IS_SYNCHRONIZED);
a61af66fc99e Initial load
duke
parents:
diff changeset
159 addField("isNative", FIELD_IS_NATIVE);
a61af66fc99e Initial load
duke
parents:
diff changeset
160 addField("isAbstract", FIELD_IS_ABSTRACT);
a61af66fc99e Initial load
duke
parents:
diff changeset
161 addField("isStrict", FIELD_IS_STRICT);
a61af66fc99e Initial load
duke
parents:
diff changeset
162 addField("isSynthetic", FIELD_IS_SYNTHETIC);
a61af66fc99e Initial load
duke
parents:
diff changeset
163 addField("isObsolete", FIELD_IS_OBSOLETE);
a61af66fc99e Initial load
duke
parents:
diff changeset
164 }
a61af66fc99e Initial load
duke
parents:
diff changeset
165 }