1947 } 1948 } else { 1949 if (TraceCallFixup) { 1950 tty->print("already patched callsite at " INTPTR_FORMAT " to compiled code for", p2i(caller_pc)); 1951 moop->print_short_name(tty); 1952 tty->print_cr(" to " INTPTR_FORMAT, p2i(entry_point)); 1953 } 1954 } 1955 return false; 1956 } 1957 1958 // --------------------------------------------------------------------------- 1959 // We are calling the interpreter via a c2i. Normally this would mean that 1960 // we were called by a compiled method. However we could have lost a race 1961 // where we went int -> i2c -> c2i and so the caller could in fact be 1962 // interpreted. If the caller is compiled we attempt to patch the caller 1963 // so he no longer calls into the interpreter. 1964 JRT_LEAF(void, SharedRuntime::fixup_callers_callsite(Method* method, address caller_pc)) 1965 Method* moop(method); 1966 1967 address entry_point = moop->from_compiled_entry_no_trampoline(); 1968 1969 // It's possible that deoptimization can occur at a call site which hasn't 1970 // been resolved yet, in which case this function will be called from 1971 // an nmethod that has been patched for deopt and we can ignore the 1972 // request for a fixup. 1973 // Also it is possible that we lost a race in that from_compiled_entry 1974 // is now back to the i2c in that case we don't need to patch and if 1975 // we did we'd leap into space because the callsite needs to use 1976 // "to interpreter" stub in order to load up the Method*. Don't 1977 // ask me how I know this... 1978 1979 CodeBlob* cb = CodeCache::find_blob(caller_pc); 1980 if (cb == NULL || !cb->is_compiled() || entry_point == moop->get_c2i_entry()) { 1981 return; 1982 } 1983 1984 // The check above makes sure this is a nmethod. 1985 CompiledMethod* nm = cb->as_compiled_method_or_null(); 1986 assert(nm, "must be"); 1987 1988 // Get the return PC for the passed caller PC. 1989 address return_pc = caller_pc + frame::pc_return_offset; 1990 1991 // There is a benign race here. We could be attempting to patch to a compiled 1992 // entry point at the same time the callee is being deoptimized. If that is 1993 // the case then entry_point may in fact point to a c2i and we'd patch the 1994 // call site with the same old data. clear_code will set code() to NULL 1995 // at the end of it. If we happen to see that NULL then we can skip trying 1996 // to patch. If we hit the window where the callee has a c2i in the 1997 // from_compiled_entry and the NULL isn't present yet then we lose the race 1998 // and patch the code with the same old data. Asi es la vida. 1999 2000 if (moop->code() == NULL) return; | 1947 } 1948 } else { 1949 if (TraceCallFixup) { 1950 tty->print("already patched callsite at " INTPTR_FORMAT " to compiled code for", p2i(caller_pc)); 1951 moop->print_short_name(tty); 1952 tty->print_cr(" to " INTPTR_FORMAT, p2i(entry_point)); 1953 } 1954 } 1955 return false; 1956 } 1957 1958 // --------------------------------------------------------------------------- 1959 // We are calling the interpreter via a c2i. Normally this would mean that 1960 // we were called by a compiled method. However we could have lost a race 1961 // where we went int -> i2c -> c2i and so the caller could in fact be 1962 // interpreted. If the caller is compiled we attempt to patch the caller 1963 // so he no longer calls into the interpreter. 1964 JRT_LEAF(void, SharedRuntime::fixup_callers_callsite(Method* method, address caller_pc)) 1965 Method* moop(method); 1966 1967 // It's possible that deoptimization can occur at a call site which hasn't 1968 // been resolved yet, in which case this function will be called from 1969 // an nmethod that has been patched for deopt and we can ignore the 1970 // request for a fixup. 1971 // Also it is possible that we lost a race in that from_compiled_entry 1972 // is now back to the i2c in that case we don't need to patch and if 1973 // we did we'd leap into space because the callsite needs to use 1974 // "to interpreter" stub in order to load up the Method*. Don't 1975 // ask me how I know this... 1976 1977 CodeBlob* cb = CodeCache::find_blob(caller_pc); 1978 if (cb == NULL || !cb->is_compiled()) { 1979 return; 1980 } 1981 address entry_point = moop->from_compiled_entry_no_trampoline(cb->is_compiled_by_c1()); 1982 if (entry_point == moop->get_c2i_entry()) { 1983 return; 1984 } 1985 1986 // The check above makes sure this is a nmethod. 1987 CompiledMethod* nm = cb->as_compiled_method_or_null(); 1988 assert(nm, "must be"); 1989 1990 // Get the return PC for the passed caller PC. 1991 address return_pc = caller_pc + frame::pc_return_offset; 1992 1993 // There is a benign race here. We could be attempting to patch to a compiled 1994 // entry point at the same time the callee is being deoptimized. If that is 1995 // the case then entry_point may in fact point to a c2i and we'd patch the 1996 // call site with the same old data. clear_code will set code() to NULL 1997 // at the end of it. If we happen to see that NULL then we can skip trying 1998 // to patch. If we hit the window where the callee has a c2i in the 1999 // from_compiled_entry and the NULL isn't present yet then we lose the race 2000 // and patch the code with the same old data. Asi es la vida. 2001 2002 if (moop->code() == NULL) return; |