mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
8c36e227e7
This implements a memory optimization for AST nodes that stores location information (lineno, filename_index) only in head nodes rather than in every node, reducing memory usage for structure nodes. Key changes: - Split node types: mrb_ast_node (structure nodes without location), mrb_ast_head_node (with location info). Sizes are platform-dependent: 8/12 bytes on 32-bit, 16/24 bytes on 64-bit platforms - Separate allocation: cons() creates structure nodes, cons_head() creates head nodes with location information - Node recycling: all nodes are recycled when freed, but only smaller structure nodes are reused from the free list to maintain type safety - Updated macro: added headn() for consistent head node casting - Removed NODE_LINENO macro: eliminated redundant location copying since head-only optimization already provides adequate location info - Fixed codegen to properly access location fields via head node casts This optimization reduces AST memory usage while preserving all debugging and location information functionality. Co-authored-by: Claude <noreply@anthropic.com>