From e8162960fcbbf4eea848fae85acb9632c7854011 Mon Sep 17 00:00:00 2001 From: Justin Viiret Date: Tue, 4 Apr 2017 11:41:50 +1000 Subject: [PATCH] unit: use bytecode_ptr instead of aligned_unique_ptr --- unit/internal/fdr.cpp | 2 +- unit/internal/fdr_loadval.cpp | 8 ++++---- unit/internal/lbr.cpp | 26 +++++++++++++------------- unit/internal/limex_nfa.cpp | 20 ++++++++++---------- unit/internal/simd_utils.cpp | 4 ++-- 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/unit/internal/fdr.cpp b/unit/internal/fdr.cpp index 8ec72598..bd0bb4c0 100644 --- a/unit/internal/fdr.cpp +++ b/unit/internal/fdr.cpp @@ -383,7 +383,7 @@ TEST_P(FDRp, moveByteStream) { size_t size = fdrSize(fdrTable0.get()); - auto fdrTable = aligned_zmalloc_unique(size); + auto fdrTable = make_bytecode_ptr(size, 64); EXPECT_NE(nullptr, fdrTable); memcpy(fdrTable.get(), fdrTable0.get(), size); diff --git a/unit/internal/fdr_loadval.cpp b/unit/internal/fdr_loadval.cpp index 22fee770..bb5efb5f 100644 --- a/unit/internal/fdr_loadval.cpp +++ b/unit/internal/fdr_loadval.cpp @@ -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 mem_p = aligned_zmalloc_unique(len + 15); + auto mem_p = make_bytecode_ptr(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 mem_p = aligned_zmalloc_unique(len + 1); + auto mem_p = make_bytecode_ptr(len + 1, 16); u8 *mem = mem_p.get() + 1; // force unaligned fillWithBytes(mem, len); diff --git a/unit/internal/lbr.cpp b/unit/internal/lbr.cpp index ab2126aa..d32f7e8f 100644 --- a/unit/internal/lbr.cpp +++ b/unit/internal/lbr.cpp @@ -29,20 +29,20 @@ #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 @@ -110,8 +110,8 @@ protected: nfa = constructLBR(*g, triggers, cc, rm); ASSERT_TRUE(nfa != nullptr); - full_state = aligned_zmalloc_unique(nfa->scratchStateSize); - stream_state = aligned_zmalloc_unique(nfa->streamStateSize); + full_state = make_bytecode_ptr(nfa->scratchStateSize, 64); + stream_state = make_bytecode_ptr(nfa->streamStateSize); } virtual void initQueue() { @@ -154,11 +154,11 @@ protected: // Compiled NFA structure. bytecode_ptr nfa; - // Space for full state. - aligned_unique_ptr full_state; + // Aligned space for full state. + bytecode_ptr full_state; // Space for stream state. - aligned_unique_ptr stream_state; + bytecode_ptr stream_state; // Queue structure. struct mq q; diff --git a/unit/internal/limex_nfa.cpp b/unit/internal/limex_nfa.cpp index a32d1bcd..c70ceeae 100644 --- a/unit/internal/limex_nfa.cpp +++ b/unit/internal/limex_nfa.cpp @@ -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(nfa->scratchStateSize); - stream_state = aligned_zmalloc_unique(nfa->streamStateSize); + full_state = make_bytecode_ptr(nfa->scratchStateSize, 64); + stream_state = make_bytecode_ptr(nfa->streamStateSize); } virtual void initQueue() { @@ -119,10 +119,10 @@ protected: bytecode_ptr nfa; // Space for full state. - aligned_unique_ptr full_state; + bytecode_ptr full_state; // Space for stream state. - aligned_unique_ptr stream_state; + bytecode_ptr 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(nfa->scratchStateSize); + auto state_copy = make_bytecode_ptr(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(nfa->scratchStateSize); - stream_state = aligned_zmalloc_unique(nfa->streamStateSize); + full_state = make_bytecode_ptr(nfa->scratchStateSize, 64); + stream_state = make_bytecode_ptr(nfa->streamStateSize); } virtual void initQueue() { @@ -412,10 +412,10 @@ protected: bytecode_ptr nfa; // Space for full state. - aligned_unique_ptr full_state; + bytecode_ptr full_state; // Space for stream state. - aligned_unique_ptr stream_state; + bytecode_ptr stream_state; // Queue structure. struct mq q; diff --git a/unit/internal/simd_utils.cpp b/unit/internal/simd_utils.cpp index 31b72648..220d2a12 100644 --- a/unit/internal/simd_utils.cpp +++ b/unit/internal/simd_utils.cpp @@ -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 mem_ptr = aligned_zmalloc_unique(sizeof(a)); + auto mem_ptr = make_bytecode_ptr(sizeof(a), alignof(TypeParam)); char *mem = mem_ptr.get(); ASSERT_EQ(0, (size_t)mem % 16U);