/** * Logic to select the appropriate guarding mechanism for the edge from caller to callee according * to the controlling {@link OPT_Options}. If we are using IG_CODE_PATCH, then this method also * records the required dependency. Precondition: lock on {@link VM_Class#OptCLDepManager} is * held. * * @param caller The caller method * @param callee The callee method * @param codePatchSupported Can we use code patching at this call site? */ private byte chooseGuard( VM_Method caller, VM_Method singleImpl, VM_Method callee, OPT_CompilationState state, boolean codePatchSupported) { byte guard = state.getOptions().INLINING_GUARD; if (codePatchSupported) { if (VM.VerifyAssertions && VM.runningVM) { VM._assert(VM_Lock.owns(VM_Class.OptCLDepManager)); } if (guard == OPT_Options.IG_CODE_PATCH) { if (OPT_ClassLoadingDependencyManager.TRACE || OPT_ClassLoadingDependencyManager.DEBUG) { VM_Class.OptCLDepManager.report( "CODE PATCH: Inlined " + singleImpl + " into " + caller + "\n"); } VM_Class.OptCLDepManager.addNotOverriddenDependency(callee, state.getCompiledMethod()); } } else if (guard == OPT_Options.IG_CODE_PATCH) { guard = OPT_Options.IG_METHOD_TEST; } if (guard == OPT_Options.IG_METHOD_TEST && singleImpl.getDeclaringClass().isFinal()) { // class test is more efficient and just as effective guard = OPT_Options.IG_CLASS_TEST; } return guard; }