mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
rose: inline block-mode eod check
This commit is contained in:
parent
159c09b70e
commit
a9eba12cce
@ -29,13 +29,14 @@
|
|||||||
#include "catchup.h"
|
#include "catchup.h"
|
||||||
#include "init.h"
|
#include "init.h"
|
||||||
#include "match.h"
|
#include "match.h"
|
||||||
|
#include "program_runtime.h"
|
||||||
|
#include "rose.h"
|
||||||
|
#include "rose_common.h"
|
||||||
#include "nfa/nfa_api.h"
|
#include "nfa/nfa_api.h"
|
||||||
#include "nfa/nfa_internal.h"
|
#include "nfa/nfa_internal.h"
|
||||||
#include "nfa/nfa_rev_api.h"
|
#include "nfa/nfa_rev_api.h"
|
||||||
#include "nfa/mcclellan.h"
|
#include "nfa/mcclellan.h"
|
||||||
#include "util/fatbit.h"
|
#include "util/fatbit.h"
|
||||||
#include "rose.h"
|
|
||||||
#include "rose_common.h"
|
|
||||||
|
|
||||||
static rose_inline
|
static rose_inline
|
||||||
void runAnchoredTableBlock(const struct RoseEngine *t, const void *atable,
|
void runAnchoredTableBlock(const struct RoseEngine *t, const void *atable,
|
||||||
@ -157,6 +158,38 @@ void init_for_block(const struct RoseEngine *t, struct hs_scratch *scratch,
|
|||||||
init_outfixes_for_block(t, scratch, state, is_small_block);
|
init_outfixes_for_block(t, scratch, state, is_small_block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static rose_inline
|
||||||
|
void roseBlockEodExec(const struct RoseEngine *t, u64a offset,
|
||||||
|
struct hs_scratch *scratch) {
|
||||||
|
assert(t->requiresEodCheck);
|
||||||
|
assert(t->maxBiAnchoredWidth == ROSE_BOUND_INF
|
||||||
|
|| offset <= t->maxBiAnchoredWidth);
|
||||||
|
|
||||||
|
assert(!can_stop_matching(scratch));
|
||||||
|
assert(t->eodProgramOffset);
|
||||||
|
|
||||||
|
// Ensure that history is correct before we look for EOD matches.
|
||||||
|
roseFlushLastByteHistory(t, scratch, offset);
|
||||||
|
scratch->tctxt.lastEndOffset = offset;
|
||||||
|
|
||||||
|
DEBUG_PRINTF("running eod program at %u\n", t->eodProgramOffset);
|
||||||
|
|
||||||
|
// There should be no pending delayed literals.
|
||||||
|
assert(!scratch->tctxt.filledDelayedSlots);
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
// Note: we ignore the result, as this is the last thing to ever happen on
|
||||||
|
// a scan.
|
||||||
|
roseRunProgram(t, scratch, t->eodProgramOffset, som, offset, match_len,
|
||||||
|
in_anchored, in_catchup, from_mpv, skip_mpv_catchup);
|
||||||
|
}
|
||||||
|
|
||||||
void roseBlockExec_i(const struct RoseEngine *t, struct hs_scratch *scratch) {
|
void roseBlockExec_i(const struct RoseEngine *t, struct hs_scratch *scratch) {
|
||||||
assert(t);
|
assert(t);
|
||||||
assert(scratch);
|
assert(scratch);
|
||||||
@ -255,4 +288,16 @@ exit:;
|
|||||||
assert(!can_stop_matching(scratch));
|
assert(!can_stop_matching(scratch));
|
||||||
|
|
||||||
roseCatchUpTo(t, scratch, length);
|
roseCatchUpTo(t, scratch, length);
|
||||||
|
|
||||||
|
if (!t->requiresEodCheck || !t->eodProgramOffset) {
|
||||||
|
DEBUG_PRINTF("no eod check required\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (can_stop_matching(scratch)) {
|
||||||
|
DEBUG_PRINTF("bailing, already halted\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
roseBlockEodExec(t, length, scratch);
|
||||||
}
|
}
|
||||||
|
@ -108,23 +108,3 @@ void roseEodExec(const struct RoseEngine *t, u64a offset,
|
|||||||
initContext(t, offset, scratch);
|
initContext(t, offset, scratch);
|
||||||
roseEodExec_i(t, offset, scratch, 1);
|
roseEodExec_i(t, offset, scratch, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static rose_inline
|
|
||||||
void prepForEod(const struct RoseEngine *t, struct hs_scratch *scratch,
|
|
||||||
size_t length) {
|
|
||||||
roseFlushLastByteHistory(t, scratch, length);
|
|
||||||
scratch->tctxt.lastEndOffset = length;
|
|
||||||
}
|
|
||||||
|
|
||||||
void roseBlockEodExec(const struct RoseEngine *t, u64a offset,
|
|
||||||
struct hs_scratch *scratch) {
|
|
||||||
assert(t->requiresEodCheck);
|
|
||||||
assert(t->maxBiAnchoredWidth == ROSE_BOUND_INF
|
|
||||||
|| offset <= t->maxBiAnchoredWidth);
|
|
||||||
|
|
||||||
assert(!can_stop_matching(scratch));
|
|
||||||
|
|
||||||
// Ensure that history is correct before we look for EOD matches
|
|
||||||
prepForEod(t, scratch, scratch->core_info.len);
|
|
||||||
roseEodExec_i(t, offset, scratch, 0);
|
|
||||||
}
|
|
||||||
|
@ -39,8 +39,6 @@
|
|||||||
// Initialise state space for engine use.
|
// Initialise state space for engine use.
|
||||||
void roseInitState(const struct RoseEngine *t, char *state);
|
void roseInitState(const struct RoseEngine *t, char *state);
|
||||||
|
|
||||||
void roseBlockEodExec(const struct RoseEngine *t, u64a offset,
|
|
||||||
struct hs_scratch *scratch);
|
|
||||||
void roseBlockExec_i(const struct RoseEngine *t, struct hs_scratch *scratch);
|
void roseBlockExec_i(const struct RoseEngine *t, struct hs_scratch *scratch);
|
||||||
|
|
||||||
/* assumes core_info in scratch has been init to point to data */
|
/* assumes core_info in scratch has been init to point to data */
|
||||||
@ -57,28 +55,15 @@ void roseBlockExec(const struct RoseEngine *t, struct hs_scratch *scratch) {
|
|||||||
// If this block is shorter than our minimum width, then no pattern in this
|
// If this block is shorter than our minimum width, then no pattern in this
|
||||||
// RoseEngine could match.
|
// RoseEngine could match.
|
||||||
/* minWidth checks should have already been performed by the caller */
|
/* minWidth checks should have already been performed by the caller */
|
||||||
const size_t length = scratch->core_info.len;
|
assert(scratch->core_info.len >= t->minWidth);
|
||||||
assert(length >= t->minWidth);
|
|
||||||
|
|
||||||
// Similarly, we may have a maximum width (for engines constructed entirely
|
// Similarly, we may have a maximum width (for engines constructed entirely
|
||||||
// of bi-anchored patterns).
|
// of bi-anchored patterns).
|
||||||
/* This check is now handled by the interpreter */
|
/* This check is now handled by the interpreter */
|
||||||
assert(t->maxBiAnchoredWidth == ROSE_BOUND_INF
|
assert(t->maxBiAnchoredWidth == ROSE_BOUND_INF
|
||||||
|| length <= t->maxBiAnchoredWidth);
|
|| scratch->core_info.len <= t->maxBiAnchoredWidth);
|
||||||
|
|
||||||
roseBlockExec_i(t, scratch);
|
roseBlockExec_i(t, scratch);
|
||||||
|
|
||||||
if (!t->requiresEodCheck) {
|
|
||||||
DEBUG_PRINTF("no eod check required\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (can_stop_matching(scratch)) {
|
|
||||||
DEBUG_PRINTF("bailing, already halted\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
roseBlockEodExec(t, length, scratch);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* assumes core_info in scratch has been init to point to data */
|
/* assumes core_info in scratch has been init to point to data */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user