]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
unit: use bytecode_ptr instead of aligned_unique_ptr
authorJustin Viiret <justin.viiret@intel.com>
Tue, 4 Apr 2017 01:41:50 +0000 (11:41 +1000)
committerMatthew Barr <matthew.barr@intel.com>
Wed, 26 Apr 2017 05:19:36 +0000 (15:19 +1000)
unit/internal/fdr.cpp
unit/internal/fdr_loadval.cpp
unit/internal/lbr.cpp
unit/internal/limex_nfa.cpp
unit/internal/simd_utils.cpp

index 8ec725985ec823c7a019da1dde90c3a4465b47bd..bd0bb4c0c047654221a883759ce1de8e9fa733b1 100644 (file)
@@ -383,7 +383,7 @@ TEST_P(FDRp, moveByteStream) {
 
     size_t size = fdrSize(fdrTable0.get());
 
-    auto fdrTable = aligned_zmalloc_unique<FDR>(size);
+    auto fdrTable = make_bytecode_ptr<FDR>(size, 64);
     EXPECT_NE(nullptr, fdrTable);
 
     memcpy(fdrTable.get(), fdrTable0.get(), size);
index 22fee7704b02ddf8484f8998fb2f17014fb7bb9b..bb5efb5f0aefe68a447815e1d27f1c3240cb70b2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Intel Corporation
+ * Copyright (c) 2015-2017, Intel Corporation
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -30,7 +30,7 @@
 #include "gtest/gtest.h"
 
 #include "fdr/fdr_loadval.h"
-#include "util/alloc.h"
+#include "util/bytecode_ptr.h"
 
 using namespace std;
 using namespace testing;
@@ -71,7 +71,7 @@ static void fillWithBytes(u8 *ptr, size_t len) {
 TYPED_TEST(FDR_Loadval, Normal) {
     // We should be able to do a normal load at any alignment.
     const size_t len = sizeof(TypeParam);
-    aligned_unique_ptr<u8> mem_p = aligned_zmalloc_unique<u8>(len + 15);
+    auto mem_p = make_bytecode_ptr<u8>(len + 15, 16);
     u8 * mem = mem_p.get();
     ASSERT_TRUE(ISALIGNED_16(mem));
     fillWithBytes(mem, len + 15);
@@ -90,7 +90,7 @@ TYPED_TEST(FDR_Loadval, CautiousEverywhere) {
     // the 'lo' ptr or after the 'hi' ptr.
     const size_t len = sizeof(TypeParam);
 
-    aligned_unique_ptr<u8> mem_p = aligned_zmalloc_unique<u8>(len + 1);
+    auto mem_p = make_bytecode_ptr<u8>(len + 1, 16);
     u8 *mem = mem_p.get() + 1; // force unaligned
     fillWithBytes(mem, len);
 
index ab2126aa4775b504b5027a2de150de5c377bb42f..d32f7e8fa8f61df06414f5ce43070fbd891a9220 100644 (file)
 #include "config.h"
 #include "gtest/gtest.h"
 
-#include "util/target_info.h"
-#include "util/charreach.h"
+#include "grey.h"
+#include "hs_compile.h" /* for controlling ssse3 usage */
+#include "compiler/compiler.h"
 #include "nfa/lbr.h"
 #include "nfa/nfa_api.h"
-#include "nfa/nfa_internal.h"
 #include "nfa/nfa_api_util.h"
+#include "nfa/nfa_internal.h"
+#include "nfagraph/ng.h"
 #include "nfagraph/ng_lbr.h"
 #include "nfagraph/ng_util.h"
-#include "util/alloc.h"
+#include "util/bytecode_ptr.h"
+#include "util/charreach.h"
 #include "util/compile_context.h"
-#include "grey.h"
-#include "nfagraph/ng.h"
-#include "compiler/compiler.h"
-#include "hs_compile.h" /* for controlling ssse3 usage */
+#include "util/target_info.h"
 
 #include <ostream>
 
@@ -110,8 +110,8 @@ protected:
         nfa = constructLBR(*g, triggers, cc, rm);
         ASSERT_TRUE(nfa != nullptr);
 
-        full_state = aligned_zmalloc_unique<char>(nfa->scratchStateSize);
-        stream_state = aligned_zmalloc_unique<char>(nfa->streamStateSize);
+        full_state = make_bytecode_ptr<char>(nfa->scratchStateSize, 64);
+        stream_state = make_bytecode_ptr<char>(nfa->streamStateSize);
     }
 
     virtual void initQueue() {
@@ -154,11 +154,11 @@ protected:
     // Compiled NFA structure.
     bytecode_ptr<NFA> nfa;
 
-    // Space for full state.
-    aligned_unique_ptr<char> full_state;
+    // Aligned space for full state.
+    bytecode_ptr<char> full_state;
 
     // Space for stream state.
-    aligned_unique_ptr<char> stream_state;
+    bytecode_ptr<char> stream_state;
 
     // Queue structure.
     struct mq q;
index a32d1bcd49dfd41445c09ec4ff5120abee3124f6..c70ceeae1cd2151f690c5e4635420abef7a43e7e 100644 (file)
@@ -38,7 +38,7 @@
 #include "nfagraph/ng.h"
 #include "nfagraph/ng_limex.h"
 #include "nfagraph/ng_util.h"
-#include "util/alloc.h"
+#include "util/bytecode_ptr.h"
 #include "util/target_info.h"
 
 using namespace std;
@@ -88,8 +88,8 @@ protected:
                            type, cc);
         ASSERT_TRUE(nfa != nullptr);
 
-        full_state = aligned_zmalloc_unique<char>(nfa->scratchStateSize);
-        stream_state = aligned_zmalloc_unique<char>(nfa->streamStateSize);
+        full_state = make_bytecode_ptr<char>(nfa->scratchStateSize, 64);
+        stream_state = make_bytecode_ptr<char>(nfa->streamStateSize);
     }
 
     virtual void initQueue() {
@@ -119,10 +119,10 @@ protected:
     bytecode_ptr<NFA> nfa;
 
     // Space for full state.
-    aligned_unique_ptr<char> full_state;
+    bytecode_ptr<char> full_state;
 
     // Space for stream state.
-    aligned_unique_ptr<char> stream_state;
+    bytecode_ptr<char> stream_state;
 
     // Queue structure.
     struct mq q;
@@ -187,7 +187,7 @@ TEST_P(LimExModelTest, CompressExpand) {
 
     // Expand state into a new copy and check that it matches the original
     // uncompressed state.
-    auto state_copy = aligned_zmalloc_unique<char>(nfa->scratchStateSize);
+    auto state_copy = make_bytecode_ptr<char>(nfa->scratchStateSize, 64);
     char *dest = state_copy.get();
     memset(dest, 0xff, nfa->scratchStateSize);
     nfaExpandState(nfa.get(), dest, q.streamState, q.offset,
@@ -381,8 +381,8 @@ protected:
                            type, cc);
         ASSERT_TRUE(nfa != nullptr);
 
-        full_state = aligned_zmalloc_unique<char>(nfa->scratchStateSize);
-        stream_state = aligned_zmalloc_unique<char>(nfa->streamStateSize);
+        full_state = make_bytecode_ptr<char>(nfa->scratchStateSize, 64);
+        stream_state = make_bytecode_ptr<char>(nfa->streamStateSize);
     }
 
     virtual void initQueue() {
@@ -412,10 +412,10 @@ protected:
     bytecode_ptr<NFA> nfa;
 
     // Space for full state.
-    aligned_unique_ptr<char> full_state;
+    bytecode_ptr<char> full_state;
 
     // Space for stream state.
-    aligned_unique_ptr<char> stream_state;
+    bytecode_ptr<char> stream_state;
 
     // Queue structure.
     struct mq q;
index 31b72648ebaf2cda5f8adfe2bfe5a93347a92efe..220d2a12c002b2bddaf5e52efe654bcfcb0a3729 100644 (file)
@@ -29,8 +29,8 @@
 #include "config.h"
 
 #include "gtest/gtest.h"
-#include "util/alloc.h"
 #include "util/arch.h"
+#include "util/bytecode_ptr.h"
 #include "util/make_unique.h"
 #include "util/simd_utils.h"
 
@@ -540,7 +540,7 @@ TYPED_TEST(SimdUtilsTest, load_store) {
         a.bytes[i] = (char)(i % 256);
     }
 
-    aligned_unique_ptr<char> mem_ptr = aligned_zmalloc_unique<char>(sizeof(a));
+    auto mem_ptr = make_bytecode_ptr<char>(sizeof(a), alignof(TypeParam));
     char *mem = mem_ptr.get();
     ASSERT_EQ(0, (size_t)mem % 16U);