mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
fdr_confirm_compile: use bytecode_ptr
This commit is contained in:
parent
97516eccb6
commit
2698e534e4
@ -45,8 +45,7 @@ using namespace std;
|
|||||||
|
|
||||||
namespace ue2 {
|
namespace ue2 {
|
||||||
|
|
||||||
using BC2CONF = map<BucketIndex,
|
using BC2CONF = map<BucketIndex, bytecode_ptr<FDRConfirm>>;
|
||||||
pair<aligned_unique_ptr<FDRConfirm>, size_t>>;
|
|
||||||
|
|
||||||
// return the number of bytes beyond a length threshold in all strings in lits
|
// return the number of bytes beyond a length threshold in all strings in lits
|
||||||
static
|
static
|
||||||
@ -148,9 +147,9 @@ void fillLitInfo(const vector<hwlmLiteral> &lits, vector<LitInfo> &tmpLitInfo,
|
|||||||
|
|
||||||
//#define FDR_CONFIRM_DUMP 1
|
//#define FDR_CONFIRM_DUMP 1
|
||||||
|
|
||||||
static pair<aligned_unique_ptr<FDRConfirm>, size_t>
|
static
|
||||||
getFDRConfirm(const vector<hwlmLiteral> &lits, bool make_small,
|
bytecode_ptr<FDRConfirm> getFDRConfirm(const vector<hwlmLiteral> &lits,
|
||||||
bool make_confirm) {
|
bool make_small, bool make_confirm) {
|
||||||
vector<LitInfo> tmpLitInfo(lits.size());
|
vector<LitInfo> tmpLitInfo(lits.size());
|
||||||
CONF_TYPE andmsk;
|
CONF_TYPE andmsk;
|
||||||
fillLitInfo(lits, tmpLitInfo, andmsk);
|
fillLitInfo(lits, tmpLitInfo, andmsk);
|
||||||
@ -285,7 +284,7 @@ getFDRConfirm(const vector<hwlmLiteral> &lits, bool make_small,
|
|||||||
sizeof(LitInfo) * lits.size() + totalLitSize;
|
sizeof(LitInfo) * lits.size() + totalLitSize;
|
||||||
size = ROUNDUP_N(size, alignof(FDRConfirm));
|
size = ROUNDUP_N(size, alignof(FDRConfirm));
|
||||||
|
|
||||||
auto fdrc = aligned_zmalloc_unique<FDRConfirm>(size);
|
auto fdrc = make_bytecode_ptr<FDRConfirm>(size);
|
||||||
assert(fdrc); // otherwise would have thrown std::bad_alloc
|
assert(fdrc); // otherwise would have thrown std::bad_alloc
|
||||||
|
|
||||||
fdrc->andmsk = andmsk;
|
fdrc->andmsk = andmsk;
|
||||||
@ -339,7 +338,7 @@ getFDRConfirm(const vector<hwlmLiteral> &lits, bool make_small,
|
|||||||
alignof(FDRConfirm));
|
alignof(FDRConfirm));
|
||||||
assert(actual_size <= size);
|
assert(actual_size <= size);
|
||||||
|
|
||||||
return {move(fdrc), actual_size};
|
return fdrc;
|
||||||
}
|
}
|
||||||
|
|
||||||
bytecode_ptr<u8>
|
bytecode_ptr<u8>
|
||||||
@ -365,7 +364,7 @@ setupFullConfs(const vector<hwlmLiteral> &lits,
|
|||||||
|
|
||||||
DEBUG_PRINTF("b %d sz %zu\n", b, vl.size());
|
DEBUG_PRINTF("b %d sz %zu\n", b, vl.size());
|
||||||
auto fc = getFDRConfirm(vl, make_small, makeConfirm);
|
auto fc = getFDRConfirm(vl, make_small, makeConfirm);
|
||||||
totalConfirmSize += fc.second;
|
totalConfirmSize += fc.size();
|
||||||
bc2Conf.emplace(b, move(fc));
|
bc2Conf.emplace(b, move(fc));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -382,11 +381,11 @@ setupFullConfs(const vector<hwlmLiteral> &lits,
|
|||||||
|
|
||||||
for (const auto &m : bc2Conf) {
|
for (const auto &m : bc2Conf) {
|
||||||
const BucketIndex &idx = m.first;
|
const BucketIndex &idx = m.first;
|
||||||
const pair<aligned_unique_ptr<FDRConfirm>, size_t> &p = m.second;
|
const bytecode_ptr<FDRConfirm> &p = m.second;
|
||||||
// confirm offset is relative to the base of this structure, now
|
// confirm offset is relative to the base of this structure, now
|
||||||
u32 confirm_offset = verify_u32(ptr - buf.get());
|
u32 confirm_offset = verify_u32(ptr - buf.get());
|
||||||
memcpy(ptr, p.first.get(), p.second);
|
memcpy(ptr, p.get(), p.size());
|
||||||
ptr += p.second;
|
ptr += p.size();
|
||||||
confBase[idx] = confirm_offset;
|
confBase[idx] = confirm_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user