2054 // either. |
2054 // either. |
2055 vtable_index = target->resolve_vtable_index(calling_klass, holder); |
2055 vtable_index = target->resolve_vtable_index(calling_klass, holder); |
2056 } |
2056 } |
2057 #endif |
2057 #endif |
2058 |
2058 |
2059 // invokespecial always needs a NULL check. invokevirtual where the target is |
2059 // A null check is required here (when there is a receiver) for any of the following cases |
2060 // final or where it's not known whether the target is final requires a NULL check. |
2060 // - invokespecial, always need a null check. |
2061 // Otherwise normal invokevirtual will perform the null check during the lookup |
2061 // - invokevirtual, when the target is final and loaded. Calls to final targets will become optimized |
2062 // logic or the unverified entry point. Profiling of calls requires that |
2062 // and require null checking. If the target is loaded a null check is emitted here. |
2063 // the null check is performed in all cases. |
2063 // If the target isn't loaded the null check must happen after the call resolution. We achieve that |
2064 |
2064 // by using the target methods unverified entry point (see CompiledIC::compute_monomorphic_entry). |
2065 bool do_null_check = (recv != NULL) && |
2065 // (The JVM specification requires that LinkageError must be thrown before a NPE. An unloaded target may |
2066 (code == Bytecodes::_invokespecial || (target->is_loaded() && (target->is_final() || (is_profiling() && profile_calls())))); |
2066 // potentially fail, and can't have the null check before the resolution.) |
2067 |
2067 // - A call that will be profiled. (But we can't add a null check when the target is unloaded, by the same |
2068 if (do_null_check) { |
2068 // reason as above, so calls with a receiver to unloaded targets can't be profiled.) |
2069 null_check(recv); |
2069 // |
|
2070 // Normal invokevirtual will perform the null check during lookup |
|
2071 |
|
2072 bool need_null_check = (code == Bytecodes::_invokespecial) || |
|
2073 (target->is_loaded() && (target->is_final_method() || (is_profiling() && profile_calls()))); |
|
2074 |
|
2075 if (need_null_check) { |
|
2076 if (recv != NULL) { |
|
2077 null_check(recv); |
|
2078 } |
2070 |
2079 |
2071 if (is_profiling()) { |
2080 if (is_profiling()) { |
2072 // Note that we'd collect profile data in this method if we wanted it. |
2081 // Note that we'd collect profile data in this method if we wanted it. |
2073 compilation()->set_would_profile(true); |
2082 compilation()->set_would_profile(true); |
2074 |
2083 |