You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A simple loop is non-reentrant and branchless, but each implemented optimization for simple loops only depends on one of these properties. We should therefore extend these optimizations to such loops that satisfy one property but not the other.
This means that the parser has to detect non-reentrancy and branchlessness independently from each other and set appropriate flags on the loop nodes. Afterwards, the matcher has to be changed to apply an optimization not just to simple loops but also when the flag for the required property is set.
It should certainly be worth it to implement this for branchless-but-reentrant loops, as this extends #5939's stack growth optimization to many more loops such as [^a]+ in the regex (a[^a]+)+. This might greatly reduce stack usage and thus time spent on reallocating the stack frame buffer, but also makes it less likely that regex matching hits the stack limit.