tmpoptions = options;
if (VM_CompilerAdviceAttribute.hasAdvice()) { VM_CompilerAdviceAttribute attr = VM_CompilerAdviceAttribute.getCompilerAdviceInfo(method); if (attr.getCompiler() != VM_CompiledMethod.OPT) { cm=fallback(method); if (VM.LogAOSEvents) { VM_AOSLogging.recordCompileTime(cm, 0.0); } return cm; } int newCMID = -2; OPT_CompilationPlan compPlan; if (VM_Controller.options.counters()) {  compPlan = VM_InvocationCounts.createCompilationPlan(method); } else {   compPlan = VM_Controller.recompilationStrategy.createCompilationPlan(method, attr.getOptLevel(), null); } if (VM.LogAOSEvents) VM_AOSLogging.recompilationStarted(compPlan); newCMID = recompileWithOpt(compPlan); cm = newCMID == -1 ? null : VM_CompiledMethods.getCompiledMethod(newCMID); if (VM.LogAOSEvents) { if (newCMID == -1) { VM_AOSLogging.recompilationAborted(compPlan); } else if (newCMID > 0) { VM_AOSLogging.recompilationCompleted(compPlan); } } if (cm == null) { cm = baselineCompile(method); VM_ControllerMemory.incrementNumBase(); } }  else {  VM_ControllerPlan plan = VM_ControllerMemory.findLatestPlan(method); if (plan == null || plan.getStatus() != VM_ControllerPlan.IN_PROGRESS) {  cm = baselineCompile(method); VM_ControllerMemory.incrementNumBase(); } else { cm = plan.doRecompile(); if (cm == null) {  cm = baselineCompile(method); } } }
  public static VM_CompiledMethod compile(VM_NormalMethod method) {    //-#if RVM_WITH_ADAPTIVE_SYSTEM    VM_CompiledMethod cm;    if (!VM_Controller.enabled) {      // System still early in boot process; compile with baseline compiler      cm = baselineCompile(method);      VM_ControllerMemory.incrementNumBase();    } else {      if (!preloadChecked) {        preloadChecked = true;                  // prevent subsequent calls        // N.B. This will use irc options        if (VM_BaselineCompiler.options.PRELOAD_CLASS != null) {          compilationInProgress = true;         // use baseline during preload          // Other than when boot options are requested (processed during preloadSpecialClass          // It is hard to communicate options for these special compilations. Use the           // default options and at least pick up the verbose if requested for base/irc          OPT_Options tmpoptions = (OPT_Options)options.clone();          tmpoptions.PRELOAD_CLASS = VM_BaselineCompiler.options.PRELOAD_CLASS;          tmpoptions.PRELOAD_AS_BOOT = VM_BaselineCompiler.options.PRELOAD_AS_BOOT;          if (VM_BaselineCompiler.options.PRINT_METHOD) {            tmpoptions.PRINT_METHOD = true;          } else {            tmpoptions = options;          }          OPT_Compiler.preloadSpecialClass(tmpoptions);          compilationInProgress = false;        }      }      if (VM_Controller.options.optIRC()) {        if (// will only run once: don't bother optimizing            method.isClassInitializer() ||             // exception in progress. can't use opt compiler:             // it uses exceptions and runtime doesn't support             // multiple pending (undelivered) exceptions [--DL]            VM_Thread.getCurrentThread().hardwareExceptionRegisters.inuse) {          // compile with baseline compiler          cm = baselineCompile(method);          VM_ControllerMemory.incrementNumBase();        } else { // compile with opt compiler          VM_AOSInstrumentationPlan instrumentationPlan =             new VM_AOSInstrumentationPlan(VM_Controller.options, method);          OPT_CompilationPlan compPlan =             new OPT_CompilationPlan(method, optimizationPlan,                                     instrumentationPlan, options);          if (offlineInlineOracle != null) {            compPlan.setInlineOracle(offlineInlineOracle);          }          cm = optCompileWithFallBack(method, compPlan);        }      } else {        if ((VM_Controller.options.BACKGROUND_RECOMPILATION             && (!VM_Controller.options.ENABLE_REPLAY_COMPILE)             && (!VM_Controller.options.ENABLE_PRECOMPILE))            ) {          // must be an inital compilation: compile with baseline compiler          // or if recompilation with OSR.           cm = baselineCompile(method);          VM_ControllerMemory.incrementNumBase();        } else {          if (VM_CompilerAdviceAttribute.hasAdvice()) {            VM_CompilerAdviceAttribute attr =              VM_CompilerAdviceAttribute.getCompilerAdviceInfo(method);            if (attr.getCompiler() != VM_CompiledMethod.OPT) {              cm=fallback(method);              if (VM.LogAOSEvents) {                VM_AOSLogging.recordCompileTime(cm, 0.0);              }              return cm;            }            int newCMID = -2;            OPT_CompilationPlan compPlan;            if (VM_Controller.options.counters()) {              // for invocation counter, we only use one optimization level              compPlan = VM_InvocationCounts.createCompilationPlan(method);            } else {               // for now there is not two options for sampling, so              // we don't have to use: if (VM_Controller.options.sampling())              compPlan = VM_Controller.recompilationStrategy.createCompilationPlan(method, attr.getOptLevel(), null);            }            if (VM.LogAOSEvents) VM_AOSLogging.recompilationStarted(compPlan);             newCMID = recompileWithOpt(compPlan);            cm = newCMID == -1 ? null : VM_CompiledMethods.getCompiledMethod(newCMID);            if (VM.LogAOSEvents) {              if (newCMID == -1) {                VM_AOSLogging.recompilationAborted(compPlan);              } else if (newCMID > 0) {                VM_AOSLogging.recompilationCompleted(compPlan);              }            }                if (cm == null) { // if recompilation is aborted              cm = baselineCompile(method);              VM_ControllerMemory.incrementNumBase();            }          }  else {            // check to see if there is a compilation plan for this method.            VM_ControllerPlan plan = VM_ControllerMemory.findLatestPlan(method);            if (plan == null || plan.getStatus() != VM_ControllerPlan.IN_PROGRESS) {              // initial compilation or some other funny state: compile with baseline compiler              cm = baselineCompile(method);              VM_ControllerMemory.incrementNumBase();            } else {              cm = plan.doRecompile();              if (cm == null) {                // opt compilation aborted for some reason.                cm = baselineCompile(method);              }            }              }               }      }    }    if ((VM_Controller.options.ENABLE_ADVICE_GENERATION)       && (cm.getCompilerType() == VM_CompiledMethod.BASELINE)       && VM_Controller.enabled) {       VM_AOSGenerator.baseCompilationCompleted(cm);    }    if (VM.LogAOSEvents) {      VM_AOSLogging.recordCompileTime(cm, 0.0);    }    return cm;    //-#else    return baselineCompile(method);    //-#endif  }