Class J2clPropertyInlinerPass

java.lang.Object
com.google.javascript.jscomp.J2clPropertyInlinerPass
All Implemented Interfaces:
CompilerPass

public class J2clPropertyInlinerPass extends Object implements CompilerPass
This pass targets J2CL output. It looks for static get and set methods defined within a class that match the signature of J2CL static fields and inlines them at their call sites. This is done for performance reasons since getter and setter accesses are slower than regular field accesses.

This will be done by looking at all property accesses and determining if they have a corresponding get or set method on the property qualifiers definition. Some caveats:

  • Avoid inlining if the property is set using compound assignments.
  • Avoid inlining if the property is incremented using ++ or --
Since this pass only really works after the AggressiveInlineAliases pass has run, we have to look for Object.defineProperties instead of es6 get and set nodes since es6 transpilation has already occurred if the language out is ES5.
  • Constructor Details

    • J2clPropertyInlinerPass

      public J2clPropertyInlinerPass(AbstractCompiler compiler)
  • Method Details

    • process

      public void process(Node externs, Node root)
      Description copied from interface: CompilerPass
      Process the JS with root node root. Can modify the contents of each Node tree
      Specified by:
      process in interface CompilerPass
      Parameters:
      externs - Top of external JS tree
      root - Top of JS tree