src/com/google/javascript/jscomp/FunctionInjector.java
/**
   * Determines whether a function can be inlined at a particular call site.
   * There are several criteria that the function and reference must hold in
   * order for the functions to be inlined:
   * 1) If a call's arguments have side effects,
   * the corresponding argument in the function must only be referenced once.
   * For instance, this will not be inlined:
   * <pre>
   *     function foo(a) { return a + a }
   *     x = foo(i++);
   * </pre>
   */
Determines whether a function can be inlined at a particular call site.
There are several criteria that the function and reference must hold in
order for the functions to be inlined:
1) If a call's arguments have side effects,
the corresponding argument in the function must only be referenced once.
For instance, this will not be inlined:

function foo(a) { return a + a }
x = foo(i++);

Determines whether a function can be inlined at a particular call site . There are several criteria that the function and reference must hold in order for the functions to be inlined : 1 ) If a call ' s arguments have side effects the corresponding argument in the function must only be referenced once . For instance this will not be inlined : function foo ( a ) { return a + a } x = foo ( i ++ ) ;
private CanInlineResult canInlineReferenceDirectly(
      Reference ref, Node fnNode, Set<String> namesToAlias) {
    if (!isDirectCallNodeReplacementPossible(fnNode)) {
      return CanInlineResult.NO;
    }
    Node callNode = ref.callNode;
    Node cArg = callNode.getSecondChild();
    if (!callNode.getFirstChild().isName()) {
      if (NodeUtil.isFunctionObjectCall(callNode)) {
        if (cArg == null || !cArg.isThis()) {
          return CanInlineResult.NO;
        }
        cArg = cArg.getNext();
      } else {
        checkState(!NodeUtil.isFunctionObjectApply(callNode));
      }
    }
    ImmutableMap<String, Node> args =
        FunctionArgumentInjector.getFunctionCallParameterMap(
            fnNode, callNode, this.throwawayNameSupplier);
    boolean hasArgs = !args.isEmpty();
    if (hasArgs) {
      Set<String> allNamesToAlias = new HashSet<>(namesToAlias);
      FunctionArgumentInjector.maybeAddTempsForCallArguments(
          fnNode, args, allNamesToAlias, compiler.getCodingConvention());
      if (!allNamesToAlias.isEmpty()) {
        return CanInlineResult.NO;
      }
    }
    return CanInlineResult.YES;
  }
private CanInlineResult canInlineReferenceDirectly ( Reference ref , Node fnNode , Set < String > namesToAlias ) { if ( ! isDirectCallNodeReplacementPossible ( fnNode ) ) { return CanInlineResult . NO ; } Node callNode = ref . callNode ; Node cArg = callNode . getSecondChild ( ) ; if ( ! callNode . getFirstChild ( ) . isName ( ) ) { if ( NodeUtil . isFunctionObjectCall ( callNode ) ) { if ( cArg == null || ! cArg . isThis ( ) ) { return CanInlineResult . NO ; } cArg = cArg . getNext ( ) ; } else { checkState ( ! NodeUtil . isFunctionObjectApply ( callNode ) ) ; } } ImmutableMap < String , Node > args = FunctionArgumentInjector . getFunctionCallParameterMap ( fnNode , callNode , this . throwawayNameSupplier ) ; boolean hasArgs = ! args . isEmpty ( ) ; if ( hasArgs ) { Set < String > allNamesToAlias = new HashSet < > ( namesToAlias ) ; FunctionArgumentInjector . maybeAddTempsForCallArguments ( fnNode , args , allNamesToAlias , compiler . getCodingConvention ( ) ) ; if ( ! allNamesToAlias . isEmpty ( ) ) { return CanInlineResult . NO ; } } return CanInlineResult . YES ; }
Determines whether a function can be inlined at a particular call site.
Determines whether a function can be inlined at a particular call site .
// CALL NODE: [ NAME, ARG1, ARG2, ... ] // Functions called via 'call' and 'apply' have a this-object as // the first parameter, but this is not part of the called function's // parameter list. // TODO(johnlenz): Support replace this with a value. // ".apply" call should be filtered before this. // Limit the inlining