Use just one callback type, with both start and end offsets.
/*
- * 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:
* 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
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;
}
}
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;
}
}
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) {
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));
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;
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);
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);
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);
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);
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;
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;
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;
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;
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;
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;
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);
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);
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);
}
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);
}
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);
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);
/*
- * 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:
}
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;
}
}
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;
}
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;
#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); \
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;
}
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;
}
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;
}
}
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);
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 */
}
*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 */
}
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 */
}
}
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,
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,
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,
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,
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;
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;
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;
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;
}
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);
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);
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);
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;
}
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;
}
* 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
* (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
*/
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.
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;
}
/*
- * 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:
* 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 */
};
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;
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) {
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;
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,
/* 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) {
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);
}
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;
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) {
}
}
-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);
}
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;
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
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)) {
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;
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) {
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);
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);
-}
/* 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 */
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 */
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;
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;
}
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;
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;
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);
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,
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.
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. */
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;
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);
}
}
assert(nfaAcceptsEod(nfa));
nfaCheckFinalState(nfa, q->state, q->streamState, q->offset, q->cb,
- q->som_cb, scratch);
+ scratch);
}
static really_inline
}
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
};
static
-int onMatch(u64a, ReportID, void *ctx) {
+int onMatch(u64a, u64a, ReportID, void *ctx) {
unsigned *matches = (unsigned *)ctx;
(*matches)++;
return MO_CONTINUE_MATCHING;
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;
}
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;
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;
}
// 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);
}
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;
}