Mercurial > hg > truffle
annotate src/share/vm/prims/methodComparator.cpp @ 1913:3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
Summary: Allow CONSTANT_InvokeDynamic nodes to have any number of extra operands.
Reviewed-by: twisti
author | jrose |
---|---|
date | Sat, 30 Oct 2010 13:08:23 -0700 |
parents | 136b78722a08 |
children | f95d63e2154a |
rev | line source |
---|---|
0 | 1 /* |
1579 | 2 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
844
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
844
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:
844
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 # include "incls/_precompiled.incl" | |
26 # include "incls/_methodComparator.cpp.incl" | |
27 | |
28 BytecodeStream *MethodComparator::_s_old; | |
29 BytecodeStream *MethodComparator::_s_new; | |
30 constantPoolOop MethodComparator::_old_cp; | |
31 constantPoolOop MethodComparator::_new_cp; | |
32 BciMap *MethodComparator::_bci_map; | |
33 bool MethodComparator::_switchable_test; | |
34 GrowableArray<int> *MethodComparator::_fwd_jmps; | |
35 | |
36 bool MethodComparator::methods_EMCP(methodOop old_method, methodOop new_method) { | |
37 if (old_method->code_size() != new_method->code_size()) | |
38 return false; | |
39 if (check_stack_and_locals_size(old_method, new_method) != 0) { | |
40 // RC_TRACE macro has an embedded ResourceMark | |
41 RC_TRACE(0x00800000, ("Methods %s non-comparable with diagnosis %d", | |
42 old_method->name()->as_C_string(), | |
43 check_stack_and_locals_size(old_method, new_method))); | |
44 return false; | |
45 } | |
46 | |
47 _old_cp = old_method->constants(); | |
48 _new_cp = new_method->constants(); | |
49 BytecodeStream s_old(old_method); | |
50 BytecodeStream s_new(new_method); | |
51 _s_old = &s_old; | |
52 _s_new = &s_new; | |
53 _switchable_test = false; | |
54 Bytecodes::Code c_old, c_new; | |
55 | |
56 while ((c_old = s_old.next()) >= 0) { | |
57 if ((c_new = s_new.next()) < 0 || c_old != c_new) | |
58 return false; | |
59 | |
60 if (! args_same(c_old, c_new)) | |
61 return false; | |
62 } | |
63 return true; | |
64 } | |
65 | |
66 | |
67 bool MethodComparator::methods_switchable(methodOop old_method, methodOop new_method, | |
68 BciMap &bci_map) { | |
69 if (old_method->code_size() > new_method->code_size()) | |
70 // Something has definitely been deleted in the new method, compared to the old one. | |
71 return false; | |
72 | |
73 if (! check_stack_and_locals_size(old_method, new_method)) | |
74 return false; | |
75 | |
76 _old_cp = old_method->constants(); | |
77 _new_cp = new_method->constants(); | |
78 BytecodeStream s_old(old_method); | |
79 BytecodeStream s_new(new_method); | |
80 _s_old = &s_old; | |
81 _s_new = &s_new; | |
82 _bci_map = &bci_map; | |
83 _switchable_test = true; | |
84 GrowableArray<int> fwd_jmps(16); | |
85 _fwd_jmps = &fwd_jmps; | |
86 Bytecodes::Code c_old, c_new; | |
87 | |
88 while ((c_old = s_old.next()) >= 0) { | |
89 if ((c_new = s_new.next()) < 0) | |
90 return false; | |
91 if (! (c_old == c_new && args_same(c_old, c_new))) { | |
92 int old_bci = s_old.bci(); | |
93 int new_st_bci = s_new.bci(); | |
94 bool found_match = false; | |
95 do { | |
96 c_new = s_new.next(); | |
97 if (c_new == c_old && args_same(c_old, c_new)) { | |
98 found_match = true; | |
99 break; | |
100 } | |
101 } while (c_new >= 0); | |
102 if (! found_match) | |
103 return false; | |
104 int new_end_bci = s_new.bci(); | |
105 bci_map.store_fragment_location(old_bci, new_st_bci, new_end_bci); | |
106 } | |
107 } | |
108 | |
109 // Now we can test all forward jumps | |
110 for (int i = 0; i < fwd_jmps.length() / 2; i++) { | |
111 if (! bci_map.old_and_new_locations_same(fwd_jmps.at(i*2), fwd_jmps.at(i*2+1))) { | |
112 RC_TRACE(0x00800000, | |
113 ("Fwd jump miss: old dest = %d, calc new dest = %d, act new dest = %d", | |
114 fwd_jmps.at(i*2), bci_map.new_bci_for_old(fwd_jmps.at(i*2)), | |
115 fwd_jmps.at(i*2+1))); | |
116 return false; | |
117 } | |
118 } | |
119 | |
120 return true; | |
121 } | |
122 | |
123 | |
124 bool MethodComparator::args_same(Bytecodes::Code c_old, Bytecodes::Code c_new) { | |
125 // BytecodeStream returns the correct standard Java bytecodes for various "fast" | |
126 // bytecode versions, so we don't have to bother about them here.. | |
127 switch (c_old) { | |
128 case Bytecodes::_new : // fall through | |
129 case Bytecodes::_anewarray : // fall through | |
130 case Bytecodes::_multianewarray : // fall through | |
131 case Bytecodes::_checkcast : // fall through | |
132 case Bytecodes::_instanceof : { | |
1565 | 133 u2 cpi_old = _s_old->get_index_u2(); |
134 u2 cpi_new = _s_new->get_index_u2(); | |
0 | 135 if ((_old_cp->klass_at_noresolve(cpi_old) != _new_cp->klass_at_noresolve(cpi_new))) |
136 return false; | |
137 if (c_old == Bytecodes::_multianewarray && | |
138 *(jbyte*)(_s_old->bcp() + 3) != *(jbyte*)(_s_new->bcp() + 3)) | |
139 return false; | |
140 break; | |
141 } | |
142 | |
143 case Bytecodes::_getstatic : // fall through | |
144 case Bytecodes::_putstatic : // fall through | |
145 case Bytecodes::_getfield : // fall through | |
146 case Bytecodes::_putfield : // fall through | |
147 case Bytecodes::_invokevirtual : // fall through | |
148 case Bytecodes::_invokespecial : // fall through | |
149 case Bytecodes::_invokestatic : // fall through | |
150 case Bytecodes::_invokeinterface : { | |
1913
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
151 int cpci_old = _s_old->get_index_u2_cpcache(); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
152 int cpci_new = _s_new->get_index_u2_cpcache(); |
0 | 153 // Check if the names of classes, field/method names and signatures at these indexes |
154 // are the same. Indices which are really into constantpool cache (rather than constant | |
155 // pool itself) are accepted by the constantpool query routines below. | |
156 if ((_old_cp->klass_ref_at_noresolve(cpci_old) != _new_cp->klass_ref_at_noresolve(cpci_new)) || | |
157 (_old_cp->name_ref_at(cpci_old) != _new_cp->name_ref_at(cpci_new)) || | |
158 (_old_cp->signature_ref_at(cpci_old) != _new_cp->signature_ref_at(cpci_new))) | |
159 return false; | |
160 break; | |
161 } | |
1913
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
162 case Bytecodes::_invokedynamic: { |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
163 int cpci_old = _s_old->get_index_u4(); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
164 int cpci_new = _s_new->get_index_u4(); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
165 // Check if the names of classes, field/method names and signatures at these indexes |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
166 // are the same. Indices which are really into constantpool cache (rather than constant |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
167 // pool itself) are accepted by the constantpool query routines below. |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
168 if ((_old_cp->name_ref_at(cpci_old) != _new_cp->name_ref_at(cpci_new)) || |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
169 (_old_cp->signature_ref_at(cpci_old) != _new_cp->signature_ref_at(cpci_new))) |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
170 return false; |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
171 int cpi_old = _old_cp->cache()->main_entry_at(cpci_old)->constant_pool_index(); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
172 int cpi_new = _new_cp->cache()->main_entry_at(cpci_new)->constant_pool_index(); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
173 int bsm_old = _old_cp->invoke_dynamic_bootstrap_method_ref_index_at(cpi_old); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
174 int bsm_new = _new_cp->invoke_dynamic_bootstrap_method_ref_index_at(cpi_new); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
175 if (!pool_constants_same(bsm_old, bsm_new)) |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
176 return false; |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
177 int cnt_old = _old_cp->invoke_dynamic_argument_count_at(cpi_old); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
178 int cnt_new = _new_cp->invoke_dynamic_argument_count_at(cpi_new); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
179 if (cnt_old != cnt_new) |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
180 return false; |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
181 for (int arg_i = 0; arg_i < cnt_old; arg_i++) { |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
182 int idx_old = _old_cp->invoke_dynamic_argument_index_at(cpi_old, arg_i); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
183 int idx_new = _new_cp->invoke_dynamic_argument_index_at(cpi_new, arg_i); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
184 if (!pool_constants_same(idx_old, idx_new)) |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
185 return false; |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
186 } |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
187 break; |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
188 } |
0 | 189 |
190 case Bytecodes::_ldc : // fall through | |
191 case Bytecodes::_ldc_w : { | |
1602 | 192 Bytecode_loadconstant* ldc_old = Bytecode_loadconstant_at(_s_old->method(), _s_old->bci()); |
193 Bytecode_loadconstant* ldc_new = Bytecode_loadconstant_at(_s_new->method(), _s_new->bci()); | |
194 int cpi_old = ldc_old->pool_index(); | |
195 int cpi_new = ldc_new->pool_index(); | |
1913
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
196 if (!pool_constants_same(cpi_old, cpi_new)) |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
197 return false; |
0 | 198 break; |
199 } | |
200 | |
201 case Bytecodes::_ldc2_w : { | |
1565 | 202 u2 cpi_old = _s_old->get_index_u2(); |
203 u2 cpi_new = _s_new->get_index_u2(); | |
0 | 204 constantTag tag_old = _old_cp->tag_at(cpi_old); |
205 constantTag tag_new = _new_cp->tag_at(cpi_new); | |
206 if (tag_old.value() != tag_new.value()) | |
207 return false; | |
208 if (tag_old.is_long()) { | |
209 if (_old_cp->long_at(cpi_old) != _new_cp->long_at(cpi_new)) | |
210 return false; | |
211 } else { | |
1574 | 212 // Use jlong_cast to compare the bits rather than numerical values. |
213 // This makes a difference for NaN constants. | |
214 if (jlong_cast(_old_cp->double_at(cpi_old)) != jlong_cast(_new_cp->double_at(cpi_new))) | |
0 | 215 return false; |
216 } | |
217 break; | |
218 } | |
219 | |
220 case Bytecodes::_bipush : | |
221 if (_s_old->bcp()[1] != _s_new->bcp()[1]) | |
222 return false; | |
223 break; | |
224 | |
225 case Bytecodes::_sipush : | |
1565 | 226 if (_s_old->get_index_u2() != _s_new->get_index_u2()) |
0 | 227 return false; |
228 break; | |
229 | |
230 case Bytecodes::_aload : // fall through | |
231 case Bytecodes::_astore : // fall through | |
232 case Bytecodes::_dload : // fall through | |
233 case Bytecodes::_dstore : // fall through | |
234 case Bytecodes::_fload : // fall through | |
235 case Bytecodes::_fstore : // fall through | |
236 case Bytecodes::_iload : // fall through | |
237 case Bytecodes::_istore : // fall through | |
238 case Bytecodes::_lload : // fall through | |
239 case Bytecodes::_lstore : // fall through | |
240 case Bytecodes::_ret : | |
241 if (_s_old->is_wide() != _s_new->is_wide()) | |
242 return false; | |
243 if (_s_old->get_index() != _s_new->get_index()) | |
244 return false; | |
245 break; | |
246 | |
247 case Bytecodes::_goto : // fall through | |
248 case Bytecodes::_if_acmpeq : // fall through | |
249 case Bytecodes::_if_acmpne : // fall through | |
250 case Bytecodes::_if_icmpeq : // fall through | |
251 case Bytecodes::_if_icmpne : // fall through | |
252 case Bytecodes::_if_icmplt : // fall through | |
253 case Bytecodes::_if_icmpge : // fall through | |
254 case Bytecodes::_if_icmpgt : // fall through | |
255 case Bytecodes::_if_icmple : // fall through | |
256 case Bytecodes::_ifeq : // fall through | |
257 case Bytecodes::_ifne : // fall through | |
258 case Bytecodes::_iflt : // fall through | |
259 case Bytecodes::_ifge : // fall through | |
260 case Bytecodes::_ifgt : // fall through | |
261 case Bytecodes::_ifle : // fall through | |
262 case Bytecodes::_ifnonnull : // fall through | |
263 case Bytecodes::_ifnull : // fall through | |
264 case Bytecodes::_jsr : { | |
1574 | 265 int old_ofs = _s_old->bytecode()->get_offset_s2(c_old); |
266 int new_ofs = _s_new->bytecode()->get_offset_s2(c_new); | |
0 | 267 if (_switchable_test) { |
268 int old_dest = _s_old->bci() + old_ofs; | |
269 int new_dest = _s_new->bci() + new_ofs; | |
270 if (old_ofs < 0 && new_ofs < 0) { | |
271 if (! _bci_map->old_and_new_locations_same(old_dest, new_dest)) | |
272 return false; | |
273 } else if (old_ofs > 0 && new_ofs > 0) { | |
274 _fwd_jmps->append(old_dest); | |
275 _fwd_jmps->append(new_dest); | |
276 } else { | |
277 return false; | |
278 } | |
279 } else { | |
280 if (old_ofs != new_ofs) | |
281 return false; | |
282 } | |
283 break; | |
284 } | |
285 | |
286 case Bytecodes::_iinc : | |
287 if (_s_old->is_wide() != _s_new->is_wide()) | |
288 return false; | |
289 if (! _s_old->is_wide()) { | |
1565 | 290 // We could use get_index_u1 and get_constant_u1, but it's simpler to grab both bytes at once: |
291 if (Bytes::get_Java_u2(_s_old->bcp() + 1) != Bytes::get_Java_u2(_s_new->bcp() + 1)) | |
0 | 292 return false; |
293 } else { | |
1565 | 294 // We could use get_index_u2 and get_constant_u2, but it's simpler to grab all four bytes at once: |
0 | 295 if (Bytes::get_Java_u4(_s_old->bcp() + 1) != Bytes::get_Java_u4(_s_new->bcp() + 1)) |
296 return false; | |
297 } | |
298 break; | |
299 | |
300 case Bytecodes::_goto_w : // fall through | |
301 case Bytecodes::_jsr_w : { | |
1574 | 302 int old_ofs = _s_old->bytecode()->get_offset_s4(c_old); |
303 int new_ofs = _s_new->bytecode()->get_offset_s4(c_new); | |
0 | 304 if (_switchable_test) { |
305 int old_dest = _s_old->bci() + old_ofs; | |
306 int new_dest = _s_new->bci() + new_ofs; | |
307 if (old_ofs < 0 && new_ofs < 0) { | |
308 if (! _bci_map->old_and_new_locations_same(old_dest, new_dest)) | |
309 return false; | |
310 } else if (old_ofs > 0 && new_ofs > 0) { | |
311 _fwd_jmps->append(old_dest); | |
312 _fwd_jmps->append(new_dest); | |
313 } else { | |
314 return false; | |
315 } | |
316 } else { | |
317 if (old_ofs != new_ofs) | |
318 return false; | |
319 } | |
320 break; | |
321 } | |
322 | |
323 case Bytecodes::_lookupswitch : // fall through | |
324 case Bytecodes::_tableswitch : { | |
325 if (_switchable_test) { | |
326 address aligned_bcp_old = (address) round_to((intptr_t)_s_old->bcp() + 1, jintSize); | |
327 address aligned_bcp_new = (address) round_to((intptr_t)_s_new->bcp() + 1, jintSize); | |
328 int default_old = (int) Bytes::get_Java_u4(aligned_bcp_old); | |
329 int default_new = (int) Bytes::get_Java_u4(aligned_bcp_new); | |
330 _fwd_jmps->append(_s_old->bci() + default_old); | |
331 _fwd_jmps->append(_s_new->bci() + default_new); | |
332 if (c_old == Bytecodes::_lookupswitch) { | |
333 int npairs_old = (int) Bytes::get_Java_u4(aligned_bcp_old + jintSize); | |
334 int npairs_new = (int) Bytes::get_Java_u4(aligned_bcp_new + jintSize); | |
335 if (npairs_old != npairs_new) | |
336 return false; | |
337 for (int i = 0; i < npairs_old; i++) { | |
338 int match_old = (int) Bytes::get_Java_u4(aligned_bcp_old + (2+2*i)*jintSize); | |
339 int match_new = (int) Bytes::get_Java_u4(aligned_bcp_new + (2+2*i)*jintSize); | |
340 if (match_old != match_new) | |
341 return false; | |
342 int ofs_old = (int) Bytes::get_Java_u4(aligned_bcp_old + (2+2*i+1)*jintSize); | |
343 int ofs_new = (int) Bytes::get_Java_u4(aligned_bcp_new + (2+2*i+1)*jintSize); | |
344 _fwd_jmps->append(_s_old->bci() + ofs_old); | |
345 _fwd_jmps->append(_s_new->bci() + ofs_new); | |
346 } | |
347 } else if (c_old == Bytecodes::_tableswitch) { | |
348 int lo_old = (int) Bytes::get_Java_u4(aligned_bcp_old + jintSize); | |
349 int lo_new = (int) Bytes::get_Java_u4(aligned_bcp_new + jintSize); | |
350 if (lo_old != lo_new) | |
351 return false; | |
352 int hi_old = (int) Bytes::get_Java_u4(aligned_bcp_old + 2*jintSize); | |
353 int hi_new = (int) Bytes::get_Java_u4(aligned_bcp_new + 2*jintSize); | |
354 if (hi_old != hi_new) | |
355 return false; | |
356 for (int i = 0; i < hi_old - lo_old + 1; i++) { | |
357 int ofs_old = (int) Bytes::get_Java_u4(aligned_bcp_old + (3+i)*jintSize); | |
358 int ofs_new = (int) Bytes::get_Java_u4(aligned_bcp_new + (3+i)*jintSize); | |
359 _fwd_jmps->append(_s_old->bci() + ofs_old); | |
360 _fwd_jmps->append(_s_new->bci() + ofs_new); | |
361 } | |
362 } | |
363 } else { // !_switchable_test, can use fast rough compare | |
1565 | 364 int len_old = _s_old->instruction_size(); |
365 int len_new = _s_new->instruction_size(); | |
0 | 366 if (len_old != len_new) |
367 return false; | |
368 if (memcmp(_s_old->bcp(), _s_new->bcp(), len_old) != 0) | |
369 return false; | |
370 } | |
371 break; | |
372 } | |
373 } | |
374 | |
375 return true; | |
376 } | |
377 | |
1913
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
378 bool MethodComparator::pool_constants_same(int cpi_old, int cpi_new) { |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
379 constantTag tag_old = _old_cp->tag_at(cpi_old); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
380 constantTag tag_new = _new_cp->tag_at(cpi_new); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
381 if (tag_old.is_int() || tag_old.is_float()) { |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
382 if (tag_old.value() != tag_new.value()) |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
383 return false; |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
384 if (tag_old.is_int()) { |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
385 if (_old_cp->int_at(cpi_old) != _new_cp->int_at(cpi_new)) |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
386 return false; |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
387 } else { |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
388 // Use jint_cast to compare the bits rather than numerical values. |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
389 // This makes a difference for NaN constants. |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
390 if (jint_cast(_old_cp->float_at(cpi_old)) != jint_cast(_new_cp->float_at(cpi_new))) |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
391 return false; |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
392 } |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
393 } else if (tag_old.is_string() || tag_old.is_unresolved_string()) { |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
394 if (! (tag_new.is_unresolved_string() || tag_new.is_string())) |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
395 return false; |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
396 if (strcmp(_old_cp->string_at_noresolve(cpi_old), |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
397 _new_cp->string_at_noresolve(cpi_new)) != 0) |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
398 return false; |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
399 } else if (tag_old.is_klass() || tag_old.is_unresolved_klass()) { |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
400 // tag_old should be klass - 4881222 |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
401 if (! (tag_new.is_unresolved_klass() || tag_new.is_klass())) |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
402 return false; |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
403 if (_old_cp->klass_at_noresolve(cpi_old) != |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
404 _new_cp->klass_at_noresolve(cpi_new)) |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
405 return false; |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
406 } else if (tag_old.is_method_type() && tag_new.is_method_type()) { |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
407 int mti_old = _old_cp->method_type_index_at(cpi_old); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
408 int mti_new = _new_cp->method_type_index_at(cpi_new); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
409 if ((_old_cp->symbol_at(mti_old) != _new_cp->symbol_at(mti_new))) |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
410 return false; |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
411 } else if (tag_old.is_method_handle() && tag_new.is_method_handle()) { |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
412 if (_old_cp->method_handle_ref_kind_at(cpi_old) != |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
413 _new_cp->method_handle_ref_kind_at(cpi_new)) |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
414 return false; |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
415 int mhi_old = _old_cp->method_handle_index_at(cpi_old); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
416 int mhi_new = _new_cp->method_handle_index_at(cpi_new); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
417 if ((_old_cp->uncached_klass_ref_at_noresolve(mhi_old) != _new_cp->uncached_klass_ref_at_noresolve(mhi_new)) || |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
418 (_old_cp->uncached_name_ref_at(mhi_old) != _new_cp->uncached_name_ref_at(mhi_new)) || |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
419 (_old_cp->uncached_signature_ref_at(mhi_old) != _new_cp->uncached_signature_ref_at(mhi_new))) |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
420 return false; |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
421 } else { |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
422 return false; // unknown tag |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
423 } |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
424 return true; |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
425 } |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1602
diff
changeset
|
426 |
0 | 427 |
428 int MethodComparator::check_stack_and_locals_size(methodOop old_method, methodOop new_method) { | |
429 if (old_method->max_stack() != new_method->max_stack()) { | |
430 return 1; | |
431 } else if (old_method->max_locals() != new_method->max_locals()) { | |
432 return 2; | |
433 } else if (old_method->size_of_parameters() != new_method->size_of_parameters()) { | |
434 return 3; | |
435 } else return 0; | |
436 } |