mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
Remove RoseContext::userCtx
All Rose callbacks receive scratch as their context.
This commit is contained in:
parent
cca4116861
commit
70620327cc
@ -135,7 +135,7 @@ void init_outfixes_for_block(const struct RoseEngine *t,
|
|||||||
static really_inline
|
static really_inline
|
||||||
void init_for_block(const struct RoseEngine *t, struct hs_scratch *scratch,
|
void init_for_block(const struct RoseEngine *t, struct hs_scratch *scratch,
|
||||||
RoseCallback callback, RoseCallbackSom som_callback,
|
RoseCallback callback, RoseCallbackSom som_callback,
|
||||||
void *ctxt, char *state, char is_small_block) {
|
char *state, char is_small_block) {
|
||||||
init_state_for_block(t, state);
|
init_state_for_block(t, state);
|
||||||
|
|
||||||
struct RoseContext *tctxt = &scratch->tctxt;
|
struct RoseContext *tctxt = &scratch->tctxt;
|
||||||
@ -147,7 +147,6 @@ void init_for_block(const struct RoseEngine *t, struct hs_scratch *scratch,
|
|||||||
tctxt->filledDelayedSlots = 0;
|
tctxt->filledDelayedSlots = 0;
|
||||||
tctxt->cb = callback;
|
tctxt->cb = callback;
|
||||||
tctxt->cb_som = som_callback;
|
tctxt->cb_som = som_callback;
|
||||||
tctxt->userCtx = ctxt;
|
|
||||||
tctxt->lastMatchOffset = 0;
|
tctxt->lastMatchOffset = 0;
|
||||||
tctxt->minMatchOffset = 0;
|
tctxt->minMatchOffset = 0;
|
||||||
tctxt->minNonMpvMatchOffset = 0;
|
tctxt->minNonMpvMatchOffset = 0;
|
||||||
@ -166,8 +165,7 @@ void init_for_block(const struct RoseEngine *t, 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,
|
||||||
RoseCallback callback, RoseCallbackSom som_callback,
|
RoseCallback callback, RoseCallbackSom som_callback) {
|
||||||
void *ctx) {
|
|
||||||
assert(t);
|
assert(t);
|
||||||
assert(scratch);
|
assert(scratch);
|
||||||
assert(scratch->core_info.buf);
|
assert(scratch->core_info.buf);
|
||||||
@ -185,7 +183,7 @@ void roseBlockExec_i(const struct RoseEngine *t, struct hs_scratch *scratch,
|
|||||||
|
|
||||||
char *state = scratch->core_info.state;
|
char *state = scratch->core_info.state;
|
||||||
|
|
||||||
init_for_block(t, scratch, callback, som_callback, ctx, state,
|
init_for_block(t, scratch, callback, som_callback, state,
|
||||||
is_small_block);
|
is_small_block);
|
||||||
|
|
||||||
struct RoseContext *tctxt = &scratch->tctxt;
|
struct RoseContext *tctxt = &scratch->tctxt;
|
||||||
|
@ -338,7 +338,7 @@ int roseNfaFinalBlastAdaptor(u64a offset, ReportID id, void *context) {
|
|||||||
return MO_CONTINUE_MATCHING;
|
return MO_CONTINUE_MATCHING;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cb_rv = tctxt->cb(offset, id, tctxt->userCtx);
|
int cb_rv = tctxt->cb(offset, id, scratch);
|
||||||
if (cb_rv == MO_HALT_MATCHING) {
|
if (cb_rv == MO_HALT_MATCHING) {
|
||||||
return MO_HALT_MATCHING;
|
return MO_HALT_MATCHING;
|
||||||
} else if (cb_rv == ROSE_CONTINUE_MATCHING_NO_EXHAUST) {
|
} else if (cb_rv == ROSE_CONTINUE_MATCHING_NO_EXHAUST) {
|
||||||
@ -364,7 +364,7 @@ int roseNfaFinalBlastAdaptorNoInternal(u64a offset, ReportID id,
|
|||||||
offset, id);
|
offset, id);
|
||||||
updateLastMatchOffset(tctxt, offset);
|
updateLastMatchOffset(tctxt, offset);
|
||||||
|
|
||||||
int cb_rv = tctxt->cb(offset, id, tctxt->userCtx);
|
int cb_rv = tctxt->cb(offset, id, scratch);
|
||||||
if (cb_rv == MO_HALT_MATCHING) {
|
if (cb_rv == MO_HALT_MATCHING) {
|
||||||
return MO_HALT_MATCHING;
|
return MO_HALT_MATCHING;
|
||||||
} else if (cb_rv == ROSE_CONTINUE_MATCHING_NO_EXHAUST) {
|
} else if (cb_rv == ROSE_CONTINUE_MATCHING_NO_EXHAUST) {
|
||||||
@ -544,7 +544,7 @@ int roseNfaBlastAdaptor(u64a offset, ReportID id, void *context) {
|
|||||||
|
|
||||||
updateLastMatchOffset(tctxt, offset);
|
updateLastMatchOffset(tctxt, offset);
|
||||||
|
|
||||||
int cb_rv = tctxt->cb(offset, id, tctxt->userCtx);
|
int cb_rv = tctxt->cb(offset, id, scratch);
|
||||||
if (cb_rv == MO_HALT_MATCHING) {
|
if (cb_rv == MO_HALT_MATCHING) {
|
||||||
return MO_HALT_MATCHING;
|
return MO_HALT_MATCHING;
|
||||||
} else if (cb_rv == ROSE_CONTINUE_MATCHING_NO_EXHAUST) {
|
} else if (cb_rv == ROSE_CONTINUE_MATCHING_NO_EXHAUST) {
|
||||||
@ -574,7 +574,7 @@ int roseNfaBlastAdaptorNoInternal(u64a offset, ReportID id, void *context) {
|
|||||||
offset, id);
|
offset, id);
|
||||||
updateLastMatchOffset(tctxt, offset);
|
updateLastMatchOffset(tctxt, offset);
|
||||||
|
|
||||||
int cb_rv = tctxt->cb(offset, id, tctxt->userCtx);
|
int cb_rv = tctxt->cb(offset, id, scratch);
|
||||||
if (cb_rv == MO_HALT_MATCHING) {
|
if (cb_rv == MO_HALT_MATCHING) {
|
||||||
return MO_HALT_MATCHING;
|
return MO_HALT_MATCHING;
|
||||||
} else if (cb_rv == ROSE_CONTINUE_MATCHING_NO_EXHAUST) {
|
} else if (cb_rv == ROSE_CONTINUE_MATCHING_NO_EXHAUST) {
|
||||||
@ -600,7 +600,7 @@ int roseNfaBlastAdaptorNoChain(u64a offset, ReportID id, void *context) {
|
|||||||
return MO_CONTINUE_MATCHING;
|
return MO_CONTINUE_MATCHING;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cb_rv = tctxt->cb(offset, id, tctxt->userCtx);
|
int cb_rv = tctxt->cb(offset, id, scratch);
|
||||||
if (cb_rv == MO_HALT_MATCHING) {
|
if (cb_rv == MO_HALT_MATCHING) {
|
||||||
return MO_HALT_MATCHING;
|
return MO_HALT_MATCHING;
|
||||||
} else if (cb_rv == ROSE_CONTINUE_MATCHING_NO_EXHAUST) {
|
} else if (cb_rv == ROSE_CONTINUE_MATCHING_NO_EXHAUST) {
|
||||||
@ -624,7 +624,7 @@ int roseNfaBlastAdaptorNoInternalNoChain(u64a offset, ReportID id,
|
|||||||
offset, id);
|
offset, id);
|
||||||
updateLastMatchOffset(tctxt, offset);
|
updateLastMatchOffset(tctxt, offset);
|
||||||
|
|
||||||
int cb_rv = tctxt->cb(offset, id, tctxt->userCtx);
|
int cb_rv = tctxt->cb(offset, id, scratch);
|
||||||
if (cb_rv == MO_HALT_MATCHING) {
|
if (cb_rv == MO_HALT_MATCHING) {
|
||||||
return MO_HALT_MATCHING;
|
return MO_HALT_MATCHING;
|
||||||
} else if (cb_rv == ROSE_CONTINUE_MATCHING_NO_EXHAUST) {
|
} else if (cb_rv == ROSE_CONTINUE_MATCHING_NO_EXHAUST) {
|
||||||
@ -656,7 +656,7 @@ int roseNfaBlastSomAdaptor(u64a from_offset, u64a offset, ReportID id,
|
|||||||
updateLastMatchOffset(tctxt, offset);
|
updateLastMatchOffset(tctxt, offset);
|
||||||
|
|
||||||
/* must be a external report as haig cannot directly participate in chain */
|
/* must be a external report as haig cannot directly participate in chain */
|
||||||
int cb_rv = tctxt->cb_som(from_offset, offset, id, tctxt->userCtx);
|
int cb_rv = tctxt->cb_som(from_offset, offset, id, scratch);
|
||||||
if (cb_rv == MO_HALT_MATCHING) {
|
if (cb_rv == MO_HALT_MATCHING) {
|
||||||
return MO_HALT_MATCHING;
|
return MO_HALT_MATCHING;
|
||||||
} else if (cb_rv == ROSE_CONTINUE_MATCHING_NO_EXHAUST) {
|
} else if (cb_rv == ROSE_CONTINUE_MATCHING_NO_EXHAUST) {
|
||||||
@ -679,7 +679,7 @@ int roseNfaAdaptor(u64a offset, ReportID id, void *context) {
|
|||||||
return MO_CONTINUE_MATCHING;
|
return MO_CONTINUE_MATCHING;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cb_rv = tctxt->cb(offset, id, tctxt->userCtx);
|
int cb_rv = tctxt->cb(offset, id, scratch);
|
||||||
return cb_rv;
|
return cb_rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -688,8 +688,7 @@ int roseNfaAdaptorNoInternal(u64a offset, ReportID id, void *context) {
|
|||||||
DEBUG_PRINTF("masky got himself a match @%llu id %u !woot!\n", offset, id);
|
DEBUG_PRINTF("masky got himself a match @%llu id %u !woot!\n", offset, id);
|
||||||
updateLastMatchOffset(tctxt, offset);
|
updateLastMatchOffset(tctxt, offset);
|
||||||
|
|
||||||
int cb_rv = tctxt->cb(offset, id, tctxt->userCtx);
|
return tctxt->cb(offset, id, tctxtToScratch(tctxt));
|
||||||
return cb_rv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int roseNfaSomAdaptor(u64a from_offset, u64a offset, ReportID id,
|
int roseNfaSomAdaptor(u64a from_offset, u64a offset, ReportID id,
|
||||||
@ -699,8 +698,7 @@ int roseNfaSomAdaptor(u64a from_offset, u64a offset, ReportID id,
|
|||||||
updateLastMatchOffset(tctxt, offset);
|
updateLastMatchOffset(tctxt, offset);
|
||||||
|
|
||||||
/* must be a external report as haig cannot directly participate in chain */
|
/* must be a external report as haig cannot directly participate in chain */
|
||||||
int cb_rv = tctxt->cb_som(from_offset, offset, id, tctxt->userCtx);
|
return tctxt->cb_som(from_offset, offset, id, tctxtToScratch(tctxt));
|
||||||
return cb_rv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static really_inline
|
static really_inline
|
||||||
@ -1155,7 +1153,7 @@ hwlmcb_rv_t roseCatchUpAll_i(s64a loc, struct hs_scratch *scratch,
|
|||||||
goto next;
|
goto next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tctxt->cb(anchored_end, anchored_report, tctxt->userCtx)
|
if (tctxt->cb(anchored_end, anchored_report, scratch)
|
||||||
== MO_HALT_MATCHING) {
|
== MO_HALT_MATCHING) {
|
||||||
DEBUG_PRINTF("termination requested\n");
|
DEBUG_PRINTF("termination requested\n");
|
||||||
return HWLM_TERMINATE_MATCHING;
|
return HWLM_TERMINATE_MATCHING;
|
||||||
@ -1271,7 +1269,7 @@ hwlmcb_rv_t roseCatchUpAnchoredOnly(s64a loc, struct hs_scratch *scratch) {
|
|||||||
goto next;
|
goto next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tctxt->cb(anchored_end, anchored_report, tctxt->userCtx)
|
if (tctxt->cb(anchored_end, anchored_report, scratch)
|
||||||
== MO_HALT_MATCHING) {
|
== MO_HALT_MATCHING) {
|
||||||
DEBUG_PRINTF("termination requested\n");
|
DEBUG_PRINTF("termination requested\n");
|
||||||
return HWLM_TERMINATE_MATCHING;
|
return HWLM_TERMINATE_MATCHING;
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
static really_inline
|
static really_inline
|
||||||
void initContext(const struct RoseEngine *t, char *state, u64a offset,
|
void initContext(const struct RoseEngine *t, char *state, u64a offset,
|
||||||
struct hs_scratch *scratch, RoseCallback callback,
|
struct hs_scratch *scratch, RoseCallback callback,
|
||||||
RoseCallbackSom som_callback, void *ctx) {
|
RoseCallbackSom som_callback) {
|
||||||
struct RoseContext *tctxt = &scratch->tctxt;
|
struct RoseContext *tctxt = &scratch->tctxt;
|
||||||
tctxt->groups = loadGroups(t, state); /* TODO: diff groups for eod */
|
tctxt->groups = loadGroups(t, state); /* TODO: diff groups for eod */
|
||||||
tctxt->lit_offset_adjust = scratch->core_info.buf_offset
|
tctxt->lit_offset_adjust = scratch->core_info.buf_offset
|
||||||
@ -46,7 +46,6 @@ void initContext(const struct RoseEngine *t, char *state, u64a offset,
|
|||||||
tctxt->filledDelayedSlots = 0;
|
tctxt->filledDelayedSlots = 0;
|
||||||
tctxt->cb = callback;
|
tctxt->cb = callback;
|
||||||
tctxt->cb_som = som_callback;
|
tctxt->cb_som = som_callback;
|
||||||
tctxt->userCtx = ctx;
|
|
||||||
tctxt->lastMatchOffset = 0;
|
tctxt->lastMatchOffset = 0;
|
||||||
tctxt->minMatchOffset = 0;
|
tctxt->minMatchOffset = 0;
|
||||||
tctxt->minNonMpvMatchOffset = 0;
|
tctxt->minNonMpvMatchOffset = 0;
|
||||||
@ -170,7 +169,7 @@ void roseCheckNfaEod(const struct RoseEngine *t, char *state,
|
|||||||
|
|
||||||
if (nfaCheckFinalState(nfa, fstate, sstate, offset, scratch->tctxt.cb,
|
if (nfaCheckFinalState(nfa, fstate, sstate, offset, scratch->tctxt.cb,
|
||||||
scratch->tctxt.cb_som,
|
scratch->tctxt.cb_som,
|
||||||
scratch->tctxt.userCtx) == MO_HALT_MATCHING) {
|
scratch) == MO_HALT_MATCHING) {
|
||||||
DEBUG_PRINTF("user instructed us to stop\n");
|
DEBUG_PRINTF("user instructed us to stop\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -219,8 +218,7 @@ void roseCheckEodSuffixes(const struct RoseEngine *t, char *state, u64a offset,
|
|||||||
if (rv) { /* nfa is still alive */
|
if (rv) { /* nfa is still alive */
|
||||||
if (nfaCheckFinalState(nfa, fstate, sstate, offset,
|
if (nfaCheckFinalState(nfa, fstate, sstate, offset,
|
||||||
scratch->tctxt.cb, scratch->tctxt.cb_som,
|
scratch->tctxt.cb, scratch->tctxt.cb_som,
|
||||||
scratch->tctxt.userCtx) ==
|
scratch) == MO_HALT_MATCHING) {
|
||||||
MO_HALT_MATCHING) {
|
|
||||||
DEBUG_PRINTF("user instructed us to stop\n");
|
DEBUG_PRINTF("user instructed us to stop\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -298,10 +296,9 @@ void roseEodExec_i(const struct RoseEngine *t, char *state, u64a offset,
|
|||||||
|
|
||||||
void roseEodExec(const struct RoseEngine *t, u64a offset,
|
void roseEodExec(const struct RoseEngine *t, u64a offset,
|
||||||
struct hs_scratch *scratch, RoseCallback callback,
|
struct hs_scratch *scratch, RoseCallback callback,
|
||||||
RoseCallbackSom som_callback, void *context) {
|
RoseCallbackSom som_callback) {
|
||||||
assert(scratch);
|
assert(scratch);
|
||||||
assert(callback);
|
assert(callback);
|
||||||
assert(context);
|
|
||||||
assert(t->requiresEodCheck);
|
assert(t->requiresEodCheck);
|
||||||
DEBUG_PRINTF("ci buf %p/%zu his %p/%zu\n", scratch->core_info.buf,
|
DEBUG_PRINTF("ci buf %p/%zu his %p/%zu\n", scratch->core_info.buf,
|
||||||
scratch->core_info.len, scratch->core_info.hbuf,
|
scratch->core_info.len, scratch->core_info.hbuf,
|
||||||
@ -317,7 +314,7 @@ void roseEodExec(const struct RoseEngine *t, u64a offset,
|
|||||||
char *state = scratch->core_info.state;
|
char *state = scratch->core_info.state;
|
||||||
assert(state);
|
assert(state);
|
||||||
|
|
||||||
initContext(t, state, offset, scratch, callback, som_callback, context);
|
initContext(t, state, offset, scratch, callback, som_callback);
|
||||||
|
|
||||||
roseEodExec_i(t, state, offset, scratch, 1);
|
roseEodExec_i(t, state, offset, scratch, 1);
|
||||||
}
|
}
|
||||||
|
@ -205,6 +205,22 @@ found_miracle:
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static rose_inline
|
||||||
|
hwlmcb_rv_t roseHaltIfExhausted(const struct RoseEngine *t,
|
||||||
|
struct hs_scratch *scratch) {
|
||||||
|
struct core_info *ci = &scratch->core_info;
|
||||||
|
if (isAllExhausted(t, ci->exhaustionVector)) {
|
||||||
|
if (!ci->broken) {
|
||||||
|
ci->broken = BROKEN_EXHAUSTED;
|
||||||
|
}
|
||||||
|
scratch->tctxt.groups = 0;
|
||||||
|
DEBUG_PRINTF("all exhausted, termination requested\n");
|
||||||
|
return HWLM_TERMINATE_MATCHING;
|
||||||
|
}
|
||||||
|
|
||||||
|
return HWLM_CONTINUE_MATCHING;
|
||||||
|
}
|
||||||
|
|
||||||
static really_inline
|
static really_inline
|
||||||
hwlmcb_rv_t ensureQueueFlushed_i(const struct RoseEngine *t,
|
hwlmcb_rv_t ensureQueueFlushed_i(const struct RoseEngine *t,
|
||||||
struct hs_scratch *scratch, u32 qi, s64a loc,
|
struct hs_scratch *scratch, u32 qi, s64a loc,
|
||||||
@ -266,16 +282,7 @@ done_queue_empty:
|
|||||||
|
|
||||||
assert(!isQueueFull(q));
|
assert(!isQueueFull(q));
|
||||||
|
|
||||||
if (isAllExhausted(t, scratch->core_info.exhaustionVector)) {
|
return roseHaltIfExhausted(t, scratch);
|
||||||
if (!scratch->core_info.broken) {
|
|
||||||
scratch->core_info.broken = BROKEN_EXHAUSTED;
|
|
||||||
}
|
|
||||||
tctxt->groups = 0;
|
|
||||||
DEBUG_PRINTF("termination requested\n");
|
|
||||||
return HWLM_TERMINATE_MATCHING;
|
|
||||||
}
|
|
||||||
|
|
||||||
return HWLM_CONTINUE_MATCHING;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static really_inline
|
static really_inline
|
||||||
@ -575,7 +582,7 @@ hwlmcb_rv_t roseHandleMatch(const struct RoseEngine *t, char *state,
|
|||||||
DEBUG_PRINTF("firing callback reportId=%u, end=%llu\n", id, end);
|
DEBUG_PRINTF("firing callback reportId=%u, end=%llu\n", id, end);
|
||||||
updateLastMatchOffset(tctxt, end);
|
updateLastMatchOffset(tctxt, end);
|
||||||
|
|
||||||
int cb_rv = tctxt->cb(end, id, tctxt->userCtx);
|
int cb_rv = tctxt->cb(end, id, scratch);
|
||||||
if (cb_rv == MO_HALT_MATCHING) {
|
if (cb_rv == MO_HALT_MATCHING) {
|
||||||
DEBUG_PRINTF("termination requested\n");
|
DEBUG_PRINTF("termination requested\n");
|
||||||
return HWLM_TERMINATE_MATCHING;
|
return HWLM_TERMINATE_MATCHING;
|
||||||
@ -585,16 +592,7 @@ hwlmcb_rv_t roseHandleMatch(const struct RoseEngine *t, char *state,
|
|||||||
return HWLM_CONTINUE_MATCHING;
|
return HWLM_CONTINUE_MATCHING;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isAllExhausted(t, scratch->core_info.exhaustionVector)) {
|
return roseHaltIfExhausted(t, scratch);
|
||||||
if (!scratch->core_info.broken) {
|
|
||||||
scratch->core_info.broken = BROKEN_EXHAUSTED;
|
|
||||||
}
|
|
||||||
tctxt->groups = 0;
|
|
||||||
DEBUG_PRINTF("termination requested\n");
|
|
||||||
return HWLM_TERMINATE_MATCHING;
|
|
||||||
}
|
|
||||||
|
|
||||||
return HWLM_CONTINUE_MATCHING;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* catches up engines enough to ensure any earlier mpv triggers are enqueued
|
/* catches up engines enough to ensure any earlier mpv triggers are enqueued
|
||||||
@ -665,7 +663,9 @@ static rose_inline
|
|||||||
hwlmcb_rv_t roseHandleSomMatch(const struct RoseEngine *t, char *state,
|
hwlmcb_rv_t roseHandleSomMatch(const struct RoseEngine *t, char *state,
|
||||||
ReportID id, u64a start, u64a end,
|
ReportID id, u64a start, u64a end,
|
||||||
struct RoseContext *tctxt, char in_anchored) {
|
struct RoseContext *tctxt, char in_anchored) {
|
||||||
if (roseCatchUpTo(t, state, end, tctxtToScratch(tctxt), in_anchored)
|
struct hs_scratch *scratch = tctxtToScratch(tctxt);
|
||||||
|
|
||||||
|
if (roseCatchUpTo(t, state, end, scratch, in_anchored)
|
||||||
== HWLM_TERMINATE_MATCHING) {
|
== HWLM_TERMINATE_MATCHING) {
|
||||||
return HWLM_TERMINATE_MATCHING;
|
return HWLM_TERMINATE_MATCHING;
|
||||||
}
|
}
|
||||||
@ -676,7 +676,7 @@ hwlmcb_rv_t roseHandleSomMatch(const struct RoseEngine *t, char *state,
|
|||||||
assert(end == tctxt->minMatchOffset);
|
assert(end == tctxt->minMatchOffset);
|
||||||
|
|
||||||
updateLastMatchOffset(tctxt, end);
|
updateLastMatchOffset(tctxt, end);
|
||||||
int cb_rv = tctxt->cb_som(start, end, id, tctxt->userCtx);
|
int cb_rv = tctxt->cb_som(start, end, id, scratch);
|
||||||
if (cb_rv == MO_HALT_MATCHING) {
|
if (cb_rv == MO_HALT_MATCHING) {
|
||||||
DEBUG_PRINTF("termination requested\n");
|
DEBUG_PRINTF("termination requested\n");
|
||||||
return HWLM_TERMINATE_MATCHING;
|
return HWLM_TERMINATE_MATCHING;
|
||||||
@ -686,17 +686,7 @@ hwlmcb_rv_t roseHandleSomMatch(const struct RoseEngine *t, char *state,
|
|||||||
return HWLM_CONTINUE_MATCHING;
|
return HWLM_CONTINUE_MATCHING;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct core_info *ci = &tctxtToScratch(tctxt)->core_info;
|
return roseHaltIfExhausted(t, scratch);
|
||||||
if (isAllExhausted(t, ci->exhaustionVector)) {
|
|
||||||
if (!ci->broken) {
|
|
||||||
ci->broken = BROKEN_EXHAUSTED;
|
|
||||||
}
|
|
||||||
tctxt->groups = 0;
|
|
||||||
DEBUG_PRINTF("termination requested\n");
|
|
||||||
return HWLM_TERMINATE_MATCHING;
|
|
||||||
}
|
|
||||||
|
|
||||||
return HWLM_CONTINUE_MATCHING;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static rose_inline
|
static rose_inline
|
||||||
@ -1064,8 +1054,7 @@ hwlmcb_rv_t roseRunProgram(const struct RoseEngine *t, u32 programOffset,
|
|||||||
PROGRAM_NEXT_INSTRUCTION
|
PROGRAM_NEXT_INSTRUCTION
|
||||||
|
|
||||||
PROGRAM_CASE(REPORT_EOD) {
|
PROGRAM_CASE(REPORT_EOD) {
|
||||||
if (tctxt->cb(end, ri->report, tctxt->userCtx) ==
|
if (tctxt->cb(end, ri->report, scratch) == MO_HALT_MATCHING) {
|
||||||
MO_HALT_MATCHING) {
|
|
||||||
return HWLM_TERMINATE_MATCHING;
|
return HWLM_TERMINATE_MATCHING;
|
||||||
}
|
}
|
||||||
work_done = 1;
|
work_done = 1;
|
||||||
|
@ -42,8 +42,7 @@ void roseInitState(const struct RoseEngine *t, char *state);
|
|||||||
void roseBlockEodExec(const struct RoseEngine *t, u64a offset,
|
void roseBlockEodExec(const struct RoseEngine *t, u64a offset,
|
||||||
struct hs_scratch *scratch);
|
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,
|
||||||
RoseCallback callback, RoseCallbackSom som_callback,
|
RoseCallback callback, RoseCallbackSom som_callback);
|
||||||
void *context);
|
|
||||||
|
|
||||||
static really_inline
|
static really_inline
|
||||||
int roseBlockHasEodWork(const struct RoseEngine *t,
|
int roseBlockHasEodWork(const struct RoseEngine *t,
|
||||||
@ -81,8 +80,7 @@ int roseBlockHasEodWork(const struct RoseEngine *t,
|
|||||||
/* assumes core_info in scratch has been init to point to data */
|
/* assumes core_info in scratch has been init to point to data */
|
||||||
static really_inline
|
static really_inline
|
||||||
void roseBlockExec(const struct RoseEngine *t, struct hs_scratch *scratch,
|
void roseBlockExec(const struct RoseEngine *t, struct hs_scratch *scratch,
|
||||||
RoseCallback callback, RoseCallbackSom som_callback,
|
RoseCallback callback, RoseCallbackSom som_callback) {
|
||||||
void *context) {
|
|
||||||
assert(t);
|
assert(t);
|
||||||
assert(scratch);
|
assert(scratch);
|
||||||
assert(scratch->core_info.buf);
|
assert(scratch->core_info.buf);
|
||||||
@ -99,7 +97,7 @@ void roseBlockExec(const struct RoseEngine *t, struct hs_scratch *scratch,
|
|||||||
assert(t->maxBiAnchoredWidth == ROSE_BOUND_INF
|
assert(t->maxBiAnchoredWidth == ROSE_BOUND_INF
|
||||||
|| length <= t->maxBiAnchoredWidth);
|
|| length <= t->maxBiAnchoredWidth);
|
||||||
|
|
||||||
roseBlockExec_i(t, scratch, callback, som_callback, context);
|
roseBlockExec_i(t, scratch, callback, som_callback);
|
||||||
|
|
||||||
if (!t->requiresEodCheck) {
|
if (!t->requiresEodCheck) {
|
||||||
return;
|
return;
|
||||||
@ -120,12 +118,11 @@ void roseBlockExec(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 */
|
||||||
void roseStreamExec(const struct RoseEngine *t, struct hs_scratch *scratch,
|
void roseStreamExec(const struct RoseEngine *t, struct hs_scratch *scratch,
|
||||||
RoseCallback callback, RoseCallbackSom som_callback,
|
RoseCallback callback, RoseCallbackSom som_callback);
|
||||||
void *context);
|
|
||||||
|
|
||||||
void roseEodExec(const struct RoseEngine *t, u64a offset,
|
void roseEodExec(const struct RoseEngine *t, u64a offset,
|
||||||
struct hs_scratch *scratch, RoseCallback callback,
|
struct hs_scratch *scratch, RoseCallback callback,
|
||||||
RoseCallbackSom som_callback, void *context);
|
RoseCallbackSom som_callback);
|
||||||
|
|
||||||
#define ROSE_CONTINUE_MATCHING_NO_EXHAUST 2
|
#define ROSE_CONTINUE_MATCHING_NO_EXHAUST 2
|
||||||
|
|
||||||
|
@ -33,7 +33,9 @@
|
|||||||
|
|
||||||
struct RoseEngine;
|
struct RoseEngine;
|
||||||
|
|
||||||
// Note: identical signature to NfaCallback
|
// Note: identical signature to NfaCallback, but all Rose callbacks must be
|
||||||
|
// passed scratch as their context ptr.
|
||||||
|
|
||||||
typedef int (*RoseCallback)(u64a offset, ReportID id, void *context);
|
typedef int (*RoseCallback)(u64a offset, ReportID id, void *context);
|
||||||
typedef int (*RoseCallbackSom)(u64a from_offset, u64a to_offset, ReportID id,
|
typedef int (*RoseCallbackSom)(u64a from_offset, u64a to_offset, ReportID id,
|
||||||
void *context);
|
void *context);
|
||||||
|
@ -424,8 +424,7 @@ void do_rebuild(const struct RoseEngine *t, const struct HWLM *ftable,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void roseStreamExec(const struct RoseEngine *t, struct hs_scratch *scratch,
|
void roseStreamExec(const struct RoseEngine *t, struct hs_scratch *scratch,
|
||||||
RoseCallback callback, RoseCallbackSom som_callback,
|
RoseCallback callback, RoseCallbackSom som_callback) {
|
||||||
void *ctx) {
|
|
||||||
DEBUG_PRINTF("OH HAI\n");
|
DEBUG_PRINTF("OH HAI\n");
|
||||||
assert(t);
|
assert(t);
|
||||||
assert(scratch->core_info.hbuf);
|
assert(scratch->core_info.hbuf);
|
||||||
@ -458,7 +457,6 @@ void roseStreamExec(const struct RoseEngine *t, struct hs_scratch *scratch,
|
|||||||
tctxt->filledDelayedSlots = 0;
|
tctxt->filledDelayedSlots = 0;
|
||||||
tctxt->cb = callback;
|
tctxt->cb = callback;
|
||||||
tctxt->cb_som = som_callback;
|
tctxt->cb_som = som_callback;
|
||||||
tctxt->userCtx = ctx;
|
|
||||||
tctxt->lastMatchOffset = 0;
|
tctxt->lastMatchOffset = 0;
|
||||||
tctxt->minMatchOffset = offset;
|
tctxt->minMatchOffset = offset;
|
||||||
tctxt->minNonMpvMatchOffset = offset;
|
tctxt->minNonMpvMatchOffset = offset;
|
||||||
|
@ -687,7 +687,7 @@ void rawBlockExec(const struct RoseEngine *rose, struct hs_scratch *scratch) {
|
|||||||
DEBUG_PRINTF("blockmode scan len=%zu\n", scratch->core_info.len);
|
DEBUG_PRINTF("blockmode scan len=%zu\n", scratch->core_info.len);
|
||||||
|
|
||||||
roseBlockExec(rose, scratch, selectAdaptor(rose),
|
roseBlockExec(rose, scratch, selectAdaptor(rose),
|
||||||
selectSomAdaptor(rose), scratch);
|
selectSomAdaptor(rose));
|
||||||
}
|
}
|
||||||
|
|
||||||
static really_inline
|
static really_inline
|
||||||
@ -1018,7 +1018,7 @@ void rawEodExec(hs_stream_t *id, hs_scratch_t *scratch) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
roseEodExec(rose, id->offset, scratch, selectAdaptor(rose),
|
roseEodExec(rose, id->offset, scratch, selectAdaptor(rose),
|
||||||
selectSomAdaptor(rose), scratch);
|
selectSomAdaptor(rose));
|
||||||
}
|
}
|
||||||
|
|
||||||
static never_inline
|
static never_inline
|
||||||
@ -1190,8 +1190,7 @@ void rawStreamExec(struct hs_stream *stream_state, struct hs_scratch *scratch) {
|
|||||||
|
|
||||||
const struct RoseEngine *rose = stream_state->rose;
|
const struct RoseEngine *rose = stream_state->rose;
|
||||||
assert(rose);
|
assert(rose);
|
||||||
roseStreamExec(rose, scratch, selectAdaptor(rose), selectSomAdaptor(rose),
|
roseStreamExec(rose, scratch, selectAdaptor(rose), selectSomAdaptor(rose));
|
||||||
scratch);
|
|
||||||
|
|
||||||
if (!told_to_stop_matching(scratch) &&
|
if (!told_to_stop_matching(scratch) &&
|
||||||
isAllExhausted(rose, scratch->core_info.exhaustionVector)) {
|
isAllExhausted(rose, scratch->core_info.exhaustionVector)) {
|
||||||
|
@ -122,7 +122,6 @@ struct RoseContext {
|
|||||||
* match, cleared if top events arrive */
|
* match, cleared if top events arrive */
|
||||||
RoseCallback cb;
|
RoseCallback cb;
|
||||||
RoseCallbackSom cb_som;
|
RoseCallbackSom cb_som;
|
||||||
void *userCtx;
|
|
||||||
u32 filledDelayedSlots;
|
u32 filledDelayedSlots;
|
||||||
u32 curr_anchored_loc; /**< last read/written row */
|
u32 curr_anchored_loc; /**< last read/written row */
|
||||||
u32 curr_row_offset; /**< last read/written entry */
|
u32 curr_row_offset; /**< last read/written entry */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user