mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
rose: move matcher bytecode to engine blob
This commit is contained in:
parent
b2aae060d8
commit
96be1190ef
@ -5420,25 +5420,11 @@ aligned_unique_ptr<RoseEngine> RoseBuildImpl::buildFinalEngine(u32 minWidth) {
|
|||||||
throw ResourceLimitError();
|
throw ResourceLimitError();
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 currOffset; /* relative to base of RoseEngine */
|
|
||||||
if (!bc.engine_blob.empty()) {
|
|
||||||
currOffset = bc.engine_blob.base_offset + bc.engine_blob.size();
|
|
||||||
} else {
|
|
||||||
currOffset = sizeof(RoseEngine);
|
|
||||||
}
|
|
||||||
|
|
||||||
UNUSED const size_t engineBlobSize = bc.engine_blob.size(); // test later
|
|
||||||
|
|
||||||
currOffset = ROUNDUP_CL(currOffset);
|
|
||||||
DEBUG_PRINTF("currOffset %u\n", currOffset);
|
|
||||||
|
|
||||||
// Build anchored matcher.
|
// Build anchored matcher.
|
||||||
size_t asize = 0;
|
size_t asize = 0;
|
||||||
auto atable = buildAnchoredMatcher(*this, anchored_dfas, &asize);
|
auto atable = buildAnchoredMatcher(*this, anchored_dfas, &asize);
|
||||||
if (atable) {
|
if (atable) {
|
||||||
currOffset = ROUNDUP_CL(currOffset);
|
proto.amatcherOffset = bc.engine_blob.add(atable.get(), asize, 64);
|
||||||
proto.amatcherOffset = currOffset;
|
|
||||||
currOffset += verify_u32(asize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build floating HWLM matcher.
|
// Build floating HWLM matcher.
|
||||||
@ -5447,9 +5433,7 @@ aligned_unique_ptr<RoseEngine> RoseBuildImpl::buildFinalEngine(u32 minWidth) {
|
|||||||
auto ftable = buildFloatingMatcher(*this, bc.longLitLengthThreshold,
|
auto ftable = buildFloatingMatcher(*this, bc.longLitLengthThreshold,
|
||||||
&fgroups, &fsize, &historyRequired);
|
&fgroups, &fsize, &historyRequired);
|
||||||
if (ftable) {
|
if (ftable) {
|
||||||
currOffset = ROUNDUP_CL(currOffset);
|
proto.fmatcherOffset = bc.engine_blob.add(ftable.get(), fsize, 64);
|
||||||
proto.fmatcherOffset = currOffset;
|
|
||||||
currOffset += verify_u32(fsize);
|
|
||||||
bc.resources.has_floating = true;
|
bc.resources.has_floating = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5458,27 +5442,21 @@ aligned_unique_ptr<RoseEngine> RoseBuildImpl::buildFinalEngine(u32 minWidth) {
|
|||||||
auto drtable =
|
auto drtable =
|
||||||
buildDelayRebuildMatcher(*this, bc.longLitLengthThreshold, &drsize);
|
buildDelayRebuildMatcher(*this, bc.longLitLengthThreshold, &drsize);
|
||||||
if (drtable) {
|
if (drtable) {
|
||||||
currOffset = ROUNDUP_CL(currOffset);
|
proto.drmatcherOffset = bc.engine_blob.add(drtable.get(), drsize, 64);
|
||||||
proto.drmatcherOffset = currOffset;
|
|
||||||
currOffset += verify_u32(drsize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build EOD-anchored HWLM matcher.
|
// Build EOD-anchored HWLM matcher.
|
||||||
size_t esize = 0;
|
size_t esize = 0;
|
||||||
auto etable = buildEodAnchoredMatcher(*this, &esize);
|
auto etable = buildEodAnchoredMatcher(*this, &esize);
|
||||||
if (etable) {
|
if (etable) {
|
||||||
currOffset = ROUNDUP_CL(currOffset);
|
proto.ematcherOffset = bc.engine_blob.add(etable.get(), esize, 64);
|
||||||
proto.ematcherOffset = currOffset;
|
|
||||||
currOffset += verify_u32(esize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build small-block HWLM matcher.
|
// Build small-block HWLM matcher.
|
||||||
size_t sbsize = 0;
|
size_t sbsize = 0;
|
||||||
auto sbtable = buildSmallBlockMatcher(*this, &sbsize);
|
auto sbtable = buildSmallBlockMatcher(*this, &sbsize);
|
||||||
if (sbtable) {
|
if (sbtable) {
|
||||||
currOffset = ROUNDUP_CL(currOffset);
|
proto.sbmatcherOffset = bc.engine_blob.add(sbtable.get(), sbsize, 64);
|
||||||
proto.sbmatcherOffset = currOffset;
|
|
||||||
currOffset += verify_u32(sbsize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
proto.activeArrayCount = proto.leftfixBeginQueue;
|
proto.activeArrayCount = proto.leftfixBeginQueue;
|
||||||
@ -5510,6 +5488,18 @@ aligned_unique_ptr<RoseEngine> RoseBuildImpl::buildFinalEngine(u32 minWidth) {
|
|||||||
proto.stateOffsets, cc.streaming, proto.activeArrayCount,
|
proto.stateOffsets, cc.streaming, proto.activeArrayCount,
|
||||||
proto.outfixBeginQueue, proto.outfixEndQueue);
|
proto.outfixBeginQueue, proto.outfixEndQueue);
|
||||||
|
|
||||||
|
u32 currOffset; /* relative to base of RoseEngine */
|
||||||
|
if (!bc.engine_blob.empty()) {
|
||||||
|
currOffset = bc.engine_blob.base_offset + bc.engine_blob.size();
|
||||||
|
} else {
|
||||||
|
currOffset = sizeof(RoseEngine);
|
||||||
|
}
|
||||||
|
|
||||||
|
UNUSED const size_t engineBlobSize = bc.engine_blob.size(); // test later
|
||||||
|
|
||||||
|
currOffset = ROUNDUP_CL(currOffset);
|
||||||
|
DEBUG_PRINTF("currOffset %u\n", currOffset);
|
||||||
|
|
||||||
currOffset = ROUNDUP_N(currOffset, alignof(scatter_unit_u64a));
|
currOffset = ROUNDUP_N(currOffset, alignof(scatter_unit_u64a));
|
||||||
u32 state_scatter_aux_offset = currOffset;
|
u32 state_scatter_aux_offset = currOffset;
|
||||||
currOffset += aux_size(state_scatter);
|
currOffset += aux_size(state_scatter);
|
||||||
@ -5579,30 +5569,6 @@ aligned_unique_ptr<RoseEngine> RoseBuildImpl::buildFinalEngine(u32 minWidth) {
|
|||||||
// Copy in our prototype engine data.
|
// Copy in our prototype engine data.
|
||||||
memcpy(engine.get(), &proto, sizeof(proto));
|
memcpy(engine.get(), &proto, sizeof(proto));
|
||||||
|
|
||||||
char *ptr = (char *)engine.get();
|
|
||||||
assert(ISALIGNED_CL(ptr));
|
|
||||||
|
|
||||||
if (atable) {
|
|
||||||
assert(proto.amatcherOffset);
|
|
||||||
memcpy(ptr + proto.amatcherOffset, atable.get(), asize);
|
|
||||||
}
|
|
||||||
if (ftable) {
|
|
||||||
assert(proto.fmatcherOffset);
|
|
||||||
memcpy(ptr + proto.fmatcherOffset, ftable.get(), fsize);
|
|
||||||
}
|
|
||||||
if (drtable) {
|
|
||||||
assert(proto.drmatcherOffset);
|
|
||||||
memcpy(ptr + proto.drmatcherOffset, drtable.get(), drsize);
|
|
||||||
}
|
|
||||||
if (etable) {
|
|
||||||
assert(proto.ematcherOffset);
|
|
||||||
memcpy(ptr + proto.ematcherOffset, etable.get(), esize);
|
|
||||||
}
|
|
||||||
if (sbtable) {
|
|
||||||
assert(proto.sbmatcherOffset);
|
|
||||||
memcpy(ptr + proto.sbmatcherOffset, sbtable.get(), sbsize);
|
|
||||||
}
|
|
||||||
|
|
||||||
write_out(&engine->state_init, (char *)engine.get(), state_scatter,
|
write_out(&engine->state_init, (char *)engine.get(), state_scatter,
|
||||||
state_scatter_aux_offset);
|
state_scatter_aux_offset);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user