comparison src/share/vm/interpreter/interpreterRuntime.cpp @ 1565:ab102d5d923e

6939207: refactor constant pool index processing Summary: Factored cleanup of instruction decode which prepares for enhanced ldc semantics. Reviewed-by: twisti
author jrose
date Sun, 23 May 2010 01:38:26 -0700
parents cd5dbf694d45
children e9ff18c4ace7
comparison
equal deleted inserted replaced
1564:61b2245abf36 1565:ab102d5d923e
61 61
62 62
63 IRT_ENTRY(void, InterpreterRuntime::ldc(JavaThread* thread, bool wide)) 63 IRT_ENTRY(void, InterpreterRuntime::ldc(JavaThread* thread, bool wide))
64 // access constant pool 64 // access constant pool
65 constantPoolOop pool = method(thread)->constants(); 65 constantPoolOop pool = method(thread)->constants();
66 int index = wide ? two_byte_index(thread) : one_byte_index(thread); 66 int index = wide ? get_index_u2(thread, Bytecodes::_ldc_w) : get_index_u1(thread, Bytecodes::_ldc);
67 constantTag tag = pool->tag_at(index); 67 constantTag tag = pool->tag_at(index);
68 68
69 if (tag.is_unresolved_klass() || tag.is_klass()) { 69 if (tag.is_unresolved_klass() || tag.is_klass()) {
70 klassOop klass = pool->klass_at(index, CHECK); 70 klassOop klass = pool->klass_at(index, CHECK);
71 oop java_class = klass->klass_part()->java_mirror(); 71 oop java_class = klass->klass_part()->java_mirror();
133 133
134 134
135 IRT_ENTRY(void, InterpreterRuntime::multianewarray(JavaThread* thread, jint* first_size_address)) 135 IRT_ENTRY(void, InterpreterRuntime::multianewarray(JavaThread* thread, jint* first_size_address))
136 // We may want to pass in more arguments - could make this slightly faster 136 // We may want to pass in more arguments - could make this slightly faster
137 constantPoolOop constants = method(thread)->constants(); 137 constantPoolOop constants = method(thread)->constants();
138 int i = two_byte_index(thread); 138 int i = get_index_u2(thread, Bytecodes::_multianewarray);
139 klassOop klass = constants->klass_at(i, CHECK); 139 klassOop klass = constants->klass_at(i, CHECK);
140 int nof_dims = number_of_dimensions(thread); 140 int nof_dims = number_of_dimensions(thread);
141 assert(oop(klass)->is_klass(), "not a class"); 141 assert(oop(klass)->is_klass(), "not a class");
142 assert(nof_dims >= 1, "multianewarray rank must be nonzero"); 142 assert(nof_dims >= 1, "multianewarray rank must be nonzero");
143 143
167 167
168 168
169 // Quicken instance-of and check-cast bytecodes 169 // Quicken instance-of and check-cast bytecodes
170 IRT_ENTRY(void, InterpreterRuntime::quicken_io_cc(JavaThread* thread)) 170 IRT_ENTRY(void, InterpreterRuntime::quicken_io_cc(JavaThread* thread))
171 // Force resolving; quicken the bytecode 171 // Force resolving; quicken the bytecode
172 int which = two_byte_index(thread); 172 int which = get_index_u2(thread, Bytecodes::_checkcast);
173 constantPoolOop cpool = method(thread)->constants(); 173 constantPoolOop cpool = method(thread)->constants();
174 // We'd expect to assert that we're only here to quicken bytecodes, but in a multithreaded 174 // We'd expect to assert that we're only here to quicken bytecodes, but in a multithreaded
175 // program we might have seen an unquick'd bytecode in the interpreter but have another 175 // program we might have seen an unquick'd bytecode in the interpreter but have another
176 // thread quicken the bytecode before we get here. 176 // thread quicken the bytecode before we get here.
177 // assert( cpool->tag_at(which).is_unresolved_klass(), "should only come here to quicken bytecodes" ); 177 // assert( cpool->tag_at(which).is_unresolved_klass(), "should only come here to quicken bytecodes" );
461 constantPoolHandle pool(thread, method(thread)->constants()); 461 constantPoolHandle pool(thread, method(thread)->constants());
462 bool is_static = (bytecode == Bytecodes::_getstatic || bytecode == Bytecodes::_putstatic); 462 bool is_static = (bytecode == Bytecodes::_getstatic || bytecode == Bytecodes::_putstatic);
463 463
464 { 464 {
465 JvmtiHideSingleStepping jhss(thread); 465 JvmtiHideSingleStepping jhss(thread);
466 LinkResolver::resolve_field(info, pool, two_byte_index(thread), 466 LinkResolver::resolve_field(info, pool, get_index_u2_cpcache(thread, bytecode),
467 bytecode, false, CHECK); 467 bytecode, false, CHECK);
468 } // end JvmtiHideSingleStepping 468 } // end JvmtiHideSingleStepping
469 469
470 // check if link resolution caused cpCache to be updated 470 // check if link resolution caused cpCache to be updated
471 if (already_resolved(thread)) return; 471 if (already_resolved(thread)) return;
632 constantPoolHandle pool(thread, method(thread)->constants()); 632 constantPoolHandle pool(thread, method(thread)->constants());
633 633
634 { 634 {
635 JvmtiHideSingleStepping jhss(thread); 635 JvmtiHideSingleStepping jhss(thread);
636 LinkResolver::resolve_invoke(info, receiver, pool, 636 LinkResolver::resolve_invoke(info, receiver, pool,
637 two_byte_index(thread), bytecode, CHECK); 637 get_index_u2_cpcache(thread, bytecode), bytecode, CHECK);
638 if (JvmtiExport::can_hotswap_or_post_breakpoint()) { 638 if (JvmtiExport::can_hotswap_or_post_breakpoint()) {
639 int retry_count = 0; 639 int retry_count = 0;
640 while (info.resolved_method()->is_old()) { 640 while (info.resolved_method()->is_old()) {
641 // It is very unlikely that method is redefined more than 100 times 641 // It is very unlikely that method is redefined more than 100 times
642 // in the middle of resolve. If it is looping here more than 100 times 642 // in the middle of resolve. If it is looping here more than 100 times
643 // means then there could be a bug here. 643 // means then there could be a bug here.
644 guarantee((retry_count++ < 100), 644 guarantee((retry_count++ < 100),
645 "Could not resolve to latest version of redefined method"); 645 "Could not resolve to latest version of redefined method");
646 // method is redefined in the middle of resolve so re-try. 646 // method is redefined in the middle of resolve so re-try.
647 LinkResolver::resolve_invoke(info, receiver, pool, 647 LinkResolver::resolve_invoke(info, receiver, pool,
648 two_byte_index(thread), bytecode, CHECK); 648 get_index_u2_cpcache(thread, bytecode), bytecode, CHECK);
649 } 649 }
650 } 650 }
651 } // end JvmtiHideSingleStepping 651 } // end JvmtiHideSingleStepping
652 652
653 // check if link resolution caused cpCache to be updated 653 // check if link resolution caused cpCache to be updated
702 int site_index = 0; 702 int site_index = 0;
703 { address caller_bcp = bcp(thread); 703 { address caller_bcp = bcp(thread);
704 caller_bci = caller_method->bci_from(caller_bcp); 704 caller_bci = caller_method->bci_from(caller_bcp);
705 site_index = Bytes::get_native_u4(caller_bcp+1); 705 site_index = Bytes::get_native_u4(caller_bcp+1);
706 } 706 }
707 assert(site_index == four_byte_index(thread), ""); 707 assert(site_index == InterpreterRuntime::bytecode(thread)->get_index_u4(bytecode), "");
708 assert(constantPoolCacheOopDesc::is_secondary_index(site_index), "proper format"); 708 assert(constantPoolCacheOopDesc::is_secondary_index(site_index), "proper format");
709 // there is a second CPC entries that is of interest; it caches signature info: 709 // there is a second CPC entries that is of interest; it caches signature info:
710 int main_index = pool->cache()->secondary_entry_at(site_index)->main_entry_index(); 710 int main_index = pool->cache()->secondary_entry_at(site_index)->main_entry_index();
711 711
712 // first resolve the signature to a MH.invoke methodOop 712 // first resolve the signature to a MH.invoke methodOop