mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-07-12 21:44:44 +03:00
eod: remove forced sparse iter optimization
This commit is contained in:
parent
7a7dff5b70
commit
9669e0fe94
@ -43,39 +43,6 @@ void roseBlockEodExec(const struct RoseEngine *t, u64a offset,
|
||||
struct hs_scratch *scratch);
|
||||
void roseBlockExec_i(const struct RoseEngine *t, struct hs_scratch *scratch);
|
||||
|
||||
static really_inline
|
||||
int roseBlockHasEodWork(const struct RoseEngine *t,
|
||||
struct hs_scratch *scratch) {
|
||||
if (t->ematcherOffset) {
|
||||
DEBUG_PRINTF("eod matcher to run\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (t->eodProgramOffset) {
|
||||
DEBUG_PRINTF("has eod program\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
void *state = scratch->core_info.state;
|
||||
if (mmbit_any(getActiveLeafArray(t, state), t->activeArrayCount)) {
|
||||
DEBUG_PRINTF("active outfix/suffix engines\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (t->eodIterOffset) {
|
||||
u32 idx;
|
||||
const struct mmbit_sparse_iter *it = getByOffset(t, t->eodIterOffset);
|
||||
struct mmbit_sparse_state si_state[MAX_SPARSE_ITER_STATES];
|
||||
if (mmbit_sparse_iter_begin(getRoleState(state), t->rolesWithStateCount,
|
||||
&idx, it, si_state) != MMB_INVALID) {
|
||||
DEBUG_PRINTF("eod iter has states on\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* assumes core_info in scratch has been init to point to data */
|
||||
static really_inline
|
||||
void roseBlockExec(const struct RoseEngine *t, struct hs_scratch *scratch) {
|
||||
@ -102,6 +69,7 @@ void roseBlockExec(const struct RoseEngine *t, struct hs_scratch *scratch) {
|
||||
roseBlockExec_i(t, scratch);
|
||||
|
||||
if (!t->requiresEodCheck) {
|
||||
DEBUG_PRINTF("no eod check required\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -110,11 +78,6 @@ void roseBlockExec(const struct RoseEngine *t, struct hs_scratch *scratch) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!roseBlockHasEodWork(t, scratch)) {
|
||||
DEBUG_PRINTF("no eod work\n");
|
||||
return;
|
||||
}
|
||||
|
||||
roseBlockEodExec(t, length, scratch);
|
||||
}
|
||||
|
||||
|
@ -3989,7 +3989,7 @@ vector<RoseInstruction> makeEodAnchorProgram(RoseBuildImpl &build,
|
||||
* Returns the pair (program offset, sparse iter offset).
|
||||
*/
|
||||
static
|
||||
pair<u32, u32> buildEodAnchorProgram(RoseBuildImpl &build, build_context &bc) {
|
||||
u32 writeEodAnchorProgram(RoseBuildImpl &build, build_context &bc) {
|
||||
const RoseGraph &g = build.g;
|
||||
|
||||
// pred state id -> list of programs
|
||||
@ -4030,18 +4030,15 @@ pair<u32, u32> buildEodAnchorProgram(RoseBuildImpl &build, build_context &bc) {
|
||||
|
||||
if (predProgramLists.empty()) {
|
||||
DEBUG_PRINTF("no eod anchored roles\n");
|
||||
return {0, 0};
|
||||
return 0;
|
||||
}
|
||||
|
||||
vector<RoseInstruction> program;
|
||||
|
||||
// Note: we force the use of a sparse iterator for the EOD program so we
|
||||
// can easily guard EOD execution at runtime.
|
||||
u32 iter_offset = addPredBlocks(bc, predProgramLists, program, true);
|
||||
addPredBlocks(bc, predProgramLists, program, false);
|
||||
|
||||
assert(program.size() > 1);
|
||||
applyFinalSpecialisation(program);
|
||||
return {writeProgram(bc, program), iter_offset};
|
||||
return writeProgram(bc, program);
|
||||
}
|
||||
|
||||
static
|
||||
@ -4311,9 +4308,7 @@ aligned_unique_ptr<RoseEngine> RoseBuildImpl::buildFinalEngine(u32 minWidth) {
|
||||
buildLiteralPrograms(*this, bc);
|
||||
|
||||
u32 eodProgramOffset = writeEodProgram(*this, bc, eodNfaIterOffset);
|
||||
u32 eodIterProgramOffset;
|
||||
u32 eodIterOffset;
|
||||
tie(eodIterProgramOffset, eodIterOffset) = buildEodAnchorProgram(*this, bc);
|
||||
u32 eodIterProgramOffset = writeEodAnchorProgram(*this, bc);
|
||||
|
||||
vector<mmbit_sparse_iter> activeLeftIter;
|
||||
buildActiveLeftIter(leftInfoTable, activeLeftIter);
|
||||
@ -4511,7 +4506,6 @@ aligned_unique_ptr<RoseEngine> RoseBuildImpl::buildFinalEngine(u32 minWidth) {
|
||||
|
||||
engine->eodProgramOffset = eodProgramOffset;
|
||||
engine->eodIterProgramOffset = eodIterProgramOffset;
|
||||
engine->eodIterOffset = eodIterOffset;
|
||||
|
||||
engine->lastByteHistoryIterOffset = lastByteOffset;
|
||||
|
||||
|
@ -1026,7 +1026,6 @@ void roseDumpStructRaw(const RoseEngine *t, FILE *f) {
|
||||
DUMP_U32(t, lookaroundReachOffset);
|
||||
DUMP_U32(t, eodProgramOffset);
|
||||
DUMP_U32(t, eodIterProgramOffset);
|
||||
DUMP_U32(t, eodIterOffset);
|
||||
DUMP_U32(t, lastByteHistoryIterOffset);
|
||||
DUMP_U32(t, minWidth);
|
||||
DUMP_U32(t, minWidthExcludingBoundaries);
|
||||
|
@ -378,7 +378,6 @@ struct RoseEngine {
|
||||
|
||||
u32 eodProgramOffset; //!< Unconditional EOD program, otherwise 0.
|
||||
u32 eodIterProgramOffset; // or 0 if no eod iterator program
|
||||
u32 eodIterOffset; // offset to EOD sparse iter or 0 if none
|
||||
|
||||
u32 lastByteHistoryIterOffset; // if non-zero
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user