From 9669e0fe941318a729c363a570121a8d110ce27a Mon Sep 17 00:00:00 2001 From: Justin Viiret Date: Fri, 10 Jun 2016 11:49:08 +1000 Subject: [PATCH] eod: remove forced sparse iter optimization --- src/rose/rose.h | 39 +------------------------------- src/rose/rose_build_bytecode.cpp | 16 ++++--------- src/rose/rose_dump.cpp | 1 - src/rose/rose_internal.h | 1 - 4 files changed, 6 insertions(+), 51 deletions(-) diff --git a/src/rose/rose.h b/src/rose/rose.h index e90d2f21..d79c2f0c 100644 --- a/src/rose/rose.h +++ b/src/rose/rose.h @@ -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); } diff --git a/src/rose/rose_build_bytecode.cpp b/src/rose/rose_build_bytecode.cpp index b37b259a..5d235fca 100644 --- a/src/rose/rose_build_bytecode.cpp +++ b/src/rose/rose_build_bytecode.cpp @@ -3989,7 +3989,7 @@ vector makeEodAnchorProgram(RoseBuildImpl &build, * Returns the pair (program offset, sparse iter offset). */ static -pair 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 buildEodAnchorProgram(RoseBuildImpl &build, build_context &bc) { if (predProgramLists.empty()) { DEBUG_PRINTF("no eod anchored roles\n"); - return {0, 0}; + return 0; } vector 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 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 activeLeftIter; buildActiveLeftIter(leftInfoTable, activeLeftIter); @@ -4511,7 +4506,6 @@ aligned_unique_ptr RoseBuildImpl::buildFinalEngine(u32 minWidth) { engine->eodProgramOffset = eodProgramOffset; engine->eodIterProgramOffset = eodIterProgramOffset; - engine->eodIterOffset = eodIterOffset; engine->lastByteHistoryIterOffset = lastByteOffset; diff --git a/src/rose/rose_dump.cpp b/src/rose/rose_dump.cpp index 59f7f751..8de33a44 100644 --- a/src/rose/rose_dump.cpp +++ b/src/rose/rose_dump.cpp @@ -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); diff --git a/src/rose/rose_internal.h b/src/rose/rose_internal.h index 2e921542..faab45f7 100644 --- a/src/rose/rose_internal.h +++ b/src/rose/rose_internal.h @@ -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