< prev index next >

src/share/vm/c1/c1_GraphBuilder.cpp

Print this page
rev 12282 : 8167656: Unstable MethodHandle inlining causing huge performance variations
Summary: Profile calls without a reciever
Reviewed-by:


2039   Value recv = has_receiver ? apop() : NULL;
2040   int vtable_index = Method::invalid_vtable_index;
2041 
2042 #ifdef SPARC
2043   // Currently only supported on Sparc.
2044   // The UseInlineCaches only controls dispatch to invokevirtuals for
2045   // loaded classes which we weren't able to statically bind.
2046   if (!UseInlineCaches && target->is_loaded() && code == Bytecodes::_invokevirtual
2047       && !target->can_be_statically_bound()) {
2048     // Find a vtable index if one is available
2049     // For arrays, callee_holder is Object. Resolving the call with
2050     // Object would allow an illegal call to finalize() on an
2051     // array. We use holder instead: illegal calls to finalize() won't
2052     // be compiled as vtable calls (IC call resolution will catch the
2053     // illegal call) and the few legal calls on array types won't be
2054     // either.
2055     vtable_index = target->resolve_vtable_index(calling_klass, holder);
2056   }
2057 #endif
2058 
2059   // invokespecial always needs a NULL check. invokevirtual where the target is
2060   // final or where it's not known whether the target is final requires a NULL check.
2061   // Otherwise normal invokevirtual will perform the null check during the lookup
2062   // logic or the unverified entry point.  Profiling of calls requires that
2063   // the null check is performed in all cases.




2064 
2065   bool do_null_check = (recv != NULL) &&
2066         (code == Bytecodes::_invokespecial || (target->is_loaded() && (target->is_final() || (is_profiling() && profile_calls()))));
2067 
2068   if (do_null_check) {

2069     null_check(recv);

2070 
2071     if (is_profiling()) {
2072       // Note that we'd collect profile data in this method if we wanted it.
2073       compilation()->set_would_profile(true);
2074 
2075       if (profile_calls()) {
2076         assert(cha_monomorphic_target == NULL || exact_target == NULL, "both can not be set");
2077         ciKlass* target_klass = NULL;
2078         if (cha_monomorphic_target != NULL) {
2079           target_klass = cha_monomorphic_target->holder();
2080         } else if (exact_target != NULL) {
2081           target_klass = exact_target->holder();
2082         }
2083         profile_call(target, recv, target_klass, collect_args_for_profiling(args, NULL, false), false);
2084       }
2085     }
2086   }
2087 
2088   Invoke* result = new Invoke(code, result_type, recv, args, vtable_index, target, state_before);
2089   // push result




2039   Value recv = has_receiver ? apop() : NULL;
2040   int vtable_index = Method::invalid_vtable_index;
2041 
2042 #ifdef SPARC
2043   // Currently only supported on Sparc.
2044   // The UseInlineCaches only controls dispatch to invokevirtuals for
2045   // loaded classes which we weren't able to statically bind.
2046   if (!UseInlineCaches && target->is_loaded() && code == Bytecodes::_invokevirtual
2047       && !target->can_be_statically_bound()) {
2048     // Find a vtable index if one is available
2049     // For arrays, callee_holder is Object. Resolving the call with
2050     // Object would allow an illegal call to finalize() on an
2051     // array. We use holder instead: illegal calls to finalize() won't
2052     // be compiled as vtable calls (IC call resolution will catch the
2053     // illegal call) and the few legal calls on array types won't be
2054     // either.
2055     vtable_index = target->resolve_vtable_index(calling_klass, holder);
2056   }
2057 #endif
2058 
2059   // A null check is required for any of the following call types
2060   // - invokespecial, always need a null check
2061   // - invokevirtual, when the target is final and loaded, will become optimized and requires a null check
2062   //   (Null check on an final but unloaded optimized call would can break the JVM specification because
2063   //    a potential LinkageError must be thrown before the NPE. Resolve will use the unverified entry point
2064   //    to cover this case)
2065   // - when the call will be profiled (but we can't add a nullcheck when the call is unloaded, and thus can't
2066   //    add a profile either)
2067   // Otherwise normal invokevirtual will perform the null check during lookup
2068 
2069   bool need_null_check = (code == Bytecodes::_invokespecial) ||
2070       (target->is_loaded() && (target->is_final_method() || (is_profiling() && profile_calls())));
2071 
2072   if (need_null_check) {
2073     if (recv != NULL) {
2074       null_check(recv);
2075     }
2076 
2077     if (is_profiling()) {
2078       // Note that we'd collect profile data in this method if we wanted it.
2079       compilation()->set_would_profile(true);
2080 
2081       if (profile_calls()) {
2082         assert(cha_monomorphic_target == NULL || exact_target == NULL, "both can not be set");
2083         ciKlass* target_klass = NULL;
2084         if (cha_monomorphic_target != NULL) {
2085           target_klass = cha_monomorphic_target->holder();
2086         } else if (exact_target != NULL) {
2087           target_klass = exact_target->holder();
2088         }
2089         profile_call(target, recv, target_klass, collect_args_for_profiling(args, NULL, false), false);
2090       }
2091     }
2092   }
2093 
2094   Invoke* result = new Invoke(code, result_type, recv, args, vtable_index, target, state_before);
2095   // push result


< prev index next >