only show floating groups to the floating table

This commit is contained in:
Alex Coyte 2016-06-23 13:14:39 +10:00 committed by Matthew Barr
parent 1c2b0a271d
commit 575e8c06dc
9 changed files with 34 additions and 8 deletions

View File

@ -260,8 +260,8 @@ int roseBlockFloating(const struct RoseEngine *t, struct hs_scratch *scratch) {
DEBUG_PRINTF("BEGIN FLOATING (over %zu/%zu)\n", flen, length); DEBUG_PRINTF("BEGIN FLOATING (over %zu/%zu)\n", flen, length);
DEBUG_PRINTF("-- %016llx\n", tctxt->groups); DEBUG_PRINTF("-- %016llx\n", tctxt->groups);
hwlmExec(ftable, buffer, flen, t->floatingMinDistance, roseCallback, hwlmExec(ftable, buffer, flen, t->floatingMinDistance, roseFloatingCallback,
scratch, tctxt->groups); scratch, tctxt->groups & t->floating_group_mask);
return can_stop_matching(scratch); return can_stop_matching(scratch);
} }

View File

@ -516,7 +516,8 @@ anchored_leftovers:;
return rv; return rv;
} }
hwlmcb_rv_t roseCallback(size_t start, size_t end, u32 id, void *ctxt) { static really_inline
hwlmcb_rv_t roseCallback_i(size_t start, size_t end, u32 id, void *ctxt) {
struct hs_scratch *scratch = ctxt; struct hs_scratch *scratch = ctxt;
struct RoseContext *tctx = &scratch->tctxt; struct RoseContext *tctx = &scratch->tctxt;
const struct RoseEngine *t = scratch->core_info.rose; const struct RoseEngine *t = scratch->core_info.rose;
@ -564,6 +565,17 @@ hwlmcb_rv_t roseCallback(size_t start, size_t end, u32 id, void *ctxt) {
return HWLM_TERMINATE_MATCHING; return HWLM_TERMINATE_MATCHING;
} }
hwlmcb_rv_t roseCallback(size_t start, size_t end, u32 id, void *ctxt) {
return roseCallback_i(start, end, id, ctxt);
}
hwlmcb_rv_t roseFloatingCallback(size_t start, size_t end, u32 id, void *ctxt) {
struct hs_scratch *scratch = ctxt;
const struct RoseEngine *t = scratch->core_info.rose;
return roseCallback_i(start, end, id, ctxt) & t->floating_group_mask;
}
/** /**
* \brief Match callback adaptor used for matches from pure-literal cases. * \brief Match callback adaptor used for matches from pure-literal cases.
* *

View File

@ -51,6 +51,7 @@ int roseNfaSomAdaptor(u64a from_offset, u64a offset, ReportID id, void *context)
/* Callbacks, defined in match.c */ /* Callbacks, defined in match.c */
hwlmcb_rv_t roseCallback(size_t start, size_t end, u32 id, void *ctx); 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, hwlmcb_rv_t roseDelayRebuildCallback(size_t start, size_t end, u32 id,
void *ctx); void *ctx);
int roseAnchoredCallback(u64a end, u32 id, void *ctx); int roseAnchoredCallback(u64a end, u32 id, void *ctx);

View File

@ -4370,9 +4370,10 @@ aligned_unique_ptr<RoseEngine> RoseBuildImpl::buildFinalEngine(u32 minWidth) {
} }
// Build floating HWLM matcher. // Build floating HWLM matcher.
rose_group fgroups = 0;
size_t fsize = 0; size_t fsize = 0;
size_t floatingStreamStateRequired = 0; size_t floatingStreamStateRequired = 0;
auto ftable = buildFloatingMatcher(*this, &fsize, &historyRequired, auto ftable = buildFloatingMatcher(*this, &fgroups, &fsize, &historyRequired,
&floatingStreamStateRequired); &floatingStreamStateRequired);
u32 fmatcherOffset = 0; u32 fmatcherOffset = 0;
if (ftable) { if (ftable) {
@ -4584,6 +4585,7 @@ aligned_unique_ptr<RoseEngine> RoseBuildImpl::buildFinalEngine(u32 minWidth) {
fillMatcherDistances(*this, engine.get()); fillMatcherDistances(*this, engine.get());
engine->initialGroups = getInitialGroups(); engine->initialGroups = getInitialGroups();
engine->floating_group_mask = fgroups;
engine->totalNumLiterals = verify_u32(literal_info.size()); engine->totalNumLiterals = verify_u32(literal_info.size());
engine->asize = verify_u32(asize); engine->asize = verify_u32(asize);
engine->ematcherRegionSize = ematcher_region_size; engine->ematcherRegionSize = ematcher_region_size;

View File

@ -580,10 +580,12 @@ vector<hwlmLiteral> fillHamsterLiteralList(const RoseBuildImpl &build,
} }
aligned_unique_ptr<HWLM> buildFloatingMatcher(const RoseBuildImpl &build, aligned_unique_ptr<HWLM> buildFloatingMatcher(const RoseBuildImpl &build,
rose_group *fgroups,
size_t *fsize, size_t *fsize,
size_t *historyRequired, size_t *historyRequired,
size_t *streamStateRequired) { size_t *streamStateRequired) {
*fsize = 0; *fsize = 0;
*fgroups = 0;
auto fl = fillHamsterLiteralList(build, ROSE_FLOATING); auto fl = fillHamsterLiteralList(build, ROSE_FLOATING);
if (fl.empty()) { if (fl.empty()) {
@ -591,6 +593,10 @@ aligned_unique_ptr<HWLM> buildFloatingMatcher(const RoseBuildImpl &build,
return nullptr; return nullptr;
} }
for (const hwlmLiteral &hlit : fl) {
*fgroups |= hlit.groups;
}
hwlmStreamingControl ctl; hwlmStreamingControl ctl;
hwlmStreamingControl *ctlp; hwlmStreamingControl *ctlp;
if (build.cc.streaming) { if (build.cc.streaming) {

View File

@ -48,6 +48,7 @@ std::vector<hwlmLiteral> fillHamsterLiteralList(const RoseBuildImpl &build,
rose_literal_table table); rose_literal_table table);
aligned_unique_ptr<HWLM> buildFloatingMatcher(const RoseBuildImpl &build, aligned_unique_ptr<HWLM> buildFloatingMatcher(const RoseBuildImpl &build,
rose_group *fgroups,
size_t *fsize, size_t *fsize,
size_t *historyRequired, size_t *historyRequired,
size_t *streamStateRequired); size_t *streamStateRequired);

View File

@ -930,6 +930,7 @@ void roseDumpText(const RoseEngine *t, FILE *f) {
fprintf(f, "\n"); fprintf(f, "\n");
fprintf(f, "initial groups : 0x%016llx\n", t->initialGroups); fprintf(f, "initial groups : 0x%016llx\n", t->initialGroups);
fprintf(f, "floating groups : 0x%016llx\n", t->floating_group_mask);
fprintf(f, "handled key count : %u\n", t->handledKeyCount); fprintf(f, "handled key count : %u\n", t->handledKeyCount);
fprintf(f, "\n"); fprintf(f, "\n");
@ -1035,6 +1036,7 @@ void roseDumpStructRaw(const RoseEngine *t, FILE *f) {
DUMP_U32(t, floatingMinLiteralMatchOffset); DUMP_U32(t, floatingMinLiteralMatchOffset);
DUMP_U32(t, nfaInfoOffset); DUMP_U32(t, nfaInfoOffset);
DUMP_U64(t, initialGroups); DUMP_U64(t, initialGroups);
DUMP_U64(t, floating_group_mask);
DUMP_U32(t, size); DUMP_U32(t, size);
DUMP_U32(t, delay_count); DUMP_U32(t, delay_count);
DUMP_U32(t, delay_base_id); DUMP_U32(t, delay_base_id);

View File

@ -401,6 +401,7 @@ struct RoseEngine {
* table */ * table */
u32 nfaInfoOffset; /* offset to the nfa info offset array */ u32 nfaInfoOffset; /* offset to the nfa info offset array */
rose_group initialGroups; rose_group initialGroups;
rose_group floating_group_mask; /* groups that are used by the ftable */
u32 size; // (bytes) u32 size; // (bytes)
u32 delay_count; /* number of delayed literal ids. */ u32 delay_count; /* number of delayed literal ids. */
u32 delay_base_id; /* literal id of the first delayed literal. u32 delay_base_id; /* literal id of the first delayed literal.

View File

@ -461,8 +461,8 @@ void roseStreamExec(const struct RoseEngine *t, struct hs_scratch *scratch) {
tctxt->minMatchOffset = offset; tctxt->minMatchOffset = offset;
tctxt->minNonMpvMatchOffset = offset; tctxt->minNonMpvMatchOffset = offset;
tctxt->next_mpv_offset = 0; tctxt->next_mpv_offset = 0;
DEBUG_PRINTF("BEGIN: history len=%zu, buffer len=%zu\n", DEBUG_PRINTF("BEGIN: history len=%zu, buffer len=%zu groups=%016llx\n",
scratch->core_info.hlen, scratch->core_info.len); scratch->core_info.hlen, scratch->core_info.len, tctxt->groups);
fatbit_clear(scratch->aqa); fatbit_clear(scratch->aqa);
scratch->al_log_sum = 0; scratch->al_log_sum = 0;
@ -540,8 +540,9 @@ void roseStreamExec(const struct RoseEngine *t, struct hs_scratch *scratch) {
} }
DEBUG_PRINTF("BEGIN FLOATING (over %zu/%zu)\n", flen, length); DEBUG_PRINTF("BEGIN FLOATING (over %zu/%zu)\n", flen, length);
hwlmExecStreaming(ftable, scratch, flen, start, roseCallback, scratch, hwlmExecStreaming(ftable, scratch, flen, start, roseFloatingCallback,
tctxt->groups, stream_state); scratch, tctxt->groups & t->floating_group_mask,
stream_state);
} }
flush_delay_and_exit: flush_delay_and_exit: