org.jikesrvm.compilers.opt.inlining
Class DefaultInlineOracle

java.lang.Object
  extended by org.jikesrvm.compilers.opt.inlining.InlineTools
      extended by org.jikesrvm.compilers.opt.inlining.DefaultInlineOracle
All Implemented Interfaces:
OptConstants, InlineOracle

public final class DefaultInlineOracle
extends InlineTools
implements InlineOracle

The default inlining oracle used by the optimizing compiler. The basic strategy is as follows:

  1. Always inline trivial methods that can be inlined without a guard
  2. At O1 and greater use a mix of profile information and static heuristics to inline larger methods and methods that require guards.


Field Summary
 
Fields inherited from interface org.jikesrvm.compilers.opt.driver.OptConstants
EPILOGUE_BCI, EPILOGUE_BLOCK_BCI, EXTANT_ANALYSIS_BCI, INSTRUMENTATION_BCI, MAYBE, METHOD_COUNTER_BCI, NO, OSR_PROLOGUE, PROLOGUE_BCI, PROLOGUE_BLOCK_BCI, RECTIFY_BCI, RUNTIME_SERVICES_BCI, SSA_SYNTH_BCI, SYNCHRONIZED_MONITORENTER_BCI, SYNCHRONIZED_MONITOREXIT_BCI, SYNTH_CATCH_BCI, SYNTH_LOOP_VERSIONING_BCI, UNKNOWN_BCI, YES
 
Constructor Summary
DefaultInlineOracle()
           
 
Method Summary
private  byte chooseGuard(RVMMethod caller, RVMMethod singleImpl, RVMMethod callee, CompilationState state, boolean codePatchSupported)
          Logic to select the appropriate guarding mechanism for the edge from caller to callee according to the controlling OptOptions.
private  int inliningActionCost(int inlinedBodyEstimate, boolean needsGuard, boolean preEx, OptOptions opts)
          Estimate the expected cost of the inlining action (includes both the inline body and the guard/off-branch code).
 InlineDecision shouldInline(CompilationState state)
          Should we inline a particular call site?
 
Methods inherited from class org.jikesrvm.compilers.opt.inlining.InlineTools
hasBody, hasInlinePragma, hasNoInlinePragma, implementsInterface, inlinedSizeEstimate, isCurrentlyFinal, isForbiddenSpeculation, needsGuard
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultInlineOracle

public DefaultInlineOracle()
Method Detail

shouldInline

public InlineDecision shouldInline(CompilationState state)
Description copied from interface: InlineOracle
Should we inline a particular call site?

Specified by:
shouldInline in interface InlineOracle
Parameters:
state - information needed to make the inlining decision
Returns:
an InlineDecision with the result

chooseGuard

private byte chooseGuard(RVMMethod caller,
                         RVMMethod singleImpl,
                         RVMMethod callee,
                         CompilationState state,
                         boolean codePatchSupported)
Logic to select the appropriate guarding mechanism for the edge from caller to callee according to the controlling OptOptions. If we are using IG_CODE_PATCH, then this method also records the required dependency. Precondition: lock on RVMClass.classLoadListener is held.

Parameters:
caller - The caller method
callee - The callee method
codePatchSupported - Can we use code patching at this call site?

inliningActionCost

private int inliningActionCost(int inlinedBodyEstimate,
                               boolean needsGuard,
                               boolean preEx,
                               OptOptions opts)
Estimate the expected cost of the inlining action (includes both the inline body and the guard/off-branch code).

Parameters:
inlinedBodyEstimate - size estimate for inlined body
needsGuard - is it going to be a guarded inline?
preEx - can preEx inlining be used to avoid the guard?
opts - controlling options object
Returns:
the estimated cost of the inlining action