mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
nfa: unify NfaCallback and SomNfaCallback
Use just one callback type, with both start and end offsets.
This commit is contained in:
parent
9087d59be5
commit
cf9e40ae1c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Intel Corporation
|
||||
* Copyright (c) 2015-2016, Intel Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@ -53,14 +53,8 @@
|
||||
* are 0, which means 'stop running the engine' or non-zero, which means
|
||||
* 'continue matching'.
|
||||
*/
|
||||
typedef int (*NfaCallback)(u64a offset, ReportID id, void *context);
|
||||
|
||||
/** \brief The type for an NFA callback which also tracks start of match.
|
||||
*
|
||||
* see \ref NfaCallback
|
||||
*/
|
||||
typedef int (*SomNfaCallback)(u64a from_offset, u64a to_offset, ReportID id,
|
||||
void *context);
|
||||
typedef int (*NfaCallback)(u64a from_offset, u64a to_offset, ReportID id,
|
||||
void *context);
|
||||
|
||||
/**
|
||||
* standard \ref NfaCallback return value indicating that engine execution
|
||||
|
@ -98,7 +98,7 @@ char subCastleReportCurrent(const struct Castle *c, struct mq *q,
|
||||
if (match == REPEAT_MATCH) {
|
||||
DEBUG_PRINTF("firing match at %llu for sub %u, report %u\n", offset,
|
||||
subIdx, sub->report);
|
||||
if (q->cb(offset, sub->report, q->context) == MO_HALT_MATCHING) {
|
||||
if (q->cb(0, offset, sub->report, q->context) == MO_HALT_MATCHING) {
|
||||
return MO_HALT_MATCHING;
|
||||
}
|
||||
}
|
||||
@ -457,7 +457,7 @@ char subCastleFireMatch(const struct Castle *c, const void *full_state,
|
||||
i = mmbit_iterate(matching, c->numRepeats, i)) {
|
||||
const struct SubCastle *sub = getSubCastle(c, i);
|
||||
DEBUG_PRINTF("firing match at %llu for sub %u\n", offset, i);
|
||||
if (cb(offset, sub->report, ctx) == MO_HALT_MATCHING) {
|
||||
if (cb(0, offset, sub->report, ctx) == MO_HALT_MATCHING) {
|
||||
DEBUG_PRINTF("caller told us to halt\n");
|
||||
return MO_HALT_MATCHING;
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ u64a expandSomValue(u32 comp_slot_width, u64a curr_offset,
|
||||
}
|
||||
|
||||
static really_inline
|
||||
char doReports(SomNfaCallback cb, void *ctxt, const struct mcclellan *m,
|
||||
char doReports(NfaCallback cb, void *ctxt, const struct mcclellan *m,
|
||||
const struct gough_som_info *som, u16 s, u64a loc,
|
||||
char eod, u16 * const cached_accept_state,
|
||||
u32 * const cached_accept_id, u32 * const cached_accept_som) {
|
||||
@ -307,7 +307,7 @@ u16 goughEnableStarts(const struct mcclellan *m, u16 s, u64a som_offset,
|
||||
static really_inline
|
||||
char goughExec16_i(const struct mcclellan *m, struct gough_som_info *som,
|
||||
u16 *state, const u8 *buf, size_t len, u64a offAdj,
|
||||
SomNfaCallback cb, void *ctxt, const u8 **c_final,
|
||||
NfaCallback cb, void *ctxt, const u8 **c_final,
|
||||
enum MatchMode mode) {
|
||||
assert(ISALIGNED_N(state, 2));
|
||||
|
||||
@ -461,7 +461,7 @@ with_accel:
|
||||
static really_inline
|
||||
char goughExec8_i(const struct mcclellan *m, struct gough_som_info *som,
|
||||
u8 *state, const u8 *buf, size_t len, u64a offAdj,
|
||||
SomNfaCallback cb, void *ctxt, const u8 **c_final,
|
||||
NfaCallback cb, void *ctxt, const u8 **c_final,
|
||||
enum MatchMode mode) {
|
||||
u8 s = *state;
|
||||
const u8 *c = buf, *c_end = buf + len;
|
||||
@ -595,7 +595,7 @@ with_accel:
|
||||
static never_inline
|
||||
char goughExec8_i_ni(const struct mcclellan *m, struct gough_som_info *som,
|
||||
u8 *state, const u8 *buf, size_t len, u64a offAdj,
|
||||
SomNfaCallback cb, void *ctxt, const u8 **final_point,
|
||||
NfaCallback cb, void *ctxt, const u8 **final_point,
|
||||
enum MatchMode mode) {
|
||||
return goughExec8_i(m, som, state, buf, len, offAdj, cb, ctxt, final_point,
|
||||
mode);
|
||||
@ -604,7 +604,7 @@ char goughExec8_i_ni(const struct mcclellan *m, struct gough_som_info *som,
|
||||
static never_inline
|
||||
char goughExec16_i_ni(const struct mcclellan *m, struct gough_som_info *som,
|
||||
u16 *state, const u8 *buf, size_t len, u64a offAdj,
|
||||
SomNfaCallback cb, void *ctxt, const u8 **final_point,
|
||||
NfaCallback cb, void *ctxt, const u8 **final_point,
|
||||
enum MatchMode mode) {
|
||||
return goughExec16_i(m, som, state, buf, len, offAdj, cb, ctxt, final_point,
|
||||
mode);
|
||||
@ -622,7 +622,7 @@ const struct gough_som_info *getSomInfoConst(const char *state_base) {
|
||||
|
||||
static really_inline
|
||||
char nfaExecGough8_Q2i(const struct NFA *n, u64a offset, const u8 *buffer,
|
||||
const u8 *hend, SomNfaCallback cb, void *context,
|
||||
const u8 *hend, NfaCallback cb, void *context,
|
||||
struct mq *q, s64a end, enum MatchMode mode) {
|
||||
DEBUG_PRINTF("enter\n");
|
||||
struct gough_som_info *som = getSomInfo(q->state);
|
||||
@ -755,7 +755,7 @@ char nfaExecGough8_Q2i(const struct NFA *n, u64a offset, const u8 *buffer,
|
||||
|
||||
static really_inline
|
||||
char nfaExecGough16_Q2i(const struct NFA *n, u64a offset, const u8 *buffer,
|
||||
const u8 *hend, SomNfaCallback cb, void *context,
|
||||
const u8 *hend, NfaCallback cb, void *context,
|
||||
struct mq *q, s64a end, enum MatchMode mode) {
|
||||
struct gough_som_info *som = getSomInfo(q->state);
|
||||
assert(n->type == GOUGH_NFA_16);
|
||||
@ -887,7 +887,7 @@ char nfaExecGough16_Q2i(const struct NFA *n, u64a offset, const u8 *buffer,
|
||||
char nfaExecGough8_Q(const struct NFA *n, struct mq *q, s64a end) {
|
||||
u64a offset = q->offset;
|
||||
const u8 *buffer = q->buffer;
|
||||
SomNfaCallback cb = q->som_cb;
|
||||
NfaCallback cb = q->cb;
|
||||
void *context = q->context;
|
||||
assert(n->type == GOUGH_NFA_8);
|
||||
const u8 *hend = q->history + q->hlength;
|
||||
@ -899,7 +899,7 @@ char nfaExecGough8_Q(const struct NFA *n, struct mq *q, s64a end) {
|
||||
char nfaExecGough16_Q(const struct NFA *n, struct mq *q, s64a end) {
|
||||
u64a offset = q->offset;
|
||||
const u8 *buffer = q->buffer;
|
||||
SomNfaCallback cb = q->som_cb;
|
||||
NfaCallback cb = q->cb;
|
||||
void *context = q->context;
|
||||
assert(n->type == GOUGH_NFA_16);
|
||||
const u8 *hend = q->history + q->hlength;
|
||||
@ -911,7 +911,7 @@ char nfaExecGough16_Q(const struct NFA *n, struct mq *q, s64a end) {
|
||||
char nfaExecGough8_Q2(const struct NFA *n, struct mq *q, s64a end) {
|
||||
u64a offset = q->offset;
|
||||
const u8 *buffer = q->buffer;
|
||||
SomNfaCallback cb = q->som_cb;
|
||||
NfaCallback cb = q->cb;
|
||||
void *context = q->context;
|
||||
assert(n->type == GOUGH_NFA_8);
|
||||
const u8 *hend = q->history + q->hlength;
|
||||
@ -923,7 +923,7 @@ char nfaExecGough8_Q2(const struct NFA *n, struct mq *q, s64a end) {
|
||||
char nfaExecGough16_Q2(const struct NFA *n, struct mq *q, s64a end) {
|
||||
u64a offset = q->offset;
|
||||
const u8 *buffer = q->buffer;
|
||||
SomNfaCallback cb = q->som_cb;
|
||||
NfaCallback cb = q->cb;
|
||||
void *context = q->context;
|
||||
assert(n->type == GOUGH_NFA_16);
|
||||
const u8 *hend = q->history + q->hlength;
|
||||
@ -935,7 +935,7 @@ char nfaExecGough16_Q2(const struct NFA *n, struct mq *q, s64a end) {
|
||||
char nfaExecGough8_QR(const struct NFA *n, struct mq *q, ReportID report) {
|
||||
u64a offset = q->offset;
|
||||
const u8 *buffer = q->buffer;
|
||||
SomNfaCallback cb = q->som_cb;
|
||||
NfaCallback cb = q->cb;
|
||||
void *context = q->context;
|
||||
assert(n->type == GOUGH_NFA_8);
|
||||
const u8 *hend = q->history + q->hlength;
|
||||
@ -952,7 +952,7 @@ char nfaExecGough8_QR(const struct NFA *n, struct mq *q, ReportID report) {
|
||||
char nfaExecGough16_QR(const struct NFA *n, struct mq *q, ReportID report) {
|
||||
u64a offset = q->offset;
|
||||
const u8 *buffer = q->buffer;
|
||||
SomNfaCallback cb = q->som_cb;
|
||||
NfaCallback cb = q->cb;
|
||||
void *context = q->context;
|
||||
assert(n->type == GOUGH_NFA_16);
|
||||
const u8 *hend = q->history + q->hlength;
|
||||
@ -994,7 +994,7 @@ char nfaExecGough16_initCompressedState(const struct NFA *nfa, u64a offset,
|
||||
|
||||
char nfaExecGough8_reportCurrent(const struct NFA *n, struct mq *q) {
|
||||
const struct mcclellan *m = (const struct mcclellan *)getImplNfa(n);
|
||||
SomNfaCallback cb = q->som_cb;
|
||||
NfaCallback cb = q->cb;
|
||||
void *ctxt = q->context;
|
||||
u8 s = *(u8 *)q->state;
|
||||
u64a offset = q_cur_offset(q);
|
||||
@ -1016,7 +1016,7 @@ char nfaExecGough8_reportCurrent(const struct NFA *n, struct mq *q) {
|
||||
|
||||
char nfaExecGough16_reportCurrent(const struct NFA *n, struct mq *q) {
|
||||
const struct mcclellan *m = (const struct mcclellan *)getImplNfa(n);
|
||||
SomNfaCallback cb = q->som_cb;
|
||||
NfaCallback cb = q->cb;
|
||||
void *ctxt = q->context;
|
||||
u16 s = *(u16 *)q->state;
|
||||
const struct mstate_aux *aux = get_aux(m, s);
|
||||
@ -1059,7 +1059,7 @@ char nfaExecGough16_inAnyAccept(const struct NFA *n, struct mq *q) {
|
||||
static
|
||||
char goughCheckEOD(const struct NFA *nfa, u16 s,
|
||||
const struct gough_som_info *som,
|
||||
u64a offset, SomNfaCallback cb, void *ctxt) {
|
||||
u64a offset, NfaCallback cb, void *ctxt) {
|
||||
const struct mcclellan *m = (const struct mcclellan *)getImplNfa(nfa);
|
||||
const struct mstate_aux *aux = get_aux(m, s);
|
||||
|
||||
@ -1070,21 +1070,19 @@ char goughCheckEOD(const struct NFA *nfa, u16 s,
|
||||
}
|
||||
|
||||
char nfaExecGough8_testEOD(const struct NFA *nfa, const char *state,
|
||||
UNUSED const char *streamState, u64a offset,
|
||||
UNUSED NfaCallback callback,
|
||||
SomNfaCallback som_callback, void *context) {
|
||||
UNUSED const char *streamState, u64a offset,
|
||||
NfaCallback callback, void *context) {
|
||||
const struct gough_som_info *som = getSomInfoConst(state);
|
||||
return goughCheckEOD(nfa, *(const u8 *)state, som, offset, som_callback,
|
||||
return goughCheckEOD(nfa, *(const u8 *)state, som, offset, callback,
|
||||
context);
|
||||
}
|
||||
|
||||
char nfaExecGough16_testEOD(const struct NFA *nfa, const char *state,
|
||||
UNUSED const char *streamState, u64a offset,
|
||||
UNUSED NfaCallback callback,
|
||||
SomNfaCallback som_callback, void *context) {
|
||||
UNUSED const char *streamState, u64a offset,
|
||||
NfaCallback callback, void *context) {
|
||||
assert(ISALIGNED_N(state, 8));
|
||||
const struct gough_som_info *som = getSomInfoConst(state);
|
||||
return goughCheckEOD(nfa, *(const u16 *)state, som, offset, som_callback,
|
||||
return goughCheckEOD(nfa, *(const u16 *)state, som, offset, callback,
|
||||
context);
|
||||
}
|
||||
|
||||
|
@ -39,8 +39,7 @@ struct mq;
|
||||
|
||||
char nfaExecGough8_testEOD(const struct NFA *nfa, const char *state,
|
||||
const char *streamState, u64a offset,
|
||||
NfaCallback callback, SomNfaCallback som_cb,
|
||||
void *context);
|
||||
NfaCallback callback, void *context);
|
||||
char nfaExecGough8_Q(const struct NFA *n, struct mq *q, s64a end);
|
||||
char nfaExecGough8_Q2(const struct NFA *n, struct mq *q, s64a end);
|
||||
char nfaExecGough8_QR(const struct NFA *n, struct mq *q, ReportID report);
|
||||
@ -62,8 +61,7 @@ char nfaExecGough8_expandState(const struct NFA *nfa, void *dest,
|
||||
|
||||
char nfaExecGough16_testEOD(const struct NFA *nfa, const char *state,
|
||||
const char *streamState, u64a offset,
|
||||
NfaCallback callback, SomNfaCallback som_cb,
|
||||
void *context);
|
||||
NfaCallback callback, void *context);
|
||||
char nfaExecGough16_Q(const struct NFA *n, struct mq *q, s64a end);
|
||||
char nfaExecGough16_Q2(const struct NFA *n, struct mq *q, s64a end);
|
||||
char nfaExecGough16_QR(const struct NFA *n, struct mq *q, ReportID report);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Intel Corporation
|
||||
* Copyright (c) 2015-2016, Intel Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@ -293,7 +293,7 @@ char lbrMatchLoop(const struct lbr_common *l, const u64a begin, const u64a end,
|
||||
}
|
||||
|
||||
DEBUG_PRINTF("firing match at %llu\n", i);
|
||||
if (cb(i, l->report, ctx) == MO_HALT_MATCHING) {
|
||||
if (cb(0, i, l->report, ctx) == MO_HALT_MATCHING) {
|
||||
return MO_HALT_MATCHING;
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ char JOIN(ENGINE_EXEC_NAME, _reportCurrent)(const struct NFA *nfa,
|
||||
const struct lbr_common *l = getImplNfa(nfa);
|
||||
u64a offset = q_cur_offset(q);
|
||||
DEBUG_PRINTF("firing match %u at %llu\n", l->report, offset);
|
||||
q->cb(offset, l->report, q->context);
|
||||
q->cb(0, offset, l->report, q->context);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -215,7 +215,7 @@ char JOIN(ENGINE_EXEC_NAME, _Q_i)(const struct NFA *nfa, struct mq *q,
|
||||
|
||||
if (q->report_current) {
|
||||
DEBUG_PRINTF("report_current: fire match at %llu\n", q_cur_offset(q));
|
||||
int rv = q->cb(q_cur_offset(q), l->report, q->context);
|
||||
int rv = q->cb(0, q_cur_offset(q), l->report, q->context);
|
||||
q->report_current = 0;
|
||||
if (rv == MO_HALT_MATCHING) {
|
||||
return MO_HALT_MATCHING;
|
||||
|
@ -54,8 +54,7 @@ extern "C"
|
||||
#define GENERATE_NFA_DECL(gf_name) \
|
||||
char gf_name##_testEOD(const struct NFA *nfa, const char *state, \
|
||||
const char *streamState, u64a offset, \
|
||||
NfaCallback callback, SomNfaCallback som_cb, \
|
||||
void *context); \
|
||||
NfaCallback callback, void *context); \
|
||||
char gf_name##_Q(const struct NFA *n, struct mq *q, s64a end); \
|
||||
char gf_name##_Q2(const struct NFA *n, struct mq *q, s64a end); \
|
||||
char gf_name##_QR(const struct NFA *n, struct mq *q, ReportID report); \
|
||||
|
@ -119,7 +119,7 @@ char PROCESS_ACCEPTS_FN(const IMPL_NFA_T *limex, STATE_T *s,
|
||||
if (TESTBIT_STATE(s, a->state)) {
|
||||
DEBUG_PRINTF("state %u is on, firing report id=%u, offset=%llu\n",
|
||||
a->state, a->externalId, offset);
|
||||
int rv = callback(offset, a->externalId, context);
|
||||
int rv = callback(0, offset, a->externalId, context);
|
||||
if (unlikely(rv == MO_HALT_MATCHING)) {
|
||||
return 1;
|
||||
}
|
||||
@ -150,7 +150,7 @@ char PROCESS_ACCEPTS_NOSQUASH_FN(const STATE_T *s,
|
||||
if (TESTBIT_STATE(s, a->state)) {
|
||||
DEBUG_PRINTF("state %u is on, firing report id=%u, offset=%llu\n",
|
||||
a->state, a->externalId, offset);
|
||||
int rv = callback(offset, a->externalId, context);
|
||||
int rv = callback(0, offset, a->externalId, context);
|
||||
if (unlikely(rv == MO_HALT_MATCHING)) {
|
||||
return 1;
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ int limexRunReports(const ReportID *reports, NfaCallback callback,
|
||||
for (; *reports != MO_INVALID_IDX; ++reports) {
|
||||
DEBUG_PRINTF("firing report for id %u at offset %llu\n",
|
||||
*reports, offset);
|
||||
int rv = callback(offset, *reports, context);
|
||||
int rv = callback(0, offset, *reports, context);
|
||||
if (rv == MO_HALT_MATCHING) {
|
||||
return MO_HALT_MATCHING;
|
||||
}
|
||||
|
@ -809,10 +809,8 @@ char JOIN(LIMEX_API_ROOT, _QR)(const struct NFA *n, struct mq *q,
|
||||
}
|
||||
|
||||
char JOIN(LIMEX_API_ROOT, _testEOD)(const struct NFA *n, const char *state,
|
||||
const char *streamState, u64a offset,
|
||||
NfaCallback callback,
|
||||
UNUSED SomNfaCallback som_callback,
|
||||
void *context) {
|
||||
const char *streamState, u64a offset,
|
||||
NfaCallback callback, void *context) {
|
||||
assert(n && state);
|
||||
|
||||
const IMPL_NFA_T *limex = getImplNfa(n);
|
||||
|
@ -42,13 +42,13 @@
|
||||
|
||||
static really_inline
|
||||
char doComplexReport(NfaCallback cb, void *ctxt, const struct mcclellan *m,
|
||||
u16 s, u64a loc, char eod, u16 * const cached_accept_state,
|
||||
u32 * const cached_accept_id) {
|
||||
u16 s, u64a loc, char eod, u16 *const cached_accept_state,
|
||||
u32 *const cached_accept_id) {
|
||||
DEBUG_PRINTF("reporting state = %hu, loc=%llu, eod %hhu\n",
|
||||
(u16)(s & STATE_MASK), loc, eod);
|
||||
|
||||
if (!eod && s == *cached_accept_state) {
|
||||
if (cb(loc, *cached_accept_id, ctxt) == MO_HALT_MATCHING) {
|
||||
if (cb(0, loc, *cached_accept_id, ctxt) == MO_HALT_MATCHING) {
|
||||
return MO_HALT_MATCHING; /* termination requested */
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ char doComplexReport(NfaCallback cb, void *ctxt, const struct mcclellan *m,
|
||||
*cached_accept_id = rl->report[0];
|
||||
|
||||
DEBUG_PRINTF("reporting %u\n", rl->report[0]);
|
||||
if (cb(loc, rl->report[0], ctxt) == MO_HALT_MATCHING) {
|
||||
if (cb(0, loc, rl->report[0], ctxt) == MO_HALT_MATCHING) {
|
||||
return MO_HALT_MATCHING; /* termination requested */
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ char doComplexReport(NfaCallback cb, void *ctxt, const struct mcclellan *m,
|
||||
|
||||
for (u32 i = 0; i < count; i++) {
|
||||
DEBUG_PRINTF("reporting %u\n", rl->report[i]);
|
||||
if (cb(loc, rl->report[i], ctxt) == MO_HALT_MATCHING) {
|
||||
if (cb(0, loc, rl->report[i], ctxt) == MO_HALT_MATCHING) {
|
||||
return MO_HALT_MATCHING; /* termination requested */
|
||||
}
|
||||
}
|
||||
@ -146,7 +146,7 @@ without_accel:
|
||||
|
||||
if (single) {
|
||||
DEBUG_PRINTF("reporting %u\n", m->arb_report);
|
||||
if (cb(loc, m->arb_report, ctxt) == MO_HALT_MATCHING) {
|
||||
if (cb(0, loc, m->arb_report, ctxt) == MO_HALT_MATCHING) {
|
||||
return MO_HALT_MATCHING; /* termination requested */
|
||||
}
|
||||
} else if (doComplexReport(cb, ctxt, m, s & STATE_MASK, loc, 0,
|
||||
@ -186,7 +186,7 @@ with_accel:
|
||||
|
||||
if (single) {
|
||||
DEBUG_PRINTF("reporting %u\n", m->arb_report);
|
||||
if (cb(loc, m->arb_report, ctxt) == MO_HALT_MATCHING) {
|
||||
if (cb(0, loc, m->arb_report, ctxt) == MO_HALT_MATCHING) {
|
||||
return MO_HALT_MATCHING; /* termination requested */
|
||||
}
|
||||
} else if (doComplexReport(cb, ctxt, m, s & STATE_MASK, loc, 0,
|
||||
@ -328,7 +328,7 @@ without_accel:
|
||||
u64a loc = (c - 1) - buf + offAdj + 1;
|
||||
if (single) {
|
||||
DEBUG_PRINTF("reporting %u\n", m->arb_report);
|
||||
if (cb(loc, m->arb_report, ctxt) == MO_HALT_MATCHING) {
|
||||
if (cb(0, loc, m->arb_report, ctxt) == MO_HALT_MATCHING) {
|
||||
return MO_HALT_MATCHING;
|
||||
}
|
||||
} else if (doComplexReport(cb, ctxt, m, s, loc, 0,
|
||||
@ -360,7 +360,7 @@ with_accel:
|
||||
u64a loc = (c - 1) - buf + offAdj + 1;
|
||||
if (single) {
|
||||
DEBUG_PRINTF("reporting %u\n", m->arb_report);
|
||||
if (cb(loc, m->arb_report, ctxt) == MO_HALT_MATCHING) {
|
||||
if (cb(0, loc, m->arb_report, ctxt) == MO_HALT_MATCHING) {
|
||||
return MO_HALT_MATCHING;
|
||||
}
|
||||
} else if (doComplexReport(cb, ctxt, m, s, loc, 0,
|
||||
@ -475,7 +475,7 @@ char nfaExecMcClellan16_Q2i(const struct NFA *n, u64a offset, const u8 *buffer,
|
||||
int rv;
|
||||
if (single) {
|
||||
DEBUG_PRINTF("reporting %u\n", m->arb_report);
|
||||
rv = cb(q_cur_offset(q), m->arb_report, context);
|
||||
rv = cb(0, q_cur_offset(q), m->arb_report, context);
|
||||
} else {
|
||||
u32 cached_accept_id = 0;
|
||||
u16 cached_accept_state = 0;
|
||||
@ -632,7 +632,7 @@ char nfaExecMcClellan8_Q2i(const struct NFA *n, u64a offset, const u8 *buffer,
|
||||
int rv;
|
||||
if (single) {
|
||||
DEBUG_PRINTF("reporting %u\n", m->arb_report);
|
||||
rv = cb(q_cur_offset(q), m->arb_report, context);
|
||||
rv = cb(0, q_cur_offset(q), m->arb_report, context);
|
||||
} else {
|
||||
u32 cached_accept_id = 0;
|
||||
u16 cached_accept_state = 0;
|
||||
@ -836,7 +836,7 @@ char nfaExecMcClellan8_reportCurrent(const struct NFA *n, struct mq *q) {
|
||||
if (s >= m->accept_limit_8) {
|
||||
if (single) {
|
||||
DEBUG_PRINTF("reporting %u\n", m->arb_report);
|
||||
cb(offset, m->arb_report, ctxt);
|
||||
cb(0, offset, m->arb_report, ctxt);
|
||||
} else {
|
||||
u32 cached_accept_id = 0;
|
||||
u16 cached_accept_state = 0;
|
||||
@ -864,7 +864,7 @@ char nfaExecMcClellan16_reportCurrent(const struct NFA *n, struct mq *q) {
|
||||
if (aux->accept) {
|
||||
if (single) {
|
||||
DEBUG_PRINTF("reporting %u\n", m->arb_report);
|
||||
cb(offset, m->arb_report, ctxt);
|
||||
cb(0, offset, m->arb_report, ctxt);
|
||||
} else {
|
||||
u32 cached_accept_id = 0;
|
||||
u16 cached_accept_state = 0;
|
||||
@ -1073,17 +1073,15 @@ void nfaExecMcClellan16_SimpStream(const struct NFA *nfa, char *state,
|
||||
}
|
||||
|
||||
char nfaExecMcClellan8_testEOD(const struct NFA *nfa, const char *state,
|
||||
UNUSED const char *streamState,
|
||||
u64a offset, NfaCallback callback,
|
||||
UNUSED SomNfaCallback som_cb, void *context) {
|
||||
UNUSED const char *streamState, u64a offset,
|
||||
NfaCallback callback, void *context) {
|
||||
return mcclellanCheckEOD(nfa, *(const u8 *)state, offset, callback,
|
||||
context);
|
||||
}
|
||||
|
||||
char nfaExecMcClellan16_testEOD(const struct NFA *nfa, const char *state,
|
||||
UNUSED const char *streamState,
|
||||
u64a offset, NfaCallback callback,
|
||||
UNUSED SomNfaCallback som_cb, void *context) {
|
||||
UNUSED const char *streamState, u64a offset,
|
||||
NfaCallback callback, void *context) {
|
||||
assert(ISALIGNED_N(state, 2));
|
||||
return mcclellanCheckEOD(nfa, *(const u16 *)state, offset, callback,
|
||||
context);
|
||||
|
@ -39,8 +39,7 @@ struct NFA;
|
||||
|
||||
char nfaExecMcClellan8_testEOD(const struct NFA *nfa, const char *state,
|
||||
const char *streamState, u64a offset,
|
||||
NfaCallback callback, SomNfaCallback som_cb,
|
||||
void *context);
|
||||
NfaCallback callback, void *context);
|
||||
char nfaExecMcClellan8_Q(const struct NFA *n, struct mq *q, s64a end);
|
||||
char nfaExecMcClellan8_Q2(const struct NFA *n, struct mq *q, s64a end);
|
||||
char nfaExecMcClellan8_QR(const struct NFA *n, struct mq *q, ReportID report);
|
||||
@ -63,8 +62,7 @@ char nfaExecMcClellan8_expandState(const struct NFA *nfa, void *dest,
|
||||
|
||||
char nfaExecMcClellan16_testEOD(const struct NFA *nfa, const char *state,
|
||||
const char *streamState, u64a offset,
|
||||
NfaCallback callback, SomNfaCallback som_cb,
|
||||
void *context);
|
||||
NfaCallback callback, void *context);
|
||||
char nfaExecMcClellan16_Q(const struct NFA *n, struct mq *q, s64a end);
|
||||
char nfaExecMcClellan16_Q2(const struct NFA *n, struct mq *q, s64a end);
|
||||
char nfaExecMcClellan16_QR(const struct NFA *n, struct mq *q, ReportID report);
|
||||
|
@ -131,7 +131,8 @@ char processReports(const struct mpv *m, u8 *reporters,
|
||||
rl_count++;
|
||||
}
|
||||
|
||||
if (cb(report_offset, curr->report, ctxt) == MO_HALT_MATCHING) {
|
||||
if (cb(0, report_offset, curr->report, ctxt) ==
|
||||
MO_HALT_MATCHING) {
|
||||
DEBUG_PRINTF("bailing\n");
|
||||
return MO_HALT_MATCHING;
|
||||
}
|
||||
@ -180,7 +181,7 @@ char processReportsForRange(const struct mpv *m, u8 *reporters,
|
||||
|
||||
for (size_t i = 2; i <= length; i++) {
|
||||
for (u32 j = 0; j < rl_count; j++) {
|
||||
if (cb(first_offset + i, rl[j], ctxt) == MO_HALT_MATCHING) {
|
||||
if (cb(0, first_offset + i, rl[j], ctxt) == MO_HALT_MATCHING) {
|
||||
DEBUG_PRINTF("bailing\n");
|
||||
return MO_HALT_MATCHING;
|
||||
}
|
||||
|
@ -225,6 +225,9 @@ char nfaQueueExecRose(const struct NFA *nfa, struct mq *q, ReportID report);
|
||||
* Runs an NFA in reverse from (buf + buflen) to buf and then from (hbuf + hlen)
|
||||
* to hbuf (main buffer and history buffer).
|
||||
*
|
||||
* Note: provides the match location as the "end" offset when the callback is
|
||||
* called.
|
||||
*
|
||||
* @param nfa engine to run
|
||||
* @param offset base offset of buf
|
||||
* @param buf main buffer
|
||||
@ -249,7 +252,6 @@ char nfaBlockExecReverse(const struct NFA *nfa, u64a offset, const u8 *buf,
|
||||
* (including br region)
|
||||
* @param offset the offset to return (via the callback) with each match
|
||||
* @param callback the callback to call for each match raised
|
||||
* @param som_cb the callback to call for each match raised (Haig)
|
||||
* @param context context pointer passed to each callback
|
||||
*
|
||||
* @return @ref MO_HALT_MATCHING if the user instructed us to halt, otherwise
|
||||
@ -257,8 +259,7 @@ char nfaBlockExecReverse(const struct NFA *nfa, u64a offset, const u8 *buf,
|
||||
*/
|
||||
char nfaCheckFinalState(const struct NFA *nfa, const char *state,
|
||||
const char *streamState, u64a offset,
|
||||
NfaCallback callback, SomNfaCallback som_cb,
|
||||
void *context);
|
||||
NfaCallback callback, void *context);
|
||||
|
||||
/**
|
||||
* Indicates if an engine is a zombie.
|
||||
|
@ -76,15 +76,14 @@
|
||||
|
||||
char nfaCheckFinalState(const struct NFA *nfa, const char *state,
|
||||
const char *streamState, u64a offset,
|
||||
NfaCallback callback, SomNfaCallback som_cb,
|
||||
void *context) {
|
||||
NfaCallback callback, void *context) {
|
||||
assert(ISALIGNED_CL(nfa) && ISALIGNED_CL(getImplNfa(nfa)));
|
||||
|
||||
// Caller should avoid calling us if we can never produce matches.
|
||||
assert(nfaAcceptsEod(nfa));
|
||||
|
||||
DISPATCH_BY_NFA_TYPE(_testEOD(nfa, state, streamState, offset, callback,
|
||||
som_cb, context));
|
||||
context));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Intel Corporation
|
||||
* Copyright (c) 2015-2016, Intel Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@ -97,7 +97,6 @@ struct mq {
|
||||
* callback. If true, the queue must be located at a
|
||||
* point where MO_MATCHES_PENDING was returned */
|
||||
NfaCallback cb; /**< callback to trigger on matches */
|
||||
SomNfaCallback som_cb; /**< callback with som info; used by haig */
|
||||
void *context; /**< context to pass along with a callback */
|
||||
struct mq_item items[MAX_MQE_LEN]; /**< queue items */
|
||||
};
|
||||
|
@ -85,7 +85,6 @@ void copyQueueProperties(const struct mq *q1, struct mq *q2,
|
||||
q2->history = q1->history;
|
||||
q2->hlength = q1->hlength;
|
||||
q2->cb = q1->cb;
|
||||
q2->som_cb = q1->som_cb;
|
||||
q2->context = q1->context;
|
||||
q2->scratch = q1->scratch;
|
||||
q2->report_current = q1->report_current;
|
||||
@ -266,8 +265,7 @@ void copyBack(const struct Tamarama *t, struct mq *q, struct mq *q1) {
|
||||
|
||||
char nfaExecTamarama0_testEOD(const struct NFA *n, const char *state,
|
||||
const char *streamState, u64a offset,
|
||||
NfaCallback callback, SomNfaCallback som_cb,
|
||||
void *context) {
|
||||
NfaCallback callback, void *context) {
|
||||
const struct Tamarama *t = getImplNfa(n);
|
||||
u32 activeIdx = loadActiveIdx(streamState, t->activeIdxSize);
|
||||
if (activeIdx == t->numSubEngines) {
|
||||
@ -278,8 +276,8 @@ char nfaExecTamarama0_testEOD(const struct NFA *n, const char *state,
|
||||
if (nfaAcceptsEod(sub)) {
|
||||
assert(!isContainerType(sub->type));
|
||||
const char *subStreamState = streamState + t->activeIdxSize;
|
||||
return nfaCheckFinalState(sub, state, subStreamState,
|
||||
offset, callback, som_cb, context);
|
||||
return nfaCheckFinalState(sub, state, subStreamState, offset, callback,
|
||||
context);
|
||||
}
|
||||
|
||||
return MO_CONTINUE_MATCHING;
|
||||
|
@ -43,8 +43,7 @@ struct hs_scratch;
|
||||
|
||||
char nfaExecTamarama0_testEOD(const struct NFA *n, const char *state,
|
||||
const char *streamState, u64a offset,
|
||||
NfaCallback callback, SomNfaCallback som_cb,
|
||||
void *context);
|
||||
NfaCallback callback, void *context);
|
||||
char nfaExecTamarama0_QR(const struct NFA *n, struct mq *q, ReportID report);
|
||||
char nfaExecTamarama0_reportCurrent(const struct NFA *n, struct mq *q);
|
||||
char nfaExecTamarama0_inAccept(const struct NFA *n, ReportID report,
|
||||
|
@ -281,14 +281,15 @@ restart:
|
||||
|
||||
/* for use by mpv (chained) only */
|
||||
static
|
||||
int roseNfaFinalBlastAdaptor(u64a offset, ReportID id, void *context) {
|
||||
int roseNfaFinalBlastAdaptor(u64a som, u64a offset, ReportID id,
|
||||
void *context) {
|
||||
struct hs_scratch *scratch = context;
|
||||
const struct RoseEngine *t = scratch->core_info.rose;
|
||||
|
||||
DEBUG_PRINTF("masky got himself a blasted match @%llu id %u !woot!\n",
|
||||
offset, id);
|
||||
|
||||
int cb_rv = roseNfaRunProgram(t, scratch, 0, offset, id, 1);
|
||||
int cb_rv = roseNfaRunProgram(t, scratch, som, offset, id, 1);
|
||||
if (cb_rv == MO_HALT_MATCHING) {
|
||||
return MO_HALT_MATCHING;
|
||||
} else if (cb_rv == ROSE_CONTINUE_MATCHING_NO_EXHAUST) {
|
||||
@ -394,7 +395,6 @@ hwlmcb_rv_t roseCatchUpMPV_i(const struct RoseEngine *t, s64a loc,
|
||||
assert(!q->report_current);
|
||||
|
||||
q->cb = roseNfaFinalBlastAdaptor;
|
||||
q->som_cb = NULL;
|
||||
|
||||
DEBUG_PRINTF("queue %u blasting, %u/%u [%lld/%lld]\n",
|
||||
qi, q->cur, q->end, q->items[q->cur].location, loc);
|
||||
@ -449,7 +449,7 @@ char in_mpv(const struct RoseEngine *rose, const struct hs_scratch *scratch) {
|
||||
}
|
||||
|
||||
static
|
||||
int roseNfaBlastAdaptor(u64a offset, ReportID id, void *context) {
|
||||
int roseNfaBlastAdaptor(u64a som, u64a offset, ReportID id, void *context) {
|
||||
struct hs_scratch *scratch = context;
|
||||
struct RoseContext *tctxt = &scratch->tctxt;
|
||||
const struct RoseEngine *t = scratch->core_info.rose;
|
||||
@ -458,7 +458,7 @@ int roseNfaBlastAdaptor(u64a offset, ReportID id, void *context) {
|
||||
offset, id);
|
||||
|
||||
const char from_mpv = in_mpv(t, scratch);
|
||||
int cb_rv = roseNfaRunProgram(t, scratch, 0, offset, id, from_mpv);
|
||||
int cb_rv = roseNfaRunProgram(t, scratch, som, offset, id, from_mpv);
|
||||
if (cb_rv == MO_HALT_MATCHING) {
|
||||
return MO_HALT_MATCHING;
|
||||
} else if (cb_rv == ROSE_CONTINUE_MATCHING_NO_EXHAUST) {
|
||||
@ -470,65 +470,8 @@ int roseNfaBlastAdaptor(u64a offset, ReportID id, void *context) {
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
int roseNfaBlastAdaptorNoInternal(u64a offset, ReportID id, void *context) {
|
||||
struct hs_scratch *scratch = context;
|
||||
struct RoseContext *tctxt = &scratch->tctxt;
|
||||
const struct RoseEngine *t = scratch->core_info.rose;
|
||||
|
||||
DEBUG_PRINTF("masky got himself a blasted match @%llu id %u !woot!\n",
|
||||
offset, id);
|
||||
|
||||
assert(!in_mpv(t, scratch));
|
||||
|
||||
int cb_rv = roseNfaRunProgram(t, scratch, 0, offset, id, 0);
|
||||
if (cb_rv == MO_HALT_MATCHING) {
|
||||
return MO_HALT_MATCHING;
|
||||
} else if (cb_rv == ROSE_CONTINUE_MATCHING_NO_EXHAUST) {
|
||||
return MO_CONTINUE_MATCHING;
|
||||
} else {
|
||||
assert(cb_rv == MO_CONTINUE_MATCHING);
|
||||
return !roseSuffixIsExhausted(t, tctxt->curr_qi,
|
||||
scratch->core_info.exhaustionVector);
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
int roseNfaBlastSomAdaptor(u64a from_offset, u64a offset, ReportID id,
|
||||
void *context) {
|
||||
struct hs_scratch *scratch = context;
|
||||
struct RoseContext *tctxt = &scratch->tctxt;
|
||||
const struct RoseEngine *t = scratch->core_info.rose;
|
||||
|
||||
DEBUG_PRINTF("masky got himself a blasted match @%llu id %u !woot!\n",
|
||||
offset, id);
|
||||
|
||||
assert(!in_mpv(t, scratch));
|
||||
|
||||
/* must be a external report as haig cannot directly participate in chain */
|
||||
int cb_rv = roseNfaRunProgram(scratch->core_info.rose, scratch, from_offset,
|
||||
offset, id, 0);
|
||||
if (cb_rv == MO_HALT_MATCHING) {
|
||||
return MO_HALT_MATCHING;
|
||||
} else if (cb_rv == ROSE_CONTINUE_MATCHING_NO_EXHAUST) {
|
||||
return MO_CONTINUE_MATCHING;
|
||||
} else {
|
||||
assert(cb_rv == MO_CONTINUE_MATCHING);
|
||||
return !roseSuffixIsExhausted(t, tctxt->curr_qi,
|
||||
scratch->core_info.exhaustionVector);
|
||||
}
|
||||
}
|
||||
|
||||
int roseNfaAdaptor(u64a offset, ReportID id, void *context) {
|
||||
struct hs_scratch *scratch = context;
|
||||
DEBUG_PRINTF("masky got himself a match @%llu id %u !woot!\n", offset, id);
|
||||
|
||||
return roseNfaRunProgram(scratch->core_info.rose, scratch, 0, offset, id,
|
||||
0);
|
||||
}
|
||||
|
||||
int roseNfaSomAdaptor(u64a from_offset, u64a offset, ReportID id,
|
||||
void *context) {
|
||||
int roseNfaAdaptor(u64a from_offset, u64a offset, ReportID id,
|
||||
void *context) {
|
||||
struct hs_scratch *scratch = context;
|
||||
DEBUG_PRINTF("masky got himself a match @%llu id %u !woot!\n", offset, id);
|
||||
|
||||
@ -538,24 +481,15 @@ int roseNfaSomAdaptor(u64a from_offset, u64a offset, ReportID id,
|
||||
}
|
||||
|
||||
static really_inline
|
||||
char blast_queue(const struct RoseEngine *t, struct hs_scratch *scratch,
|
||||
struct mq *q, u32 qi, s64a to_loc, char report_current) {
|
||||
struct RoseContext *tctxt = &scratch->tctxt;
|
||||
const struct NfaInfo *info = getNfaInfoByQueue(t, qi);
|
||||
|
||||
tctxt->curr_qi = qi;
|
||||
if (info->only_external) {
|
||||
q->cb = roseNfaBlastAdaptorNoInternal;
|
||||
} else {
|
||||
q->cb = roseNfaBlastAdaptor;
|
||||
}
|
||||
char blast_queue(struct hs_scratch *scratch, struct mq *q, u32 qi, s64a to_loc,
|
||||
char report_current) {
|
||||
scratch->tctxt.curr_qi = qi;
|
||||
q->cb = roseNfaBlastAdaptor;
|
||||
q->report_current = report_current;
|
||||
q->som_cb = roseNfaBlastSomAdaptor;
|
||||
DEBUG_PRINTF("queue %u blasting, %u/%u [%lld/%lld]\n", qi, q->cur, q->end,
|
||||
q_cur_loc(q), to_loc);
|
||||
char alive = nfaQueueExec(q->nfa, q, to_loc);
|
||||
q->cb = roseNfaAdaptor;
|
||||
q->som_cb = roseNfaSomAdaptor;
|
||||
assert(!q->report_current);
|
||||
|
||||
return alive;
|
||||
@ -585,7 +519,7 @@ hwlmcb_rv_t buildSufPQ_final(const struct RoseEngine *t, s64a report_ok_loc,
|
||||
|
||||
ensureEnd(q, a_qi, final_loc);
|
||||
|
||||
char alive = blast_queue(t, scratch, q, a_qi, second_place_loc, 0);
|
||||
char alive = blast_queue(scratch, q, a_qi, second_place_loc, 0);
|
||||
|
||||
/* We have three possible outcomes:
|
||||
* (1) the nfa died
|
||||
@ -881,7 +815,7 @@ hwlmcb_rv_t roseCatchUpNfas(const struct RoseEngine *t, s64a loc,
|
||||
continue;
|
||||
}
|
||||
|
||||
char alive = blast_queue(t, scratch, q, qi, second_place_loc, 1);
|
||||
char alive = blast_queue(scratch, q, qi, second_place_loc, 1);
|
||||
|
||||
if (!alive) {
|
||||
if (can_stop_matching(scratch)) {
|
||||
|
@ -211,7 +211,7 @@ event_enqueued:
|
||||
return HWLM_CONTINUE_MATCHING;
|
||||
}
|
||||
|
||||
int roseAnchoredCallback(u64a end, u32 id, void *ctx) {
|
||||
int roseAnchoredCallback(u64a som, u64a end, u32 id, void *ctx) {
|
||||
struct hs_scratch *scratch = ctx;
|
||||
struct RoseContext *tctxt = &scratch->tctxt;
|
||||
struct core_info *ci = &scratch->core_info;
|
||||
@ -243,7 +243,6 @@ int roseAnchoredCallback(u64a end, u32 id, void *ctx) {
|
||||
|
||||
const u32 *programs = getByOffset(t, t->litProgramOffset);
|
||||
assert(id < t->literalCount);
|
||||
const u64a som = 0;
|
||||
const u8 flags = ROSE_PROG_FLAG_IN_ANCHORED;
|
||||
if (roseRunProgram(t, scratch, programs[id], som, real_end, match_len,
|
||||
flags) == HWLM_TERMINATE_MATCHING) {
|
||||
@ -648,8 +647,8 @@ int roseRunBoundaryProgram(const struct RoseEngine *rose, u32 program,
|
||||
return MO_CONTINUE_MATCHING;
|
||||
}
|
||||
|
||||
static really_inline
|
||||
int roseReportAdaptor_i(u64a som, u64a offset, ReportID id, void *context) {
|
||||
int roseReportAdaptor(u64a som, u64a offset, ReportID id, void *context) {
|
||||
DEBUG_PRINTF("som=%llu, offset=%llu, id=%u\n", som, offset, id);
|
||||
struct hs_scratch *scratch = context;
|
||||
assert(scratch && scratch->magic == SCRATCH_MAGIC);
|
||||
|
||||
@ -667,13 +666,3 @@ int roseReportAdaptor_i(u64a som, u64a offset, ReportID id, void *context) {
|
||||
|
||||
return can_stop_matching(scratch) ? MO_HALT_MATCHING : MO_CONTINUE_MATCHING;
|
||||
}
|
||||
|
||||
int roseReportAdaptor(u64a offset, ReportID id, void *context) {
|
||||
DEBUG_PRINTF("offset=%llu, id=%u\n", offset, id);
|
||||
return roseReportAdaptor_i(0, offset, id, context);
|
||||
}
|
||||
|
||||
int roseReportSomAdaptor(u64a som, u64a offset, ReportID id, void *context) {
|
||||
DEBUG_PRINTF("som=%llu, offset=%llu, id=%u\n", som, offset, id);
|
||||
return roseReportAdaptor_i(som, offset, id, context);
|
||||
}
|
||||
|
@ -48,8 +48,7 @@
|
||||
|
||||
/* Callbacks, defined in catchup.c */
|
||||
|
||||
int roseNfaAdaptor(u64a offset, ReportID id, void *context);
|
||||
int roseNfaSomAdaptor(u64a from_offset, u64a offset, ReportID id, void *context);
|
||||
int roseNfaAdaptor(u64a from_offset, u64a offset, ReportID id, void *context);
|
||||
|
||||
/* Callbacks, defined in match.c */
|
||||
|
||||
@ -57,7 +56,7 @@ hwlmcb_rv_t roseCallback(size_t start, size_t end, u32 id, void *ctx);
|
||||
hwlmcb_rv_t roseFloatingCallback(size_t start, size_t end, u32 id, void *ctx);
|
||||
hwlmcb_rv_t roseDelayRebuildCallback(size_t start, size_t end, u32 id,
|
||||
void *ctx);
|
||||
int roseAnchoredCallback(u64a end, u32 id, void *ctx);
|
||||
int roseAnchoredCallback(u64a som, u64a end, u32 id, void *ctx);
|
||||
|
||||
/* Common code, used all over Rose runtime */
|
||||
|
||||
@ -82,7 +81,6 @@ void initQueue(struct mq *q, u32 qi, const struct RoseEngine *t,
|
||||
q->history = scratch->core_info.hbuf;
|
||||
q->hlength = scratch->core_info.hlen;
|
||||
q->cb = roseNfaAdaptor;
|
||||
q->som_cb = roseNfaSomAdaptor;
|
||||
q->context = scratch;
|
||||
q->report_current = 0;
|
||||
|
||||
|
@ -722,13 +722,13 @@ u64a roseGetHaigSom(const struct RoseEngine *t, struct hs_scratch *scratch,
|
||||
u64a start = ~0ULL;
|
||||
|
||||
/* switch the callback + context for a fun one */
|
||||
q->som_cb = roseNfaEarliestSom;
|
||||
q->cb = roseNfaEarliestSom;
|
||||
q->context = &start;
|
||||
|
||||
nfaReportCurrentMatches(q->nfa, q);
|
||||
|
||||
/* restore the old callback + context */
|
||||
q->som_cb = roseNfaSomAdaptor;
|
||||
q->cb = roseNfaAdaptor;
|
||||
q->context = NULL;
|
||||
DEBUG_PRINTF("earliest som is %llu\n", start);
|
||||
return start;
|
||||
@ -779,7 +779,7 @@ hwlmcb_rv_t roseEnginesEod(const struct RoseEngine *rose,
|
||||
}
|
||||
|
||||
if (nfaCheckFinalState(q->nfa, q->state, q->streamState, offset,
|
||||
roseReportAdaptor, roseReportSomAdaptor,
|
||||
roseReportAdaptor,
|
||||
scratch) == MO_HALT_MATCHING) {
|
||||
DEBUG_PRINTF("user instructed us to stop\n");
|
||||
return HWLM_TERMINATE_MATCHING;
|
||||
@ -815,7 +815,7 @@ hwlmcb_rv_t roseSuffixesEod(const struct RoseEngine *rose,
|
||||
continue;
|
||||
}
|
||||
if (nfaCheckFinalState(q->nfa, q->state, q->streamState, offset,
|
||||
roseReportAdaptor, roseReportSomAdaptor,
|
||||
roseReportAdaptor,
|
||||
scratch) == MO_HALT_MATCHING) {
|
||||
DEBUG_PRINTF("user instructed us to stop\n");
|
||||
return HWLM_TERMINATE_MATCHING;
|
||||
|
@ -49,8 +49,7 @@ void roseStreamEodExec(const struct RoseEngine *t, u64a offset,
|
||||
hwlmcb_rv_t rosePureLiteralCallback(size_t start, size_t end, u32 id,
|
||||
void *context);
|
||||
|
||||
int roseReportAdaptor(u64a offset, ReportID id, void *context);
|
||||
int roseReportSomAdaptor(u64a som, u64a offset, ReportID id, void *context);
|
||||
int roseReportAdaptor(u64a som, u64a offset, ReportID id, void *context);
|
||||
|
||||
int roseRunBoundaryProgram(const struct RoseEngine *rose, u32 program,
|
||||
u64a stream_offset, struct hs_scratch *scratch);
|
||||
|
@ -2616,16 +2616,6 @@ bool anyEndfixMpvTriggers(const RoseBuildImpl &tbi) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static
|
||||
bool hasInternalReport(const set<ReportID> &reports, const ReportManager &rm) {
|
||||
for (ReportID r : reports) {
|
||||
if (!isExternalReport(rm.getReport(r))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static
|
||||
void populateNfaInfoBasics(const RoseBuildImpl &build, const build_context &bc,
|
||||
const vector<OutfixInfo> &outfixes,
|
||||
@ -2643,24 +2633,10 @@ void populateNfaInfoBasics(const RoseBuildImpl &build, const build_context &bc,
|
||||
info.no_retrigger = contains(no_retrigger_queues, qi) ? 1 : 0;
|
||||
}
|
||||
|
||||
// Mark outfixes that only trigger external reports.
|
||||
// Mark outfixes that are in the small block matcher.
|
||||
for (const auto &out : outfixes) {
|
||||
const u32 qi = out.get_queue();
|
||||
|
||||
infos[qi].in_sbmatcher = out.in_sbmatcher;
|
||||
if (!hasInternalReport(all_reports(out), build.rm)) {
|
||||
infos[qi].only_external = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Mark suffixes that only trigger external reports.
|
||||
for (const auto &e : bc.suffixes) {
|
||||
const suffix_id &s = e.first;
|
||||
u32 qi = e.second;
|
||||
|
||||
if (!hasInternalReport(all_reports(s), build.rm)) {
|
||||
infos[qi].only_external = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Mark suffixes triggered by EOD table literals.
|
||||
|
@ -156,8 +156,6 @@ struct NfaInfo {
|
||||
u32 fullStateOffset; /* offset in scratch, relative to ??? */
|
||||
u32 ekeyListOffset; /* suffix, relative to base of rose, 0 if no ekeys */
|
||||
u8 no_retrigger; /* TODO */
|
||||
u8 only_external; /**< does not raise any som internal events or chained
|
||||
* rose events */
|
||||
u8 in_sbmatcher; /**< this outfix should not be run in small-block
|
||||
* execution, as it will be handled by the sbmatcher
|
||||
* HWLM table. */
|
||||
|
@ -217,7 +217,6 @@ void initOutfixQueue(struct mq *q, u32 qi, const struct RoseEngine *t,
|
||||
q->history = scratch->core_info.hbuf;
|
||||
q->hlength = scratch->core_info.hlen;
|
||||
q->cb = roseReportAdaptor;
|
||||
q->som_cb = roseReportSomAdaptor;
|
||||
q->context = scratch;
|
||||
q->report_current = 0;
|
||||
|
||||
@ -257,8 +256,8 @@ void soleOutfixBlockExec(const struct RoseEngine *t,
|
||||
char rv = nfaQueueExec(q->nfa, q, scratch->core_info.len);
|
||||
|
||||
if (rv && nfaAcceptsEod(nfa) && len == scratch->core_info.len) {
|
||||
nfaCheckFinalState(nfa, q->state, q->streamState, q->length,
|
||||
q->cb, q->som_cb, scratch);
|
||||
nfaCheckFinalState(nfa, q->state, q->streamState, q->length, q->cb,
|
||||
scratch);
|
||||
}
|
||||
}
|
||||
|
||||
@ -568,7 +567,7 @@ void soleOutfixEodExec(hs_stream_t *id, hs_scratch_t *scratch) {
|
||||
|
||||
assert(nfaAcceptsEod(nfa));
|
||||
nfaCheckFinalState(nfa, q->state, q->streamState, q->offset, q->cb,
|
||||
q->som_cb, scratch);
|
||||
scratch);
|
||||
}
|
||||
|
||||
static really_inline
|
||||
|
@ -87,7 +87,7 @@ char ok_and_mark_if_unset(u8 *som_store_valid, struct fatbit *som_set_now,
|
||||
}
|
||||
|
||||
static
|
||||
int somRevCallback(u64a offset, ReportID id, void *ctx) {
|
||||
int somRevCallback(UNUSED u64a som, u64a offset, ReportID id, void *ctx) {
|
||||
DEBUG_PRINTF("offset=%llu, id=%u\n", offset, id);
|
||||
|
||||
// We use the id to store the offset adjustment (for assertions like a
|
||||
|
@ -71,7 +71,7 @@ struct LbrTestParams {
|
||||
};
|
||||
|
||||
static
|
||||
int onMatch(u64a, ReportID, void *ctx) {
|
||||
int onMatch(u64a, u64a, ReportID, void *ctx) {
|
||||
unsigned *matches = (unsigned *)ctx;
|
||||
(*matches)++;
|
||||
return MO_CONTINUE_MATCHING;
|
||||
@ -125,7 +125,6 @@ protected:
|
||||
q.scratch = nullptr; // not needed by LBR
|
||||
q.report_current = 0;
|
||||
q.cb = onMatch;
|
||||
q.som_cb = nullptr; // only used by Haig
|
||||
q.context = &matches;
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ static const string SCAN_DATA = "___foo______\n___foofoo_foo_^^^^^^^^^^^^^^^^^^"
|
||||
static const u32 MATCH_REPORT = 1024;
|
||||
|
||||
static
|
||||
int onMatch(u64a, ReportID, void *ctx) {
|
||||
int onMatch(u64a, u64a, ReportID, void *ctx) {
|
||||
unsigned *matches = (unsigned *)ctx;
|
||||
(*matches)++;
|
||||
return MO_CONTINUE_MATCHING;
|
||||
@ -105,7 +105,6 @@ protected:
|
||||
q.scratch = nullptr; /* limex does not use scratch */
|
||||
q.report_current = 0;
|
||||
q.cb = onMatch;
|
||||
q.som_cb = nullptr; // only used by Haig
|
||||
q.context = &matches;
|
||||
}
|
||||
|
||||
@ -293,8 +292,7 @@ TEST_P(LimExModelTest, CheckFinalState) {
|
||||
|
||||
// Check for EOD matches.
|
||||
char rv = nfaCheckFinalState(nfa.get(), full_state.get(),
|
||||
stream_state.get(), end, onMatch, nullptr,
|
||||
&matches);
|
||||
stream_state.get(), end, onMatch, &matches);
|
||||
ASSERT_EQ(MO_CONTINUE_MATCHING, rv);
|
||||
}
|
||||
|
||||
@ -400,7 +398,6 @@ protected:
|
||||
q.scratch = nullptr; /* limex does not use scratch */
|
||||
q.report_current = 0;
|
||||
q.cb = onMatch;
|
||||
q.som_cb = nullptr; // only used by Haig
|
||||
q.context = &matches;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user