This mapping has 7 all-to-all groups: every node on one side corresponds to every node on the other, and none is deleted or inserted. Each member carries an all N:M badge; selecting one highlights all of its counterparts, in the tree and in the code view alike.

Code view:

A painting is a person's account of this edit as text, recorded independently of the node mapping - a rendering often has several equally defensible answers where the mapping has one. Deletions and insertions carry no position on the opposite side in a painting, so that panel draws no caret for them.

Before

…lines 1–39 unchanged (39 lines)
40 private final AbstractCompiler compiler;
41 private final boolean allowDecomposition;
42 private Set<String> knownConstants = Sets.newHashSet();
43 private final boolean assumeStrictThis;
44 private final boolean assumeMinimumCapture;
45 private final Supplier<String> safeNameIdSupplier;
46
47 /**
48 * @param allowDecomposition Whether an effort should be made to break down
49 * expressions into simpler expressions to allow functions to be injected
50 * where they would otherwise be disallowed.
51 */
52 public FunctionInjector(
…lines 53–201 unchanged (149 lines)
202 // TODO(johnlenz): Allow 'this' references to be replaced with a
203 // global 'this' object.
204 return CanInlineResult.NO;
205 }
206
207 if (mode == InliningMode.DIRECT) {
208 return canInlineReferenceDirectly(callNode, fnNode);
209 } else {
210 return canInlineReferenceAsStatementBlock(
211 t, callNode, fnNode, needAliases);
212 }
213 }
214
…lines 215–683 unchanged (469 lines)
684 * <pre>
685 * function foo(a) { return a + a }
686 * x = foo(i++);
687 * </pre>
688 */
689 private CanInlineResult canInlineReferenceDirectly(
690 Node callNode, Node fnNode) {
691 if (!isDirectCallNodeReplacementPossible(fnNode)) {
692 return CanInlineResult.NO;
693 }
694
695 Node block = fnNode.getLastChild();
696 // CALL NODE: [ NAME, ARG1, ARG2, ... ]
697 Node cArg = callNode.getFirstChild().getNext();
698
699 // Functions called via 'call' and 'apply' have a this-object as
700 // the first parameter, but this is not part of the called function's
701 // parameter list.
…lines 702–707 unchanged (6 lines)
708 cArg = cArg.getNext();
709 } else {
710 // ".apply" call should be filtered before this.
711 Preconditions.checkState(!NodeUtil.isFunctionObjectApply(callNode));
712 }
713 }
714
715 Node fnParam = NodeUtil.getFunctionParameters(fnNode).getFirstChild();
716 while (cArg != null || fnParam != null) {
717 if (fnParam != null) {
718 if (cArg != null) {
719 if (NodeUtil.mayEffectMutableState(cArg, compiler)
720 && NodeUtil.getNameReferenceCount(
721 block, fnParam.getString()) > 1) {
722 return CanInlineResult.NO;
723 }
724 }
725 fnParam = fnParam.getNext();
726 }
727 // Limit the inlining
728 if (cArg != null) {
729 if (NodeUtil.mayHaveSideEffects(cArg, compiler)) {
730 return CanInlineResult.NO;
731 }
732 cArg = cArg.getNext();
733 }
734 }
735
736 return CanInlineResult.YES;
737 }
738
739 /**
740 * Determine if inlining the function is likely to reduce the code size.
…lines 741–927 unchanged (187 lines)

After

…lines 1–39 unchanged (39 lines)
40 private final AbstractCompiler compiler;
41 private final boolean allowDecomposition;
42 private Set<String> knownConstants = Sets.newHashSet();
43 private final boolean assumeStrictThis;
44 private final boolean assumeMinimumCapture;
45 private final Supplier<String> safeNameIdSupplier;
46 private final Supplier<String> throwawayNameSupplier =
47 new Supplier<String>() {
48 private int nextId = 0;
49 @Override
50 public String get() {
51 return String.valueOf(nextId++);
52 }
53 };
54
55 /**
56 * @param allowDecomposition Whether an effort should be made to break down
57 * expressions into simpler expressions to allow functions to be injected
58 * where they would otherwise be disallowed.
59 */
…lines 60–209 unchanged (150 lines)
210 // TODO(johnlenz): Allow 'this' references to be replaced with a
211 // global 'this' object.
212 return CanInlineResult.NO;
213 }
214
215 if (mode == InliningMode.DIRECT) {
216 return canInlineReferenceDirectly(callNode, fnNode, needAliases);
217 } else {
218 return canInlineReferenceAsStatementBlock(
219 t, callNode, fnNode, needAliases);
220 }
221 }
222
…lines 223–691 unchanged (469 lines)
692 * <pre>
693 * function foo(a) { return a + a }
694 * x = foo(i++);
695 * </pre>
696 */
697 private CanInlineResult canInlineReferenceDirectly(
698 Node callNode, Node fnNode, Set<String> namesToAlias) {
699 if (!isDirectCallNodeReplacementPossible(fnNode)) {
700 return CanInlineResult.NO;
701 }
702
703 // CALL NODE: [ NAME, ARG1, ARG2, ... ]
704 Node cArg = callNode.getFirstChild().getNext();
705
706 // Functions called via 'call' and 'apply' have a this-object as
707 // the first parameter, but this is not part of the called function's
708 // parameter list.
…lines 709–714 unchanged (6 lines)
715 cArg = cArg.getNext();
716 } else {
717 // ".apply" call should be filtered before this.
718 Preconditions.checkState(!NodeUtil.isFunctionObjectApply(callNode));
719 }
720 }
721
722 Map<String, Node> args =
723 FunctionArgumentInjector.getFunctionCallParameterMap(
724 fnNode, callNode, this.throwawayNameSupplier);
725 boolean hasArgs = !args.isEmpty();
726 if (hasArgs) {
727 // Limit the inlining
728 Set<String> allNamesToAlias = Sets.newHashSet(namesToAlias);
729 FunctionArgumentInjector.maybeAddTempsForCallArguments(
730 fnNode, args, allNamesToAlias, compiler.getCodingConvention());
731 if (!allNamesToAlias.isEmpty()) {
732 return CanInlineResult.NO;
733 }
734 }
735
736 return CanInlineResult.YES;
737 }
738
739 /**
740 * Determine if inlining the function is likely to reduce the code size.
…lines 741–927 unchanged (187 lines)

Before

program
block_comment "/*\n * Copyright 2008 The Closure Compiler Authors.\n *\n * Lic"...
package_declaration
package "package"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "jscomp"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "common"
. "."
identifier "base"
. "."
identifier "Preconditions"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "common"
. "."
identifier "base"
. "."
identifier "Predicate"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "common"
. "."
identifier "base"
. "."
identifier "Predicates"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "common"
. "."
identifier "base"
. "."
identifier "Supplier"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "common"
. "."
identifier "collect"
. "."
identifier "Sets"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "jscomp"
. "."
identifier "ExpressionDecomposer"
. "."
identifier "DecompositionType"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "rhino"
. "."
identifier "Node"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "rhino"
. "."
identifier "Token"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Collection"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Map"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Set"
; ";"
block_comment "/**\n * A set of utility functions that replaces CALL with a "...
class_declaration
class "class"
identifier "FunctionInjector"
class_body
{ "{"
field_declaration
modifiers
private "private"
final "final"
type_identifier "AbstractCompiler"
variable_declarator
identifier "compiler"
; ";"
field_declaration
modifiers
private "private"
final "final"
boolean_type "boolean"
variable_declarator
identifier "allowDecomposition"
; ";"
field_declaration
modifiers
private "private"
generic_type
type_identifier "Set"
type_arguments
< "<"
type_identifier "String"
> ">"
variable_declarator
identifier "knownConstants"
= "="
method_invocation
identifier "Sets"
. "."
identifier "newHashSet"
argument_list
( "("
) ")"
; ";"
field_declaration
modifiers
private "private"
final "final"
boolean_type "boolean"
variable_declarator
identifier "assumeStrictThis"
; ";"
field_declaration
modifiers
private "private"
final "final"
boolean_type "boolean"
variable_declarator
identifier "assumeMinimumCapture"
; ";"
field_declaration
modifiers
private "private"
final "final"
generic_type
type_identifier "Supplier"
type_arguments
< "<"
type_identifier "String"
> ">"
variable_declarator
identifier "safeNameIdSupplier"
; ";"
block_comment "/**\n * @param allowDecomposition Whether an effort should "...
constructor_declaration (+99 nodes collapsed)
block_comment "/** The type of inlining to perform. */"
enum_declaration
enum "enum"
identifier "InliningMode"
enum_body
{ "{"
block_comment "/**\n * Directly replace the call expression. Only functi"...
enum_constant
identifier "DIRECT"
, ","
block_comment "/**\n * Replaces the call expression with a block of stat"...
enum_constant
identifier "BLOCK"
} "}"
block_comment "/** Holds a reference to the call node of a function call */"
class_declaration (+75 nodes collapsed)
block_comment "/**\n * In order to estimate the cost of lining, we make th"...
field_declaration
modifiers
private "private"
static "static"
final "final"
integral_type
int "int"
variable_declarator
identifier "NAME_COST_ESTIMATE"
= "="
field_access
identifier "InlineCostEstimator"
. "."
identifier "ESTIMATED_IDENTIFIER_COST"
; ";"
block_comment "/** The cost of a argument separator (a comma). */"
field_declaration
modifiers
private "private"
static "static"
final "final"
integral_type
int "int"
variable_declarator
identifier "COMMA_COST"
= "="
decimal_integer_literal "1"
; ";"
block_comment "/** The cost of the parentheses needed to make a call.*/"
field_declaration
modifiers
private "private"
static "static"
final "final"
integral_type
int "int"
variable_declarator
identifier "PAREN_COST"
= "="
decimal_integer_literal "2"
; ";"
block_comment "/**\n * @param fnName The name of this function. This eithe"...
method_declaration (+300 nodes collapsed)
block_comment "/**\n * @param t The traversal use to reach the call site."...
method_declaration
type_identifier "CanInlineResult"
identifier "canInlineReferenceToFunction"
formal_parameters (+35 nodes collapsed)
block
{ "{"
line_comment "// TODO(johnlenz): This function takes too many parameter, w"...
line_comment "// context. Modify the API to take a structure describing t"...
line_comment "// Allow direct function calls or \"fn.call\" style calls."
if_statement (+23 nodes collapsed)
line_comment "// Limit where functions that contain functions can be inlin"...
line_comment "// an inner function into another function can capture a var"...
line_comment "// a memory leak. This isn't a problem in the global scope "...
line_comment "// last until explicitly cleared."
if_statement (+66 nodes collapsed)
line_comment "// TODO(johnlenz): Add support for 'apply'"
if_statement (+30 nodes collapsed)
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "mode"
== "=="
field_access
identifier "InliningMode"
. "."
identifier "DIRECT"
) ")"
block
{ "{"
return_statement
return "return"
method_invocation
identifier "canInlineReferenceDirectly"
argument_list
( "("
identifier "callNode"
, ","
identifier "fnNode"
) ")"
; ";"
} "}"
else "else"
block
{ "{"
return_statement
return "return"
method_invocation
identifier "canInlineReferenceAsStatementBlock"
argument_list
( "("
identifier "t"
, ","
identifier "callNode"
, ","
identifier "fnNode"
, ","
identifier "needAliases"
) ")"
; ";"
} "}"
} "}"
block_comment "/**\n * Only \".call\" calls and direct calls to functions ar"...
method_declaration (+135 nodes collapsed)
block_comment "/**\n * Inline a function into the call site.\n */"
method_declaration (+89 nodes collapsed)
block_comment "/**\n * Inline a function that fulfills the requirements of"...
method_declaration (+226 nodes collapsed)
block_comment "/**\n * Supported call site types.\n */"
enum_declaration (+340 nodes collapsed)
block_comment "/**\n * Determine which, if any, of the supported types the"...
method_declaration (+326 nodes collapsed)
method_declaration (+25 nodes collapsed)
block_comment "/**\n * If required, rewrite the statement containing the c"...
method_declaration (+36 nodes collapsed)
block_comment "/**\n * Inline a function which fulfills the requirements o"...
method_declaration (+458 nodes collapsed)
block_comment "/**\n * Checks if the given function matches the criteria f"...
method_declaration (+115 nodes collapsed)
enum_declaration
enum "enum"
identifier "CanInlineResult"
enum_body
{ "{"
enum_constant
identifier "YES"
, ","
enum_constant
identifier "AFTER_PREPARATION"
, ","
enum_constant
identifier "NO"
} "}"
block_comment "/**\n * Determines whether a function can be inlined at a p"...
method_declaration (+175 nodes collapsed)
block_comment "/**\n * Determines whether a function can be inlined at a p"...
method_declaration (+420 nodes collapsed)
block_comment "/**\n * Determines whether a function can be inlined at a p"...
method_declaration
modifiers
private "private"
type_identifier "CanInlineResult"
identifier "canInlineReferenceDirectly"
formal_parameters
( "("
formal_parameter
type_identifier "Node"
identifier "callNode"
, ","
formal_parameter
type_identifier "Node"
identifier "fnNode"
) ")"
block
{ "{"
if_statement (+23 nodes collapsed)
local_variable_declaration
type_identifier "Node"
variable_declarator
identifier "block"
= "="
method_invocation
identifier "fnNode"
. "."
identifier "getLastChild"
argument_list
( "("
) ")"
; ";"
line_comment "// CALL NODE: [ NAME, ARG1, ARG2, ... ]"
local_variable_declaration
type_identifier "Node"
variable_declarator
identifier "cArg"
= "="
method_invocation
method_invocation
identifier "callNode"
. "."
identifier "getFirstChild"
argument_list
( "("
) ")"
. "."
identifier "getNext"
argument_list
( "("
) ")"
; ";"
line_comment "// Functions called via 'call' and 'apply' have a this-objec"...
line_comment "// the first parameter, but this is not part of the called f"...
line_comment "// parameter list."
if_statement (+106 nodes collapsed)
local_variable_declaration
type_identifier "Node"
variable_declarator
identifier "fnParam"
= "="
method_invocation
method_invocation
identifier "NodeUtil"
. "."
identifier "getFunctionParameters"
argument_list
( "("
identifier "fnNode"
) ")"
. "."
identifier "getFirstChild"
argument_list
( "("
) ")"
; ";"
while_statement
while "while"
parenthesized_expression
( "("
binary_expression
binary_expression
identifier "cArg"
!= "!="
null_literal "null"
|| "||"
binary_expression
identifier "fnParam"
!= "!="
null_literal "null"
) ")"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "fnParam"
!= "!="
null_literal "null"
) ")"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "cArg"
!= "!="
null_literal "null"
) ")"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
method_invocation
identifier "NodeUtil"
. "."
identifier "mayEffectMutableState"
argument_list
( "("
identifier "cArg"
, ","
identifier "compiler"
) ")"
&& "&&"
binary_expression
method_invocation
identifier "NodeUtil"
. "."
identifier "getNameReferenceCount"
argument_list
( "("
identifier "block"
, ","
method_invocation
identifier "fnParam"
. "."
identifier "getString"
argument_list
( "("
) ")"
) ")"
> ">"
decimal_integer_literal "1"
) ")"
block
{ "{"
return_statement all 2:1
return "return" all 2:1
field_access all 2:1
identifier "CanInlineResult" all 2:1
. "." all 2:1
identifier "NO" all 2:1
; ";" all 2:1
} "}"
} "}"
expression_statement
assignment_expression
identifier "fnParam"
= "="
method_invocation
identifier "fnParam"
. "."
identifier "getNext"
argument_list
( "("
) ")"
; ";"
} "}"
line_comment "// Limit the inlining"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "cArg"
!= "!="
null_literal "null"
) ")"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
method_invocation
identifier "NodeUtil"
. "."
identifier "mayHaveSideEffects"
argument_list
( "("
identifier "cArg"
, ","
identifier "compiler"
) ")"
) ")"
block
{ "{"
return_statement all 2:1
return "return" all 2:1
field_access all 2:1
identifier "CanInlineResult" all 2:1
. "." all 2:1
identifier "NO" all 2:1
; ";" all 2:1
} "}"
expression_statement
assignment_expression
identifier "cArg"
= "="
method_invocation
identifier "cArg"
. "."
identifier "getNext"
argument_list
( "("
) ")"
; ";"
} "}"
} "}"
return_statement
return "return"
field_access
identifier "CanInlineResult"
. "."
identifier "YES"
; ";"
} "}"
block_comment "/**\n * Determine if inlining the function is likely to red"...
method_declaration (+338 nodes collapsed)
block_comment "/**\n * @return Whether inlining will lower cost.\n */"
method_declaration (+170 nodes collapsed)
block_comment "/**\n * Gets an estimate of the cost in characters of makin"...
method_declaration (+125 nodes collapsed)
block_comment "/**\n * @return The difference between the function definit"...
method_declaration (+343 nodes collapsed)
block_comment "/**\n * Store the names of known constants to be used when "...
method_declaration (+49 nodes collapsed)
} "}"

After

program
block_comment "/*\n * Copyright 2008 The Closure Compiler Authors.\n *\n * Lic"...
package_declaration
package "package"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "jscomp"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "common"
. "."
identifier "base"
. "."
identifier "Preconditions"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "common"
. "."
identifier "base"
. "."
identifier "Predicate"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "common"
. "."
identifier "base"
. "."
identifier "Predicates"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "common"
. "."
identifier "base"
. "."
identifier "Supplier"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "common"
. "."
identifier "collect"
. "."
identifier "Sets"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "jscomp"
. "."
identifier "ExpressionDecomposer"
. "."
identifier "DecompositionType"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "rhino"
. "."
identifier "Node"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "rhino"
. "."
identifier "Token"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Collection"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Map"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Set"
; ";"
block_comment "/**\n * A set of utility functions that replaces CALL with a "...
class_declaration
class "class"
identifier "FunctionInjector"
class_body
{ "{"
field_declaration
modifiers
private "private"
final "final"
type_identifier "AbstractCompiler"
variable_declarator
identifier "compiler"
; ";"
field_declaration
modifiers
private "private"
final "final"
boolean_type "boolean"
variable_declarator
identifier "allowDecomposition"
; ";"
field_declaration
modifiers
private "private"
generic_type
type_identifier "Set"
type_arguments
< "<"
type_identifier "String"
> ">"
variable_declarator
identifier "knownConstants"
= "="
method_invocation
identifier "Sets"
. "."
identifier "newHashSet"
argument_list
( "("
) ")"
; ";"
field_declaration
modifiers
private "private"
final "final"
boolean_type "boolean"
variable_declarator
identifier "assumeStrictThis"
; ";"
field_declaration
modifiers
private "private"
final "final"
boolean_type "boolean"
variable_declarator
identifier "assumeMinimumCapture"
; ";"
field_declaration
modifiers
private "private"
final "final"
generic_type
type_identifier "Supplier"
type_arguments
< "<"
type_identifier "String"
> ">"
variable_declarator
identifier "safeNameIdSupplier"
; ";"
field_declaration
modifiers
private "private"
final "final"
generic_type
type_identifier "Supplier"
type_arguments
< "<"
type_identifier "String"
> ">"
variable_declarator
identifier "throwawayNameSupplier"
= "="
object_creation_expression
new "new"
generic_type
type_identifier "Supplier"
type_arguments
< "<"
type_identifier "String"
> ">"
argument_list
( "("
) ")"
class_body
{ "{"
field_declaration
modifiers
private "private"
integral_type
int "int"
variable_declarator
identifier "nextId"
= "="
decimal_integer_literal "0"
; ";"
method_declaration
modifiers
marker_annotation
@ "@"
identifier "Override"
public "public"
type_identifier "String"
identifier "get"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
method_invocation
identifier "String"
. "."
identifier "valueOf"
argument_list
( "("
update_expression
identifier "nextId"
++ "++"
) ")"
; ";"
} "}"
} "}"
; ";"
block_comment "/**\n * @param allowDecomposition Whether an effort should "...
constructor_declaration (+99 nodes collapsed)
block_comment "/** The type of inlining to perform. */"
enum_declaration
enum "enum"
identifier "InliningMode"
enum_body
{ "{"
block_comment "/**\n * Directly replace the call expression. Only functi"...
enum_constant
identifier "DIRECT"
, ","
block_comment "/**\n * Replaces the call expression with a block of stat"...
enum_constant
identifier "BLOCK"
} "}"
block_comment "/** Holds a reference to the call node of a function call */"
class_declaration (+75 nodes collapsed)
block_comment "/**\n * In order to estimate the cost of lining, we make th"...
field_declaration
modifiers
private "private"
static "static"
final "final"
integral_type
int "int"
variable_declarator
identifier "NAME_COST_ESTIMATE"
= "="
field_access
identifier "InlineCostEstimator"
. "."
identifier "ESTIMATED_IDENTIFIER_COST"
; ";"
block_comment "/** The cost of a argument separator (a comma). */"
field_declaration
modifiers
private "private"
static "static"
final "final"
integral_type
int "int"
variable_declarator
identifier "COMMA_COST"
= "="
decimal_integer_literal "1"
; ";"
block_comment "/** The cost of the parentheses needed to make a call.*/"
field_declaration
modifiers
private "private"
static "static"
final "final"
integral_type
int "int"
variable_declarator
identifier "PAREN_COST"
= "="
decimal_integer_literal "2"
; ";"
block_comment "/**\n * @param fnName The name of this function. This eithe"...
method_declaration (+300 nodes collapsed)
block_comment "/**\n * @param t The traversal use to reach the call site."...
method_declaration
type_identifier "CanInlineResult"
identifier "canInlineReferenceToFunction"
formal_parameters (+35 nodes collapsed)
block
{ "{"
line_comment "// TODO(johnlenz): This function takes too many parameter, w"...
line_comment "// context. Modify the API to take a structure describing t"...
line_comment "// Allow direct function calls or \"fn.call\" style calls."
if_statement (+23 nodes collapsed)
line_comment "// Limit where functions that contain functions can be inlin"...
line_comment "// an inner function into another function can capture a var"...
line_comment "// a memory leak. This isn't a problem in the global scope "...
line_comment "// last until explicitly cleared."
if_statement (+66 nodes collapsed)
line_comment "// TODO(johnlenz): Add support for 'apply'"
if_statement (+30 nodes collapsed)
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "mode"
== "=="
field_access
identifier "InliningMode"
. "."
identifier "DIRECT"
) ")"
block
{ "{"
return_statement
return "return"
method_invocation
identifier "canInlineReferenceDirectly"
argument_list
( "("
identifier "callNode"
, ","
identifier "fnNode"
, ","
identifier "needAliases"
) ")"
; ";"
} "}"
else "else"
block
{ "{"
return_statement
return "return"
method_invocation
identifier "canInlineReferenceAsStatementBlock"
argument_list
( "("
identifier "t"
, ","
identifier "callNode"
, ","
identifier "fnNode"
, ","
identifier "needAliases"
) ")"
; ";"
} "}"
} "}"
block_comment "/**\n * Only \".call\" calls and direct calls to functions ar"...
method_declaration (+135 nodes collapsed)
block_comment "/**\n * Inline a function into the call site.\n */"
method_declaration (+89 nodes collapsed)
block_comment "/**\n * Inline a function that fulfills the requirements of"...
method_declaration (+226 nodes collapsed)
block_comment "/**\n * Supported call site types.\n */"
enum_declaration (+340 nodes collapsed)
block_comment "/**\n * Determine which, if any, of the supported types the"...
method_declaration (+326 nodes collapsed)
method_declaration (+25 nodes collapsed)
block_comment "/**\n * If required, rewrite the statement containing the c"...
method_declaration (+36 nodes collapsed)
block_comment "/**\n * Inline a function which fulfills the requirements o"...
method_declaration (+458 nodes collapsed)
block_comment "/**\n * Checks if the given function matches the criteria f"...
method_declaration (+115 nodes collapsed)
enum_declaration
enum "enum"
identifier "CanInlineResult"
enum_body
{ "{"
enum_constant
identifier "YES"
, ","
enum_constant
identifier "AFTER_PREPARATION"
, ","
enum_constant
identifier "NO"
} "}"
block_comment "/**\n * Determines whether a function can be inlined at a p"...
method_declaration (+175 nodes collapsed)
block_comment "/**\n * Determines whether a function can be inlined at a p"...
method_declaration (+420 nodes collapsed)
block_comment "/**\n * Determines whether a function can be inlined at a p"...
method_declaration
modifiers
private "private"
type_identifier "CanInlineResult"
identifier "canInlineReferenceDirectly"
formal_parameters
( "("
formal_parameter
type_identifier "Node"
identifier "callNode"
, ","
formal_parameter
type_identifier "Node"
identifier "fnNode"
, ","
formal_parameter
generic_type
type_identifier "Set"
type_arguments
< "<"
type_identifier "String"
> ">"
identifier "namesToAlias"
) ")"
block
{ "{"
if_statement (+23 nodes collapsed)
line_comment "// CALL NODE: [ NAME, ARG1, ARG2, ... ]"
local_variable_declaration
type_identifier "Node"
variable_declarator
identifier "cArg"
= "="
method_invocation
method_invocation
identifier "callNode"
. "."
identifier "getFirstChild"
argument_list
( "("
) ")"
. "."
identifier "getNext"
argument_list
( "("
) ")"
; ";"
line_comment "// Functions called via 'call' and 'apply' have a this-objec"...
line_comment "// the first parameter, but this is not part of the called f"...
line_comment "// parameter list."
if_statement (+106 nodes collapsed)
local_variable_declaration
generic_type
type_identifier "Map"
type_arguments
< "<"
type_identifier "String"
, ","
type_identifier "Node"
> ">"
variable_declarator
identifier "args"
= "="
method_invocation
identifier "FunctionArgumentInjector"
. "."
identifier "getFunctionCallParameterMap"
argument_list
( "("
identifier "fnNode"
, ","
identifier "callNode"
, ","
field_access
this "this"
. "."
identifier "throwawayNameSupplier"
) ")"
; ";"
local_variable_declaration
boolean_type "boolean"
variable_declarator
identifier "hasArgs"
= "="
unary_expression
! "!"
method_invocation
identifier "args"
. "."
identifier "isEmpty"
argument_list
( "("
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
identifier "hasArgs"
) ")"
block
{ "{"
line_comment "// Limit the inlining"
local_variable_declaration
generic_type
type_identifier "Set"
type_arguments
< "<"
type_identifier "String"
> ">"
variable_declarator
identifier "allNamesToAlias"
= "="
method_invocation
identifier "Sets"
. "."
identifier "newHashSet"
argument_list
( "("
identifier "namesToAlias"
) ")"
; ";"
expression_statement
method_invocation
identifier "FunctionArgumentInjector"
. "."
identifier "maybeAddTempsForCallArguments"
argument_list
( "("
identifier "fnNode"
, ","
identifier "args"
, ","
identifier "allNamesToAlias"
, ","
method_invocation
identifier "compiler"
. "."
identifier "getCodingConvention"
argument_list
( "("
) ")"
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
unary_expression
! "!"
method_invocation
identifier "allNamesToAlias"
. "."
identifier "isEmpty"
argument_list
( "("
) ")"
) ")"
block
{ "{"
return_statement all 2:1
return "return" all 2:1
field_access all 2:1
identifier "CanInlineResult" all 2:1
. "." all 2:1
identifier "NO" all 2:1
; ";" all 2:1
} "}"
} "}"
return_statement
return "return"
field_access
identifier "CanInlineResult"
. "."
identifier "YES"
; ";"
} "}"
block_comment "/**\n * Determine if inlining the function is likely to red"...
method_declaration (+338 nodes collapsed)
block_comment "/**\n * @return Whether inlining will lower cost.\n */"
method_declaration (+170 nodes collapsed)
block_comment "/**\n * Gets an estimate of the cost in characters of makin"...
method_declaration (+125 nodes collapsed)
block_comment "/**\n * @return The difference between the function definit"...
method_declaration (+343 nodes collapsed)
block_comment "/**\n * Store the names of known constants to be used when "...
method_declaration (+49 nodes collapsed)
} "}"