]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
move eod iter program into general eod program
authorJustin Viiret <justin.viiret@intel.com>
Tue, 14 Jun 2016 00:39:02 +0000 (10:39 +1000)
committerMatthew Barr <matthew.barr@intel.com>
Fri, 8 Jul 2016 00:55:36 +0000 (10:55 +1000)
src/rose/program_runtime.h
src/rose/rose_build_bytecode.cpp
src/rose/rose_dump.cpp
src/rose/rose_internal.h

index 5d255cf1224e7e292f9d4e4e97651008e7c67e7d..e23a395cd7590d11df2f602621574522d018cd9a 100644 (file)
 #include "util/fatbit.h"
 #include "util/multibit.h"
 
-static rose_inline
-hwlmcb_rv_t roseRunProgram(const struct RoseEngine *t,
-                           struct hs_scratch *scratch, u32 programOffset,
-                           u64a som, u64a end, size_t match_len,
-                           char in_anchored, char in_catchup, char from_mpv,
-                           char skip_mpv_catchup);
-
 static rose_inline
 int roseCheckBenefits(const struct core_info *ci, u64a end, u32 mask_rewind,
                       const u8 *and_mask, const u8 *exp_mask) {
@@ -901,30 +894,6 @@ hwlmcb_rv_t roseSuffixesEod(const struct RoseEngine *rose,
 }
 
 static rose_inline
-int roseEodRunIterator(const struct RoseEngine *t, u64a offset,
-                       struct hs_scratch *scratch) {
-    if (!t->eodIterProgramOffset) {
-        return MO_CONTINUE_MATCHING;
-    }
-
-    DEBUG_PRINTF("running eod program at offset %u\n", t->eodIterProgramOffset);
-
-    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;
-    if (roseRunProgram(t, scratch, t->eodIterProgramOffset, som, offset,
-                       match_len, in_anchored, in_catchup,
-                       from_mpv, skip_mpv_catchup) == HWLM_TERMINATE_MATCHING) {
-        return MO_HALT_MATCHING;
-    }
-
-    return MO_CONTINUE_MATCHING;
-}
-
-static
 hwlmcb_rv_t roseMatcherEod(const struct RoseEngine *rose,
                            struct hs_scratch *scratch, u64a offset) {
     assert(rose->ematcherOffset);
@@ -977,13 +946,6 @@ hwlmcb_rv_t roseMatcherEod(const struct RoseEngine *rose,
     }
 
     roseFlushLastByteHistory(rose, scratch, offset);
-
-    // Fire any new EOD reports.
-    if (roseEodRunIterator(rose, offset, scratch) == MO_HALT_MATCHING) {
-        DEBUG_PRINTF("user instructed us to stop\n");
-        return HWLM_TERMINATE_MATCHING;
-    }
-
     return HWLM_CONTINUE_MATCHING;
 }
 
index c472337d3d73c70c58f85f167a3f9281aad20863..32150b79cbffb4204ad8656ca151cfa97faeffe4 100644 (file)
@@ -4015,11 +4015,9 @@ bool hasEodMatcher(const RoseBuildImpl &build) {
     return false;
 }
 
-/**
- * Returns the pair (program offset, sparse iter offset).
- */
 static
-u32 writeEodAnchorProgram(RoseBuildImpl &build, build_context &bc) {
+void addEodAnchorProgram(RoseBuildImpl &build, build_context &bc,
+                         vector<RoseInstruction> &program) {
     const RoseGraph &g = build.g;
 
     // pred state id -> list of programs
@@ -4058,10 +4056,7 @@ u32 writeEodAnchorProgram(RoseBuildImpl &build, build_context &bc) {
         }
     }
 
-    vector<RoseInstruction> program;
-    if (!predProgramLists.empty()) {
-        addPredBlocks(bc, predProgramLists, program);
-    }
+    addPredBlocks(bc, predProgramLists, program);
 
     if (hasEodAnchoredSuffix(build)) {
         if (!program.empty()) {
@@ -4069,17 +4064,8 @@ u32 writeEodAnchorProgram(RoseBuildImpl &build, build_context &bc) {
             program.pop_back();
         }
         program.emplace_back(ROSE_INSTR_SUFFIXES_EOD);
+        program.emplace_back(ROSE_INSTR_END);
     }
-
-    if (program.empty()) {
-        return 0;
-    }
-
-    program = flattenProgram({program});
-
-    assert(program.size() > 1);
-    applyFinalSpecialisation(program);
-    return writeProgram(bc, program);
 }
 
 static
@@ -4139,6 +4125,11 @@ void addGeneralEodAnchorProgram(RoseBuildImpl &build, build_context &bc,
         program.emplace_back(ROSE_INSTR_MATCHER_EOD);
         program.emplace_back(ROSE_INSTR_END);
     }
+
+    if (!program.empty()) {
+        assert(program.back().code() == ROSE_INSTR_END);
+        program.pop_back();
+    }
 }
 
 static
@@ -4184,11 +4175,18 @@ u32 writeEodProgram(RoseBuildImpl &build, build_context &bc,
     }
 
     addGeneralEodAnchorProgram(build, bc, program);
+    addEodAnchorProgram(build, bc, program);
+
+    if (program.size() == 1) {
+        assert(program.back().code() == ROSE_INSTR_END);
+        return 0;
+    }
 
     if (program.empty()) {
         return 0;
     }
 
+
     applyFinalSpecialisation(program);
     return writeProgram(bc, program);
 }
@@ -4355,7 +4353,6 @@ aligned_unique_ptr<RoseEngine> RoseBuildImpl::buildFinalEngine(u32 minWidth) {
         buildLiteralPrograms(*this, bc);
 
     u32 eodProgramOffset = writeEodProgram(*this, bc, eodNfaIterOffset);
-    u32 eodIterProgramOffset = writeEodAnchorProgram(*this, bc);
 
     vector<mmbit_sparse_iter> activeLeftIter;
     buildActiveLeftIter(leftInfoTable, activeLeftIter);
@@ -4552,7 +4549,6 @@ aligned_unique_ptr<RoseEngine> RoseBuildImpl::buildFinalEngine(u32 minWidth) {
     engine->nfaInfoOffset = nfaInfoOffset;
 
     engine->eodProgramOffset = eodProgramOffset;
-    engine->eodIterProgramOffset = eodIterProgramOffset;
 
     engine->lastByteHistoryIterOffset = lastByteOffset;
 
index 5bcff4fcf4c16e92f95a44cce021beab1ce260d4..40979e8cfcf377e475a5cb1d1914361f02f13c33 100644 (file)
@@ -542,7 +542,7 @@ void dumpRoseEodPrograms(const RoseEngine *t, const string &filename) {
     ofstream os(filename);
     const char *base = (const char *)t;
 
-    os << "Unconditional EOD Program:" << endl;
+    os << "EOD Program:" << endl;
 
     if (t->eodProgramOffset) {
         dumpProgram(os, t, base + t->eodProgramOffset);
@@ -551,14 +551,6 @@ void dumpRoseEodPrograms(const RoseEngine *t, const string &filename) {
         os << "<No EOD Program>" << endl;
     }
 
-    os << "Sparse Iter EOD Program:" << endl;
-
-    if (t->eodIterProgramOffset) {
-        dumpProgram(os, t, base + t->eodIterProgramOffset);
-    } else {
-        os << "<No EOD Iter Program>" << endl;
-    }
-
     os.close();
 }
 
@@ -1031,7 +1023,6 @@ void roseDumpStructRaw(const RoseEngine *t, FILE *f) {
     DUMP_U32(t, lookaroundTableOffset);
     DUMP_U32(t, lookaroundReachOffset);
     DUMP_U32(t, eodProgramOffset);
-    DUMP_U32(t, eodIterProgramOffset);
     DUMP_U32(t, lastByteHistoryIterOffset);
     DUMP_U32(t, minWidth);
     DUMP_U32(t, minWidthExcludingBoundaries);
index faab45f7976ceb2899b129c6e975ed28dd96d87d..366636b68343b59ff0f5eb8820819c6e710944d3 100644 (file)
@@ -376,8 +376,7 @@ struct RoseEngine {
     u32 lookaroundReachOffset; /**< base of lookaround reach bitvectors (32
                                 * bytes each) */
 
-    u32 eodProgramOffset; //!< Unconditional EOD program, otherwise 0.
-    u32 eodIterProgramOffset; // or 0 if no eod iterator program
+    u32 eodProgramOffset; //!< EOD program, otherwise 0.
 
     u32 lastByteHistoryIterOffset; // if non-zero