mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-11-17 01:41:51 +03:00
limex: rework accept handling
Rather that iterating over NFAAccept structures and testing individual bits in the state structure, iterate over the state vector and index into accept structures. Adds report list support to this path, unified with the report lists used for exception handling.
This commit is contained in:
committed by
Matthew Barr
parent
3dcfea19e0
commit
77fe1ef6e5
@@ -103,8 +103,7 @@
|
||||
// continue, 1 if an accept was fired and the user instructed us to halt.
|
||||
static really_inline
|
||||
char RUN_EXCEPTIONS_FN(const IMPL_NFA_T *limex, const EXCEPTION_T *exceptions,
|
||||
const ReportID *exReports, STATE_T s,
|
||||
const STATE_T emask, size_t i, u64a offset,
|
||||
STATE_T s, const STATE_T emask, size_t i, u64a offset,
|
||||
STATE_T *succ, u64a *final_loc, struct CONTEXT_T *ctx,
|
||||
const char flags, const char in_rev,
|
||||
const char first_match) {
|
||||
@@ -131,7 +130,7 @@ char RUN_EXCEPTIONS_FN(const IMPL_NFA_T *limex, const EXCEPTION_T *exceptions,
|
||||
char localflags = (!i && !in_rev) ? NO_OUTPUT | FIRST_BYTE : flags;
|
||||
|
||||
int rv = JOIN(processExceptional, SIZE)(
|
||||
pass_state, pass_estate, diffmask, succ, limex, exceptions, exReports,
|
||||
pass_state, pass_estate, diffmask, succ, limex, exceptions,
|
||||
callback_offset, ctx, in_rev, localflags);
|
||||
if (rv == PE_RV_HALT) {
|
||||
return 1; // Halt matching.
|
||||
@@ -207,7 +206,6 @@ char STREAM_FN(const IMPL_NFA_T *limex, const u8 *input, size_t length,
|
||||
const union AccelAux *accelAux =
|
||||
(const union AccelAux *)((const char *)limex + limex->accelAuxOffset);
|
||||
const EXCEPTION_T *exceptions = getExceptionTable(EXCEPTION_T, limex);
|
||||
const ReportID *exReports = getExReports(limex);
|
||||
STATE_T s = ctx->s;
|
||||
|
||||
/* assert(ISALIGNED_16(exceptions)); */
|
||||
@@ -235,9 +233,8 @@ without_accel:
|
||||
STATE_T succ;
|
||||
NFA_EXEC_GET_LIM_SUCC(limex, s, succ);
|
||||
|
||||
if (RUN_EXCEPTIONS_FN(limex, exceptions, exReports, s, EXCEPTION_MASK,
|
||||
i, offset, &succ, final_loc, ctx, flags, 0,
|
||||
first_match)) {
|
||||
if (RUN_EXCEPTIONS_FN(limex, exceptions, s, EXCEPTION_MASK, i, offset,
|
||||
&succ, final_loc, ctx, flags, 0, first_match)) {
|
||||
return MO_HALT_MATCHING;
|
||||
}
|
||||
|
||||
@@ -286,9 +283,8 @@ with_accel:
|
||||
STATE_T succ;
|
||||
NFA_EXEC_GET_LIM_SUCC(limex, s, succ);
|
||||
|
||||
if (RUN_EXCEPTIONS_FN(limex, exceptions, exReports, s, EXCEPTION_MASK,
|
||||
i, offset, &succ, final_loc, ctx, flags, 0,
|
||||
first_match)) {
|
||||
if (RUN_EXCEPTIONS_FN(limex, exceptions, s, EXCEPTION_MASK, i, offset,
|
||||
&succ, final_loc, ctx, flags, 0, first_match)) {
|
||||
return MO_HALT_MATCHING;
|
||||
}
|
||||
|
||||
@@ -300,8 +296,6 @@ with_accel:
|
||||
if ((first_match || (flags & CALLBACK_OUTPUT)) && limex->acceptCount) {
|
||||
STATE_T acceptMask = LOAD_FROM_ENG(&limex->accept);
|
||||
const struct NFAAccept *acceptTable = getAcceptTable(limex);
|
||||
const u32 acceptCount = limex->acceptCount;
|
||||
|
||||
STATE_T foundAccepts = AND_STATE(s, acceptMask);
|
||||
if (unlikely(ISNONZERO_STATE(foundAccepts))) {
|
||||
if (first_match) {
|
||||
@@ -309,8 +303,8 @@ with_accel:
|
||||
assert(final_loc);
|
||||
*final_loc = length;
|
||||
return MO_HALT_MATCHING;
|
||||
} else if (PROCESS_ACCEPTS_FN(limex, &ctx->s, acceptTable,
|
||||
acceptCount, offset + length,
|
||||
} else if (PROCESS_ACCEPTS_FN(limex, &ctx->s, &acceptMask,
|
||||
acceptTable, offset + length,
|
||||
ctx->callback, ctx->context)) {
|
||||
return MO_HALT_MATCHING;
|
||||
}
|
||||
@@ -331,7 +325,6 @@ char REV_STREAM_FN(const IMPL_NFA_T *limex, const u8 *input, size_t length,
|
||||
const STATE_T exceptionMask = LOAD_FROM_ENG(&limex->exceptionMask);
|
||||
#endif
|
||||
const EXCEPTION_T *exceptions = getExceptionTable(EXCEPTION_T, limex);
|
||||
const ReportID *exReports = getExReports(limex);
|
||||
STATE_T s = ctx->s;
|
||||
|
||||
/* assert(ISALIGNED_16(exceptions)); */
|
||||
@@ -351,9 +344,8 @@ char REV_STREAM_FN(const IMPL_NFA_T *limex, const u8 *input, size_t length,
|
||||
STATE_T succ;
|
||||
NFA_EXEC_GET_LIM_SUCC(limex, s, succ);
|
||||
|
||||
if (RUN_EXCEPTIONS_FN(limex, exceptions, exReports, s,
|
||||
EXCEPTION_MASK, i, offset, &succ, final_loc, ctx,
|
||||
flags, 1, 0)) {
|
||||
if (RUN_EXCEPTIONS_FN(limex, exceptions, s, EXCEPTION_MASK, i, offset,
|
||||
&succ, final_loc, ctx, flags, 1, 0)) {
|
||||
return MO_HALT_MATCHING;
|
||||
}
|
||||
|
||||
@@ -369,8 +361,8 @@ char REV_STREAM_FN(const IMPL_NFA_T *limex, const u8 *input, size_t length,
|
||||
if (acceptCount) {
|
||||
STATE_T foundAccepts = AND_STATE(s, acceptMask);
|
||||
if (unlikely(ISNONZERO_STATE(foundAccepts))) {
|
||||
if (PROCESS_ACCEPTS_NOSQUASH_FN(&ctx->s, acceptTable, acceptCount,
|
||||
offset, ctx->callback,
|
||||
if (PROCESS_ACCEPTS_NOSQUASH_FN(limex, &ctx->s, &acceptMask,
|
||||
acceptTable, offset, ctx->callback,
|
||||
ctx->context)) {
|
||||
return MO_HALT_MATCHING;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user