annotate src/share/vm/prims/jvmtiRedefineClasses.hpp @ 3992:d1bdeef3e3e2

7098282: G1: assert(interval >= 0) failed: Sanity check, referencePolicy.cpp: 76 Summary: There is a race between one thread successfully forwarding and copying the klass mirror for the SoftReference class (including the static master clock) and another thread attempting to use the master clock while attempting to discover a soft reference object. Maintain a shadow copy of the soft reference master clock and use the shadow during reference discovery and reference processing. Reviewed-by: tonyp, brutisso, ysr
author johnc
date Wed, 12 Oct 2011 10:25:51 -0700
parents 1d1603768966
children da91efe96a93
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
2426
1d1603768966 7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass
trims
parents: 2177
diff changeset
2 * Copyright (c) 2003, 2011, 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
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #ifndef SHARE_VM_PRIMS_JVMTIREDEFINECLASSES_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_PRIMS_JVMTIREDEFINECLASSES_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "jvmtifiles/jvmtiEnv.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "memory/oopFactory.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "memory/resourceArea.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #include "oops/objArrayKlass.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32 #include "oops/objArrayOop.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
33 #include "prims/jvmtiRedefineClassesTrace.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
34 #include "runtime/vm_operations.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
35
0
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // Introduction:
a61af66fc99e Initial load
duke
parents:
diff changeset
37 //
a61af66fc99e Initial load
duke
parents:
diff changeset
38 // The RedefineClasses() API is used to change the definition of one or
a61af66fc99e Initial load
duke
parents:
diff changeset
39 // more classes. While the API supports redefining more than one class
a61af66fc99e Initial load
duke
parents:
diff changeset
40 // in a single call, in general, the API is discussed in the context of
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // changing the definition of a single current class to a single new
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // class. For clarity, the current class is will always be called
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // "the_class" and the new class will always be called "scratch_class".
a61af66fc99e Initial load
duke
parents:
diff changeset
44 //
a61af66fc99e Initial load
duke
parents:
diff changeset
45 // The name "the_class" is used because there is only one structure
a61af66fc99e Initial load
duke
parents:
diff changeset
46 // that represents a specific class; redefinition does not replace the
a61af66fc99e Initial load
duke
parents:
diff changeset
47 // structure, but instead replaces parts of the structure. The name
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // "scratch_class" is used because the structure that represents the
a61af66fc99e Initial load
duke
parents:
diff changeset
49 // new definition of a specific class is simply used to carry around
a61af66fc99e Initial load
duke
parents:
diff changeset
50 // the parts of the new definition until they are used to replace the
a61af66fc99e Initial load
duke
parents:
diff changeset
51 // appropriate parts in the_class. Once redefinition of a class is
a61af66fc99e Initial load
duke
parents:
diff changeset
52 // complete, scratch_class is thrown away.
a61af66fc99e Initial load
duke
parents:
diff changeset
53 //
a61af66fc99e Initial load
duke
parents:
diff changeset
54 //
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // Implementation Overview:
a61af66fc99e Initial load
duke
parents:
diff changeset
56 //
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // The RedefineClasses() API is mostly a wrapper around the VM op that
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // does the real work. The work is split in varying degrees between
a61af66fc99e Initial load
duke
parents:
diff changeset
59 // doit_prologue(), doit() and doit_epilogue().
a61af66fc99e Initial load
duke
parents:
diff changeset
60 //
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // 1) doit_prologue() is called by the JavaThread on the way to a
a61af66fc99e Initial load
duke
parents:
diff changeset
62 // safepoint. It does parameter verification and loads scratch_class
a61af66fc99e Initial load
duke
parents:
diff changeset
63 // which involves:
a61af66fc99e Initial load
duke
parents:
diff changeset
64 // - parsing the incoming class definition using the_class' class
a61af66fc99e Initial load
duke
parents:
diff changeset
65 // loader and security context
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // - linking scratch_class
a61af66fc99e Initial load
duke
parents:
diff changeset
67 // - merging constant pools and rewriting bytecodes as needed
a61af66fc99e Initial load
duke
parents:
diff changeset
68 // for the merged constant pool
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // - verifying the bytecodes in scratch_class
a61af66fc99e Initial load
duke
parents:
diff changeset
70 // - setting up the constant pool cache and rewriting bytecodes
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // as needed to use the cache
a61af66fc99e Initial load
duke
parents:
diff changeset
72 // - finally, scratch_class is compared to the_class to verify
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // that it is a valid replacement class
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // - if everything is good, then scratch_class is saved in an
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // instance field in the VM operation for the doit() call
a61af66fc99e Initial load
duke
parents:
diff changeset
76 //
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // Note: A JavaThread must do the above work.
a61af66fc99e Initial load
duke
parents:
diff changeset
78 //
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // 2) doit() is called by the VMThread during a safepoint. It installs
a61af66fc99e Initial load
duke
parents:
diff changeset
80 // the new class definition(s) which involves:
a61af66fc99e Initial load
duke
parents:
diff changeset
81 // - retrieving the scratch_class from the instance field in the
a61af66fc99e Initial load
duke
parents:
diff changeset
82 // VM operation
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // - house keeping (flushing breakpoints and caches, deoptimizing
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // dependent compiled code)
a61af66fc99e Initial load
duke
parents:
diff changeset
85 // - replacing parts in the_class with parts from scratch_class
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // - adding weak reference(s) to track the obsolete but interesting
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // parts of the_class
a61af66fc99e Initial load
duke
parents:
diff changeset
88 // - adjusting constant pool caches and vtables in other classes
a61af66fc99e Initial load
duke
parents:
diff changeset
89 // that refer to methods in the_class. These adjustments use the
a61af66fc99e Initial load
duke
parents:
diff changeset
90 // SystemDictionary::classes_do() facility which only allows
a61af66fc99e Initial load
duke
parents:
diff changeset
91 // a helper method to be specified. The interesting parameters
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // that we would like to pass to the helper method are saved in
a61af66fc99e Initial load
duke
parents:
diff changeset
93 // static global fields in the VM operation.
a61af66fc99e Initial load
duke
parents:
diff changeset
94 // - telling the SystemDictionary to notice our changes
a61af66fc99e Initial load
duke
parents:
diff changeset
95 //
a61af66fc99e Initial load
duke
parents:
diff changeset
96 // Note: the above work must be done by the VMThread to be safe.
a61af66fc99e Initial load
duke
parents:
diff changeset
97 //
a61af66fc99e Initial load
duke
parents:
diff changeset
98 // 3) doit_epilogue() is called by the JavaThread after the VM op
a61af66fc99e Initial load
duke
parents:
diff changeset
99 // is finished and the safepoint is done. It simply cleans up
a61af66fc99e Initial load
duke
parents:
diff changeset
100 // memory allocated in doit_prologue() and used in doit().
a61af66fc99e Initial load
duke
parents:
diff changeset
101 //
a61af66fc99e Initial load
duke
parents:
diff changeset
102 //
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // Constant Pool Details:
a61af66fc99e Initial load
duke
parents:
diff changeset
104 //
a61af66fc99e Initial load
duke
parents:
diff changeset
105 // When the_class is redefined, we cannot just replace the constant
a61af66fc99e Initial load
duke
parents:
diff changeset
106 // pool in the_class with the constant pool from scratch_class because
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // that could confuse obsolete methods that may still be running.
a61af66fc99e Initial load
duke
parents:
diff changeset
108 // Instead, the constant pool from the_class, old_cp, is merged with
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // the constant pool from scratch_class, scratch_cp. The resulting
a61af66fc99e Initial load
duke
parents:
diff changeset
110 // constant pool, merge_cp, replaces old_cp in the_class.
a61af66fc99e Initial load
duke
parents:
diff changeset
111 //
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // The key part of any merging algorithm is the entry comparison
a61af66fc99e Initial load
duke
parents:
diff changeset
113 // function so we have to know the types of entries in a constant pool
a61af66fc99e Initial load
duke
parents:
diff changeset
114 // in order to merge two of them together. Constant pools can contain
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // up to 12 different kinds of entries; the JVM_CONSTANT_Unicode entry
a61af66fc99e Initial load
duke
parents:
diff changeset
116 // is not presently used so we only have to worry about the other 11
a61af66fc99e Initial load
duke
parents:
diff changeset
117 // entry types. For the purposes of constant pool merging, it is
a61af66fc99e Initial load
duke
parents:
diff changeset
118 // helpful to know that the 11 entry types fall into 3 different
a61af66fc99e Initial load
duke
parents:
diff changeset
119 // subtypes: "direct", "indirect" and "double-indirect".
a61af66fc99e Initial load
duke
parents:
diff changeset
120 //
a61af66fc99e Initial load
duke
parents:
diff changeset
121 // Direct CP entries contain data and do not contain references to
a61af66fc99e Initial load
duke
parents:
diff changeset
122 // other CP entries. The following are direct CP entries:
a61af66fc99e Initial load
duke
parents:
diff changeset
123 // JVM_CONSTANT_{Double,Float,Integer,Long,Utf8}
a61af66fc99e Initial load
duke
parents:
diff changeset
124 //
a61af66fc99e Initial load
duke
parents:
diff changeset
125 // Indirect CP entries contain 1 or 2 references to a direct CP entry
a61af66fc99e Initial load
duke
parents:
diff changeset
126 // and no other data. The following are indirect CP entries:
a61af66fc99e Initial load
duke
parents:
diff changeset
127 // JVM_CONSTANT_{Class,NameAndType,String}
a61af66fc99e Initial load
duke
parents:
diff changeset
128 //
a61af66fc99e Initial load
duke
parents:
diff changeset
129 // Double-indirect CP entries contain two references to indirect CP
a61af66fc99e Initial load
duke
parents:
diff changeset
130 // entries and no other data. The following are double-indirect CP
a61af66fc99e Initial load
duke
parents:
diff changeset
131 // entries:
a61af66fc99e Initial load
duke
parents:
diff changeset
132 // JVM_CONSTANT_{Fieldref,InterfaceMethodref,Methodref}
a61af66fc99e Initial load
duke
parents:
diff changeset
133 //
a61af66fc99e Initial load
duke
parents:
diff changeset
134 // When comparing entries between two constant pools, the entry types
a61af66fc99e Initial load
duke
parents:
diff changeset
135 // are compared first and if they match, then further comparisons are
a61af66fc99e Initial load
duke
parents:
diff changeset
136 // made depending on the entry subtype. Comparing direct CP entries is
a61af66fc99e Initial load
duke
parents:
diff changeset
137 // simply a matter of comparing the data associated with each entry.
a61af66fc99e Initial load
duke
parents:
diff changeset
138 // Comparing both indirect and double-indirect CP entries requires
a61af66fc99e Initial load
duke
parents:
diff changeset
139 // recursion.
a61af66fc99e Initial load
duke
parents:
diff changeset
140 //
a61af66fc99e Initial load
duke
parents:
diff changeset
141 // Fortunately, the recursive combinations are limited because indirect
a61af66fc99e Initial load
duke
parents:
diff changeset
142 // CP entries can only refer to direct CP entries and double-indirect
a61af66fc99e Initial load
duke
parents:
diff changeset
143 // CP entries can only refer to indirect CP entries. The following is
a61af66fc99e Initial load
duke
parents:
diff changeset
144 // an example illustration of the deepest set of indirections needed to
a61af66fc99e Initial load
duke
parents:
diff changeset
145 // access the data associated with a JVM_CONSTANT_Fieldref entry:
a61af66fc99e Initial load
duke
parents:
diff changeset
146 //
a61af66fc99e Initial load
duke
parents:
diff changeset
147 // JVM_CONSTANT_Fieldref {
a61af66fc99e Initial load
duke
parents:
diff changeset
148 // class_index => JVM_CONSTANT_Class {
a61af66fc99e Initial load
duke
parents:
diff changeset
149 // name_index => JVM_CONSTANT_Utf8 {
a61af66fc99e Initial load
duke
parents:
diff changeset
150 // <data-1>
a61af66fc99e Initial load
duke
parents:
diff changeset
151 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
152 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
153 // name_and_type_index => JVM_CONSTANT_NameAndType {
a61af66fc99e Initial load
duke
parents:
diff changeset
154 // name_index => JVM_CONSTANT_Utf8 {
a61af66fc99e Initial load
duke
parents:
diff changeset
155 // <data-2>
a61af66fc99e Initial load
duke
parents:
diff changeset
156 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
157 // descriptor_index => JVM_CONSTANT_Utf8 {
a61af66fc99e Initial load
duke
parents:
diff changeset
158 // <data-3>
a61af66fc99e Initial load
duke
parents:
diff changeset
159 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
160 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
161 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
162 //
a61af66fc99e Initial load
duke
parents:
diff changeset
163 // The above illustration is not a data structure definition for any
a61af66fc99e Initial load
duke
parents:
diff changeset
164 // computer language. The curly braces ('{' and '}') are meant to
a61af66fc99e Initial load
duke
parents:
diff changeset
165 // delimit the context of the "fields" in the CP entry types shown.
a61af66fc99e Initial load
duke
parents:
diff changeset
166 // Each indirection from the JVM_CONSTANT_Fieldref entry is shown via
a61af66fc99e Initial load
duke
parents:
diff changeset
167 // "=>", e.g., the class_index is used to indirectly reference a
a61af66fc99e Initial load
duke
parents:
diff changeset
168 // JVM_CONSTANT_Class entry where the name_index is used to indirectly
a61af66fc99e Initial load
duke
parents:
diff changeset
169 // reference a JVM_CONSTANT_Utf8 entry which contains the interesting
a61af66fc99e Initial load
duke
parents:
diff changeset
170 // <data-1>. In order to understand a JVM_CONSTANT_Fieldref entry, we
a61af66fc99e Initial load
duke
parents:
diff changeset
171 // have to do a total of 5 indirections just to get to the CP entries
a61af66fc99e Initial load
duke
parents:
diff changeset
172 // that contain the interesting pieces of data and then we have to
a61af66fc99e Initial load
duke
parents:
diff changeset
173 // fetch the three pieces of data. This means we have to do a total of
a61af66fc99e Initial load
duke
parents:
diff changeset
174 // (5 + 3) * 2 == 16 dereferences to compare two JVM_CONSTANT_Fieldref
a61af66fc99e Initial load
duke
parents:
diff changeset
175 // entries.
a61af66fc99e Initial load
duke
parents:
diff changeset
176 //
a61af66fc99e Initial load
duke
parents:
diff changeset
177 // Here is the indirection, data and dereference count for each entry
a61af66fc99e Initial load
duke
parents:
diff changeset
178 // type:
a61af66fc99e Initial load
duke
parents:
diff changeset
179 //
a61af66fc99e Initial load
duke
parents:
diff changeset
180 // JVM_CONSTANT_Class 1 indir, 1 data, 2 derefs
a61af66fc99e Initial load
duke
parents:
diff changeset
181 // JVM_CONSTANT_Double 0 indir, 1 data, 1 deref
a61af66fc99e Initial load
duke
parents:
diff changeset
182 // JVM_CONSTANT_Fieldref 2 indir, 3 data, 8 derefs
a61af66fc99e Initial load
duke
parents:
diff changeset
183 // JVM_CONSTANT_Float 0 indir, 1 data, 1 deref
a61af66fc99e Initial load
duke
parents:
diff changeset
184 // JVM_CONSTANT_Integer 0 indir, 1 data, 1 deref
a61af66fc99e Initial load
duke
parents:
diff changeset
185 // JVM_CONSTANT_InterfaceMethodref 2 indir, 3 data, 8 derefs
a61af66fc99e Initial load
duke
parents:
diff changeset
186 // JVM_CONSTANT_Long 0 indir, 1 data, 1 deref
a61af66fc99e Initial load
duke
parents:
diff changeset
187 // JVM_CONSTANT_Methodref 2 indir, 3 data, 8 derefs
a61af66fc99e Initial load
duke
parents:
diff changeset
188 // JVM_CONSTANT_NameAndType 1 indir, 2 data, 4 derefs
a61af66fc99e Initial load
duke
parents:
diff changeset
189 // JVM_CONSTANT_String 1 indir, 1 data, 2 derefs
a61af66fc99e Initial load
duke
parents:
diff changeset
190 // JVM_CONSTANT_Utf8 0 indir, 1 data, 1 deref
a61af66fc99e Initial load
duke
parents:
diff changeset
191 //
a61af66fc99e Initial load
duke
parents:
diff changeset
192 // So different subtypes of CP entries require different amounts of
a61af66fc99e Initial load
duke
parents:
diff changeset
193 // work for a proper comparison.
a61af66fc99e Initial load
duke
parents:
diff changeset
194 //
a61af66fc99e Initial load
duke
parents:
diff changeset
195 // Now that we've talked about the different entry types and how to
a61af66fc99e Initial load
duke
parents:
diff changeset
196 // compare them we need to get back to merging. This is not a merge in
a61af66fc99e Initial load
duke
parents:
diff changeset
197 // the "sort -u" sense or even in the "sort" sense. When we merge two
a61af66fc99e Initial load
duke
parents:
diff changeset
198 // constant pools, we copy all the entries from old_cp to merge_cp,
a61af66fc99e Initial load
duke
parents:
diff changeset
199 // preserving entry order. Next we append all the unique entries from
a61af66fc99e Initial load
duke
parents:
diff changeset
200 // scratch_cp to merge_cp and we track the index changes from the
a61af66fc99e Initial load
duke
parents:
diff changeset
201 // location in scratch_cp to the possibly new location in merge_cp.
a61af66fc99e Initial load
duke
parents:
diff changeset
202 // When we are done, any obsolete code that is still running that
a61af66fc99e Initial load
duke
parents:
diff changeset
203 // uses old_cp should not be able to observe any difference if it
a61af66fc99e Initial load
duke
parents:
diff changeset
204 // were to use merge_cp. As for the new code in scratch_class, it is
a61af66fc99e Initial load
duke
parents:
diff changeset
205 // modified to use the appropriate index values in merge_cp before it
a61af66fc99e Initial load
duke
parents:
diff changeset
206 // is used to replace the code in the_class.
a61af66fc99e Initial load
duke
parents:
diff changeset
207 //
a61af66fc99e Initial load
duke
parents:
diff changeset
208 // There is one small complication in copying the entries from old_cp
a61af66fc99e Initial load
duke
parents:
diff changeset
209 // to merge_cp. Two of the CP entry types are special in that they are
a61af66fc99e Initial load
duke
parents:
diff changeset
210 // lazily resolved. Before explaining the copying complication, we need
a61af66fc99e Initial load
duke
parents:
diff changeset
211 // to digress into CP entry resolution.
a61af66fc99e Initial load
duke
parents:
diff changeset
212 //
a61af66fc99e Initial load
duke
parents:
diff changeset
213 // JVM_CONSTANT_Class and JVM_CONSTANT_String entries are present in
a61af66fc99e Initial load
duke
parents:
diff changeset
214 // the class file, but are not stored in memory as such until they are
a61af66fc99e Initial load
duke
parents:
diff changeset
215 // resolved. The entries are not resolved unless they are used because
a61af66fc99e Initial load
duke
parents:
diff changeset
216 // resolution is expensive. During class file parsing the entries are
a61af66fc99e Initial load
duke
parents:
diff changeset
217 // initially stored in memory as JVM_CONSTANT_ClassIndex and
a61af66fc99e Initial load
duke
parents:
diff changeset
218 // JVM_CONSTANT_StringIndex entries. These special CP entry types
a61af66fc99e Initial load
duke
parents:
diff changeset
219 // indicate that the JVM_CONSTANT_Class and JVM_CONSTANT_String entries
a61af66fc99e Initial load
duke
parents:
diff changeset
220 // have been parsed, but the index values in the entries have not been
a61af66fc99e Initial load
duke
parents:
diff changeset
221 // validated. After the entire constant pool has been parsed, the index
a61af66fc99e Initial load
duke
parents:
diff changeset
222 // values can be validated and then the entries are converted into
a61af66fc99e Initial load
duke
parents:
diff changeset
223 // JVM_CONSTANT_UnresolvedClass and JVM_CONSTANT_UnresolvedString
a61af66fc99e Initial load
duke
parents:
diff changeset
224 // entries. During this conversion process, the UTF8 values that are
a61af66fc99e Initial load
duke
parents:
diff changeset
225 // indirectly referenced by the JVM_CONSTANT_ClassIndex and
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
226 // JVM_CONSTANT_StringIndex entries are changed into Symbol*s and the
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
227 // entries are modified to refer to the Symbol*s. This optimization
0
a61af66fc99e Initial load
duke
parents:
diff changeset
228 // eliminates one level of indirection for those two CP entry types and
a61af66fc99e Initial load
duke
parents:
diff changeset
229 // gets the entries ready for verification. During class file parsing
a61af66fc99e Initial load
duke
parents:
diff changeset
230 // it is also possible for JVM_CONSTANT_UnresolvedString entries to be
a61af66fc99e Initial load
duke
parents:
diff changeset
231 // resolved into JVM_CONSTANT_String entries. Verification expects to
a61af66fc99e Initial load
duke
parents:
diff changeset
232 // find JVM_CONSTANT_UnresolvedClass and either JVM_CONSTANT_String or
a61af66fc99e Initial load
duke
parents:
diff changeset
233 // JVM_CONSTANT_UnresolvedString entries and not JVM_CONSTANT_Class
a61af66fc99e Initial load
duke
parents:
diff changeset
234 // entries.
a61af66fc99e Initial load
duke
parents:
diff changeset
235 //
a61af66fc99e Initial load
duke
parents:
diff changeset
236 // Now we can get back to the copying complication. When we copy
a61af66fc99e Initial load
duke
parents:
diff changeset
237 // entries from old_cp to merge_cp, we have to revert any
a61af66fc99e Initial load
duke
parents:
diff changeset
238 // JVM_CONSTANT_Class entries to JVM_CONSTANT_UnresolvedClass entries
a61af66fc99e Initial load
duke
parents:
diff changeset
239 // or verification will fail.
a61af66fc99e Initial load
duke
parents:
diff changeset
240 //
a61af66fc99e Initial load
duke
parents:
diff changeset
241 // It is important to explicitly state that the merging algorithm
a61af66fc99e Initial load
duke
parents:
diff changeset
242 // effectively unresolves JVM_CONSTANT_Class entries that were in the
a61af66fc99e Initial load
duke
parents:
diff changeset
243 // old_cp when they are changed into JVM_CONSTANT_UnresolvedClass
a61af66fc99e Initial load
duke
parents:
diff changeset
244 // entries in the merge_cp. This is done both to make verification
a61af66fc99e Initial load
duke
parents:
diff changeset
245 // happy and to avoid adding more brittleness between RedefineClasses
a61af66fc99e Initial load
duke
parents:
diff changeset
246 // and the constant pool cache. By allowing the constant pool cache
a61af66fc99e Initial load
duke
parents:
diff changeset
247 // implementation to (re)resolve JVM_CONSTANT_UnresolvedClass entries
a61af66fc99e Initial load
duke
parents:
diff changeset
248 // into JVM_CONSTANT_Class entries, we avoid having to embed knowledge
a61af66fc99e Initial load
duke
parents:
diff changeset
249 // about those algorithms in RedefineClasses.
a61af66fc99e Initial load
duke
parents:
diff changeset
250 //
a61af66fc99e Initial load
duke
parents:
diff changeset
251 // Appending unique entries from scratch_cp to merge_cp is straight
a61af66fc99e Initial load
duke
parents:
diff changeset
252 // forward for direct CP entries and most indirect CP entries. For the
a61af66fc99e Initial load
duke
parents:
diff changeset
253 // indirect CP entry type JVM_CONSTANT_NameAndType and for the double-
a61af66fc99e Initial load
duke
parents:
diff changeset
254 // indirect CP entry types, the presence of more than one piece of
a61af66fc99e Initial load
duke
parents:
diff changeset
255 // interesting data makes appending the entries more complicated.
a61af66fc99e Initial load
duke
parents:
diff changeset
256 //
a61af66fc99e Initial load
duke
parents:
diff changeset
257 // For the JVM_CONSTANT_{Double,Float,Integer,Long,Utf8} entry types,
a61af66fc99e Initial load
duke
parents:
diff changeset
258 // the entry is simply copied from scratch_cp to the end of merge_cp.
a61af66fc99e Initial load
duke
parents:
diff changeset
259 // If the index in scratch_cp is different than the destination index
a61af66fc99e Initial load
duke
parents:
diff changeset
260 // in merge_cp, then the change in index value is tracked.
a61af66fc99e Initial load
duke
parents:
diff changeset
261 //
a61af66fc99e Initial load
duke
parents:
diff changeset
262 // Note: the above discussion for the direct CP entries also applies
a61af66fc99e Initial load
duke
parents:
diff changeset
263 // to the JVM_CONSTANT_Unresolved{Class,String} entry types.
a61af66fc99e Initial load
duke
parents:
diff changeset
264 //
a61af66fc99e Initial load
duke
parents:
diff changeset
265 // For the JVM_CONSTANT_{Class,String} entry types, since there is only
a61af66fc99e Initial load
duke
parents:
diff changeset
266 // one data element at the end of the recursion, we know that we have
a61af66fc99e Initial load
duke
parents:
diff changeset
267 // either one or two unique entries. If the JVM_CONSTANT_Utf8 entry is
a61af66fc99e Initial load
duke
parents:
diff changeset
268 // unique then it is appended to merge_cp before the current entry.
a61af66fc99e Initial load
duke
parents:
diff changeset
269 // If the JVM_CONSTANT_Utf8 entry is not unique, then the current entry
a61af66fc99e Initial load
duke
parents:
diff changeset
270 // is updated to refer to the duplicate entry in merge_cp before it is
a61af66fc99e Initial load
duke
parents:
diff changeset
271 // appended to merge_cp. Again, any changes in index values are tracked
a61af66fc99e Initial load
duke
parents:
diff changeset
272 // as needed.
a61af66fc99e Initial load
duke
parents:
diff changeset
273 //
a61af66fc99e Initial load
duke
parents:
diff changeset
274 // Note: the above discussion for JVM_CONSTANT_{Class,String} entry
a61af66fc99e Initial load
duke
parents:
diff changeset
275 // types is theoretical. Since those entry types have already been
a61af66fc99e Initial load
duke
parents:
diff changeset
276 // optimized into JVM_CONSTANT_Unresolved{Class,String} entry types,
a61af66fc99e Initial load
duke
parents:
diff changeset
277 // they are handled as direct CP entries.
a61af66fc99e Initial load
duke
parents:
diff changeset
278 //
a61af66fc99e Initial load
duke
parents:
diff changeset
279 // For the JVM_CONSTANT_NameAndType entry type, since there are two
a61af66fc99e Initial load
duke
parents:
diff changeset
280 // data elements at the end of the recursions, we know that we have
a61af66fc99e Initial load
duke
parents:
diff changeset
281 // between one and three unique entries. Any unique JVM_CONSTANT_Utf8
a61af66fc99e Initial load
duke
parents:
diff changeset
282 // entries are appended to merge_cp before the current entry. For any
a61af66fc99e Initial load
duke
parents:
diff changeset
283 // JVM_CONSTANT_Utf8 entries that are not unique, the current entry is
a61af66fc99e Initial load
duke
parents:
diff changeset
284 // updated to refer to the duplicate entry in merge_cp before it is
a61af66fc99e Initial load
duke
parents:
diff changeset
285 // appended to merge_cp. Again, any changes in index values are tracked
a61af66fc99e Initial load
duke
parents:
diff changeset
286 // as needed.
a61af66fc99e Initial load
duke
parents:
diff changeset
287 //
a61af66fc99e Initial load
duke
parents:
diff changeset
288 // For the JVM_CONSTANT_{Fieldref,InterfaceMethodref,Methodref} entry
a61af66fc99e Initial load
duke
parents:
diff changeset
289 // types, since there are two indirect CP entries and three data
a61af66fc99e Initial load
duke
parents:
diff changeset
290 // elements at the end of the recursions, we know that we have between
a61af66fc99e Initial load
duke
parents:
diff changeset
291 // one and six unique entries. See the JVM_CONSTANT_Fieldref diagram
a61af66fc99e Initial load
duke
parents:
diff changeset
292 // above for an example of all six entries. The uniqueness algorithm
a61af66fc99e Initial load
duke
parents:
diff changeset
293 // for the JVM_CONSTANT_Class and JVM_CONSTANT_NameAndType entries is
a61af66fc99e Initial load
duke
parents:
diff changeset
294 // covered above. Any unique entries are appended to merge_cp before
a61af66fc99e Initial load
duke
parents:
diff changeset
295 // the current entry. For any entries that are not unique, the current
a61af66fc99e Initial load
duke
parents:
diff changeset
296 // entry is updated to refer to the duplicate entry in merge_cp before
a61af66fc99e Initial load
duke
parents:
diff changeset
297 // it is appended to merge_cp. Again, any changes in index values are
a61af66fc99e Initial load
duke
parents:
diff changeset
298 // tracked as needed.
a61af66fc99e Initial load
duke
parents:
diff changeset
299 //
a61af66fc99e Initial load
duke
parents:
diff changeset
300 //
a61af66fc99e Initial load
duke
parents:
diff changeset
301 // Other Details:
a61af66fc99e Initial load
duke
parents:
diff changeset
302 //
a61af66fc99e Initial load
duke
parents:
diff changeset
303 // Details for other parts of RedefineClasses need to be written.
a61af66fc99e Initial load
duke
parents:
diff changeset
304 // This is a placeholder section.
a61af66fc99e Initial load
duke
parents:
diff changeset
305 //
a61af66fc99e Initial load
duke
parents:
diff changeset
306 //
a61af66fc99e Initial load
duke
parents:
diff changeset
307 // Open Issues (in no particular order):
a61af66fc99e Initial load
duke
parents:
diff changeset
308 //
a61af66fc99e Initial load
duke
parents:
diff changeset
309 // - How do we serialize the RedefineClasses() API without deadlocking?
a61af66fc99e Initial load
duke
parents:
diff changeset
310 //
a61af66fc99e Initial load
duke
parents:
diff changeset
311 // - SystemDictionary::parse_stream() was called with a NULL protection
a61af66fc99e Initial load
duke
parents:
diff changeset
312 // domain since the initial version. This has been changed to pass
a61af66fc99e Initial load
duke
parents:
diff changeset
313 // the_class->protection_domain(). This change has been tested with
a61af66fc99e Initial load
duke
parents:
diff changeset
314 // all NSK tests and nothing broke, but what will adding it now break
a61af66fc99e Initial load
duke
parents:
diff changeset
315 // in ways that we don't test?
a61af66fc99e Initial load
duke
parents:
diff changeset
316 //
a61af66fc99e Initial load
duke
parents:
diff changeset
317 // - GenerateOopMap::rewrite_load_or_store() has a comment in its
a61af66fc99e Initial load
duke
parents:
diff changeset
318 // (indirect) use of the Relocator class that the max instruction
a61af66fc99e Initial load
duke
parents:
diff changeset
319 // size is 4 bytes. goto_w and jsr_w are 5 bytes and wide/iinc is
a61af66fc99e Initial load
duke
parents:
diff changeset
320 // 6 bytes. Perhaps Relocator only needs a 4 byte buffer to do
a61af66fc99e Initial load
duke
parents:
diff changeset
321 // what it does to the bytecodes. More investigation is needed.
a61af66fc99e Initial load
duke
parents:
diff changeset
322 //
a61af66fc99e Initial load
duke
parents:
diff changeset
323 // - java.lang.Object methods can be called on arrays. This is
a61af66fc99e Initial load
duke
parents:
diff changeset
324 // implemented via the arrayKlassOop vtable which we don't
a61af66fc99e Initial load
duke
parents:
diff changeset
325 // update. For example, if we redefine java.lang.Object.toString(),
a61af66fc99e Initial load
duke
parents:
diff changeset
326 // then the new version of the method will not be called for array
a61af66fc99e Initial load
duke
parents:
diff changeset
327 // objects.
a61af66fc99e Initial load
duke
parents:
diff changeset
328 //
a61af66fc99e Initial load
duke
parents:
diff changeset
329 // - How do we know if redefine_single_class() and the guts of
a61af66fc99e Initial load
duke
parents:
diff changeset
330 // instanceKlass are out of sync? I don't think this can be
a61af66fc99e Initial load
duke
parents:
diff changeset
331 // automated, but we should probably order the work in
a61af66fc99e Initial load
duke
parents:
diff changeset
332 // redefine_single_class() to match the order of field
a61af66fc99e Initial load
duke
parents:
diff changeset
333 // definitions in instanceKlass. We also need to add some
a61af66fc99e Initial load
duke
parents:
diff changeset
334 // comments about keeping things in sync.
a61af66fc99e Initial load
duke
parents:
diff changeset
335 //
a61af66fc99e Initial load
duke
parents:
diff changeset
336 // - set_new_constant_pool() is huge and we should consider refactoring
a61af66fc99e Initial load
duke
parents:
diff changeset
337 // it into smaller chunks of work.
a61af66fc99e Initial load
duke
parents:
diff changeset
338 //
a61af66fc99e Initial load
duke
parents:
diff changeset
339 // - The exception table update code in set_new_constant_pool() defines
a61af66fc99e Initial load
duke
parents:
diff changeset
340 // const values that are also defined in a local context elsewhere.
a61af66fc99e Initial load
duke
parents:
diff changeset
341 // The same literal values are also used in elsewhere. We need to
a61af66fc99e Initial load
duke
parents:
diff changeset
342 // coordinate a cleanup of these constants with Runtime.
a61af66fc99e Initial load
duke
parents:
diff changeset
343 //
a61af66fc99e Initial load
duke
parents:
diff changeset
344
a61af66fc99e Initial load
duke
parents:
diff changeset
345 class VM_RedefineClasses: public VM_Operation {
a61af66fc99e Initial load
duke
parents:
diff changeset
346 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
347 // These static fields are needed by SystemDictionary::classes_do()
a61af66fc99e Initial load
duke
parents:
diff changeset
348 // facility and the adjust_cpool_cache_and_vtable() helper:
a61af66fc99e Initial load
duke
parents:
diff changeset
349 static objArrayOop _old_methods;
a61af66fc99e Initial load
duke
parents:
diff changeset
350 static objArrayOop _new_methods;
a61af66fc99e Initial load
duke
parents:
diff changeset
351 static methodOop* _matching_old_methods;
a61af66fc99e Initial load
duke
parents:
diff changeset
352 static methodOop* _matching_new_methods;
a61af66fc99e Initial load
duke
parents:
diff changeset
353 static methodOop* _deleted_methods;
a61af66fc99e Initial load
duke
parents:
diff changeset
354 static methodOop* _added_methods;
a61af66fc99e Initial load
duke
parents:
diff changeset
355 static int _matching_methods_length;
a61af66fc99e Initial load
duke
parents:
diff changeset
356 static int _deleted_methods_length;
a61af66fc99e Initial load
duke
parents:
diff changeset
357 static int _added_methods_length;
a61af66fc99e Initial load
duke
parents:
diff changeset
358 static klassOop _the_class_oop;
a61af66fc99e Initial load
duke
parents:
diff changeset
359
a61af66fc99e Initial load
duke
parents:
diff changeset
360 // The instance fields are used to pass information from
a61af66fc99e Initial load
duke
parents:
diff changeset
361 // doit_prologue() to doit() and doit_epilogue().
a61af66fc99e Initial load
duke
parents:
diff changeset
362 jint _class_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
363 const jvmtiClassDefinition *_class_defs; // ptr to _class_count defs
a61af66fc99e Initial load
duke
parents:
diff changeset
364
a61af66fc99e Initial load
duke
parents:
diff changeset
365 // This operation is used by both RedefineClasses and
a61af66fc99e Initial load
duke
parents:
diff changeset
366 // RetransformClasses. Indicate which.
a61af66fc99e Initial load
duke
parents:
diff changeset
367 JvmtiClassLoadKind _class_load_kind;
a61af66fc99e Initial load
duke
parents:
diff changeset
368
a61af66fc99e Initial load
duke
parents:
diff changeset
369 // _index_map_count is just an optimization for knowing if
a61af66fc99e Initial load
duke
parents:
diff changeset
370 // _index_map_p contains any entries.
a61af66fc99e Initial load
duke
parents:
diff changeset
371 int _index_map_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
372 intArray * _index_map_p;
a61af66fc99e Initial load
duke
parents:
diff changeset
373 // ptr to _class_count scratch_classes
a61af66fc99e Initial load
duke
parents:
diff changeset
374 instanceKlassHandle * _scratch_classes;
a61af66fc99e Initial load
duke
parents:
diff changeset
375 jvmtiError _res;
a61af66fc99e Initial load
duke
parents:
diff changeset
376
a61af66fc99e Initial load
duke
parents:
diff changeset
377 // Performance measurement support. These timers do not cover all
a61af66fc99e Initial load
duke
parents:
diff changeset
378 // the work done for JVM/TI RedefineClasses() but they do cover
a61af66fc99e Initial load
duke
parents:
diff changeset
379 // the heavy lifting.
a61af66fc99e Initial load
duke
parents:
diff changeset
380 elapsedTimer _timer_rsc_phase1;
a61af66fc99e Initial load
duke
parents:
diff changeset
381 elapsedTimer _timer_rsc_phase2;
a61af66fc99e Initial load
duke
parents:
diff changeset
382 elapsedTimer _timer_vm_op_prologue;
a61af66fc99e Initial load
duke
parents:
diff changeset
383
a61af66fc99e Initial load
duke
parents:
diff changeset
384 // These routines are roughly in call order unless otherwise noted.
a61af66fc99e Initial load
duke
parents:
diff changeset
385
a61af66fc99e Initial load
duke
parents:
diff changeset
386 // Load the caller's new class definition(s) into _scratch_classes.
a61af66fc99e Initial load
duke
parents:
diff changeset
387 // Constant pool merging work is done here as needed. Also calls
a61af66fc99e Initial load
duke
parents:
diff changeset
388 // compare_and_normalize_class_versions() to verify the class
a61af66fc99e Initial load
duke
parents:
diff changeset
389 // definition(s).
a61af66fc99e Initial load
duke
parents:
diff changeset
390 jvmtiError load_new_class_versions(TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
391
a61af66fc99e Initial load
duke
parents:
diff changeset
392 // Verify that the caller provided class definition(s) that meet
a61af66fc99e Initial load
duke
parents:
diff changeset
393 // the restrictions of RedefineClasses. Normalize the order of
a61af66fc99e Initial load
duke
parents:
diff changeset
394 // overloaded methods as needed.
a61af66fc99e Initial load
duke
parents:
diff changeset
395 jvmtiError compare_and_normalize_class_versions(
a61af66fc99e Initial load
duke
parents:
diff changeset
396 instanceKlassHandle the_class, instanceKlassHandle scratch_class);
a61af66fc99e Initial load
duke
parents:
diff changeset
397
a61af66fc99e Initial load
duke
parents:
diff changeset
398 // Swap annotations[i] with annotations[j]
a61af66fc99e Initial load
duke
parents:
diff changeset
399 // Used by compare_and_normalize_class_versions() when normalizing
a61af66fc99e Initial load
duke
parents:
diff changeset
400 // overloaded methods or changing idnum as when adding or deleting methods.
a61af66fc99e Initial load
duke
parents:
diff changeset
401 void swap_all_method_annotations(int i, int j, instanceKlassHandle scratch_class);
a61af66fc99e Initial load
duke
parents:
diff changeset
402
a61af66fc99e Initial load
duke
parents:
diff changeset
403 // Figure out which new methods match old methods in name and signature,
a61af66fc99e Initial load
duke
parents:
diff changeset
404 // which methods have been added, and which are no longer present
a61af66fc99e Initial load
duke
parents:
diff changeset
405 void compute_added_deleted_matching_methods();
a61af66fc99e Initial load
duke
parents:
diff changeset
406
a61af66fc99e Initial load
duke
parents:
diff changeset
407 // Change jmethodIDs to point to the new methods
a61af66fc99e Initial load
duke
parents:
diff changeset
408 void update_jmethod_ids();
a61af66fc99e Initial load
duke
parents:
diff changeset
409
a61af66fc99e Initial load
duke
parents:
diff changeset
410 // In addition to marking methods as obsolete, this routine
a61af66fc99e Initial load
duke
parents:
diff changeset
411 // records which methods are EMCP (Equivalent Module Constant
a61af66fc99e Initial load
duke
parents:
diff changeset
412 // Pool) in the emcp_methods BitMap and returns the number of
a61af66fc99e Initial load
duke
parents:
diff changeset
413 // EMCP methods via emcp_method_count_p. This information is
a61af66fc99e Initial load
duke
parents:
diff changeset
414 // used when information about the previous version of the_class
a61af66fc99e Initial load
duke
parents:
diff changeset
415 // is squirreled away.
a61af66fc99e Initial load
duke
parents:
diff changeset
416 void check_methods_and_mark_as_obsolete(BitMap *emcp_methods,
a61af66fc99e Initial load
duke
parents:
diff changeset
417 int * emcp_method_count_p);
a61af66fc99e Initial load
duke
parents:
diff changeset
418 void transfer_old_native_function_registrations(instanceKlassHandle the_class);
a61af66fc99e Initial load
duke
parents:
diff changeset
419
a61af66fc99e Initial load
duke
parents:
diff changeset
420 // Unevolving classes may point to methods of the_class directly
a61af66fc99e Initial load
duke
parents:
diff changeset
421 // from their constant pool caches, itables, and/or vtables. We
a61af66fc99e Initial load
duke
parents:
diff changeset
422 // use the SystemDictionary::classes_do() facility and this helper
a61af66fc99e Initial load
duke
parents:
diff changeset
423 // to fix up these pointers.
a61af66fc99e Initial load
duke
parents:
diff changeset
424 static void adjust_cpool_cache_and_vtable(klassOop k_oop, oop loader, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
425
a61af66fc99e Initial load
duke
parents:
diff changeset
426 // Install the redefinition of a class
a61af66fc99e Initial load
duke
parents:
diff changeset
427 void redefine_single_class(jclass the_jclass,
a61af66fc99e Initial load
duke
parents:
diff changeset
428 instanceKlassHandle scratch_class, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
429
a61af66fc99e Initial load
duke
parents:
diff changeset
430 // Increment the classRedefinedCount field in the specific instanceKlass
a61af66fc99e Initial load
duke
parents:
diff changeset
431 // and in all direct and indirect subclasses.
a61af66fc99e Initial load
duke
parents:
diff changeset
432 void increment_class_counter(instanceKlass *ik, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
433
a61af66fc99e Initial load
duke
parents:
diff changeset
434 // Support for constant pool merging (these routines are in alpha
a61af66fc99e Initial load
duke
parents:
diff changeset
435 // order):
a61af66fc99e Initial load
duke
parents:
diff changeset
436 void append_entry(constantPoolHandle scratch_cp, int scratch_i,
a61af66fc99e Initial load
duke
parents:
diff changeset
437 constantPoolHandle *merge_cp_p, int *merge_cp_length_p, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
438 int find_new_index(int old_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
439 bool is_unresolved_class_mismatch(constantPoolHandle cp1, int index1,
a61af66fc99e Initial load
duke
parents:
diff changeset
440 constantPoolHandle cp2, int index2);
a61af66fc99e Initial load
duke
parents:
diff changeset
441 bool is_unresolved_string_mismatch(constantPoolHandle cp1, int index1,
a61af66fc99e Initial load
duke
parents:
diff changeset
442 constantPoolHandle cp2, int index2);
a61af66fc99e Initial load
duke
parents:
diff changeset
443 void map_index(constantPoolHandle scratch_cp, int old_index, int new_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
444 bool merge_constant_pools(constantPoolHandle old_cp,
a61af66fc99e Initial load
duke
parents:
diff changeset
445 constantPoolHandle scratch_cp, constantPoolHandle *merge_cp_p,
a61af66fc99e Initial load
duke
parents:
diff changeset
446 int *merge_cp_length_p, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
447 jvmtiError merge_cp_and_rewrite(instanceKlassHandle the_class,
a61af66fc99e Initial load
duke
parents:
diff changeset
448 instanceKlassHandle scratch_class, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
449 u2 rewrite_cp_ref_in_annotation_data(
a61af66fc99e Initial load
duke
parents:
diff changeset
450 typeArrayHandle annotations_typeArray, int &byte_i_ref,
a61af66fc99e Initial load
duke
parents:
diff changeset
451 const char * trace_mesg, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
452 bool rewrite_cp_refs(instanceKlassHandle scratch_class, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
453 bool rewrite_cp_refs_in_annotation_struct(
a61af66fc99e Initial load
duke
parents:
diff changeset
454 typeArrayHandle class_annotations, int &byte_i_ref, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
455 bool rewrite_cp_refs_in_annotations_typeArray(
a61af66fc99e Initial load
duke
parents:
diff changeset
456 typeArrayHandle annotations_typeArray, int &byte_i_ref, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
457 bool rewrite_cp_refs_in_class_annotations(
a61af66fc99e Initial load
duke
parents:
diff changeset
458 instanceKlassHandle scratch_class, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
459 bool rewrite_cp_refs_in_element_value(
a61af66fc99e Initial load
duke
parents:
diff changeset
460 typeArrayHandle class_annotations, int &byte_i_ref, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
461 bool rewrite_cp_refs_in_fields_annotations(
a61af66fc99e Initial load
duke
parents:
diff changeset
462 instanceKlassHandle scratch_class, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
463 void rewrite_cp_refs_in_method(methodHandle method,
a61af66fc99e Initial load
duke
parents:
diff changeset
464 methodHandle * new_method_p, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
465 bool rewrite_cp_refs_in_methods(instanceKlassHandle scratch_class, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
466 bool rewrite_cp_refs_in_methods_annotations(
a61af66fc99e Initial load
duke
parents:
diff changeset
467 instanceKlassHandle scratch_class, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
468 bool rewrite_cp_refs_in_methods_default_annotations(
a61af66fc99e Initial load
duke
parents:
diff changeset
469 instanceKlassHandle scratch_class, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
470 bool rewrite_cp_refs_in_methods_parameter_annotations(
a61af66fc99e Initial load
duke
parents:
diff changeset
471 instanceKlassHandle scratch_class, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
472 void rewrite_cp_refs_in_stack_map_table(methodHandle method, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
473 void rewrite_cp_refs_in_verification_type_info(
a61af66fc99e Initial load
duke
parents:
diff changeset
474 address& stackmap_addr_ref, address stackmap_end, u2 frame_i,
a61af66fc99e Initial load
duke
parents:
diff changeset
475 u1 frame_size, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
476 void set_new_constant_pool(instanceKlassHandle scratch_class,
a61af66fc99e Initial load
duke
parents:
diff changeset
477 constantPoolHandle scratch_cp, int scratch_cp_length, bool shrink, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
478
a61af66fc99e Initial load
duke
parents:
diff changeset
479 void flush_dependent_code(instanceKlassHandle k_h, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
480
a61af66fc99e Initial load
duke
parents:
diff changeset
481 static void check_class(klassOop k_oop, oop initiating_loader, TRAPS) PRODUCT_RETURN;
a61af66fc99e Initial load
duke
parents:
diff changeset
482
a61af66fc99e Initial load
duke
parents:
diff changeset
483 static void dump_methods() PRODUCT_RETURN;
a61af66fc99e Initial load
duke
parents:
diff changeset
484
a61af66fc99e Initial load
duke
parents:
diff changeset
485 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
486 VM_RedefineClasses(jint class_count,
a61af66fc99e Initial load
duke
parents:
diff changeset
487 const jvmtiClassDefinition *class_defs,
a61af66fc99e Initial load
duke
parents:
diff changeset
488 JvmtiClassLoadKind class_load_kind);
a61af66fc99e Initial load
duke
parents:
diff changeset
489 VMOp_Type type() const { return VMOp_RedefineClasses; }
a61af66fc99e Initial load
duke
parents:
diff changeset
490 bool doit_prologue();
a61af66fc99e Initial load
duke
parents:
diff changeset
491 void doit();
a61af66fc99e Initial load
duke
parents:
diff changeset
492 void doit_epilogue();
a61af66fc99e Initial load
duke
parents:
diff changeset
493
a61af66fc99e Initial load
duke
parents:
diff changeset
494 bool allow_nested_vm_operations() const { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
495 jvmtiError check_error() { return _res; }
a61af66fc99e Initial load
duke
parents:
diff changeset
496
a61af66fc99e Initial load
duke
parents:
diff changeset
497 // Modifiable test must be shared between IsModifiableClass query
a61af66fc99e Initial load
duke
parents:
diff changeset
498 // and redefine implementation
a61af66fc99e Initial load
duke
parents:
diff changeset
499 static bool is_modifiable_class(oop klass_mirror);
a61af66fc99e Initial load
duke
parents:
diff changeset
500 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
501
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
502 #endif // SHARE_VM_PRIMS_JVMTIREDEFINECLASSES_HPP