Attribute alias optimization

Issue #206 new
Jesper Öqvist created an issue

It is not uncommon to create one attribute that acts as an alias for another attribute, for example:

syn boolean A.modified() = isModifiedInScope();

Using the alias attribute results in an unnecessary call, which is solved by caching at the cost of extra memory used for the cache value.

It would be possible for JastAdd to detect when an attribute equation is just calling another attribute, and in that case improve the code generation slightly by reusing the cache fields for the original attribute and calling the original _compute-method. This makes the cost of calling the alias attribute equal to the cost of calling the original attribute.

Some things to consider if this is implemented:

  • Special care must be taken to ensure that the attributes affected by the optimization really are aliases and that all equations for the attribute are identical.
  • Aliases could work for not only attributes but also would work well for reference attributes that provide aliases to child nodes. For example syn Expr Binary.left() = getLeftOperand().

Comments (1)

  1. Log in to comment