From c619621573805985411668397e58c8e3f00f7709 Mon Sep 17 00:00:00 2001 From: Justin Viiret Date: Tue, 28 Feb 2017 13:55:46 +1100 Subject: [PATCH] rose: move leftfix info into engine blob, refactor --- src/rose/rose_build_bytecode.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/rose/rose_build_bytecode.cpp b/src/rose/rose_build_bytecode.cpp index 871d78c0..330f4e46 100644 --- a/src/rose/rose_build_bytecode.cpp +++ b/src/rose/rose_build_bytecode.cpp @@ -2718,6 +2718,18 @@ void writeDkeyInfo(const ReportManager &rm, build_context &bc, proto.dkeyLogSize = fatbit_size(proto.dkeyCount); } +static +void writeLeftInfo(build_context &bc, RoseEngine &proto, + const vector &leftInfoTable) { + proto.leftOffset = + bc.engine_blob.add(begin(leftInfoTable), end(leftInfoTable)); + proto.activeLeftIterOffset = writeActiveLeftIter(bc, leftInfoTable); + proto.roseCount = verify_u32(leftInfoTable.size()); + proto.activeLeftCount = verify_u32(leftInfoTable.size()); + proto.rosePrefixCount = countRosePrefixes(leftInfoTable); + +} + static bool hasBoundaryReports(const BoundaryReports &boundary) { if (!boundary.report_at_0.empty()) { @@ -5388,12 +5400,12 @@ aligned_unique_ptr RoseBuildImpl::buildFinalEngine(u32 minWidth) { proto.lastByteHistoryIterOffset = buildLastByteIter(g, bc); proto.eagerIterOffset = writeEagerQueueIter( eager_queues, proto.leftfixBeginQueue, queue_count, bc); - proto.activeLeftIterOffset = writeActiveLeftIter(bc, leftInfoTable); addSomRevNfas(bc, proto, ssm); writeLookaroundTables(bc, proto); writeDkeyInfo(rm, bc, proto); + writeLeftInfo(bc, proto, leftInfoTable); // Enforce role table resource limit. if (num_vertices(g) > cc.grey.limitRoseRoleCount) { @@ -5461,17 +5473,11 @@ aligned_unique_ptr RoseBuildImpl::buildFinalEngine(u32 minWidth) { currOffset += verify_u32(sbsize); } - currOffset = ROUNDUP_N(currOffset, alignof(LeftNfaInfo)); - proto.leftOffset = currOffset; - currOffset += sizeof(LeftNfaInfo) * leftInfoTable.size(); - currOffset = ROUNDUP_N(currOffset, sizeof(u32)); proto.nfaInfoOffset = currOffset; currOffset += sizeof(NfaInfo) * queue_count; proto.activeArrayCount = proto.leftfixBeginQueue; - proto.activeLeftCount = verify_u32(leftInfoTable.size()); - proto.rosePrefixCount = countRosePrefixes(leftInfoTable); proto.anchorStateSize = atable ? anchoredStateSize(*atable) : 0; @@ -5517,7 +5523,6 @@ aligned_unique_ptr RoseBuildImpl::buildFinalEngine(u32 minWidth) { proto.rolesWithStateCount = bc.numStates; - proto.roseCount = verify_u32(leftInfoTable.size()); proto.initMpvNfa = mpv_as_outfix ? 0 : MO_INVALID_IDX; proto.stateSize = mmbit_size(bc.numStates); @@ -5600,7 +5605,6 @@ aligned_unique_ptr RoseBuildImpl::buildFinalEngine(u32 minWidth) { // Copy in other tables bc.engine_blob.write_bytes(engine.get()); - copy_bytes(ptr + engine->leftOffset, leftInfoTable); // Safety check: we shouldn't have written anything to the engine blob // after we copied it into the engine bytecode.