unit: use bytecode_ptr instead of aligned_unique_ptr

This commit is contained in:
Justin Viiret 2017-04-04 11:41:50 +10:00 committed by Matthew Barr
parent b6047ea5d4
commit e8162960fc
5 changed files with 30 additions and 30 deletions

View 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);

View 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);

View File

@ -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 <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;

View 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;

View 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);