mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
Account for multi-dfa case with ANCHORED_DELAY
Specifically, we must set build_context::floatingMinLiteralMatchOffset to 1 when thew anchored table contains multiple DFAs, as they can produce unordered matches. This check was already been done, but too late to affect the generation of ANCHORED_DELAY instructions.
This commit is contained in:
parent
d7c8ffc7fd
commit
69682ed263
@ -235,13 +235,9 @@ u32 anchoredStateSize(const anchored_matcher_info *atable) {
|
|||||||
return curr->state_offset + nfa->scratchStateSize;
|
return curr->state_offset + nfa->scratchStateSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool anchoredIsMulti(const RoseEngine &engine) {
|
bool anchoredIsMulti(const anchored_matcher_info *atable) {
|
||||||
const struct anchored_matcher_info *curr
|
return atable && atable->next_offset;
|
||||||
= (const anchored_matcher_info *)getALiteralMatcher(&engine);
|
}
|
||||||
|
|
||||||
return curr && curr->next_offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -51,7 +51,12 @@ aligned_unique_ptr<anchored_matcher_info>
|
|||||||
buildAnchoredAutomataMatcher(RoseBuildImpl &build, size_t *asize);
|
buildAnchoredAutomataMatcher(RoseBuildImpl &build, size_t *asize);
|
||||||
|
|
||||||
u32 anchoredStateSize(const anchored_matcher_info *atable);
|
u32 anchoredStateSize(const anchored_matcher_info *atable);
|
||||||
bool anchoredIsMulti(const RoseEngine &engine);
|
|
||||||
|
/**
|
||||||
|
* \brief True if there is an anchored matcher and it consists of multiple
|
||||||
|
* DFAs.
|
||||||
|
*/
|
||||||
|
bool anchoredIsMulti(const anchored_matcher_info *atable);
|
||||||
|
|
||||||
#define ANCHORED_FAIL 0
|
#define ANCHORED_FAIL 0
|
||||||
#define ANCHORED_SUCCESS 1
|
#define ANCHORED_SUCCESS 1
|
||||||
|
@ -2243,7 +2243,15 @@ void enforceEngineSizeLimit(const NFA *n, const size_t nfa_size, const Grey &gre
|
|||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
u32 findMinFloatingLiteralMatch(const RoseBuildImpl &build) {
|
u32 findMinFloatingLiteralMatch(const RoseBuildImpl &build,
|
||||||
|
const anchored_matcher_info *atable) {
|
||||||
|
if (anchoredIsMulti(atable)) {
|
||||||
|
DEBUG_PRINTF("multiple anchored dfas\n");
|
||||||
|
/* We must regard matches from other anchored tables as unordered, as
|
||||||
|
* we do for floating matches. */
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
const RoseGraph &g = build.g;
|
const RoseGraph &g = build.g;
|
||||||
u32 minWidth = ROSE_BOUND_INF;
|
u32 minWidth = ROSE_BOUND_INF;
|
||||||
for (auto v : vertices_range(g)) {
|
for (auto v : vertices_range(g)) {
|
||||||
@ -4036,7 +4044,8 @@ aligned_unique_ptr<RoseEngine> RoseBuildImpl::buildFinalEngine(u32 minWidth) {
|
|||||||
aligned_unique_ptr<HWLM> sbtable = buildSmallBlockMatcher(*this, &sbsize);
|
aligned_unique_ptr<HWLM> sbtable = buildSmallBlockMatcher(*this, &sbsize);
|
||||||
|
|
||||||
build_context bc;
|
build_context bc;
|
||||||
bc.floatingMinLiteralMatchOffset = findMinFloatingLiteralMatch(*this);
|
bc.floatingMinLiteralMatchOffset =
|
||||||
|
findMinFloatingLiteralMatch(*this, atable.get());
|
||||||
|
|
||||||
// Build NFAs
|
// Build NFAs
|
||||||
set<u32> no_retrigger_queues;
|
set<u32> no_retrigger_queues;
|
||||||
@ -4363,12 +4372,8 @@ aligned_unique_ptr<RoseEngine> RoseBuildImpl::buildFinalEngine(u32 minWidth) {
|
|||||||
write_out(&engine->state_init, (char *)engine.get(), state_scatter,
|
write_out(&engine->state_init, (char *)engine.get(), state_scatter,
|
||||||
state_scatter_aux_offset);
|
state_scatter_aux_offset);
|
||||||
|
|
||||||
if (anchoredIsMulti(*engine)) {
|
if (anchoredIsMulti(atable.get())) {
|
||||||
DEBUG_PRINTF("multiple anchored dfas\n");
|
|
||||||
engine->maxSafeAnchoredDROffset = 1;
|
engine->maxSafeAnchoredDROffset = 1;
|
||||||
engine->floatingMinLiteralMatchOffset = 1; /* regard matches from other
|
|
||||||
anchored tables as
|
|
||||||
floating as unordered. */
|
|
||||||
} else {
|
} else {
|
||||||
/* overly conservative, really need the min offset of non dr anchored
|
/* overly conservative, really need the min offset of non dr anchored
|
||||||
matches */
|
matches */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user