mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
rose: move active leftfix iter to engine blob
This commit is contained in:
parent
282f72e04d
commit
b6254ca11f
@ -2601,26 +2601,25 @@ u32 writeProgram(build_context &bc, RoseProgram &&program) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
vector<mmbit_sparse_iter>
|
u32 writeActiveLeftIter(build_context &bc,
|
||||||
buildActiveLeftIter(const vector<LeftNfaInfo> &leftTable) {
|
const vector<LeftNfaInfo> &leftInfoTable) {
|
||||||
vector<mmbit_sparse_iter> out;
|
|
||||||
|
|
||||||
vector<u32> keys;
|
vector<u32> keys;
|
||||||
for (size_t i = 0; i < leftTable.size(); i++) {
|
for (size_t i = 0; i < leftInfoTable.size(); i++) {
|
||||||
if (!leftTable[i].transient) {
|
if (!leftInfoTable[i].transient) {
|
||||||
DEBUG_PRINTF("rose %zu is active\n", i);
|
DEBUG_PRINTF("leftfix %zu is active\n", i);
|
||||||
keys.push_back(verify_u32(i));
|
keys.push_back(verify_u32(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_PRINTF("%zu active roses\n", keys.size());
|
DEBUG_PRINTF("%zu active leftfixes\n", keys.size());
|
||||||
|
|
||||||
if (keys.empty()) {
|
if (keys.empty()) {
|
||||||
return out;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
mmbBuildSparseIterator(out, keys, leftTable.size());
|
vector<mmbit_sparse_iter> iter;
|
||||||
return out;
|
mmbBuildSparseIterator(iter, keys, verify_u32(leftInfoTable.size()));
|
||||||
|
return bc.engine_blob.add_iterator(iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
@ -5149,9 +5148,8 @@ void fillMatcherDistances(const RoseBuildImpl &build, RoseEngine *engine) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
u32 buildEagerQueueIter(const set<u32> &eager, u32 leftfixBeginQueue,
|
u32 writeEagerQueueIter(const set<u32> &eager, u32 leftfixBeginQueue,
|
||||||
u32 queue_count,
|
u32 queue_count, build_context &bc) {
|
||||||
build_context &bc) {
|
|
||||||
if (eager.empty()) {
|
if (eager.empty()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -5372,8 +5370,9 @@ aligned_unique_ptr<RoseEngine> RoseBuildImpl::buildFinalEngine(u32 minWidth) {
|
|||||||
&longLitStreamStateRequired);
|
&longLitStreamStateRequired);
|
||||||
|
|
||||||
proto.lastByteHistoryIterOffset = buildLastByteIter(g, bc);
|
proto.lastByteHistoryIterOffset = buildLastByteIter(g, bc);
|
||||||
proto.eagerIterOffset = buildEagerQueueIter(
|
proto.eagerIterOffset = writeEagerQueueIter(
|
||||||
eager_queues, proto.leftfixBeginQueue, queue_count, bc);
|
eager_queues, proto.leftfixBeginQueue, queue_count, bc);
|
||||||
|
proto.activeLeftIterOffset = writeActiveLeftIter(bc, leftInfoTable);
|
||||||
|
|
||||||
addSomRevNfas(bc, proto, ssm);
|
addSomRevNfas(bc, proto, ssm);
|
||||||
|
|
||||||
@ -5457,13 +5456,6 @@ aligned_unique_ptr<RoseEngine> RoseBuildImpl::buildFinalEngine(u32 minWidth) {
|
|||||||
proto.nfaInfoOffset = currOffset;
|
proto.nfaInfoOffset = currOffset;
|
||||||
currOffset += sizeof(NfaInfo) * queue_count;
|
currOffset += sizeof(NfaInfo) * queue_count;
|
||||||
|
|
||||||
auto activeLeftIter = buildActiveLeftIter(leftInfoTable);
|
|
||||||
if (!activeLeftIter.empty()) {
|
|
||||||
currOffset = ROUNDUP_N(currOffset, alignof(mmbit_sparse_iter));
|
|
||||||
proto.activeLeftIterOffset = currOffset;
|
|
||||||
currOffset += activeLeftIter.size() * sizeof(mmbit_sparse_iter);
|
|
||||||
}
|
|
||||||
|
|
||||||
proto.activeArrayCount = proto.leftfixBeginQueue;
|
proto.activeArrayCount = proto.leftfixBeginQueue;
|
||||||
proto.activeLeftCount = verify_u32(leftInfoTable.size());
|
proto.activeLeftCount = verify_u32(leftInfoTable.size());
|
||||||
proto.rosePrefixCount = countRosePrefixes(leftInfoTable);
|
proto.rosePrefixCount = countRosePrefixes(leftInfoTable);
|
||||||
@ -5608,8 +5600,6 @@ aligned_unique_ptr<RoseEngine> RoseBuildImpl::buildFinalEngine(u32 minWidth) {
|
|||||||
fillLookaroundTables(ptr + proto.lookaroundTableOffset,
|
fillLookaroundTables(ptr + proto.lookaroundTableOffset,
|
||||||
ptr + proto.lookaroundReachOffset, bc.lookaround);
|
ptr + proto.lookaroundReachOffset, bc.lookaround);
|
||||||
|
|
||||||
copy_bytes(ptr + engine->activeLeftIterOffset, activeLeftIter);
|
|
||||||
|
|
||||||
// Safety check: we shouldn't have written anything to the engine blob
|
// Safety check: we shouldn't have written anything to the engine blob
|
||||||
// after we copied it into the engine bytecode.
|
// after we copied it into the engine bytecode.
|
||||||
assert(bc.engine_blob.size() == engineBlobSize);
|
assert(bc.engine_blob.size() == engineBlobSize);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user