#include "util/fatbit.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
int roseCheckBenefits(const struct core_info *ci, u64a end, u32 mask_rewind,
const u8 *and_mask, const u8 *exp_mask) {
}
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,
struct hs_scratch *scratch, u64a offset) {
assert(rose->ematcherOffset);
}
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 false;
}
-/**
- * Returns the pair (program offset, sparse iter offset).
- */
static
-u32 writeEodAnchorProgram(RoseBuildImpl &build, build_context &bc) {
+void addEodAnchorProgram(RoseBuildImpl &build, build_context &bc,
+ vector<RoseInstruction> &program) {
const RoseGraph &g = build.g;
// pred state id -> list of programs
}
}
- vector<RoseInstruction> program;
- if (!predProgramLists.empty()) {
- addPredBlocks(bc, predProgramLists, program);
- }
+ addPredBlocks(bc, predProgramLists, program);
if (hasEodAnchoredSuffix(build)) {
if (!program.empty()) {
program.pop_back();
}
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
program.emplace_back(ROSE_INSTR_MATCHER_EOD);
program.emplace_back(ROSE_INSTR_END);
}
+
+ if (!program.empty()) {
+ assert(program.back().code() == ROSE_INSTR_END);
+ program.pop_back();
+ }
}
static
}
addGeneralEodAnchorProgram(build, bc, program);
+ addEodAnchorProgram(build, bc, program);
+
+ if (program.size() == 1) {
+ assert(program.back().code() == ROSE_INSTR_END);
+ return 0;
+ }
if (program.empty()) {
return 0;
}
+
applyFinalSpecialisation(program);
return writeProgram(bc, program);
}
buildLiteralPrograms(*this, bc);
u32 eodProgramOffset = writeEodProgram(*this, bc, eodNfaIterOffset);
- u32 eodIterProgramOffset = writeEodAnchorProgram(*this, bc);
vector<mmbit_sparse_iter> activeLeftIter;
buildActiveLeftIter(leftInfoTable, activeLeftIter);
engine->nfaInfoOffset = nfaInfoOffset;
engine->eodProgramOffset = eodProgramOffset;
- engine->eodIterProgramOffset = eodIterProgramOffset;
engine->lastByteHistoryIterOffset = lastByteOffset;
ofstream os(filename);
const char *base = (const char *)t;
- os << "Unconditional EOD Program:" << endl;
+ os << "EOD Program:" << endl;
if (t->eodProgramOffset) {
dumpProgram(os, t, base + t->eodProgramOffset);
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();
}
DUMP_U32(t, lookaroundTableOffset);
DUMP_U32(t, lookaroundReachOffset);
DUMP_U32(t, eodProgramOffset);
- DUMP_U32(t, eodIterProgramOffset);
DUMP_U32(t, lastByteHistoryIterOffset);
DUMP_U32(t, minWidth);
DUMP_U32(t, minWidthExcludingBoundaries);
u32 lookaroundReachOffset; /**< base of lookaround reach bitvectors (32
* bytes each) */
- u32 eodProgramOffset; //!< Unconditional EOD program, otherwise 0.
- u32 eodIterProgramOffset; // or 0 if no eod iterator program
+ u32 eodProgramOffset; //!< EOD program, otherwise 0.
u32 lastByteHistoryIterOffset; // if non-zero