]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
only show floating groups to the floating table
authorAlex Coyte <a.coyte@intel.com>
Thu, 23 Jun 2016 03:14:39 +0000 (13:14 +1000)
committerMatthew Barr <matthew.barr@intel.com>
Fri, 8 Jul 2016 00:59:40 +0000 (10:59 +1000)
src/rose/block.c
src/rose/match.c
src/rose/match.h
src/rose/rose_build_bytecode.cpp
src/rose/rose_build_matchers.cpp
src/rose/rose_build_matchers.h
src/rose/rose_dump.cpp
src/rose/rose_internal.h
src/rose/stream.c

index c0b5e0e44b75a26374064a69322872acb7b18977..55323c2e57ce2a111428e5ead370476a347032b8 100644 (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("-- %016llx\n", tctxt->groups);
-    hwlmExec(ftable, buffer, flen, t->floatingMinDistance, roseCallback,
-             scratch, tctxt->groups);
+    hwlmExec(ftable, buffer, flen, t->floatingMinDistance, roseFloatingCallback,
+             scratch, tctxt->groups & t->floating_group_mask);
 
     return can_stop_matching(scratch);
 }
index 4e9e72a6cc1d6aaf1d4f474287d4f8c3248a4571..e89c8d3a7f07cd083f2912c49d2cf3ff971c16d6 100644 (file)
@@ -516,7 +516,8 @@ anchored_leftovers:;
     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 RoseContext *tctx = &scratch->tctxt;
     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;
 }
 
+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.
  *
index cee32fc24edce498a73b26b47f36958502969ed1..5b587aec9b5c5516e62f5bb90553fe2a6eeb24c5 100644 (file)
@@ -51,6 +51,7 @@ int roseNfaSomAdaptor(u64a from_offset, u64a offset, ReportID id, void *context)
 /* Callbacks, defined in match.c */
 
 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);
index cab0d60a3c220ac45744855e940a3d5f5ff758c9..3f36a05e1984163a56375640649c2d069597af16 100644 (file)
@@ -4370,9 +4370,10 @@ aligned_unique_ptr<RoseEngine> RoseBuildImpl::buildFinalEngine(u32 minWidth) {
     }
 
     // Build floating HWLM matcher.
+    rose_group fgroups = 0;
     size_t fsize = 0;
     size_t floatingStreamStateRequired = 0;
-    auto ftable = buildFloatingMatcher(*this, &fsize, &historyRequired,
+    auto ftable = buildFloatingMatcher(*this, &fgroups, &fsize, &historyRequired,
                                        &floatingStreamStateRequired);
     u32 fmatcherOffset = 0;
     if (ftable) {
@@ -4584,6 +4585,7 @@ aligned_unique_ptr<RoseEngine> RoseBuildImpl::buildFinalEngine(u32 minWidth) {
     fillMatcherDistances(*this, engine.get());
 
     engine->initialGroups = getInitialGroups();
+    engine->floating_group_mask = fgroups;
     engine->totalNumLiterals = verify_u32(literal_info.size());
     engine->asize = verify_u32(asize);
     engine->ematcherRegionSize = ematcher_region_size;
index f4597de7f19399d7be4dceeb16b829da1eba8e3c..b66556fc6cad34e71c5cfb969fedf57500813a40 100644 (file)
@@ -580,10 +580,12 @@ vector<hwlmLiteral> fillHamsterLiteralList(const RoseBuildImpl &build,
 }
 
 aligned_unique_ptr<HWLM> buildFloatingMatcher(const RoseBuildImpl &build,
+                                              rose_group *fgroups,
                                               size_t *fsize,
                                               size_t *historyRequired,
                                               size_t *streamStateRequired) {
     *fsize = 0;
+    *fgroups = 0;
 
     auto fl = fillHamsterLiteralList(build, ROSE_FLOATING);
     if (fl.empty()) {
@@ -591,6 +593,10 @@ aligned_unique_ptr<HWLM> buildFloatingMatcher(const RoseBuildImpl &build,
         return nullptr;
     }
 
+    for (const hwlmLiteral &hlit : fl) {
+        *fgroups |= hlit.groups;
+    }
+
     hwlmStreamingControl ctl;
     hwlmStreamingControl *ctlp;
     if (build.cc.streaming) {
index 1dd53cd8bb0d905cffa17f032ee2a03f83573b73..7d5c92835b45052cde8f51855d0415de1bbddc83 100644 (file)
@@ -48,6 +48,7 @@ std::vector<hwlmLiteral> fillHamsterLiteralList(const RoseBuildImpl &build,
                                                 rose_literal_table table);
 
 aligned_unique_ptr<HWLM> buildFloatingMatcher(const RoseBuildImpl &build,
+                                              rose_group *fgroups,
                                               size_t *fsize,
                                               size_t *historyRequired,
                                               size_t *streamStateRequired);
index 40979e8cfcf377e475a5cb1d1914361f02f13c33..9f55dbf22a769a7fc0257095b1583a4648b66c73 100644 (file)
@@ -930,6 +930,7 @@ void roseDumpText(const RoseEngine *t, FILE *f) {
     fprintf(f, "\n");
 
     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, "\n");
 
@@ -1035,6 +1036,7 @@ void roseDumpStructRaw(const RoseEngine *t, FILE *f) {
     DUMP_U32(t, floatingMinLiteralMatchOffset);
     DUMP_U32(t, nfaInfoOffset);
     DUMP_U64(t, initialGroups);
+    DUMP_U64(t, floating_group_mask);
     DUMP_U32(t, size);
     DUMP_U32(t, delay_count);
     DUMP_U32(t, delay_base_id);
index af5b2a9536598c982c242d9f5367b46d92d3a6ad..9dd173500ec05b2353b2e522d265e3a9833b9997 100644 (file)
@@ -401,6 +401,7 @@ struct RoseEngine {
                                         * table */
     u32 nfaInfoOffset; /* offset to the nfa info offset array */
     rose_group initialGroups;
+    rose_group floating_group_mask; /* groups that are used by the ftable */
     u32 size; // (bytes)
     u32 delay_count; /* number of delayed literal ids. */
     u32 delay_base_id; /* literal id of the first delayed literal.
index 0e382f035ccec3e19b1ea58e3c7458d3a9fa1d95..ffe965dd2ce06f4df02f7d8b7e2e8010845af7e0 100644 (file)
@@ -461,8 +461,8 @@ void roseStreamExec(const struct RoseEngine *t, struct hs_scratch *scratch) {
     tctxt->minMatchOffset = offset;
     tctxt->minNonMpvMatchOffset = offset;
     tctxt->next_mpv_offset = 0;
-    DEBUG_PRINTF("BEGIN: history len=%zu, buffer len=%zu\n",
-                  scratch->core_info.hlen, scratch->core_info.len);
+    DEBUG_PRINTF("BEGIN: history len=%zu, buffer len=%zu groups=%016llx\n",
+                 scratch->core_info.hlen, scratch->core_info.len, tctxt->groups);
 
     fatbit_clear(scratch->aqa);
     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);
-        hwlmExecStreaming(ftable, scratch, flen, start, roseCallback, scratch,
-                          tctxt->groups, stream_state);
+        hwlmExecStreaming(ftable, scratch, flen, start, roseFloatingCallback,
+                          scratch, tctxt->groups & t->floating_group_mask,
+                          stream_state);
     }
 
 flush_delay_and_exit: