* \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"
#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"
void dumpMasks(const u8 *defaultMask);
#endif
void setupTab();
- aligned_unique_ptr<FDR> setupFDR();
+ bytecode_ptr<FDR> setupFDR();
void createInitialState(FDR *fdr);
public:
: eng(eng_in), grey(grey_in), tab(eng_in.getTabSizeBytes()),
lits(move(lits_in)), make_small(make_small_in) {}
- aligned_unique_ptr<FDR> build();
+ bytecode_ptr<FDR> build();
};
u8 *FDRCompiler::tabIndexToMask(u32 indexInTable) {
}
}
-aligned_unique_ptr<FDR> FDRCompiler::setupFDR() {
+bytecode_ptr<FDR> FDRCompiler::setupFDR() {
size_t tabSize = eng.getTabSizeBytes();
auto floodControlTmp = setupFDRFloodControl(lits, eng, grey);
headerSize, tabSize, confirmTmp.size(), floodControlTmp.size(),
size);
- auto fdr = aligned_zmalloc_unique<FDR>(size);
+ auto fdr = make_bytecode_ptr<FDR>(size, 64);
assert(fdr); // otherwise would have thrown std::bad_alloc
fdr->size = size;
#endif
}
-aligned_unique_ptr<FDR> FDRCompiler::build() {
+bytecode_ptr<FDR> FDRCompiler::build() {
assignStringsToBuckets();
setupTab();
return setupFDR();
} // namespace
static
-aligned_unique_ptr<FDR> fdrBuildTableInternal(const vector<hwlmLiteral> &lits,
- bool make_small,
- const target_t &target,
- const Grey &grey, u32 hint) {
+bytecode_ptr<FDR> fdrBuildTableInternal(const vector<hwlmLiteral> &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) {
}
}
- const unique_ptr<FDREngineDescription> 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;
}
return fc.build();
}
-aligned_unique_ptr<FDR> fdrBuildTable(const vector<hwlmLiteral> &lits,
- bool make_small, const target_t &target,
- const Grey &grey) {
+bytecode_ptr<FDR> fdrBuildTable(const vector<hwlmLiteral> &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<FDR> fdrBuildTableHinted(const vector<hwlmLiteral> &lits,
- bool make_small, u32 hint,
- const target_t &target,
- const Grey &grey) {
+bytecode_ptr<FDR> fdrBuildTableHinted(const vector<hwlmLiteral> &lits,
+ bool make_small, u32 hint,
+ const target_t &target,
+ const Grey &grey) {
return fdrBuildTableInternal(lits, make_small, target, grey, hint);
}
#define FDR_COMPILE_H
#include "ue2common.h"
-#include "util/alloc.h"
+#include "util/bytecode_ptr.h"
#include <vector>
struct Grey;
struct target_t;
-ue2::aligned_unique_ptr<FDR>
-fdrBuildTable(const std::vector<hwlmLiteral> &lits, bool make_small,
- const target_t &target, const Grey &grey);
+bytecode_ptr<FDR> fdrBuildTable(const std::vector<hwlmLiteral> &lits,
+ bool make_small, const target_t &target,
+ const Grey &grey);
#if !defined(RELEASE_BUILD)
-ue2::aligned_unique_ptr<FDR>
-fdrBuildTableHinted(const std::vector<hwlmLiteral> &lits, bool make_small,
- u32 hint, const target_t &target, const Grey &grey);
+bytecode_ptr<FDR> fdrBuildTableHinted(const std::vector<hwlmLiteral> &lits,
+ bool make_small, u32 hint,
+ const target_t &target, const Grey &grey);
#endif
* 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"
#include "util/target_info.h"
#include "util/verify_types.h"
-#include "teddy_compile.h"
-#include "teddy_internal.h"
-#include "teddy_engine_description.h"
#include <algorithm>
#include <cassert>
: eng(eng_in), grey(grey_in), lits(lits_in), make_small(make_small_in) {
}
- aligned_unique_ptr<FDR> build();
+ bytecode_ptr<FDR> build();
bool pack(map<BucketIndex, std::vector<LiteralIndex> > &bucketToLits);
};
return true;
}
-aligned_unique_ptr<FDR> TeddyCompiler::build() {
+bytecode_ptr<FDR> TeddyCompiler::build() {
if (lits.size() > eng.getNumBuckets() * TEDDY_BUCKET_LOAD) {
DEBUG_PRINTF("too many literals: %zu\n", lits.size());
return nullptr;
floodControlTmp.size(),
16 * maskWidth);
- auto fdr = aligned_zmalloc_unique<FDR>(size);
+ auto fdr = make_bytecode_ptr<FDR>(size, 64);
assert(fdr); // otherwise would have thrown std::bad_alloc
Teddy *teddy = (Teddy *)fdr.get(); // ugly
u8 *teddy_base = (u8 *)teddy;
} // namespace
-aligned_unique_ptr<FDR> teddyBuildTableHinted(const vector<hwlmLiteral> &lits,
- bool make_small, u32 hint,
- const target_t &target,
- const Grey &grey) {
+bytecode_ptr<FDR> teddyBuildTableHinted(const vector<hwlmLiteral> &lits,
+ bool make_small, u32 hint,
+ const target_t &target,
+ const Grey &grey) {
unique_ptr<TeddyEngineDescription> des;
if (hint == HINT_INVALID) {
des = chooseTeddyEngine(target, lits);