Mercurial > hg > graal-jvmci-8
annotate src/share/vm/interpreter/rewriter.cpp @ 844:bd02caa94611
6862919: Update copyright year
Summary: Update copyright for files that have been modified in 2009, up to 07/09
Reviewed-by: tbell, ohair
author | xdono |
---|---|
date | Tue, 28 Jul 2009 12:12:40 -0700 |
parents | be93aad57795 |
children | 75596850f863 |
rev | line source |
---|---|
0 | 1 /* |
579 | 2 * Copyright 1998-2009 Sun Microsystems, Inc. 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 * | |
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
22 * | |
23 */ | |
24 | |
25 # include "incls/_precompiled.incl" | |
26 # include "incls/_rewriter.cpp.incl" | |
27 | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
28 // Computes a CPC map (new_index -> original_index) for constant pool entries |
0 | 29 // that are referred to by the interpreter at runtime via the constant pool cache. |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
30 // Also computes a CP map (original_index -> new_index). |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
31 // Marks entries in CP which require additional processing. |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
32 void Rewriter::compute_index_maps() { |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
33 const int length = _pool->length(); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
34 init_cp_map(length); |
0 | 35 for (int i = 0; i < length; i++) { |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
36 int tag = _pool->tag_at(i).value(); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
37 switch (tag) { |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
38 case JVM_CONSTANT_InterfaceMethodref: |
0 | 39 case JVM_CONSTANT_Fieldref : // fall through |
40 case JVM_CONSTANT_Methodref : // fall through | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
41 add_cp_cache_entry(i); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
42 break; |
0 | 43 } |
44 } | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
45 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
46 guarantee((int)_cp_cache_map.length()-1 <= (int)((u2)-1), |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
47 "all cp cache indexes fit in a u2"); |
0 | 48 } |
49 | |
50 | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
51 int Rewriter::add_extra_cp_cache_entry(int main_entry) { |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
52 // Hack: We put it on the map as an encoded value. |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
53 // The only place that consumes this is ConstantPoolCacheEntry::set_initial_state |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
54 int encoded = constantPoolCacheOopDesc::encode_secondary_index(main_entry); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
55 int plain_secondary_index = _cp_cache_map.append(encoded); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
56 return constantPoolCacheOopDesc::encode_secondary_index(plain_secondary_index); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
57 } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
58 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
59 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
60 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
61 // Creates a constant pool cache given a CPC map |
542
9a25e0c45327
6792421: assert(_bitMap->isMarked(addr+size-1),inconsistent Printezis mark)
jmasa
parents:
0
diff
changeset
|
62 // This creates the constant pool cache initially in a state |
9a25e0c45327
6792421: assert(_bitMap->isMarked(addr+size-1),inconsistent Printezis mark)
jmasa
parents:
0
diff
changeset
|
63 // that is unsafe for concurrent GC processing but sets it to |
9a25e0c45327
6792421: assert(_bitMap->isMarked(addr+size-1),inconsistent Printezis mark)
jmasa
parents:
0
diff
changeset
|
64 // a safe mode before the constant pool cache is returned. |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
65 void Rewriter::make_constant_pool_cache(TRAPS) { |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
66 const int length = _cp_cache_map.length(); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
67 constantPoolCacheOop cache = |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
68 oopFactory::new_constantPoolCache(length, methodOopDesc::IsUnsafeConc, CHECK); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
69 cache->initialize(_cp_cache_map); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
70 _pool->set_cache(cache); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
71 cache->set_constant_pool(_pool()); |
0 | 72 } |
73 | |
74 | |
75 | |
76 // The new finalization semantics says that registration of | |
77 // finalizable objects must be performed on successful return from the | |
78 // Object.<init> constructor. We could implement this trivially if | |
79 // <init> were never rewritten but since JVMTI allows this to occur, a | |
80 // more complicated solution is required. A special return bytecode | |
81 // is used only by Object.<init> to signal the finalization | |
82 // registration point. Additionally local 0 must be preserved so it's | |
83 // available to pass to the registration function. For simplicty we | |
84 // require that local 0 is never overwritten so it's available as an | |
85 // argument for registration. | |
86 | |
87 void Rewriter::rewrite_Object_init(methodHandle method, TRAPS) { | |
88 RawBytecodeStream bcs(method); | |
89 while (!bcs.is_last_bytecode()) { | |
90 Bytecodes::Code opcode = bcs.raw_next(); | |
91 switch (opcode) { | |
92 case Bytecodes::_return: *bcs.bcp() = Bytecodes::_return_register_finalizer; break; | |
93 | |
94 case Bytecodes::_istore: | |
95 case Bytecodes::_lstore: | |
96 case Bytecodes::_fstore: | |
97 case Bytecodes::_dstore: | |
98 case Bytecodes::_astore: | |
99 if (bcs.get_index() != 0) continue; | |
100 | |
101 // fall through | |
102 case Bytecodes::_istore_0: | |
103 case Bytecodes::_lstore_0: | |
104 case Bytecodes::_fstore_0: | |
105 case Bytecodes::_dstore_0: | |
106 case Bytecodes::_astore_0: | |
107 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), | |
108 "can't overwrite local 0 in Object.<init>"); | |
109 break; | |
110 } | |
111 } | |
112 } | |
113 | |
114 | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
115 // Rewrite a classfile-order CP index into a native-order CPC index. |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
116 int Rewriter::rewrite_member_reference(address bcp, int offset) { |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
117 address p = bcp + offset; |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
118 int cp_index = Bytes::get_Java_u2(p); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
119 int cache_index = cp_entry_to_cp_cache(cp_index); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
120 Bytes::put_native_u2(p, cache_index); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
121 return cp_index; |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
122 } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
123 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
124 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
125 void Rewriter::rewrite_invokedynamic(address bcp, int offset, int delete_me) { |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
126 address p = bcp + offset; |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
127 assert(p[-1] == Bytecodes::_invokedynamic, ""); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
128 int cp_index = Bytes::get_Java_u2(p); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
129 int cpc = maybe_add_cp_cache_entry(cp_index); // add lazily |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
130 int cpc2 = add_extra_cp_cache_entry(cpc); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
131 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
132 // Replace the trailing four bytes with a CPC index for the dynamic |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
133 // call site. Unlike other CPC entries, there is one per bytecode, |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
134 // not just one per distinct CP entry. In other words, the |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
135 // CPC-to-CP relation is many-to-one for invokedynamic entries. |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
136 // This means we must use a larger index size than u2 to address |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
137 // all these entries. That is the main reason invokedynamic |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
138 // must have a five-byte instruction format. (Of course, other JVM |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
139 // implementations can use the bytes for other purposes.) |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
140 Bytes::put_native_u4(p, cpc2); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
141 // Note: We use native_u4 format exclusively for 4-byte indexes. |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
142 } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
143 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
144 |
0 | 145 // Rewrites a method given the index_map information |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
146 void Rewriter::scan_method(methodOop method) { |
0 | 147 |
148 int nof_jsrs = 0; | |
149 bool has_monitor_bytecodes = false; | |
150 | |
151 { | |
152 // We cannot tolerate a GC in this block, because we've | |
153 // cached the bytecodes in 'code_base'. If the methodOop | |
154 // moves, the bytecodes will also move. | |
155 No_Safepoint_Verifier nsv; | |
156 Bytecodes::Code c; | |
157 | |
158 // Bytecodes and their length | |
159 const address code_base = method->code_base(); | |
160 const int code_length = method->code_size(); | |
161 | |
162 int bc_length; | |
163 for (int bci = 0; bci < code_length; bci += bc_length) { | |
164 address bcp = code_base + bci; | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
165 int prefix_length = 0; |
0 | 166 c = (Bytecodes::Code)(*bcp); |
167 | |
168 // Since we have the code, see if we can get the length | |
169 // directly. Some more complicated bytecodes will report | |
170 // a length of zero, meaning we need to make another method | |
171 // call to calculate the length. | |
172 bc_length = Bytecodes::length_for(c); | |
173 if (bc_length == 0) { | |
174 bc_length = Bytecodes::length_at(bcp); | |
175 | |
176 // length_at will put us at the bytecode after the one modified | |
177 // by 'wide'. We don't currently examine any of the bytecodes | |
178 // modified by wide, but in case we do in the future... | |
179 if (c == Bytecodes::_wide) { | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
180 prefix_length = 1; |
0 | 181 c = (Bytecodes::Code)bcp[1]; |
182 } | |
183 } | |
184 | |
185 assert(bc_length != 0, "impossible bytecode length"); | |
186 | |
187 switch (c) { | |
188 case Bytecodes::_lookupswitch : { | |
189 #ifndef CC_INTERP | |
190 Bytecode_lookupswitch* bc = Bytecode_lookupswitch_at(bcp); | |
191 bc->set_code( | |
192 bc->number_of_pairs() < BinarySwitchThreshold | |
193 ? Bytecodes::_fast_linearswitch | |
194 : Bytecodes::_fast_binaryswitch | |
195 ); | |
196 #endif | |
197 break; | |
198 } | |
199 case Bytecodes::_getstatic : // fall through | |
200 case Bytecodes::_putstatic : // fall through | |
201 case Bytecodes::_getfield : // fall through | |
202 case Bytecodes::_putfield : // fall through | |
203 case Bytecodes::_invokevirtual : // fall through | |
204 case Bytecodes::_invokespecial : // fall through | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
205 case Bytecodes::_invokestatic : |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
206 case Bytecodes::_invokeinterface: |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
207 rewrite_member_reference(bcp, prefix_length+1); |
0 | 208 break; |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
209 case Bytecodes::_invokedynamic: |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
210 rewrite_invokedynamic(bcp, prefix_length+1, int(sizeof"@@@@DELETE ME")); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
211 break; |
0 | 212 case Bytecodes::_jsr : // fall through |
213 case Bytecodes::_jsr_w : nof_jsrs++; break; | |
214 case Bytecodes::_monitorenter : // fall through | |
215 case Bytecodes::_monitorexit : has_monitor_bytecodes = true; break; | |
216 } | |
217 } | |
218 } | |
219 | |
220 // Update access flags | |
221 if (has_monitor_bytecodes) { | |
222 method->set_has_monitor_bytecodes(); | |
223 } | |
224 | |
225 // The present of a jsr bytecode implies that the method might potentially | |
226 // have to be rewritten, so we run the oopMapGenerator on the method | |
227 if (nof_jsrs > 0) { | |
228 method->set_has_jsrs(); | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
229 // Second pass will revisit this method. |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
230 assert(method->has_jsrs(), ""); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
231 } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
232 } |
0 | 233 |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
234 // After constant pool is created, revisit methods containing jsrs. |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
235 methodHandle Rewriter::rewrite_jsrs(methodHandle method, TRAPS) { |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
236 ResolveOopMapConflicts romc(method); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
237 methodHandle original_method = method; |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
238 method = romc.do_potential_rewrite(CHECK_(methodHandle())); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
239 if (method() != original_method()) { |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
240 // Insert invalid bytecode into original methodOop and set |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
241 // interpreter entrypoint, so that a executing this method |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
242 // will manifest itself in an easy recognizable form. |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
243 address bcp = original_method->bcp_from(0); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
244 *bcp = (u1)Bytecodes::_shouldnotreachhere; |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
245 int kind = Interpreter::method_kind(original_method); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
246 original_method->set_interpreter_kind(kind); |
0 | 247 } |
248 | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
249 // Update monitor matching info. |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
250 if (romc.monitor_safe()) { |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
251 method->set_guaranteed_monitor_matching(); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
252 } |
0 | 253 |
254 return method; | |
255 } | |
256 | |
257 | |
258 void Rewriter::rewrite(instanceKlassHandle klass, TRAPS) { | |
259 ResourceMark rm(THREAD); | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
260 Rewriter rw(klass, CHECK); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
261 // (That's all, folks.) |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
262 } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
263 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
264 Rewriter::Rewriter(instanceKlassHandle klass, TRAPS) |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
265 : _klass(klass), |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
266 // gather starting points |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
267 _pool( THREAD, klass->constants()), |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
268 _methods(THREAD, klass->methods()) |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
269 { |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
270 assert(_pool->cache() == NULL, "constant pool cache must not be set yet"); |
0 | 271 |
272 // determine index maps for methodOop rewriting | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
273 compute_index_maps(); |
0 | 274 |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
275 if (RegisterFinalizersAtInit && _klass->name() == vmSymbols::java_lang_Object()) { |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
276 int i = _methods->length(); |
0 | 277 while (i-- > 0) { |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
278 methodOop method = (methodOop)_methods->obj_at(i); |
0 | 279 if (method->intrinsic_id() == vmIntrinsics::_Object_init) { |
280 // rewrite the return bytecodes of Object.<init> to register the | |
281 // object for finalization if needed. | |
282 methodHandle m(THREAD, method); | |
283 rewrite_Object_init(m, CHECK); | |
284 break; | |
285 } | |
286 } | |
287 } | |
288 | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
289 // rewrite methods, in two passes |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
290 int i, len = _methods->length(); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
291 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
292 for (i = len; --i >= 0; ) { |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
293 methodOop method = (methodOop)_methods->obj_at(i); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
294 scan_method(method); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
295 } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
296 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
297 // allocate constant pool cache, now that we've seen all the bytecodes |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
298 make_constant_pool_cache(CHECK); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
299 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
300 for (i = len; --i >= 0; ) { |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
301 methodHandle m(THREAD, (methodOop)_methods->obj_at(i)); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
302 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
303 if (m->has_jsrs()) { |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
304 m = rewrite_jsrs(m, CHECK); |
0 | 305 // Method might have gotten rewritten. |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
306 _methods->obj_at_put(i, m()); |
0 | 307 } |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
308 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
309 // Set up method entry points for compiler and interpreter. |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
310 m->link_method(m, CHECK); |
0 | 311 } |
312 } |