src/share/vm/interpreter/interpreterRuntime.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 8014013 Sdiff src/share/vm/interpreter

src/share/vm/interpreter/interpreterRuntime.cpp

Print this page




 479   // nothing to do - eventually we should remove this code entirely (see comments @ call sites)
 480 IRT_END
 481 
 482 
 483 IRT_ENTRY(void, InterpreterRuntime::throw_AbstractMethodError(JavaThread* thread))
 484   THROW(vmSymbols::java_lang_AbstractMethodError());
 485 IRT_END
 486 
 487 
 488 IRT_ENTRY(void, InterpreterRuntime::throw_IncompatibleClassChangeError(JavaThread* thread))
 489   THROW(vmSymbols::java_lang_IncompatibleClassChangeError());
 490 IRT_END
 491 
 492 
 493 //------------------------------------------------------------------------------------------------------------------------
 494 // Fields
 495 //
 496 
 497 IRT_ENTRY(void, InterpreterRuntime::resolve_get_put(JavaThread* thread, Bytecodes::Code bytecode))
 498   // resolve field
 499   FieldAccessInfo info;
 500   constantPoolHandle pool(thread, method(thread)->constants());
 501   bool is_put    = (bytecode == Bytecodes::_putfield  || bytecode == Bytecodes::_putstatic);
 502   bool is_static = (bytecode == Bytecodes::_getstatic || bytecode == Bytecodes::_putstatic);
 503 
 504   {
 505     JvmtiHideSingleStepping jhss(thread);
 506     LinkResolver::resolve_field(info, pool, get_index_u2_cpcache(thread, bytecode),
 507                                 bytecode, false, CHECK);
 508   } // end JvmtiHideSingleStepping
 509 
 510   // check if link resolution caused cpCache to be updated
 511   if (already_resolved(thread)) return;
 512 
 513   // compute auxiliary field attributes
 514   TosState state  = as_TosState(info.field_type());
 515 
 516   // We need to delay resolving put instructions on final fields
 517   // until we actually invoke one. This is required so we throw
 518   // exceptions at the correct place. If we do not resolve completely
 519   // in the current pass, leaving the put_code set to zero will
 520   // cause the next put instruction to reresolve.
 521   Bytecodes::Code put_code = (Bytecodes::Code)0;
 522 
 523   // We also need to delay resolving getstatic instructions until the
 524   // class is intitialized.  This is required so that access to the static
 525   // field will call the initialization function every time until the class
 526   // is completely initialized ala. in 2.17.5 in JVM Specification.
 527   InstanceKlass *klass = InstanceKlass::cast(info.klass()());
 528   bool uninitialized_static = ((bytecode == Bytecodes::_getstatic || bytecode == Bytecodes::_putstatic) &&
 529                                !klass->is_initialized());
 530   Bytecodes::Code get_code = (Bytecodes::Code)0;
 531 
 532   if (!uninitialized_static) {
 533     get_code = ((is_static) ? Bytecodes::_getstatic : Bytecodes::_getfield);
 534     if (is_put || !info.access_flags().is_final()) {
 535       put_code = ((is_static) ? Bytecodes::_putstatic : Bytecodes::_putfield);
 536     }
 537   }
 538 
 539   cache_entry(thread)->set_field(
 540     get_code,
 541     put_code,
 542     info.klass(),
 543     info.field_index(),
 544     info.field_offset(),
 545     state,
 546     info.access_flags().is_final(),
 547     info.access_flags().is_volatile(),
 548     pool->pool_holder()
 549   );
 550 IRT_END
 551 
 552 
 553 //------------------------------------------------------------------------------------------------------------------------
 554 // Synchronization
 555 //
 556 // The interpreter's synchronization code is factored out so that it can
 557 // be shared by method invocation and synchronized blocks.
 558 //%note synchronization_3
 559 
 560 //%note monitor_1
 561 IRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorenter(JavaThread* thread, BasicObjectLock* elem))
 562 #ifdef ASSERT
 563   thread->last_frame().interpreter_frame_verify_monitor(elem);
 564 #endif


 669                                  get_index_u2_cpcache(thread, bytecode), bytecode, CHECK);
 670     if (JvmtiExport::can_hotswap_or_post_breakpoint()) {
 671       int retry_count = 0;
 672       while (info.resolved_method()->is_old()) {
 673         // It is very unlikely that method is redefined more than 100 times
 674         // in the middle of resolve. If it is looping here more than 100 times
 675         // means then there could be a bug here.
 676         guarantee((retry_count++ < 100),
 677                   "Could not resolve to latest version of redefined method");
 678         // method is redefined in the middle of resolve so re-try.
 679         LinkResolver::resolve_invoke(info, receiver, pool,
 680                                      get_index_u2_cpcache(thread, bytecode), bytecode, CHECK);
 681       }
 682     }
 683   } // end JvmtiHideSingleStepping
 684 
 685   // check if link resolution caused cpCache to be updated
 686   if (already_resolved(thread)) return;
 687 
 688   if (bytecode == Bytecodes::_invokeinterface) {
 689 
 690     if (TraceItables && Verbose) {
 691       ResourceMark rm(thread);
 692       tty->print_cr("Resolving: klass: %s to method: %s", info.resolved_klass()->name()->as_C_string(), info.resolved_method()->name()->as_C_string());
 693     }



 694     if (info.resolved_method()->method_holder() ==
 695                                             SystemDictionary::Object_klass()) {
 696       // NOTE: THIS IS A FIX FOR A CORNER CASE in the JVM spec
 697       // (see also cpCacheOop.cpp for details)


 698       methodHandle rm = info.resolved_method();
 699       assert(rm->is_final() || info.has_vtable_index(),
 700              "should have been set already");
 701       cache_entry(thread)->set_method(bytecode, rm, info.vtable_index());


 702     } else {
 703       // Setup itable entry
 704       int index = klassItable::compute_itable_index(info.resolved_method()());
 705       cache_entry(thread)->set_interface_call(info.resolved_method(), index);

 706     }
 707   } else {
 708     cache_entry(thread)->set_method(











 709       bytecode,
 710       info.resolved_method(),
 711       info.vtable_index());








 712   }
 713 }
 714 IRT_END
 715 
 716 
 717 // First time execution:  Resolve symbols, create a permanent MethodType object.
 718 IRT_ENTRY(void, InterpreterRuntime::resolve_invokehandle(JavaThread* thread)) {
 719   assert(EnableInvokeDynamic, "");
 720   const Bytecodes::Code bytecode = Bytecodes::_invokehandle;
 721 
 722   // resolve method
 723   CallInfo info;
 724   constantPoolHandle pool(thread, method(thread)->constants());
 725 
 726   {
 727     JvmtiHideSingleStepping jhss(thread);
 728     LinkResolver::resolve_invoke(info, Handle(), pool,
 729                                  get_index_u2_cpcache(thread, bytecode), bytecode, CHECK);
 730   } // end JvmtiHideSingleStepping
 731 




 479   // nothing to do - eventually we should remove this code entirely (see comments @ call sites)
 480 IRT_END
 481 
 482 
 483 IRT_ENTRY(void, InterpreterRuntime::throw_AbstractMethodError(JavaThread* thread))
 484   THROW(vmSymbols::java_lang_AbstractMethodError());
 485 IRT_END
 486 
 487 
 488 IRT_ENTRY(void, InterpreterRuntime::throw_IncompatibleClassChangeError(JavaThread* thread))
 489   THROW(vmSymbols::java_lang_IncompatibleClassChangeError());
 490 IRT_END
 491 
 492 
 493 //------------------------------------------------------------------------------------------------------------------------
 494 // Fields
 495 //
 496 
 497 IRT_ENTRY(void, InterpreterRuntime::resolve_get_put(JavaThread* thread, Bytecodes::Code bytecode))
 498   // resolve field
 499   fieldDescriptor info;
 500   constantPoolHandle pool(thread, method(thread)->constants());
 501   bool is_put    = (bytecode == Bytecodes::_putfield  || bytecode == Bytecodes::_putstatic);
 502   bool is_static = (bytecode == Bytecodes::_getstatic || bytecode == Bytecodes::_putstatic);
 503 
 504   {
 505     JvmtiHideSingleStepping jhss(thread);
 506     LinkResolver::resolve_field_access(info, pool, get_index_u2_cpcache(thread, bytecode),
 507                                        bytecode, CHECK);
 508   } // end JvmtiHideSingleStepping
 509 
 510   // check if link resolution caused cpCache to be updated
 511   if (already_resolved(thread)) return;
 512 
 513   // compute auxiliary field attributes
 514   TosState state  = as_TosState(info.field_type());
 515 
 516   // We need to delay resolving put instructions on final fields
 517   // until we actually invoke one. This is required so we throw
 518   // exceptions at the correct place. If we do not resolve completely
 519   // in the current pass, leaving the put_code set to zero will
 520   // cause the next put instruction to reresolve.
 521   Bytecodes::Code put_code = (Bytecodes::Code)0;
 522 
 523   // We also need to delay resolving getstatic instructions until the
 524   // class is intitialized.  This is required so that access to the static
 525   // field will call the initialization function every time until the class
 526   // is completely initialized ala. in 2.17.5 in JVM Specification.
 527   InstanceKlass* klass = InstanceKlass::cast(info.field_holder());
 528   bool uninitialized_static = ((bytecode == Bytecodes::_getstatic || bytecode == Bytecodes::_putstatic) &&
 529                                !klass->is_initialized());
 530   Bytecodes::Code get_code = (Bytecodes::Code)0;
 531 
 532   if (!uninitialized_static) {
 533     get_code = ((is_static) ? Bytecodes::_getstatic : Bytecodes::_getfield);
 534     if (is_put || !info.access_flags().is_final()) {
 535       put_code = ((is_static) ? Bytecodes::_putstatic : Bytecodes::_putfield);
 536     }
 537   }
 538 
 539   cache_entry(thread)->set_field(
 540     get_code,
 541     put_code,
 542     info.field_holder(),
 543     info.index(),
 544     info.offset(),
 545     state,
 546     info.access_flags().is_final(),
 547     info.access_flags().is_volatile(),
 548     pool->pool_holder()
 549   );
 550 IRT_END
 551 
 552 
 553 //------------------------------------------------------------------------------------------------------------------------
 554 // Synchronization
 555 //
 556 // The interpreter's synchronization code is factored out so that it can
 557 // be shared by method invocation and synchronized blocks.
 558 //%note synchronization_3
 559 
 560 //%note monitor_1
 561 IRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorenter(JavaThread* thread, BasicObjectLock* elem))
 562 #ifdef ASSERT
 563   thread->last_frame().interpreter_frame_verify_monitor(elem);
 564 #endif


 669                                  get_index_u2_cpcache(thread, bytecode), bytecode, CHECK);
 670     if (JvmtiExport::can_hotswap_or_post_breakpoint()) {
 671       int retry_count = 0;
 672       while (info.resolved_method()->is_old()) {
 673         // It is very unlikely that method is redefined more than 100 times
 674         // in the middle of resolve. If it is looping here more than 100 times
 675         // means then there could be a bug here.
 676         guarantee((retry_count++ < 100),
 677                   "Could not resolve to latest version of redefined method");
 678         // method is redefined in the middle of resolve so re-try.
 679         LinkResolver::resolve_invoke(info, receiver, pool,
 680                                      get_index_u2_cpcache(thread, bytecode), bytecode, CHECK);
 681       }
 682     }
 683   } // end JvmtiHideSingleStepping
 684 
 685   // check if link resolution caused cpCache to be updated
 686   if (already_resolved(thread)) return;
 687 
 688   if (bytecode == Bytecodes::_invokeinterface) {

 689     if (TraceItables && Verbose) {
 690       ResourceMark rm(thread);
 691       tty->print_cr("Resolving: klass: %s to method: %s", info.resolved_klass()->name()->as_C_string(), info.resolved_method()->name()->as_C_string());
 692     }
 693   }
 694 #ifdef ASSERT
 695   if (bytecode == Bytecodes::_invokeinterface) {
 696     if (info.resolved_method()->method_holder() ==
 697                                             SystemDictionary::Object_klass()) {
 698       // NOTE: THIS IS A FIX FOR A CORNER CASE in the JVM spec
 699       // (see also CallInfo::set_interface for details)
 700       assert(info.call_kind() == CallInfo::vtable_call ||
 701              info.call_kind() == CallInfo::direct_call, "");
 702       methodHandle rm = info.resolved_method();
 703       assert(rm->is_final() || info.has_vtable_index(),
 704              "should have been set already");
 705     } else if (!info.resolved_method()->has_itable_index()) {
 706       // Resolved something like CharSequence.toString.  Use vtable not itable.
 707       assert(info.call_kind() != CallInfo::itable_call, "");
 708     } else {
 709       // Setup itable entry
 710       assert(info.call_kind() == CallInfo::itable_call, "");
 711       int index = info.resolved_method()->itable_index();
 712       assert(info.itable_index() == index, "");
 713     }
 714   } else {
 715     assert(info.call_kind() == CallInfo::direct_call ||
 716            info.call_kind() == CallInfo::vtable_call, "");
 717   }
 718 #endif
 719   switch (info.call_kind()) {
 720   case CallInfo::direct_call:
 721     cache_entry(thread)->set_direct_call(
 722       bytecode,
 723       info.resolved_method());
 724     break;
 725   case CallInfo::vtable_call:
 726     cache_entry(thread)->set_vtable_call(
 727       bytecode,
 728       info.resolved_method(),
 729       info.vtable_index());
 730     break;
 731   case CallInfo::itable_call:
 732     cache_entry(thread)->set_itable_call(
 733       bytecode,
 734       info.resolved_method(),
 735       info.itable_index());
 736     break;
 737   default:  ShouldNotReachHere();
 738   }
 739 }
 740 IRT_END
 741 
 742 
 743 // First time execution:  Resolve symbols, create a permanent MethodType object.
 744 IRT_ENTRY(void, InterpreterRuntime::resolve_invokehandle(JavaThread* thread)) {
 745   assert(EnableInvokeDynamic, "");
 746   const Bytecodes::Code bytecode = Bytecodes::_invokehandle;
 747 
 748   // resolve method
 749   CallInfo info;
 750   constantPoolHandle pool(thread, method(thread)->constants());
 751 
 752   {
 753     JvmtiHideSingleStepping jhss(thread);
 754     LinkResolver::resolve_invoke(info, Handle(), pool,
 755                                  get_index_u2_cpcache(thread, bytecode), bytecode, CHECK);
 756   } // end JvmtiHideSingleStepping
 757 


src/share/vm/interpreter/interpreterRuntime.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File