Skip to content

FlatExpression: optimize representation #533

@dadhi

Description

@dadhi

To prepare FE for #531, #530 and going forward we need:

  • Reduce Constant node inplace value from 8 to 4, bigger values are stored as boxed Obj. The free 4 bytes should be used to add back NextIdx to simplify chaining, and to store NodeType to simplify constant conditional logic
  • Parameter nodes should be of 2 types, 1st is Parameter declaration node, 2nd is Parameter usage node. Param decl node should use its ChildIdx to point to the lambda or block where it declared and use ChildCount to store pos of the node in lambda or block (so we can simplify comparison of the params/vars by their scope and position). Those data should be written to Parameter (decl) node in tje lambda or block method. If the data is already there it means the declared same var twice which is error. When passing the Parameter nodr index to other expr factory methods - we need to create a Param usage node for each pass. Parsm usage node ChildIdx should be the Param decl index. The Type should and the Name should be the same to avoif index chaising for trivisl checks.
  • General change - the NextIdx for every type of node in the last node in the chain sjould point to the parent/owner expression to allow to reach the parent from its children. To enable stop for loops and check we need to use one bit in those meta bits after NodeType.
  • Genersl perf - Avoid exceptions with Try... methods returning bool result or when impossible use Throw static helpers introduced by modern .net and create such wrappers for older plats - avoidance of bare throw will allow inlining of the method.
  • Genetal perf - Move the bounds check to api surface and avoid checking them every time with SmallList indexer - use GetSurePresentRef instead, etc. Add Debug.Assert where needed to be on the safe side.

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions