diff --git a/src/fdr/fdr_compile.cpp b/src/fdr/fdr_compile.cpp index 8346e520..36bcda69 100644 --- a/src/fdr/fdr_compile.cpp +++ b/src/fdr/fdr_compile.cpp @@ -30,8 +30,9 @@ * \brief FDR literal matcher: build API. */ -#include "fdr_internal.h" #include "fdr_compile.h" + +#include "fdr_internal.h" #include "fdr_confirm.h" #include "fdr_compile_internal.h" #include "fdr_engine_description.h" @@ -40,7 +41,6 @@ #include "grey.h" #include "ue2common.h" #include "hwlm/hwlm_build.h" -#include "util/alloc.h" #include "util/compare.h" #include "util/dump_mask.h" #include "util/math.h" @@ -86,7 +86,7 @@ private: void dumpMasks(const u8 *defaultMask); #endif void setupTab(); - aligned_unique_ptr setupFDR(); + bytecode_ptr setupFDR(); void createInitialState(FDR *fdr); public: @@ -95,7 +95,7 @@ public: : eng(eng_in), grey(grey_in), tab(eng_in.getTabSizeBytes()), lits(move(lits_in)), make_small(make_small_in) {} - aligned_unique_ptr build(); + bytecode_ptr build(); }; u8 *FDRCompiler::tabIndexToMask(u32 indexInTable) { @@ -144,7 +144,7 @@ void FDRCompiler::createInitialState(FDR *fdr) { } } -aligned_unique_ptr FDRCompiler::setupFDR() { +bytecode_ptr FDRCompiler::setupFDR() { size_t tabSize = eng.getTabSizeBytes(); auto floodControlTmp = setupFDRFloodControl(lits, eng, grey); @@ -162,7 +162,7 @@ aligned_unique_ptr FDRCompiler::setupFDR() { headerSize, tabSize, confirmTmp.size(), floodControlTmp.size(), size); - auto fdr = aligned_zmalloc_unique(size); + auto fdr = make_bytecode_ptr(size, 64); assert(fdr); // otherwise would have thrown std::bad_alloc fdr->size = size; @@ -528,7 +528,7 @@ void FDRCompiler::setupTab() { #endif } -aligned_unique_ptr FDRCompiler::build() { +bytecode_ptr FDRCompiler::build() { assignStringsToBuckets(); setupTab(); return setupFDR(); @@ -537,10 +537,9 @@ aligned_unique_ptr FDRCompiler::build() { } // namespace static -aligned_unique_ptr fdrBuildTableInternal(const vector &lits, - bool make_small, - const target_t &target, - const Grey &grey, u32 hint) { +bytecode_ptr fdrBuildTableInternal(const vector &lits, + bool make_small, const target_t &target, + const Grey &grey, u32 hint) { DEBUG_PRINTF("cpu has %s\n", target.has_avx2() ? "avx2" : "no-avx2"); if (grey.fdrAllowTeddy) { @@ -553,10 +552,8 @@ aligned_unique_ptr fdrBuildTableInternal(const vector &lits, } } - const unique_ptr des = - (hint == HINT_INVALID) ? chooseEngine(target, lits, make_small) - : getFdrDescription(hint); - + auto des = (hint == HINT_INVALID) ? chooseEngine(target, lits, make_small) + : getFdrDescription(hint); if (!des) { return nullptr; } @@ -571,18 +568,18 @@ aligned_unique_ptr fdrBuildTableInternal(const vector &lits, return fc.build(); } -aligned_unique_ptr fdrBuildTable(const vector &lits, - bool make_small, const target_t &target, - const Grey &grey) { +bytecode_ptr fdrBuildTable(const vector &lits, + bool make_small, const target_t &target, + const Grey &grey) { return fdrBuildTableInternal(lits, make_small, target, grey, HINT_INVALID); } #if !defined(RELEASE_BUILD) -aligned_unique_ptr fdrBuildTableHinted(const vector &lits, - bool make_small, u32 hint, - const target_t &target, - const Grey &grey) { +bytecode_ptr fdrBuildTableHinted(const vector &lits, + bool make_small, u32 hint, + const target_t &target, + const Grey &grey) { return fdrBuildTableInternal(lits, make_small, target, grey, hint); } diff --git a/src/fdr/fdr_compile.h b/src/fdr/fdr_compile.h index a135a6e1..58047600 100644 --- a/src/fdr/fdr_compile.h +++ b/src/fdr/fdr_compile.h @@ -34,7 +34,7 @@ #define FDR_COMPILE_H #include "ue2common.h" -#include "util/alloc.h" +#include "util/bytecode_ptr.h" #include @@ -46,15 +46,15 @@ struct hwlmLiteral; struct Grey; struct target_t; -ue2::aligned_unique_ptr -fdrBuildTable(const std::vector &lits, bool make_small, - const target_t &target, const Grey &grey); +bytecode_ptr fdrBuildTable(const std::vector &lits, + bool make_small, const target_t &target, + const Grey &grey); #if !defined(RELEASE_BUILD) -ue2::aligned_unique_ptr -fdrBuildTableHinted(const std::vector &lits, bool make_small, - u32 hint, const target_t &target, const Grey &grey); +bytecode_ptr fdrBuildTableHinted(const std::vector &lits, + bool make_small, u32 hint, + const target_t &target, const Grey &grey); #endif diff --git a/src/fdr/teddy_compile.cpp b/src/fdr/teddy_compile.cpp index a5856110..33a1050c 100644 --- a/src/fdr/teddy_compile.cpp +++ b/src/fdr/teddy_compile.cpp @@ -26,11 +26,15 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "teddy_compile.h" + #include "fdr.h" #include "fdr_internal.h" #include "fdr_compile_internal.h" #include "fdr_confirm.h" #include "fdr_engine_description.h" +#include "teddy_internal.h" +#include "teddy_engine_description.h" #include "grey.h" #include "ue2common.h" #include "util/alloc.h" @@ -40,9 +44,6 @@ #include "util/target_info.h" #include "util/verify_types.h" -#include "teddy_compile.h" -#include "teddy_internal.h" -#include "teddy_engine_description.h" #include #include @@ -77,7 +78,7 @@ public: : eng(eng_in), grey(grey_in), lits(lits_in), make_small(make_small_in) { } - aligned_unique_ptr build(); + bytecode_ptr build(); bool pack(map > &bucketToLits); }; @@ -277,7 +278,7 @@ bool TeddyCompiler::pack(map TeddyCompiler::build() { +bytecode_ptr TeddyCompiler::build() { if (lits.size() > eng.getNumBuckets() * TEDDY_BUCKET_LOAD) { DEBUG_PRINTF("too many literals: %zu\n", lits.size()); return nullptr; @@ -319,7 +320,7 @@ aligned_unique_ptr TeddyCompiler::build() { floodControlTmp.size(), 16 * maskWidth); - auto fdr = aligned_zmalloc_unique(size); + auto fdr = make_bytecode_ptr(size, 64); assert(fdr); // otherwise would have thrown std::bad_alloc Teddy *teddy = (Teddy *)fdr.get(); // ugly u8 *teddy_base = (u8 *)teddy; @@ -418,10 +419,10 @@ aligned_unique_ptr TeddyCompiler::build() { } // namespace -aligned_unique_ptr teddyBuildTableHinted(const vector &lits, - bool make_small, u32 hint, - const target_t &target, - const Grey &grey) { +bytecode_ptr teddyBuildTableHinted(const vector &lits, + bool make_small, u32 hint, + const target_t &target, + const Grey &grey) { unique_ptr des; if (hint == HINT_INVALID) { des = chooseTeddyEngine(target, lits); diff --git a/src/fdr/teddy_compile.h b/src/fdr/teddy_compile.h index 07eb18f6..22e87405 100644 --- a/src/fdr/teddy_compile.h +++ b/src/fdr/teddy_compile.h @@ -34,7 +34,7 @@ #define TEDDY_COMPILE_H #include "ue2common.h" -#include "util/alloc.h" +#include "util/bytecode_ptr.h" #include @@ -46,9 +46,10 @@ namespace ue2 { struct Grey; struct hwlmLiteral; -ue2::aligned_unique_ptr -teddyBuildTableHinted(const std::vector &lits, bool make_small, - u32 hint, const target_t &target, const Grey &grey); +bytecode_ptr teddyBuildTableHinted(const std::vector &lits, + bool make_small, u32 hint, + const target_t &target, + const Grey &grey); } // namespace ue2