]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
rose: inline block-mode eod check
authorJustin Viiret <justin.viiret@intel.com>
Tue, 14 Jun 2016 06:58:13 +0000 (16:58 +1000)
committerMatthew Barr <matthew.barr@intel.com>
Fri, 8 Jul 2016 00:55:36 +0000 (10:55 +1000)
src/rose/block.c
src/rose/eod.c
src/rose/rose.h

index 5fc5c8a14f81f9928aa8e4843724a82dc40c6f74..0df5144cb47390c23e8e9323a817606849408688 100644 (file)
 #include "catchup.h"
 #include "init.h"
 #include "match.h"
+#include "program_runtime.h"
+#include "rose.h"
+#include "rose_common.h"
 #include "nfa/nfa_api.h"
 #include "nfa/nfa_internal.h"
 #include "nfa/nfa_rev_api.h"
 #include "nfa/mcclellan.h"
 #include "util/fatbit.h"
-#include "rose.h"
-#include "rose_common.h"
 
 static rose_inline
 void runAnchoredTableBlock(const struct RoseEngine *t, const void *atable,
@@ -157,6 +158,38 @@ void init_for_block(const struct RoseEngine *t, struct hs_scratch *scratch,
     init_outfixes_for_block(t, scratch, state, is_small_block);
 }
 
+static rose_inline
+void roseBlockEodExec(const struct RoseEngine *t, u64a offset,
+                      struct hs_scratch *scratch) {
+    assert(t->requiresEodCheck);
+    assert(t->maxBiAnchoredWidth == ROSE_BOUND_INF
+           || offset <= t->maxBiAnchoredWidth);
+
+    assert(!can_stop_matching(scratch));
+    assert(t->eodProgramOffset);
+
+    // Ensure that history is correct before we look for EOD matches.
+    roseFlushLastByteHistory(t, scratch, offset);
+    scratch->tctxt.lastEndOffset = offset;
+
+    DEBUG_PRINTF("running eod program at %u\n", t->eodProgramOffset);
+
+    // There should be no pending delayed literals.
+    assert(!scratch->tctxt.filledDelayedSlots);
+
+    const u64a som = 0;
+    const size_t match_len = 0;
+    const char in_anchored = 0;
+    const char in_catchup = 0;
+    const char from_mpv = 0;
+    const char skip_mpv_catchup = 1;
+
+    // Note: we ignore the result, as this is the last thing to ever happen on
+    // a scan.
+    roseRunProgram(t, scratch, t->eodProgramOffset, som, offset, match_len,
+                   in_anchored, in_catchup, from_mpv, skip_mpv_catchup);
+}
+
 void roseBlockExec_i(const struct RoseEngine *t, struct hs_scratch *scratch) {
     assert(t);
     assert(scratch);
@@ -255,4 +288,16 @@ exit:;
     assert(!can_stop_matching(scratch));
 
     roseCatchUpTo(t, scratch, length);
+
+    if (!t->requiresEodCheck || !t->eodProgramOffset) {
+        DEBUG_PRINTF("no eod check required\n");
+        return;
+    }
+
+    if (can_stop_matching(scratch)) {
+        DEBUG_PRINTF("bailing, already halted\n");
+        return;
+    }
+
+    roseBlockEodExec(t, length, scratch);
 }
index 4dee0150a3f57f249ad316c91eb2e5498e985014..249e7a9c35534b29d549f0c32ecec143accc806c 100644 (file)
@@ -108,23 +108,3 @@ void roseEodExec(const struct RoseEngine *t, u64a offset,
     initContext(t, offset, scratch);
     roseEodExec_i(t, offset, scratch, 1);
 }
-
-static rose_inline
-void prepForEod(const struct RoseEngine *t, struct hs_scratch *scratch,
-                size_t length) {
-    roseFlushLastByteHistory(t, scratch, length);
-    scratch->tctxt.lastEndOffset = length;
-}
-
-void roseBlockEodExec(const struct RoseEngine *t, u64a offset,
-                      struct hs_scratch *scratch) {
-    assert(t->requiresEodCheck);
-    assert(t->maxBiAnchoredWidth == ROSE_BOUND_INF
-           || offset <= t->maxBiAnchoredWidth);
-
-    assert(!can_stop_matching(scratch));
-
-    // Ensure that history is correct before we look for EOD matches
-    prepForEod(t, scratch, scratch->core_info.len);
-    roseEodExec_i(t, offset, scratch, 0);
-}
index d79c2f0c5f1fc6b0a5aa3de9ed27131868df213c..5b7940a24c683920cbc5a3aa41ba172e49b9182c 100644 (file)
@@ -39,8 +39,6 @@
 // Initialise state space for engine use.
 void roseInitState(const struct RoseEngine *t, char *state);
 
-void roseBlockEodExec(const struct RoseEngine *t, u64a offset,
-                      struct hs_scratch *scratch);
 void roseBlockExec_i(const struct RoseEngine *t, struct hs_scratch *scratch);
 
 /* assumes core_info in scratch has been init to point to data */
@@ -57,28 +55,15 @@ void roseBlockExec(const struct RoseEngine *t, struct hs_scratch *scratch) {
     // If this block is shorter than our minimum width, then no pattern in this
     // RoseEngine could match.
     /* minWidth checks should have already been performed by the caller */
-    const size_t length = scratch->core_info.len;
-    assert(length >= t->minWidth);
+    assert(scratch->core_info.len >= t->minWidth);
 
     // Similarly, we may have a maximum width (for engines constructed entirely
     // of bi-anchored patterns).
     /* This check is now handled by the interpreter */
     assert(t->maxBiAnchoredWidth == ROSE_BOUND_INF
-           || length <= t->maxBiAnchoredWidth);
+           || scratch->core_info.len <= t->maxBiAnchoredWidth);
 
     roseBlockExec_i(t, scratch);
-
-    if (!t->requiresEodCheck) {
-        DEBUG_PRINTF("no eod check required\n");
-        return;
-    }
-
-    if (can_stop_matching(scratch)) {
-        DEBUG_PRINTF("bailing, already halted\n");
-        return;
-    }
-
-    roseBlockEodExec(t, length, scratch);
 }
 
 /* assumes core_info in scratch has been init to point to data */