]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
rose: use normal callback for pure-literal cases
authorJustin Viiret <justin.viiret@intel.com>
Tue, 5 Jul 2016 04:37:22 +0000 (14:37 +1000)
committerMatthew Barr <matthew.barr@intel.com>
Wed, 10 Aug 2016 04:52:56 +0000 (14:52 +1000)
src/rose/match.c
src/rose/rose.h
src/runtime.c

index 2b05fd7649d8a642a3dcaffdeae1b94ffc7b3b53..15d3534c38edc00531fce9f3c37857ecaf825eef 100644 (file)
@@ -582,29 +582,6 @@ hwlmcb_rv_t roseFloatingCallback(size_t start, size_t end, u32 id, void *ctxt) {
     return roseCallback_i(start, end, id, ctxt) & t->floating_group_mask;
 }
 
-/**
- * \brief Match callback adaptor used for matches from pure-literal cases.
- *
- * Literal match IDs in this path run limited Rose programs that do not use
- * Rose state (which is not initialised in the pure-literal path). They can
- * still, for example, check lookarounds or literal masks.
- */
-hwlmcb_rv_t rosePureLiteralCallback(size_t start, size_t end, u32 id,
-                                    void *context) {
-    DEBUG_PRINTF("start=%zu, end=%zu, id=%u\n", start, end, id);
-    struct hs_scratch *scratch = context;
-    struct core_info *ci = &scratch->core_info;
-    const u64a real_end = (u64a)end + ci->buf_offset + 1;
-    const u64a som = 0;
-    const size_t match_len = end - start + 1;
-    const struct RoseEngine *rose = ci->rose;
-    const u32 *programs = getByOffset(rose, rose->litProgramOffset);
-    assert(id < rose->literalCount);
-    const u8 flags = 0;
-    return roseRunProgram(rose, scratch, programs[id], som, real_end, match_len,
-                          flags);
-}
-
 /**
  * \brief Execute a boundary report program.
  *
index 280e3bd53b4c305f249f006921968e05af171534..9a50f0e91a3a92b184fd9c63e5901632ec663018 100644 (file)
@@ -46,8 +46,7 @@ void roseStreamExec(const struct RoseEngine *t, struct hs_scratch *scratch);
 void roseStreamEodExec(const struct RoseEngine *t, u64a offset,
                        struct hs_scratch *scratch);
 
-hwlmcb_rv_t rosePureLiteralCallback(size_t start, size_t end, u32 id,
-                                    void *context);
+hwlmcb_rv_t roseCallback(size_t start, size_t end, u32 id, void *context);
 
 int roseReportAdaptor(u64a start, u64a end, ReportID id, void *context);
 
index 2def17c8581e943fa615b1e9d83c52dfe0f57cd7..fc867b8e7c37796ce1b9f2c8e9d4f20ef712664b 100644 (file)
@@ -198,7 +198,11 @@ void pureLiteralBlockExec(const struct RoseEngine *rose,
     size_t length = scratch->core_info.len;
     DEBUG_PRINTF("rose engine %d\n", rose->runtimeImpl);
 
-    hwlmExec(ftable, buffer, length, 0, rosePureLiteralCallback, scratch,
+    // RoseContext values that need to be set for use by roseCallback.
+    scratch->tctxt.groups = rose->initialGroups;
+    scratch->tctxt.lit_offset_adjust = 1;
+
+    hwlmExec(ftable, buffer, length, 0, roseCallback, scratch,
              rose->initialGroups);
 }
 
@@ -742,11 +746,15 @@ void pureLiteralStreamExec(struct hs_stream *stream_state,
     DEBUG_PRINTF("::: streaming rose ::: offset = %llu len = %zu\n",
                  stream_state->offset, scratch->core_info.len);
 
+    // RoseContext values that need to be set for use by roseCallback.
+    scratch->tctxt.groups = loadGroups(rose, scratch->core_info.state);
+    scratch->tctxt.lit_offset_adjust = scratch->core_info.buf_offset + 1;
+
     // Pure literal cases don't have floatingMinDistance set, so we always
     // start the match region at zero.
     const size_t start = 0;
 
-    hwlmExecStreaming(ftable, scratch, len2, start, rosePureLiteralCallback,
+    hwlmExecStreaming(ftable, scratch, len2, start, roseCallback,
                       scratch, rose->initialGroups, hwlm_stream_state);
 
     if (!told_to_stop_matching(scratch) &&