Skip to content

<regex>: Extend some optimizations for simple loops to branchless but reentrant and branching but non-reentrant loops #5957

@muellerj2

Description

@muellerj2

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    performanceMust go fasterregexmeow is a substring of homeowner

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions