120 fwd_jmps.at(i*2+1))); 121 return false; 122 } 123 } 124 125 return true; 126 } 127 128 129 bool MethodComparator::args_same(Bytecodes::Code c_old, Bytecodes::Code c_new) { 130 // BytecodeStream returns the correct standard Java bytecodes for various "fast" 131 // bytecode versions, so we don't have to bother about them here.. 132 switch (c_old) { 133 case Bytecodes::_new : // fall through 134 case Bytecodes::_anewarray : // fall through 135 case Bytecodes::_multianewarray : // fall through 136 case Bytecodes::_checkcast : // fall through 137 case Bytecodes::_instanceof : { 138 u2 cpi_old = _s_old->get_index_u2(); 139 u2 cpi_new = _s_new->get_index_u2(); 140 if ((_old_cp->klass_at_noresolve(cpi_old) != _new_cp->klass_at_noresolve(cpi_new))) 141 return false; 142 if (c_old == Bytecodes::_multianewarray && 143 *(jbyte*)(_s_old->bcp() + 3) != *(jbyte*)(_s_new->bcp() + 3)) 144 return false; 145 break; 146 } 147 148 case Bytecodes::_getstatic : // fall through 149 case Bytecodes::_putstatic : // fall through 150 case Bytecodes::_getfield : // fall through 151 case Bytecodes::_putfield : // fall through 152 case Bytecodes::_invokevirtual : // fall through 153 case Bytecodes::_invokespecial : // fall through 154 case Bytecodes::_invokestatic : // fall through 155 case Bytecodes::_invokeinterface : { 156 int cpci_old = _s_old->get_index_u2_cpcache(); 157 int cpci_new = _s_new->get_index_u2_cpcache(); 158 // Check if the names of classes, field/method names and signatures at these indexes 159 // are the same. Indices which are really into constantpool cache (rather than constant 160 // pool itself) are accepted by the constantpool query routines below. 161 if ((_old_cp->klass_ref_at_noresolve(cpci_old) != _new_cp->klass_ref_at_noresolve(cpci_new)) || 162 (_old_cp->name_ref_at(cpci_old) != _new_cp->name_ref_at(cpci_new)) || 163 (_old_cp->signature_ref_at(cpci_old) != _new_cp->signature_ref_at(cpci_new))) 164 return false; 165 break; 166 } 167 case Bytecodes::_invokedynamic: { 168 int cpci_old = _s_old->get_index_u4(); 169 int cpci_new = _s_new->get_index_u4(); 170 171 // Check if the names of classes, field/method names and signatures at these indexes 172 // are the same. Indices which are really into constantpool cache (rather than constant 173 // pool itself) are accepted by the constantpool query routines below. 174 if ((_old_cp->name_ref_at(cpci_old) != _new_cp->name_ref_at(cpci_new)) || 175 (_old_cp->signature_ref_at(cpci_old) != _new_cp->signature_ref_at(cpci_new))) 176 return false; 177 178 // Translate object indexes to constant pool cache indexes. 179 cpci_old = _old_cp->invokedynamic_cp_cache_index(cpci_old); 180 cpci_new = _new_cp->invokedynamic_cp_cache_index(cpci_new); 181 182 int cpi_old = _old_cp->cache()->entry_at(cpci_old)->constant_pool_index(); 183 int cpi_new = _new_cp->cache()->entry_at(cpci_new)->constant_pool_index(); 184 int bsm_old = _old_cp->invoke_dynamic_bootstrap_method_ref_index_at(cpi_old); 185 int bsm_new = _new_cp->invoke_dynamic_bootstrap_method_ref_index_at(cpi_new); 186 if (!pool_constants_same(bsm_old, bsm_new)) 187 return false; 188 int cnt_old = _old_cp->invoke_dynamic_argument_count_at(cpi_old); 189 int cnt_new = _new_cp->invoke_dynamic_argument_count_at(cpi_new); 190 if (cnt_old != cnt_new) 191 return false; 192 for (int arg_i = 0; arg_i < cnt_old; arg_i++) { 193 int idx_old = _old_cp->invoke_dynamic_argument_index_at(cpi_old, arg_i); 194 int idx_new = _new_cp->invoke_dynamic_argument_index_at(cpi_new, arg_i); 195 if (!pool_constants_same(idx_old, idx_new)) 394 return false; 395 if (tag_old.is_int()) { 396 if (_old_cp->int_at(cpi_old) != _new_cp->int_at(cpi_new)) 397 return false; 398 } else { 399 // Use jint_cast to compare the bits rather than numerical values. 400 // This makes a difference for NaN constants. 401 if (jint_cast(_old_cp->float_at(cpi_old)) != jint_cast(_new_cp->float_at(cpi_new))) 402 return false; 403 } 404 } else if (tag_old.is_string() && tag_new.is_string()) { 405 if (strcmp(_old_cp->string_at_noresolve(cpi_old), 406 _new_cp->string_at_noresolve(cpi_new)) != 0) 407 return false; 408 if (_old_cp->is_pseudo_string_at(cpi_old) || _new_cp->is_pseudo_string_at(cpi_new)) 409 return (_old_cp->is_pseudo_string_at(cpi_old) == _new_cp->is_pseudo_string_at(cpi_new)); 410 } else if (tag_old.is_klass() || tag_old.is_unresolved_klass()) { 411 // tag_old should be klass - 4881222 412 if (! (tag_new.is_unresolved_klass() || tag_new.is_klass())) 413 return false; 414 if (_old_cp->klass_at_noresolve(cpi_old) != 415 _new_cp->klass_at_noresolve(cpi_new)) 416 return false; 417 } else if (tag_old.is_method_type() && tag_new.is_method_type()) { 418 int mti_old = _old_cp->method_type_index_at(cpi_old); 419 int mti_new = _new_cp->method_type_index_at(cpi_new); 420 if ((_old_cp->symbol_at(mti_old) != _new_cp->symbol_at(mti_new))) 421 return false; 422 } else if (tag_old.is_method_handle() && tag_new.is_method_handle()) { 423 if (_old_cp->method_handle_ref_kind_at(cpi_old) != 424 _new_cp->method_handle_ref_kind_at(cpi_new)) 425 return false; 426 int mhi_old = _old_cp->method_handle_index_at(cpi_old); 427 int mhi_new = _new_cp->method_handle_index_at(cpi_new); 428 if ((_old_cp->uncached_klass_ref_at_noresolve(mhi_old) != _new_cp->uncached_klass_ref_at_noresolve(mhi_new)) || 429 (_old_cp->uncached_name_ref_at(mhi_old) != _new_cp->uncached_name_ref_at(mhi_new)) || 430 (_old_cp->uncached_signature_ref_at(mhi_old) != _new_cp->uncached_signature_ref_at(mhi_new))) 431 return false; 432 } else { 433 return false; // unknown tag 434 } 435 return true; 436 } 437 438 439 int MethodComparator::check_stack_and_locals_size(Method* old_method, Method* new_method) { 440 if (old_method->max_stack() != new_method->max_stack()) { 441 return 1; 442 } else if (old_method->max_locals() != new_method->max_locals()) { 443 return 2; 444 } else if (old_method->size_of_parameters() != new_method->size_of_parameters()) { 445 return 3; 446 } else return 0; 447 } | 120 fwd_jmps.at(i*2+1))); 121 return false; 122 } 123 } 124 125 return true; 126 } 127 128 129 bool MethodComparator::args_same(Bytecodes::Code c_old, Bytecodes::Code c_new) { 130 // BytecodeStream returns the correct standard Java bytecodes for various "fast" 131 // bytecode versions, so we don't have to bother about them here.. 132 switch (c_old) { 133 case Bytecodes::_new : // fall through 134 case Bytecodes::_anewarray : // fall through 135 case Bytecodes::_multianewarray : // fall through 136 case Bytecodes::_checkcast : // fall through 137 case Bytecodes::_instanceof : { 138 u2 cpi_old = _s_old->get_index_u2(); 139 u2 cpi_new = _s_new->get_index_u2(); 140 if ((_old_cp->klass_at_noresolve(cpi_old)->not_equals(_new_cp->klass_at_noresolve(cpi_new)))) 141 return false; 142 if (c_old == Bytecodes::_multianewarray && 143 *(jbyte*)(_s_old->bcp() + 3) != *(jbyte*)(_s_new->bcp() + 3)) 144 return false; 145 break; 146 } 147 148 case Bytecodes::_getstatic : // fall through 149 case Bytecodes::_putstatic : // fall through 150 case Bytecodes::_getfield : // fall through 151 case Bytecodes::_putfield : // fall through 152 case Bytecodes::_invokevirtual : // fall through 153 case Bytecodes::_invokespecial : // fall through 154 case Bytecodes::_invokestatic : // fall through 155 case Bytecodes::_invokeinterface : { 156 int cpci_old = _s_old->get_index_u2_cpcache(); 157 int cpci_new = _s_new->get_index_u2_cpcache(); 158 // Check if the names of classes, field/method names and signatures at these indexes 159 // are the same. Indices which are really into constantpool cache (rather than constant 160 // pool itself) are accepted by the constantpool query routines below. 161 if ((_old_cp->klass_ref_at_noresolve(cpci_old)->not_equals(_new_cp->klass_ref_at_noresolve(cpci_new))) || 162 (_old_cp->name_ref_at(cpci_old)->not_equals(_new_cp->name_ref_at(cpci_new))) || 163 (_old_cp->signature_ref_at(cpci_old)->not_equals(_new_cp->signature_ref_at(cpci_new)))) 164 return false; 165 break; 166 } 167 case Bytecodes::_invokedynamic: { 168 int cpci_old = _s_old->get_index_u4(); 169 int cpci_new = _s_new->get_index_u4(); 170 171 // Check if the names of classes, field/method names and signatures at these indexes 172 // are the same. Indices which are really into constantpool cache (rather than constant 173 // pool itself) are accepted by the constantpool query routines below. 174 if ((_old_cp->name_ref_at(cpci_old)->not_equals(_new_cp->name_ref_at(cpci_new))) || 175 (_old_cp->signature_ref_at(cpci_old)->not_equals(_new_cp->signature_ref_at(cpci_new)))) 176 return false; 177 178 // Translate object indexes to constant pool cache indexes. 179 cpci_old = _old_cp->invokedynamic_cp_cache_index(cpci_old); 180 cpci_new = _new_cp->invokedynamic_cp_cache_index(cpci_new); 181 182 int cpi_old = _old_cp->cache()->entry_at(cpci_old)->constant_pool_index(); 183 int cpi_new = _new_cp->cache()->entry_at(cpci_new)->constant_pool_index(); 184 int bsm_old = _old_cp->invoke_dynamic_bootstrap_method_ref_index_at(cpi_old); 185 int bsm_new = _new_cp->invoke_dynamic_bootstrap_method_ref_index_at(cpi_new); 186 if (!pool_constants_same(bsm_old, bsm_new)) 187 return false; 188 int cnt_old = _old_cp->invoke_dynamic_argument_count_at(cpi_old); 189 int cnt_new = _new_cp->invoke_dynamic_argument_count_at(cpi_new); 190 if (cnt_old != cnt_new) 191 return false; 192 for (int arg_i = 0; arg_i < cnt_old; arg_i++) { 193 int idx_old = _old_cp->invoke_dynamic_argument_index_at(cpi_old, arg_i); 194 int idx_new = _new_cp->invoke_dynamic_argument_index_at(cpi_new, arg_i); 195 if (!pool_constants_same(idx_old, idx_new)) 394 return false; 395 if (tag_old.is_int()) { 396 if (_old_cp->int_at(cpi_old) != _new_cp->int_at(cpi_new)) 397 return false; 398 } else { 399 // Use jint_cast to compare the bits rather than numerical values. 400 // This makes a difference for NaN constants. 401 if (jint_cast(_old_cp->float_at(cpi_old)) != jint_cast(_new_cp->float_at(cpi_new))) 402 return false; 403 } 404 } else if (tag_old.is_string() && tag_new.is_string()) { 405 if (strcmp(_old_cp->string_at_noresolve(cpi_old), 406 _new_cp->string_at_noresolve(cpi_new)) != 0) 407 return false; 408 if (_old_cp->is_pseudo_string_at(cpi_old) || _new_cp->is_pseudo_string_at(cpi_new)) 409 return (_old_cp->is_pseudo_string_at(cpi_old) == _new_cp->is_pseudo_string_at(cpi_new)); 410 } else if (tag_old.is_klass() || tag_old.is_unresolved_klass()) { 411 // tag_old should be klass - 4881222 412 if (! (tag_new.is_unresolved_klass() || tag_new.is_klass())) 413 return false; 414 if (_old_cp->klass_at_noresolve(cpi_old)->not_equals( 415 _new_cp->klass_at_noresolve(cpi_new))) 416 return false; 417 } else if (tag_old.is_method_type() && tag_new.is_method_type()) { 418 int mti_old = _old_cp->method_type_index_at(cpi_old); 419 int mti_new = _new_cp->method_type_index_at(cpi_new); 420 if ((_old_cp->symbol_at(mti_old)->not_equals(_new_cp->symbol_at(mti_new)))) 421 return false; 422 } else if (tag_old.is_method_handle() && tag_new.is_method_handle()) { 423 if (_old_cp->method_handle_ref_kind_at(cpi_old) != 424 _new_cp->method_handle_ref_kind_at(cpi_new)) 425 return false; 426 int mhi_old = _old_cp->method_handle_index_at(cpi_old); 427 int mhi_new = _new_cp->method_handle_index_at(cpi_new); 428 if ((_old_cp->uncached_klass_ref_at_noresolve(mhi_old)->not_equals(_new_cp->uncached_klass_ref_at_noresolve(mhi_new))) || 429 (_old_cp->uncached_name_ref_at(mhi_old)->not_equals(_new_cp->uncached_name_ref_at(mhi_new))) || 430 (_old_cp->uncached_signature_ref_at(mhi_old)->not_equals(_new_cp->uncached_signature_ref_at(mhi_new)))) 431 return false; 432 } else { 433 return false; // unknown tag 434 } 435 return true; 436 } 437 438 439 int MethodComparator::check_stack_and_locals_size(Method* old_method, Method* new_method) { 440 if (old_method->max_stack() != new_method->max_stack()) { 441 return 1; 442 } else if (old_method->max_locals() != new_method->max_locals()) { 443 return 2; 444 } else if (old_method->size_of_parameters() != new_method->size_of_parameters()) { 445 return 3; 446 } else return 0; 447 } |