mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 13:07:46 +00:00
LibRegex: Add a basic optimization pass
This currently tries to convert forking loops to atomic groups, and unify the left side of alternations.
This commit is contained in:
parent
913382734c
commit
246ab432ff
9 changed files with 677 additions and 24 deletions
|
@ -24,6 +24,15 @@
|
|||
|
||||
namespace regex {
|
||||
|
||||
namespace Detail {
|
||||
|
||||
struct Block {
|
||||
size_t start;
|
||||
size_t end;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
static constexpr const size_t c_max_recursion = 5000;
|
||||
static constexpr const size_t c_match_preallocation_count = 0;
|
||||
|
||||
|
@ -217,6 +226,12 @@ public:
|
|||
RegexResult result = matcher->match(views, AllOptions { regex_options.value_or({}) } | AllFlags::SkipSubExprResults);
|
||||
return result.success;
|
||||
}
|
||||
|
||||
private:
|
||||
void run_optimization_passes();
|
||||
using BasicBlockList = Vector<Detail::Block>;
|
||||
BasicBlockList split_basic_blocks();
|
||||
void attempt_rewrite_loops_as_atomic_groups(BasicBlockList const&);
|
||||
};
|
||||
|
||||
// free standing functions for match, search and has_match
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue