< prev index next >

src/share/vm/interpreter/linkResolver.cpp

Print this page




 107                           const methodHandle& selected_method,
 108                           CallKind kind,
 109                           int index,
 110                           TRAPS) {
 111   assert(resolved_method->signature() == selected_method->signature(), "signatures must correspond");
 112   _resolved_klass  = resolved_klass;
 113   _selected_klass  = selected_klass;
 114   _resolved_method = resolved_method;
 115   _selected_method = selected_method;
 116   _call_kind       = kind;
 117   _call_index      = index;
 118   _resolved_appendix = Handle();
 119   DEBUG_ONLY(verify());  // verify before making side effects
 120 
 121   if (CompilationPolicy::must_be_compiled(selected_method)) {
 122     // This path is unusual, mostly used by the '-Xcomp' stress test mode.
 123 
 124     // Note: with several active threads, the must_be_compiled may be true
 125     //       while can_be_compiled is false; remove assert
 126     // assert(CompilationPolicy::can_be_compiled(selected_method), "cannot compile");
 127     if (THREAD->is_Compiler_thread()) {
 128       // don't force compilation, resolve was on behalf of compiler
 129       return;
 130     }
 131     if (selected_method->method_holder()->is_not_initialized()) {
 132       // 'is_not_initialized' means not only '!is_initialized', but also that
 133       // initialization has not been started yet ('!being_initialized')
 134       // Do not force compilation of methods in uninitialized classes.
 135       // Note that doing this would throw an assert later,
 136       // in CompileBroker::compile_method.
 137       // We sometimes use the link resolver to do reflective lookups
 138       // even before classes are initialized.
 139       return;
 140     }
 141     CompileBroker::compile_method(selected_method, InvocationEntryBci,
 142                                   CompilationPolicy::policy()->initial_compile_level(),
 143                                   methodHandle(), 0, "must_be_compiled", CHECK);
 144   }
 145 }
 146 
 147 // utility query for unreflecting a method


 433         ResourceMark rm(THREAD);
 434         tty->print_cr("lookup_polymorphic_method %s %s => basic %s",
 435                       name->as_C_string(),
 436                       full_signature->as_C_string(),
 437                       basic_signature->as_C_string());
 438       }
 439       methodHandle result = SystemDictionary::find_method_handle_intrinsic(iid,
 440                                                               basic_signature,
 441                                                               CHECK_NULL);
 442       if (result.not_null()) {
 443         assert(result->is_method_handle_intrinsic(), "MH.invokeBasic or MH.linkTo* intrinsic");
 444         assert(result->intrinsic_id() != vmIntrinsics::_invokeGeneric, "wrong place to find this");
 445         assert(basic_signature == result->signature(), "predict the result signature");
 446         if (TraceMethodHandles) {
 447           tty->print("lookup_polymorphic_method => intrinsic ");
 448           result->print_on(tty);
 449         }
 450       }
 451       return result;
 452     } else if (iid == vmIntrinsics::_invokeGeneric
 453                && !THREAD->is_Compiler_thread()
 454                && appendix_result_or_null != NULL) {
 455       // This is a method with type-checking semantics.
 456       // We will ask Java code to spin an adapter method for it.
 457       if (!MethodHandles::enabled()) {
 458         // Make sure the Java part of the runtime has been booted up.
 459         Klass* natives = SystemDictionary::MethodHandleNatives_klass();
 460         if (natives == NULL || InstanceKlass::cast(natives)->is_not_initialized()) {
 461           SystemDictionary::resolve_or_fail(vmSymbols::java_lang_invoke_MethodHandleNatives(),
 462                                             Handle(),
 463                                             Handle(),
 464                                             true,
 465                                             CHECK_NULL);
 466         }
 467       }
 468 
 469       Handle appendix;
 470       Handle method_type;
 471       methodHandle result = SystemDictionary::find_method_handle_invoker(
 472                                                             name,
 473                                                             full_signature,




 107                           const methodHandle& selected_method,
 108                           CallKind kind,
 109                           int index,
 110                           TRAPS) {
 111   assert(resolved_method->signature() == selected_method->signature(), "signatures must correspond");
 112   _resolved_klass  = resolved_klass;
 113   _selected_klass  = selected_klass;
 114   _resolved_method = resolved_method;
 115   _selected_method = selected_method;
 116   _call_kind       = kind;
 117   _call_index      = index;
 118   _resolved_appendix = Handle();
 119   DEBUG_ONLY(verify());  // verify before making side effects
 120 
 121   if (CompilationPolicy::must_be_compiled(selected_method)) {
 122     // This path is unusual, mostly used by the '-Xcomp' stress test mode.
 123 
 124     // Note: with several active threads, the must_be_compiled may be true
 125     //       while can_be_compiled is false; remove assert
 126     // assert(CompilationPolicy::can_be_compiled(selected_method), "cannot compile");
 127     if (!THREAD->can_call_java()) {
 128       // don't force compilation, resolve was on behalf of compiler
 129       return;
 130     }
 131     if (selected_method->method_holder()->is_not_initialized()) {
 132       // 'is_not_initialized' means not only '!is_initialized', but also that
 133       // initialization has not been started yet ('!being_initialized')
 134       // Do not force compilation of methods in uninitialized classes.
 135       // Note that doing this would throw an assert later,
 136       // in CompileBroker::compile_method.
 137       // We sometimes use the link resolver to do reflective lookups
 138       // even before classes are initialized.
 139       return;
 140     }
 141     CompileBroker::compile_method(selected_method, InvocationEntryBci,
 142                                   CompilationPolicy::policy()->initial_compile_level(),
 143                                   methodHandle(), 0, "must_be_compiled", CHECK);
 144   }
 145 }
 146 
 147 // utility query for unreflecting a method


 433         ResourceMark rm(THREAD);
 434         tty->print_cr("lookup_polymorphic_method %s %s => basic %s",
 435                       name->as_C_string(),
 436                       full_signature->as_C_string(),
 437                       basic_signature->as_C_string());
 438       }
 439       methodHandle result = SystemDictionary::find_method_handle_intrinsic(iid,
 440                                                               basic_signature,
 441                                                               CHECK_NULL);
 442       if (result.not_null()) {
 443         assert(result->is_method_handle_intrinsic(), "MH.invokeBasic or MH.linkTo* intrinsic");
 444         assert(result->intrinsic_id() != vmIntrinsics::_invokeGeneric, "wrong place to find this");
 445         assert(basic_signature == result->signature(), "predict the result signature");
 446         if (TraceMethodHandles) {
 447           tty->print("lookup_polymorphic_method => intrinsic ");
 448           result->print_on(tty);
 449         }
 450       }
 451       return result;
 452     } else if (iid == vmIntrinsics::_invokeGeneric
 453                && THREAD->can_call_java()
 454                && appendix_result_or_null != NULL) {
 455       // This is a method with type-checking semantics.
 456       // We will ask Java code to spin an adapter method for it.
 457       if (!MethodHandles::enabled()) {
 458         // Make sure the Java part of the runtime has been booted up.
 459         Klass* natives = SystemDictionary::MethodHandleNatives_klass();
 460         if (natives == NULL || InstanceKlass::cast(natives)->is_not_initialized()) {
 461           SystemDictionary::resolve_or_fail(vmSymbols::java_lang_invoke_MethodHandleNatives(),
 462                                             Handle(),
 463                                             Handle(),
 464                                             true,
 465                                             CHECK_NULL);
 466         }
 467       }
 468 
 469       Handle appendix;
 470       Handle method_type;
 471       methodHandle result = SystemDictionary::find_method_handle_invoker(
 472                                                             name,
 473                                                             full_signature,


< prev index next >