Reviewers: metaweta,

Description:
For my current testcase, this is about a 10% speedup to the cajoler.

- The rewriter relies extensively on a marker "synthetic", which
  is stored as a key-value pair in a HashMap.  The map lookups
  have a noticeable cost.

  This change adds a boolean "synthetic" to AbstractParseTreeNode
  and uses that instead of the HashMap.  This is the largest
  speedup in this change.

- Rewriter#expand will pre-filter rules in a ruleset based on
  specific nodetype.  So, it knows that when it's examining a
  Declaration node, it doesn't have to try running a rule that
  can only match AssignOperation.  It determines a rule's
  matchable nodetype by parsing the rule's "matches" attribute.

  Some rules do not have a parseable "matches", because the match
  condition is not expressible with quasi syntax, so these rules
  are always checked against every nodetype, even though they
  might apply to just a specific nodetype.

  This change adds another attribute "matchNode", which lets us
  specify a nodetype that the rule must match.

- The nodetype SpecialOperation represents several semantically
  different javascript operators, and this interferes with the
  rule filtering in Rewriter#expand.  For instance, a rule that
  matches "@v.@p" is a SpecialOperation nodetype, which means the
  rule is also tried against the "delete" operator, the comma
  operator, etc.

  This change adds another type of rule pre-filter that looks at
  the specific operator being matched.

Please review this at http://codereview.appspot.com/5486048/

Affected files:
  M     build.xml
  M     src/com/google/caja/lang/css/Partitions.java
  M     src/com/google/caja/parser/AbstractParseTreeNode.java
  M     src/com/google/caja/parser/js/Operator.java
  M     src/com/google/caja/parser/js/ReturnStmt.java
  M     src/com/google/caja/parser/js/SyntheticNodes.java
  M     src/com/google/caja/parser/quasiliteral/ES53Rewriter.java
M src/com/google/caja/parser/quasiliteral/IllegalReferenceCheckRewriter.java
  A     src/com/google/caja/parser/quasiliteral/NodeTypeFilter.java
  M     src/com/google/caja/parser/quasiliteral/NonAsciiCheckVisitor.java
  M     src/com/google/caja/parser/quasiliteral/QuasiBuilder.java
  A     src/com/google/caja/parser/quasiliteral/QuasiCache.java
  M     src/com/google/caja/parser/quasiliteral/Rewriter.java
  M     src/com/google/caja/parser/quasiliteral/Rule.java
  M     src/com/google/caja/parser/quasiliteral/RuleChain.java
  M     src/com/google/caja/parser/quasiliteral/RuleDescription.java
  A     src/com/google/caja/parser/quasiliteral/RuleFilter.java
  M     src/com/google/caja/parser/quasiliteral/Scope.java
  M     src/com/google/caja/parser/quasiliteral/SimpleQuasiNode.java
  A     src/com/google/caja/parser/quasiliteral/SpecialOpFilter.java
  M     src/com/google/caja/parser/quasiliteral/SyntheticRuleSet.java
  M     src/com/google/caja/parser/quasiliteral/TrailingUnderscoresHole.java
  M     tests/com/google/caja/parser/ParseTreeNodeTest.java


Reply via email to