]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
rose_build_anchored: use bytecode_ptr
authorJustin Viiret <justin.viiret@intel.com>
Mon, 3 Apr 2017 06:47:21 +0000 (16:47 +1000)
committerMatthew Barr <matthew.barr@intel.com>
Wed, 26 Apr 2017 05:19:36 +0000 (15:19 +1000)
src/rose/rose_build_anchored.cpp
src/rose/rose_build_anchored.h
src/rose/rose_build_bytecode.cpp

index 6c7bb1c1e6faea33bcaee2e9596becbdaa6eaf7a..065990ecfa5f3c5e391a02cd3ae39e75b301cd9c 100644 (file)
@@ -869,14 +869,13 @@ vector<raw_dfa> buildAnchoredDfas(RoseBuildImpl &build,
     return dfas;
 }
 
-aligned_unique_ptr<anchored_matcher_info>
+bytecode_ptr<anchored_matcher_info>
 buildAnchoredMatcher(RoseBuildImpl &build, const vector<LitFragment> &fragments,
-                     vector<raw_dfa> &dfas, size_t *asize) {
+                     vector<raw_dfa> &dfas) {
     const CompileContext &cc = build.cc;
 
     if (dfas.empty()) {
         DEBUG_PRINTF("empty\n");
-        *asize = 0;
         return nullptr;
     }
 
@@ -892,8 +891,7 @@ buildAnchoredMatcher(RoseBuildImpl &build, const vector<LitFragment> &fragments,
         throw ResourceLimitError();
     }
 
-    *asize = total_size;
-    auto atable = aligned_zmalloc_unique<anchored_matcher_info>(total_size);
+    auto atable = make_bytecode_ptr<anchored_matcher_info>(total_size, 64);
     char *curr = (char *)atable.get();
 
     u32 state_offset = 0;
@@ -919,7 +917,7 @@ buildAnchoredMatcher(RoseBuildImpl &build, const vector<LitFragment> &fragments,
         ami->anchoredMinDistance = start_offset[i];
     }
 
-    DEBUG_PRINTF("success %zu\n", *asize);
+    DEBUG_PRINTF("success %zu\n", atable.size());
     return atable;
 }
 
index dd59ca32b19e2b061786ac9782d74fe1bb6c424d..37d268ac5a74a3906cc2523af32d50cf1fb85ad0 100644 (file)
@@ -32,7 +32,7 @@
 #include "ue2common.h"
 #include "rose_build_impl.h"
 #include "nfagraph/ng_holder.h"
-#include "util/alloc.h"
+#include "util/bytecode_ptr.h"
 
 #include <map>
 #include <vector>
@@ -59,10 +59,10 @@ std::vector<raw_dfa> buildAnchoredDfas(RoseBuildImpl &build,
  * Remap the literal final_ids used for raw_dfa reports to the program offsets
  * given in litPrograms.
  */
-aligned_unique_ptr<anchored_matcher_info>
+bytecode_ptr<anchored_matcher_info>
 buildAnchoredMatcher(RoseBuildImpl &build,
                      const std::vector<LitFragment> &fragments,
-                     std::vector<raw_dfa> &dfas, size_t *asize);
+                     std::vector<raw_dfa> &dfas);
 
 u32 anchoredStateSize(const anchored_matcher_info &atable);
 
index f7c8cf06c9eadbb4410e35541ecfcb4665b77506..c0747d97cd6f7d76fc82fda6e42434fff7cbec66 100644 (file)
@@ -5824,10 +5824,9 @@ bytecode_ptr<RoseEngine> RoseBuildImpl::buildFinalEngine(u32 minWidth) {
     writeLeftInfo(bc.engine_blob, proto, leftInfoTable);
 
     // Build anchored matcher.
-    size_t asize = 0;
-    auto atable = buildAnchoredMatcher(*this, fragments, anchored_dfas, &asize);
+    auto atable = buildAnchoredMatcher(*this, fragments, anchored_dfas);
     if (atable) {
-        proto.amatcherOffset = bc.engine_blob.add(atable.get(), asize, 64);
+        proto.amatcherOffset = bc.engine_blob.add(atable);
     }
 
     // Build floating HWLM matcher.
@@ -5952,7 +5951,7 @@ bytecode_ptr<RoseEngine> RoseBuildImpl::buildFinalEngine(u32 minWidth) {
     proto.initialGroups = getInitialGroups();
     proto.floating_group_mask = fgroups;
     proto.totalNumLiterals = verify_u32(literal_info.size());
-    proto.asize = verify_u32(asize);
+    proto.asize = verify_u32(atable.size());
     proto.ematcherRegionSize = ematcher_region_size;
     proto.longLitStreamState = verify_u32(longLitStreamStateRequired);