Add data-oriented flat expression tree (ExprTree/ExprNode) with LightExpression conversion#519
Closed
Copilot wants to merge 3 commits into
Closed
Add data-oriented flat expression tree (ExprTree/ExprNode) with LightExpression conversion#519Copilot wants to merge 3 commits into
Copilot wants to merge 3 commits into
Conversation
…onTests Agent-Logs-Url: https://github.com/dadhi/FastExpressionCompiler/sessions/106c0b3a-7cd7-4eb7-a391-c8ac412e1222 Co-authored-by: dadhi <39516+dadhi@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dadhi/FastExpressionCompiler/sessions/106c0b3a-7cd7-4eb7-a391-c8ac412e1222 Co-authored-by: dadhi <39516+dadhi@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Optimize data-oriented representation of Expression for serialization
Add data-oriented flat expression tree (ExprTree/ExprNode) with LightExpression conversion
Apr 19, 2026
Owner
|
Wrong |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements a compact, struct-based, stack-friendly representation of expression trees as described in the issue — suitable for serialization, structural equality, and future compiler integration.
Core design
ExprNode— a single node withType,Obj(payload), and a packedulong _data:Extraencodes auxiliary per-type data (lambda param count, block var count, goto kind, try variant, by-ref flag, instance flag).ExprTree— the flat container:First 16 nodes and 16 child-pool slots live on the stack; larger trees spill to the heap.
Non-intrusive child pool
Uses a flat
ChildPool(array ofushortindices) instead of the intrusiveNextSiblingIdxapproach sketched in the issue. This avoids corruption when the same node (e.g. aParameter) appears as a child of multiple parents — the common case for lambda parameters used in the body.API
Factory methods on
ExprTreereturnushortnode indices:Covers all expression types supported by LightExpression: constants, parameters/variables, constructors, method calls, field/property/index access, all binary and unary ops, lambda, block, conditional, loop, try/catch/finally/fault, label, goto/return/break/continue, switch, type tests, default, invoke, array init/bounds, member init, list init.
Conversion to LightExpression
ToLightExpression(ushort)recursively converts with aParameterExpression[]cache (indexed by node index) to ensure the sameParameterExpressioninstance is reused across all references to the same parameter node — required by the LightExpression/FEC compiler.Not wired into the FEC compiler directly yet; conversion via
ToLightExpressionenables full test coverage of all expression shapes.