mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-07-14 06:24:43 +03:00
move eod iter program into general eod program
This commit is contained in:
parent
39461cc806
commit
78e4332a8b
@ -46,13 +46,6 @@
|
|||||||
#include "util/fatbit.h"
|
#include "util/fatbit.h"
|
||||||
#include "util/multibit.h"
|
#include "util/multibit.h"
|
||||||
|
|
||||||
static rose_inline
|
|
||||||
hwlmcb_rv_t roseRunProgram(const struct RoseEngine *t,
|
|
||||||
struct hs_scratch *scratch, u32 programOffset,
|
|
||||||
u64a som, u64a end, size_t match_len,
|
|
||||||
char in_anchored, char in_catchup, char from_mpv,
|
|
||||||
char skip_mpv_catchup);
|
|
||||||
|
|
||||||
static rose_inline
|
static rose_inline
|
||||||
int roseCheckBenefits(const struct core_info *ci, u64a end, u32 mask_rewind,
|
int roseCheckBenefits(const struct core_info *ci, u64a end, u32 mask_rewind,
|
||||||
const u8 *and_mask, const u8 *exp_mask) {
|
const u8 *and_mask, const u8 *exp_mask) {
|
||||||
@ -901,30 +894,6 @@ hwlmcb_rv_t roseSuffixesEod(const struct RoseEngine *rose,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static rose_inline
|
static rose_inline
|
||||||
int roseEodRunIterator(const struct RoseEngine *t, u64a offset,
|
|
||||||
struct hs_scratch *scratch) {
|
|
||||||
if (!t->eodIterProgramOffset) {
|
|
||||||
return MO_CONTINUE_MATCHING;
|
|
||||||
}
|
|
||||||
|
|
||||||
DEBUG_PRINTF("running eod program at offset %u\n", t->eodIterProgramOffset);
|
|
||||||
|
|
||||||
const u64a som = 0;
|
|
||||||
const size_t match_len = 0;
|
|
||||||
const char in_anchored = 0;
|
|
||||||
const char in_catchup = 0;
|
|
||||||
const char from_mpv = 0;
|
|
||||||
const char skip_mpv_catchup = 1;
|
|
||||||
if (roseRunProgram(t, scratch, t->eodIterProgramOffset, som, offset,
|
|
||||||
match_len, in_anchored, in_catchup,
|
|
||||||
from_mpv, skip_mpv_catchup) == HWLM_TERMINATE_MATCHING) {
|
|
||||||
return MO_HALT_MATCHING;
|
|
||||||
}
|
|
||||||
|
|
||||||
return MO_CONTINUE_MATCHING;
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
|
||||||
hwlmcb_rv_t roseMatcherEod(const struct RoseEngine *rose,
|
hwlmcb_rv_t roseMatcherEod(const struct RoseEngine *rose,
|
||||||
struct hs_scratch *scratch, u64a offset) {
|
struct hs_scratch *scratch, u64a offset) {
|
||||||
assert(rose->ematcherOffset);
|
assert(rose->ematcherOffset);
|
||||||
@ -977,13 +946,6 @@ hwlmcb_rv_t roseMatcherEod(const struct RoseEngine *rose,
|
|||||||
}
|
}
|
||||||
|
|
||||||
roseFlushLastByteHistory(rose, scratch, offset);
|
roseFlushLastByteHistory(rose, scratch, offset);
|
||||||
|
|
||||||
// Fire any new EOD reports.
|
|
||||||
if (roseEodRunIterator(rose, offset, scratch) == MO_HALT_MATCHING) {
|
|
||||||
DEBUG_PRINTF("user instructed us to stop\n");
|
|
||||||
return HWLM_TERMINATE_MATCHING;
|
|
||||||
}
|
|
||||||
|
|
||||||
return HWLM_CONTINUE_MATCHING;
|
return HWLM_CONTINUE_MATCHING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4015,11 +4015,9 @@ bool hasEodMatcher(const RoseBuildImpl &build) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the pair (program offset, sparse iter offset).
|
|
||||||
*/
|
|
||||||
static
|
static
|
||||||
u32 writeEodAnchorProgram(RoseBuildImpl &build, build_context &bc) {
|
void addEodAnchorProgram(RoseBuildImpl &build, build_context &bc,
|
||||||
|
vector<RoseInstruction> &program) {
|
||||||
const RoseGraph &g = build.g;
|
const RoseGraph &g = build.g;
|
||||||
|
|
||||||
// pred state id -> list of programs
|
// pred state id -> list of programs
|
||||||
@ -4058,10 +4056,7 @@ u32 writeEodAnchorProgram(RoseBuildImpl &build, build_context &bc) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<RoseInstruction> program;
|
addPredBlocks(bc, predProgramLists, program);
|
||||||
if (!predProgramLists.empty()) {
|
|
||||||
addPredBlocks(bc, predProgramLists, program);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasEodAnchoredSuffix(build)) {
|
if (hasEodAnchoredSuffix(build)) {
|
||||||
if (!program.empty()) {
|
if (!program.empty()) {
|
||||||
@ -4069,17 +4064,8 @@ u32 writeEodAnchorProgram(RoseBuildImpl &build, build_context &bc) {
|
|||||||
program.pop_back();
|
program.pop_back();
|
||||||
}
|
}
|
||||||
program.emplace_back(ROSE_INSTR_SUFFIXES_EOD);
|
program.emplace_back(ROSE_INSTR_SUFFIXES_EOD);
|
||||||
|
program.emplace_back(ROSE_INSTR_END);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (program.empty()) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
program = flattenProgram({program});
|
|
||||||
|
|
||||||
assert(program.size() > 1);
|
|
||||||
applyFinalSpecialisation(program);
|
|
||||||
return writeProgram(bc, program);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
@ -4139,6 +4125,11 @@ void addGeneralEodAnchorProgram(RoseBuildImpl &build, build_context &bc,
|
|||||||
program.emplace_back(ROSE_INSTR_MATCHER_EOD);
|
program.emplace_back(ROSE_INSTR_MATCHER_EOD);
|
||||||
program.emplace_back(ROSE_INSTR_END);
|
program.emplace_back(ROSE_INSTR_END);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!program.empty()) {
|
||||||
|
assert(program.back().code() == ROSE_INSTR_END);
|
||||||
|
program.pop_back();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
@ -4184,11 +4175,18 @@ u32 writeEodProgram(RoseBuildImpl &build, build_context &bc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
addGeneralEodAnchorProgram(build, bc, program);
|
addGeneralEodAnchorProgram(build, bc, program);
|
||||||
|
addEodAnchorProgram(build, bc, program);
|
||||||
|
|
||||||
|
if (program.size() == 1) {
|
||||||
|
assert(program.back().code() == ROSE_INSTR_END);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (program.empty()) {
|
if (program.empty()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
applyFinalSpecialisation(program);
|
applyFinalSpecialisation(program);
|
||||||
return writeProgram(bc, program);
|
return writeProgram(bc, program);
|
||||||
}
|
}
|
||||||
@ -4355,7 +4353,6 @@ aligned_unique_ptr<RoseEngine> RoseBuildImpl::buildFinalEngine(u32 minWidth) {
|
|||||||
buildLiteralPrograms(*this, bc);
|
buildLiteralPrograms(*this, bc);
|
||||||
|
|
||||||
u32 eodProgramOffset = writeEodProgram(*this, bc, eodNfaIterOffset);
|
u32 eodProgramOffset = writeEodProgram(*this, bc, eodNfaIterOffset);
|
||||||
u32 eodIterProgramOffset = writeEodAnchorProgram(*this, bc);
|
|
||||||
|
|
||||||
vector<mmbit_sparse_iter> activeLeftIter;
|
vector<mmbit_sparse_iter> activeLeftIter;
|
||||||
buildActiveLeftIter(leftInfoTable, activeLeftIter);
|
buildActiveLeftIter(leftInfoTable, activeLeftIter);
|
||||||
@ -4552,7 +4549,6 @@ aligned_unique_ptr<RoseEngine> RoseBuildImpl::buildFinalEngine(u32 minWidth) {
|
|||||||
engine->nfaInfoOffset = nfaInfoOffset;
|
engine->nfaInfoOffset = nfaInfoOffset;
|
||||||
|
|
||||||
engine->eodProgramOffset = eodProgramOffset;
|
engine->eodProgramOffset = eodProgramOffset;
|
||||||
engine->eodIterProgramOffset = eodIterProgramOffset;
|
|
||||||
|
|
||||||
engine->lastByteHistoryIterOffset = lastByteOffset;
|
engine->lastByteHistoryIterOffset = lastByteOffset;
|
||||||
|
|
||||||
|
@ -542,7 +542,7 @@ void dumpRoseEodPrograms(const RoseEngine *t, const string &filename) {
|
|||||||
ofstream os(filename);
|
ofstream os(filename);
|
||||||
const char *base = (const char *)t;
|
const char *base = (const char *)t;
|
||||||
|
|
||||||
os << "Unconditional EOD Program:" << endl;
|
os << "EOD Program:" << endl;
|
||||||
|
|
||||||
if (t->eodProgramOffset) {
|
if (t->eodProgramOffset) {
|
||||||
dumpProgram(os, t, base + t->eodProgramOffset);
|
dumpProgram(os, t, base + t->eodProgramOffset);
|
||||||
@ -551,14 +551,6 @@ void dumpRoseEodPrograms(const RoseEngine *t, const string &filename) {
|
|||||||
os << "<No EOD Program>" << endl;
|
os << "<No EOD Program>" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
os << "Sparse Iter EOD Program:" << endl;
|
|
||||||
|
|
||||||
if (t->eodIterProgramOffset) {
|
|
||||||
dumpProgram(os, t, base + t->eodIterProgramOffset);
|
|
||||||
} else {
|
|
||||||
os << "<No EOD Iter Program>" << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
os.close();
|
os.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1031,7 +1023,6 @@ void roseDumpStructRaw(const RoseEngine *t, FILE *f) {
|
|||||||
DUMP_U32(t, lookaroundTableOffset);
|
DUMP_U32(t, lookaroundTableOffset);
|
||||||
DUMP_U32(t, lookaroundReachOffset);
|
DUMP_U32(t, lookaroundReachOffset);
|
||||||
DUMP_U32(t, eodProgramOffset);
|
DUMP_U32(t, eodProgramOffset);
|
||||||
DUMP_U32(t, eodIterProgramOffset);
|
|
||||||
DUMP_U32(t, lastByteHistoryIterOffset);
|
DUMP_U32(t, lastByteHistoryIterOffset);
|
||||||
DUMP_U32(t, minWidth);
|
DUMP_U32(t, minWidth);
|
||||||
DUMP_U32(t, minWidthExcludingBoundaries);
|
DUMP_U32(t, minWidthExcludingBoundaries);
|
||||||
|
@ -376,8 +376,7 @@ struct RoseEngine {
|
|||||||
u32 lookaroundReachOffset; /**< base of lookaround reach bitvectors (32
|
u32 lookaroundReachOffset; /**< base of lookaround reach bitvectors (32
|
||||||
* bytes each) */
|
* bytes each) */
|
||||||
|
|
||||||
u32 eodProgramOffset; //!< Unconditional EOD program, otherwise 0.
|
u32 eodProgramOffset; //!< EOD program, otherwise 0.
|
||||||
u32 eodIterProgramOffset; // or 0 if no eod iterator program
|
|
||||||
|
|
||||||
u32 lastByteHistoryIterOffset; // if non-zero
|
u32 lastByteHistoryIterOffset; // if non-zero
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user