rose_build_anchored: use bytecode_ptr

This commit is contained in:
Justin Viiret 2017-04-03 16:47:21 +10:00 committed by Matthew Barr
parent 7b17d418e7
commit 905ac78061
3 changed files with 10 additions and 13 deletions

View File

@ -869,14 +869,13 @@ vector<raw_dfa> buildAnchoredDfas(RoseBuildImpl &build,
return dfas;
}
aligned_unique_ptr<anchored_matcher_info>
bytecode_ptr<anchored_matcher_info>
buildAnchoredMatcher(RoseBuildImpl &build, const vector<LitFragment> &fragments,
vector<raw_dfa> &dfas, size_t *asize) {
vector<raw_dfa> &dfas) {
const CompileContext &cc = build.cc;
if (dfas.empty()) {
DEBUG_PRINTF("empty\n");
*asize = 0;
return nullptr;
}
@ -892,8 +891,7 @@ buildAnchoredMatcher(RoseBuildImpl &build, const vector<LitFragment> &fragments,
throw ResourceLimitError();
}
*asize = total_size;
auto atable = aligned_zmalloc_unique<anchored_matcher_info>(total_size);
auto atable = make_bytecode_ptr<anchored_matcher_info>(total_size, 64);
char *curr = (char *)atable.get();
u32 state_offset = 0;
@ -919,7 +917,7 @@ buildAnchoredMatcher(RoseBuildImpl &build, const vector<LitFragment> &fragments,
ami->anchoredMinDistance = start_offset[i];
}
DEBUG_PRINTF("success %zu\n", *asize);
DEBUG_PRINTF("success %zu\n", atable.size());
return atable;
}

View File

@ -32,7 +32,7 @@
#include "ue2common.h"
#include "rose_build_impl.h"
#include "nfagraph/ng_holder.h"
#include "util/alloc.h"
#include "util/bytecode_ptr.h"
#include <map>
#include <vector>
@ -59,10 +59,10 @@ std::vector<raw_dfa> buildAnchoredDfas(RoseBuildImpl &build,
* Remap the literal final_ids used for raw_dfa reports to the program offsets
* given in litPrograms.
*/
aligned_unique_ptr<anchored_matcher_info>
bytecode_ptr<anchored_matcher_info>
buildAnchoredMatcher(RoseBuildImpl &build,
const std::vector<LitFragment> &fragments,
std::vector<raw_dfa> &dfas, size_t *asize);
std::vector<raw_dfa> &dfas);
u32 anchoredStateSize(const anchored_matcher_info &atable);

View File

@ -5824,10 +5824,9 @@ bytecode_ptr<RoseEngine> RoseBuildImpl::buildFinalEngine(u32 minWidth) {
writeLeftInfo(bc.engine_blob, proto, leftInfoTable);
// Build anchored matcher.
size_t asize = 0;
auto atable = buildAnchoredMatcher(*this, fragments, anchored_dfas, &asize);
auto atable = buildAnchoredMatcher(*this, fragments, anchored_dfas);
if (atable) {
proto.amatcherOffset = bc.engine_blob.add(atable.get(), asize, 64);
proto.amatcherOffset = bc.engine_blob.add(atable);
}
// Build floating HWLM matcher.
@ -5952,7 +5951,7 @@ bytecode_ptr<RoseEngine> RoseBuildImpl::buildFinalEngine(u32 minWidth) {
proto.initialGroups = getInitialGroups();
proto.floating_group_mask = fgroups;
proto.totalNumLiterals = verify_u32(literal_info.size());
proto.asize = verify_u32(asize);
proto.asize = verify_u32(atable.size());
proto.ematcherRegionSize = ematcher_region_size;
proto.longLitStreamState = verify_u32(longLitStreamStateRequired);