Mercurial > hg > truffle
comparison 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 |
comparison
equal
deleted
inserted
replaced
1912:8213b0f5c92d | 1913:3b2dea75431e |
---|---|
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 | |
151 case Bytecodes::_invokeinterface : { | 150 case Bytecodes::_invokeinterface : { |
152 int cpci_old = _s_old->has_index_u4() ? _s_old->get_index_u4() : _s_old->get_index_u2_cpcache(); | 151 int cpci_old = _s_old->get_index_u2_cpcache(); |
153 int cpci_new = _s_new->has_index_u4() ? _s_new->get_index_u4() : _s_new->get_index_u2_cpcache(); | 152 int cpci_new = _s_new->get_index_u2_cpcache(); |
154 // Check if the names of classes, field/method names and signatures at these indexes | 153 // Check if the names of classes, field/method names and signatures at these indexes |
155 // are the same. Indices which are really into constantpool cache (rather than constant | 154 // are the same. Indices which are really into constantpool cache (rather than constant |
156 // pool itself) are accepted by the constantpool query routines below. | 155 // pool itself) are accepted by the constantpool query routines below. |
157 if ((_old_cp->klass_ref_at_noresolve(cpci_old) != _new_cp->klass_ref_at_noresolve(cpci_new)) || | 156 if ((_old_cp->klass_ref_at_noresolve(cpci_old) != _new_cp->klass_ref_at_noresolve(cpci_new)) || |
158 (_old_cp->name_ref_at(cpci_old) != _new_cp->name_ref_at(cpci_new)) || | 157 (_old_cp->name_ref_at(cpci_old) != _new_cp->name_ref_at(cpci_new)) || |
159 (_old_cp->signature_ref_at(cpci_old) != _new_cp->signature_ref_at(cpci_new))) | 158 (_old_cp->signature_ref_at(cpci_old) != _new_cp->signature_ref_at(cpci_new))) |
160 return false; | 159 return false; |
161 break; | 160 break; |
162 } | 161 } |
162 case Bytecodes::_invokedynamic: { | |
163 int cpci_old = _s_old->get_index_u4(); | |
164 int cpci_new = _s_new->get_index_u4(); | |
165 // Check if the names of classes, field/method names and signatures at these indexes | |
166 // are the same. Indices which are really into constantpool cache (rather than constant | |
167 // pool itself) are accepted by the constantpool query routines below. | |
168 if ((_old_cp->name_ref_at(cpci_old) != _new_cp->name_ref_at(cpci_new)) || | |
169 (_old_cp->signature_ref_at(cpci_old) != _new_cp->signature_ref_at(cpci_new))) | |
170 return false; | |
171 int cpi_old = _old_cp->cache()->main_entry_at(cpci_old)->constant_pool_index(); | |
172 int cpi_new = _new_cp->cache()->main_entry_at(cpci_new)->constant_pool_index(); | |
173 int bsm_old = _old_cp->invoke_dynamic_bootstrap_method_ref_index_at(cpi_old); | |
174 int bsm_new = _new_cp->invoke_dynamic_bootstrap_method_ref_index_at(cpi_new); | |
175 if (!pool_constants_same(bsm_old, bsm_new)) | |
176 return false; | |
177 int cnt_old = _old_cp->invoke_dynamic_argument_count_at(cpi_old); | |
178 int cnt_new = _new_cp->invoke_dynamic_argument_count_at(cpi_new); | |
179 if (cnt_old != cnt_new) | |
180 return false; | |
181 for (int arg_i = 0; arg_i < cnt_old; arg_i++) { | |
182 int idx_old = _old_cp->invoke_dynamic_argument_index_at(cpi_old, arg_i); | |
183 int idx_new = _new_cp->invoke_dynamic_argument_index_at(cpi_new, arg_i); | |
184 if (!pool_constants_same(idx_old, idx_new)) | |
185 return false; | |
186 } | |
187 break; | |
188 } | |
163 | 189 |
164 case Bytecodes::_ldc : // fall through | 190 case Bytecodes::_ldc : // fall through |
165 case Bytecodes::_ldc_w : { | 191 case Bytecodes::_ldc_w : { |
166 Bytecode_loadconstant* ldc_old = Bytecode_loadconstant_at(_s_old->method(), _s_old->bci()); | 192 Bytecode_loadconstant* ldc_old = Bytecode_loadconstant_at(_s_old->method(), _s_old->bci()); |
167 Bytecode_loadconstant* ldc_new = Bytecode_loadconstant_at(_s_new->method(), _s_new->bci()); | 193 Bytecode_loadconstant* ldc_new = Bytecode_loadconstant_at(_s_new->method(), _s_new->bci()); |
168 int cpi_old = ldc_old->pool_index(); | 194 int cpi_old = ldc_old->pool_index(); |
169 int cpi_new = ldc_new->pool_index(); | 195 int cpi_new = ldc_new->pool_index(); |
170 constantTag tag_old = _old_cp->tag_at(cpi_old); | 196 if (!pool_constants_same(cpi_old, cpi_new)) |
171 constantTag tag_new = _new_cp->tag_at(cpi_new); | 197 return false; |
172 if (tag_old.is_int() || tag_old.is_float()) { | |
173 if (tag_old.value() != tag_new.value()) | |
174 return false; | |
175 if (tag_old.is_int()) { | |
176 if (_old_cp->int_at(cpi_old) != _new_cp->int_at(cpi_new)) | |
177 return false; | |
178 } else { | |
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))) | |
182 return false; | |
183 } | |
184 } else if (tag_old.is_string() || tag_old.is_unresolved_string()) { | |
185 if (! (tag_new.is_unresolved_string() || tag_new.is_string())) | |
186 return false; | |
187 if (strcmp(_old_cp->string_at_noresolve(cpi_old), | |
188 _new_cp->string_at_noresolve(cpi_new)) != 0) | |
189 return false; | |
190 } else if (tag_old.is_klass() || tag_old.is_unresolved_klass()) { | |
191 // tag_old should be klass - 4881222 | |
192 if (! (tag_new.is_unresolved_klass() || tag_new.is_klass())) | |
193 return false; | |
194 if (_old_cp->klass_at_noresolve(cpi_old) != | |
195 _new_cp->klass_at_noresolve(cpi_new)) | |
196 return false; | |
197 } else if (tag_old.is_method_type() && tag_new.is_method_type()) { | |
198 int mti_old = _old_cp->method_type_index_at(cpi_old); | |
199 int mti_new = _new_cp->method_type_index_at(cpi_new); | |
200 if ((_old_cp->symbol_at(mti_old) != _new_cp->symbol_at(mti_new))) | |
201 return false; | |
202 } else if (tag_old.is_method_handle() && tag_new.is_method_handle()) { | |
203 if (_old_cp->method_handle_ref_kind_at(cpi_old) != | |
204 _new_cp->method_handle_ref_kind_at(cpi_new)) | |
205 return false; | |
206 int mhi_old = _old_cp->method_handle_index_at(cpi_old); | |
207 int mhi_new = _new_cp->method_handle_index_at(cpi_new); | |
208 if ((_old_cp->uncached_klass_ref_at_noresolve(mhi_old) != _new_cp->uncached_klass_ref_at_noresolve(mhi_new)) || | |
209 (_old_cp->uncached_name_ref_at(mhi_old) != _new_cp->uncached_name_ref_at(mhi_new)) || | |
210 (_old_cp->uncached_signature_ref_at(mhi_old) != _new_cp->uncached_signature_ref_at(mhi_new))) | |
211 return false; | |
212 } else { | |
213 return false; // unknown tag | |
214 } | |
215 break; | 198 break; |
216 } | 199 } |
217 | 200 |
218 case Bytecodes::_ldc2_w : { | 201 case Bytecodes::_ldc2_w : { |
219 u2 cpi_old = _s_old->get_index_u2(); | 202 u2 cpi_old = _s_old->get_index_u2(); |
390 } | 373 } |
391 | 374 |
392 return true; | 375 return true; |
393 } | 376 } |
394 | 377 |
378 bool MethodComparator::pool_constants_same(int cpi_old, int cpi_new) { | |
379 constantTag tag_old = _old_cp->tag_at(cpi_old); | |
380 constantTag tag_new = _new_cp->tag_at(cpi_new); | |
381 if (tag_old.is_int() || tag_old.is_float()) { | |
382 if (tag_old.value() != tag_new.value()) | |
383 return false; | |
384 if (tag_old.is_int()) { | |
385 if (_old_cp->int_at(cpi_old) != _new_cp->int_at(cpi_new)) | |
386 return false; | |
387 } else { | |
388 // Use jint_cast to compare the bits rather than numerical values. | |
389 // This makes a difference for NaN constants. | |
390 if (jint_cast(_old_cp->float_at(cpi_old)) != jint_cast(_new_cp->float_at(cpi_new))) | |
391 return false; | |
392 } | |
393 } else if (tag_old.is_string() || tag_old.is_unresolved_string()) { | |
394 if (! (tag_new.is_unresolved_string() || tag_new.is_string())) | |
395 return false; | |
396 if (strcmp(_old_cp->string_at_noresolve(cpi_old), | |
397 _new_cp->string_at_noresolve(cpi_new)) != 0) | |
398 return false; | |
399 } else if (tag_old.is_klass() || tag_old.is_unresolved_klass()) { | |
400 // tag_old should be klass - 4881222 | |
401 if (! (tag_new.is_unresolved_klass() || tag_new.is_klass())) | |
402 return false; | |
403 if (_old_cp->klass_at_noresolve(cpi_old) != | |
404 _new_cp->klass_at_noresolve(cpi_new)) | |
405 return false; | |
406 } else if (tag_old.is_method_type() && tag_new.is_method_type()) { | |
407 int mti_old = _old_cp->method_type_index_at(cpi_old); | |
408 int mti_new = _new_cp->method_type_index_at(cpi_new); | |
409 if ((_old_cp->symbol_at(mti_old) != _new_cp->symbol_at(mti_new))) | |
410 return false; | |
411 } else if (tag_old.is_method_handle() && tag_new.is_method_handle()) { | |
412 if (_old_cp->method_handle_ref_kind_at(cpi_old) != | |
413 _new_cp->method_handle_ref_kind_at(cpi_new)) | |
414 return false; | |
415 int mhi_old = _old_cp->method_handle_index_at(cpi_old); | |
416 int mhi_new = _new_cp->method_handle_index_at(cpi_new); | |
417 if ((_old_cp->uncached_klass_ref_at_noresolve(mhi_old) != _new_cp->uncached_klass_ref_at_noresolve(mhi_new)) || | |
418 (_old_cp->uncached_name_ref_at(mhi_old) != _new_cp->uncached_name_ref_at(mhi_new)) || | |
419 (_old_cp->uncached_signature_ref_at(mhi_old) != _new_cp->uncached_signature_ref_at(mhi_new))) | |
420 return false; | |
421 } else { | |
422 return false; // unknown tag | |
423 } | |
424 return true; | |
425 } | |
426 | |
395 | 427 |
396 int MethodComparator::check_stack_and_locals_size(methodOop old_method, methodOop new_method) { | 428 int MethodComparator::check_stack_and_locals_size(methodOop old_method, methodOop new_method) { |
397 if (old_method->max_stack() != new_method->max_stack()) { | 429 if (old_method->max_stack() != new_method->max_stack()) { |
398 return 1; | 430 return 1; |
399 } else if (old_method->max_locals() != new_method->max_locals()) { | 431 } else if (old_method->max_locals() != new_method->max_locals()) { |