mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2026-01-01 14:15:43 +03:00
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:
committed by
Matthew Barr
parent
981b59fd05
commit
4dbbc4eaa5
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user