rose: add RECORD_ANCHORED instruction to program

Moves recordAnchoredLiteralMatch from an unconditional call in the
anchored callback to being driven by a program instruction.
This commit is contained in:
Justin Viiret
2016-07-14 10:05:47 +10:00
committed by Matthew Barr
parent 981b59fd05
commit 4dbbc4eaa5
5 changed files with 100 additions and 29 deletions

View File

@@ -165,6 +165,33 @@ void rosePushDelayedMatch(const struct RoseEngine *t,
fatbit_set(slot, delay_count, delay_index);
}
static rose_inline
void recordAnchoredLiteralMatch(const struct RoseEngine *t,
struct hs_scratch *scratch, u32 literal_id,
u64a end) {
assert(end);
if (end <= t->floatingMinLiteralMatchOffset) {
return;
}
struct fatbit **anchoredLiteralRows = getAnchoredLiteralLog(scratch);
DEBUG_PRINTF("record %u @ %llu\n", literal_id, end);
if (!bf64_set(&scratch->al_log_sum, end - 1)) {
// first time, clear row
DEBUG_PRINTF("clearing %llu/%u\n", end - 1, t->anchored_count);
fatbit_clear(anchoredLiteralRows[end - 1]);
}
u32 rel_idx = literal_id - t->anchored_base_id;
DEBUG_PRINTF("record %u @ %llu index %u/%u\n", literal_id, end, rel_idx,
t->anchored_count);
assert(rel_idx < t->anchored_count);
fatbit_set(anchoredLiteralRows[end - 1], t->anchored_count, rel_idx);
}
static rose_inline
char roseLeftfixCheckMiracles(const struct RoseEngine *t,
const struct LeftNfaInfo *left,
@@ -1226,6 +1253,11 @@ hwlmcb_rv_t roseRunProgram_i(const struct RoseEngine *t,
}
PROGRAM_NEXT_INSTRUCTION
PROGRAM_CASE(RECORD_ANCHORED) {
recordAnchoredLiteralMatch(t, scratch, ri->id, end);
}
PROGRAM_NEXT_INSTRUCTION
PROGRAM_CASE(CATCH_UP) {
if (roseCatchUpTo(t, scratch, end) == HWLM_TERMINATE_MATCHING) {
return HWLM_TERMINATE_MATCHING;