Skip to content
  • Damien George's avatar
    py/grammar: Group no-compile grammar rules together to shrink tables. · 71019ae4
    Damien George authored
    Grammar rules have 2 variants: ones that are attached to a specific
    compile function which is called to compile that grammar node, and ones
    that don't have a compile function and are instead just inspected to see
    what form they take.
    
    In the compiler there is a table of all grammar rules, with each entry
    having a pointer to the associated compile function.  Those rules with no
    compile function have a null pointer.  There are 120 such rules, so that's
    120 words of essentially wasted code space.
    
    By grouping together the compile vs no-compile rules we can put all the
    no-compile rules at the end of the list of rules, and then we don't need
    to store the null pointers.  We just have a truncated table and it's
    guaranteed that when indexing this table we only index the first half,
    the half with populated pointers.
    
    This patch implements such a grouping by having a specific macro for the
    compile vs no-compile grammar rules (DEF_RULE vs DEF_RULE_NC).  It saves
    around 460 bytes of code on 32-bit archs.
    71019ae4