1 /* |
1 /* |
2 * Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
128 case Bytecodes::_new : // fall through |
128 case Bytecodes::_new : // fall through |
129 case Bytecodes::_anewarray : // fall through |
129 case Bytecodes::_anewarray : // fall through |
130 case Bytecodes::_multianewarray : // fall through |
130 case Bytecodes::_multianewarray : // fall through |
131 case Bytecodes::_checkcast : // fall through |
131 case Bytecodes::_checkcast : // fall through |
132 case Bytecodes::_instanceof : { |
132 case Bytecodes::_instanceof : { |
133 u2 cpi_old = _s_old->get_index_big(); |
133 u2 cpi_old = _s_old->get_index_u2(); |
134 u2 cpi_new = _s_new->get_index_big(); |
134 u2 cpi_new = _s_new->get_index_u2(); |
135 if ((_old_cp->klass_at_noresolve(cpi_old) != _new_cp->klass_at_noresolve(cpi_new))) |
135 if ((_old_cp->klass_at_noresolve(cpi_old) != _new_cp->klass_at_noresolve(cpi_new))) |
136 return false; |
136 return false; |
137 if (c_old == Bytecodes::_multianewarray && |
137 if (c_old == Bytecodes::_multianewarray && |
138 *(jbyte*)(_s_old->bcp() + 3) != *(jbyte*)(_s_new->bcp() + 3)) |
138 *(jbyte*)(_s_old->bcp() + 3) != *(jbyte*)(_s_new->bcp() + 3)) |
139 return false; |
139 return false; |
145 case Bytecodes::_getfield : // fall through |
145 case Bytecodes::_getfield : // fall through |
146 case Bytecodes::_putfield : // fall through |
146 case Bytecodes::_putfield : // fall through |
147 case Bytecodes::_invokevirtual : // fall through |
147 case Bytecodes::_invokevirtual : // fall through |
148 case Bytecodes::_invokespecial : // fall through |
148 case Bytecodes::_invokespecial : // fall through |
149 case Bytecodes::_invokestatic : // fall through |
149 case Bytecodes::_invokestatic : // fall through |
|
150 case Bytecodes::_invokedynamic : // fall through |
150 case Bytecodes::_invokeinterface : { |
151 case Bytecodes::_invokeinterface : { |
151 u2 cpci_old = _s_old->get_index_int(); |
152 int cpci_old = _s_old->has_index_u4() ? _s_old->get_index_u4() : _s_old->get_index_u2_cpcache(); |
152 u2 cpci_new = _s_new->get_index_int(); |
153 int cpci_new = _s_new->has_index_u4() ? _s_new->get_index_u4() : _s_new->get_index_u2_cpcache(); |
153 // Check if the names of classes, field/method names and signatures at these indexes |
154 // 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 // 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 // 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 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->name_ref_at(cpci_old) != _new_cp->name_ref_at(cpci_new)) || |
160 break; |
161 break; |
161 } |
162 } |
162 |
163 |
163 case Bytecodes::_ldc : // fall through |
164 case Bytecodes::_ldc : // fall through |
164 case Bytecodes::_ldc_w : { |
165 case Bytecodes::_ldc_w : { |
165 u2 cpi_old, cpi_new; |
166 Bytecode_loadconstant* ldc_old = Bytecode_loadconstant_at(_s_old->method()(), _s_old->bcp()); |
166 if (c_old == Bytecodes::_ldc) { |
167 Bytecode_loadconstant* ldc_new = Bytecode_loadconstant_at(_s_new->method()(), _s_new->bcp()); |
167 cpi_old = _s_old->bcp()[1]; |
168 int cpi_old = ldc_old->index(); |
168 cpi_new = _s_new->bcp()[1]; |
169 int cpi_new = ldc_new->index(); |
169 } else { |
|
170 cpi_old = _s_old->get_index_big(); |
|
171 cpi_new = _s_new->get_index_big(); |
|
172 } |
|
173 constantTag tag_old = _old_cp->tag_at(cpi_old); |
170 constantTag tag_old = _old_cp->tag_at(cpi_old); |
174 constantTag tag_new = _new_cp->tag_at(cpi_new); |
171 constantTag tag_new = _new_cp->tag_at(cpi_new); |
175 if (tag_old.is_int() || tag_old.is_float()) { |
172 if (tag_old.is_int() || tag_old.is_float()) { |
176 if (tag_old.value() != tag_new.value()) |
173 if (tag_old.value() != tag_new.value()) |
177 return false; |
174 return false; |
178 if (tag_old.is_int()) { |
175 if (tag_old.is_int()) { |
179 if (_old_cp->int_at(cpi_old) != _new_cp->int_at(cpi_new)) |
176 if (_old_cp->int_at(cpi_old) != _new_cp->int_at(cpi_new)) |
180 return false; |
177 return false; |
181 } else { |
178 } else { |
182 if (_old_cp->float_at(cpi_old) != _new_cp->float_at(cpi_new)) |
179 // Use jint_cast to compare the bits rather than numerical values. |
|
180 // This makes a difference for NaN constants. |
|
181 if (jint_cast(_old_cp->float_at(cpi_old)) != jint_cast(_new_cp->float_at(cpi_new))) |
183 return false; |
182 return false; |
184 } |
183 } |
185 } else if (tag_old.is_string() || tag_old.is_unresolved_string()) { |
184 } else if (tag_old.is_string() || tag_old.is_unresolved_string()) { |
186 if (! (tag_new.is_unresolved_string() || tag_new.is_string())) |
185 if (! (tag_new.is_unresolved_string() || tag_new.is_string())) |
187 return false; |
186 return false; |
197 } |
196 } |
198 break; |
197 break; |
199 } |
198 } |
200 |
199 |
201 case Bytecodes::_ldc2_w : { |
200 case Bytecodes::_ldc2_w : { |
202 u2 cpi_old = _s_old->get_index_big(); |
201 u2 cpi_old = _s_old->get_index_u2(); |
203 u2 cpi_new = _s_new->get_index_big(); |
202 u2 cpi_new = _s_new->get_index_u2(); |
204 constantTag tag_old = _old_cp->tag_at(cpi_old); |
203 constantTag tag_old = _old_cp->tag_at(cpi_old); |
205 constantTag tag_new = _new_cp->tag_at(cpi_new); |
204 constantTag tag_new = _new_cp->tag_at(cpi_new); |
206 if (tag_old.value() != tag_new.value()) |
205 if (tag_old.value() != tag_new.value()) |
207 return false; |
206 return false; |
208 if (tag_old.is_long()) { |
207 if (tag_old.is_long()) { |
209 if (_old_cp->long_at(cpi_old) != _new_cp->long_at(cpi_new)) |
208 if (_old_cp->long_at(cpi_old) != _new_cp->long_at(cpi_new)) |
210 return false; |
209 return false; |
211 } else { |
210 } else { |
212 if (_old_cp->double_at(cpi_old) != _new_cp->double_at(cpi_new)) |
211 // Use jlong_cast to compare the bits rather than numerical values. |
|
212 // This makes a difference for NaN constants. |
|
213 if (jlong_cast(_old_cp->double_at(cpi_old)) != jlong_cast(_new_cp->double_at(cpi_new))) |
213 return false; |
214 return false; |
214 } |
215 } |
215 break; |
216 break; |
216 } |
217 } |
217 |
218 |
219 if (_s_old->bcp()[1] != _s_new->bcp()[1]) |
220 if (_s_old->bcp()[1] != _s_new->bcp()[1]) |
220 return false; |
221 return false; |
221 break; |
222 break; |
222 |
223 |
223 case Bytecodes::_sipush : |
224 case Bytecodes::_sipush : |
224 if (_s_old->get_index_big() != _s_new->get_index_big()) |
225 if (_s_old->get_index_u2() != _s_new->get_index_u2()) |
225 return false; |
226 return false; |
226 break; |
227 break; |
227 |
228 |
228 case Bytecodes::_aload : // fall through |
229 case Bytecodes::_aload : // fall through |
229 case Bytecodes::_astore : // fall through |
230 case Bytecodes::_astore : // fall through |
258 case Bytecodes::_ifgt : // fall through |
259 case Bytecodes::_ifgt : // fall through |
259 case Bytecodes::_ifle : // fall through |
260 case Bytecodes::_ifle : // fall through |
260 case Bytecodes::_ifnonnull : // fall through |
261 case Bytecodes::_ifnonnull : // fall through |
261 case Bytecodes::_ifnull : // fall through |
262 case Bytecodes::_ifnull : // fall through |
262 case Bytecodes::_jsr : { |
263 case Bytecodes::_jsr : { |
263 short old_ofs = (short) _s_old->get_index_big(); |
264 int old_ofs = _s_old->bytecode()->get_offset_s2(c_old); |
264 short new_ofs = (short) _s_new->get_index_big(); |
265 int new_ofs = _s_new->bytecode()->get_offset_s2(c_new); |
265 if (_switchable_test) { |
266 if (_switchable_test) { |
266 int old_dest = _s_old->bci() + old_ofs; |
267 int old_dest = _s_old->bci() + old_ofs; |
267 int new_dest = _s_new->bci() + new_ofs; |
268 int new_dest = _s_new->bci() + new_ofs; |
268 if (old_ofs < 0 && new_ofs < 0) { |
269 if (old_ofs < 0 && new_ofs < 0) { |
269 if (! _bci_map->old_and_new_locations_same(old_dest, new_dest)) |
270 if (! _bci_map->old_and_new_locations_same(old_dest, new_dest)) |
283 |
284 |
284 case Bytecodes::_iinc : |
285 case Bytecodes::_iinc : |
285 if (_s_old->is_wide() != _s_new->is_wide()) |
286 if (_s_old->is_wide() != _s_new->is_wide()) |
286 return false; |
287 return false; |
287 if (! _s_old->is_wide()) { |
288 if (! _s_old->is_wide()) { |
288 if (_s_old->get_index_big() != _s_new->get_index_big()) |
289 // We could use get_index_u1 and get_constant_u1, but it's simpler to grab both bytes at once: |
|
290 if (Bytes::get_Java_u2(_s_old->bcp() + 1) != Bytes::get_Java_u2(_s_new->bcp() + 1)) |
289 return false; |
291 return false; |
290 } else { |
292 } else { |
|
293 // We could use get_index_u2 and get_constant_u2, but it's simpler to grab all four bytes at once: |
291 if (Bytes::get_Java_u4(_s_old->bcp() + 1) != Bytes::get_Java_u4(_s_new->bcp() + 1)) |
294 if (Bytes::get_Java_u4(_s_old->bcp() + 1) != Bytes::get_Java_u4(_s_new->bcp() + 1)) |
292 return false; |
295 return false; |
293 } |
296 } |
294 break; |
297 break; |
295 |
298 |
296 case Bytecodes::_goto_w : // fall through |
299 case Bytecodes::_goto_w : // fall through |
297 case Bytecodes::_jsr_w : { |
300 case Bytecodes::_jsr_w : { |
298 int old_ofs = (int) Bytes::get_Java_u4(_s_old->bcp() + 1); |
301 int old_ofs = _s_old->bytecode()->get_offset_s4(c_old); |
299 int new_ofs = (int) Bytes::get_Java_u4(_s_new->bcp() + 1); |
302 int new_ofs = _s_new->bytecode()->get_offset_s4(c_new); |
300 if (_switchable_test) { |
303 if (_switchable_test) { |
301 int old_dest = _s_old->bci() + old_ofs; |
304 int old_dest = _s_old->bci() + old_ofs; |
302 int new_dest = _s_new->bci() + new_ofs; |
305 int new_dest = _s_new->bci() + new_ofs; |
303 if (old_ofs < 0 && new_ofs < 0) { |
306 if (old_ofs < 0 && new_ofs < 0) { |
304 if (! _bci_map->old_and_new_locations_same(old_dest, new_dest)) |
307 if (! _bci_map->old_and_new_locations_same(old_dest, new_dest)) |
355 _fwd_jmps->append(_s_old->bci() + ofs_old); |
358 _fwd_jmps->append(_s_old->bci() + ofs_old); |
356 _fwd_jmps->append(_s_new->bci() + ofs_new); |
359 _fwd_jmps->append(_s_new->bci() + ofs_new); |
357 } |
360 } |
358 } |
361 } |
359 } else { // !_switchable_test, can use fast rough compare |
362 } else { // !_switchable_test, can use fast rough compare |
360 int len_old = _s_old->next_bcp() - _s_old->bcp(); |
363 int len_old = _s_old->instruction_size(); |
361 int len_new = _s_new->next_bcp() - _s_new->bcp(); |
364 int len_new = _s_new->instruction_size(); |
362 if (len_old != len_new) |
365 if (len_old != len_new) |
363 return false; |
366 return false; |
364 if (memcmp(_s_old->bcp(), _s_new->bcp(), len_old) != 0) |
367 if (memcmp(_s_old->bcp(), _s_new->bcp(), len_old) != 0) |
365 return false; |
368 return false; |
366 } |
369 } |