123 Bytecodes::Code opcode = bcs.raw_next(); 124 switch (opcode) { 125 case Bytecodes::_return: *bcs.bcp() = Bytecodes::_return_register_finalizer; break; 126 127 case Bytecodes::_istore: 128 case Bytecodes::_lstore: 129 case Bytecodes::_fstore: 130 case Bytecodes::_dstore: 131 case Bytecodes::_astore: 132 if (bcs.get_index() != 0) continue; 133 134 // fall through 135 case Bytecodes::_istore_0: 136 case Bytecodes::_lstore_0: 137 case Bytecodes::_fstore_0: 138 case Bytecodes::_dstore_0: 139 case Bytecodes::_astore_0: 140 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), 141 "can't overwrite local 0 in Object.<init>"); 142 break; 143 } 144 } 145 } 146 147 148 // Rewrite a classfile-order CP index into a native-order CPC index. 149 void Rewriter::rewrite_member_reference(address bcp, int offset, bool reverse) { 150 address p = bcp + offset; 151 if (!reverse) { 152 int cp_index = Bytes::get_Java_u2(p); 153 int cache_index = cp_entry_to_cp_cache(cp_index); 154 Bytes::put_native_u2(p, cache_index); 155 if (!_method_handle_invokers.is_empty()) 156 maybe_rewrite_invokehandle(p - 1, cp_index, cache_index, reverse); 157 } else { 158 int cache_index = Bytes::get_native_u2(p); 159 int pool_index = cp_cache_entry_pool_index(cache_index); 160 Bytes::put_Java_u2(p, pool_index); 161 if (!_method_handle_invokers.is_empty()) 162 maybe_rewrite_invokehandle(p - 1, pool_index, cache_index, reverse); 450 case Bytecodes::_invokestatic : 451 case Bytecodes::_invokeinterface: 452 case Bytecodes::_invokehandle : // if reverse=true 453 rewrite_member_reference(bcp, prefix_length+1, reverse); 454 break; 455 case Bytecodes::_invokedynamic: 456 rewrite_invokedynamic(bcp, prefix_length+1, reverse); 457 break; 458 case Bytecodes::_ldc: 459 case Bytecodes::_fast_aldc: // if reverse=true 460 maybe_rewrite_ldc(bcp, prefix_length+1, false, reverse); 461 break; 462 case Bytecodes::_ldc_w: 463 case Bytecodes::_fast_aldc_w: // if reverse=true 464 maybe_rewrite_ldc(bcp, prefix_length+1, true, reverse); 465 break; 466 case Bytecodes::_jsr : // fall through 467 case Bytecodes::_jsr_w : nof_jsrs++; break; 468 case Bytecodes::_monitorenter : // fall through 469 case Bytecodes::_monitorexit : has_monitor_bytecodes = true; break; 470 } 471 } 472 } 473 474 // Update access flags 475 if (has_monitor_bytecodes) { 476 method->set_has_monitor_bytecodes(); 477 } 478 479 // The present of a jsr bytecode implies that the method might potentially 480 // have to be rewritten, so we run the oopMapGenerator on the method 481 if (nof_jsrs > 0) { 482 method->set_has_jsrs(); 483 // Second pass will revisit this method. 484 assert(method->has_jsrs(), "didn't we just set this?"); 485 } 486 } 487 488 // After constant pool is created, revisit methods containing jsrs. 489 methodHandle Rewriter::rewrite_jsrs(methodHandle method, TRAPS) { | 123 Bytecodes::Code opcode = bcs.raw_next(); 124 switch (opcode) { 125 case Bytecodes::_return: *bcs.bcp() = Bytecodes::_return_register_finalizer; break; 126 127 case Bytecodes::_istore: 128 case Bytecodes::_lstore: 129 case Bytecodes::_fstore: 130 case Bytecodes::_dstore: 131 case Bytecodes::_astore: 132 if (bcs.get_index() != 0) continue; 133 134 // fall through 135 case Bytecodes::_istore_0: 136 case Bytecodes::_lstore_0: 137 case Bytecodes::_fstore_0: 138 case Bytecodes::_dstore_0: 139 case Bytecodes::_astore_0: 140 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), 141 "can't overwrite local 0 in Object.<init>"); 142 break; 143 144 default: 145 break; 146 } 147 } 148 } 149 150 151 // Rewrite a classfile-order CP index into a native-order CPC index. 152 void Rewriter::rewrite_member_reference(address bcp, int offset, bool reverse) { 153 address p = bcp + offset; 154 if (!reverse) { 155 int cp_index = Bytes::get_Java_u2(p); 156 int cache_index = cp_entry_to_cp_cache(cp_index); 157 Bytes::put_native_u2(p, cache_index); 158 if (!_method_handle_invokers.is_empty()) 159 maybe_rewrite_invokehandle(p - 1, cp_index, cache_index, reverse); 160 } else { 161 int cache_index = Bytes::get_native_u2(p); 162 int pool_index = cp_cache_entry_pool_index(cache_index); 163 Bytes::put_Java_u2(p, pool_index); 164 if (!_method_handle_invokers.is_empty()) 165 maybe_rewrite_invokehandle(p - 1, pool_index, cache_index, reverse); 453 case Bytecodes::_invokestatic : 454 case Bytecodes::_invokeinterface: 455 case Bytecodes::_invokehandle : // if reverse=true 456 rewrite_member_reference(bcp, prefix_length+1, reverse); 457 break; 458 case Bytecodes::_invokedynamic: 459 rewrite_invokedynamic(bcp, prefix_length+1, reverse); 460 break; 461 case Bytecodes::_ldc: 462 case Bytecodes::_fast_aldc: // if reverse=true 463 maybe_rewrite_ldc(bcp, prefix_length+1, false, reverse); 464 break; 465 case Bytecodes::_ldc_w: 466 case Bytecodes::_fast_aldc_w: // if reverse=true 467 maybe_rewrite_ldc(bcp, prefix_length+1, true, reverse); 468 break; 469 case Bytecodes::_jsr : // fall through 470 case Bytecodes::_jsr_w : nof_jsrs++; break; 471 case Bytecodes::_monitorenter : // fall through 472 case Bytecodes::_monitorexit : has_monitor_bytecodes = true; break; 473 474 default: break; 475 } 476 } 477 } 478 479 // Update access flags 480 if (has_monitor_bytecodes) { 481 method->set_has_monitor_bytecodes(); 482 } 483 484 // The present of a jsr bytecode implies that the method might potentially 485 // have to be rewritten, so we run the oopMapGenerator on the method 486 if (nof_jsrs > 0) { 487 method->set_has_jsrs(); 488 // Second pass will revisit this method. 489 assert(method->has_jsrs(), "didn't we just set this?"); 490 } 491 } 492 493 // After constant pool is created, revisit methods containing jsrs. 494 methodHandle Rewriter::rewrite_jsrs(methodHandle method, TRAPS) { |