mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-10-09 07:42:21 +03:00
castle/repeat: fix a number of bugs
- Add fits_in_len_bytes assertions for packed stores. Corrects the assertion formerly on line 888. - In exclusive mode, don't overwrite packedCtrlSize with the max of the group; each repeat should know how many bytes it is using, even if they share the same stream state. - Ensure that exclusive mode stream state is sized correctly.
This commit is contained in:
committed by
Matthew Barr
parent
e10d2eb269
commit
d0aa138ada
@@ -361,25 +361,22 @@ void buildSubcastles(const CastleProto &proto, vector<SubCastle> &subs,
|
||||
DEBUG_PRINTF("sub %u: selected %s model for %s repeat\n", i,
|
||||
repeatTypeName(rtype), pr.bounds.str().c_str());
|
||||
|
||||
u32 subScratchStateSize;
|
||||
u32 subStreamStateSize;
|
||||
|
||||
SubCastle &sub = subs[i];
|
||||
RepeatInfo &info = infos[i];
|
||||
|
||||
// handle exclusive case differently
|
||||
info.packedCtrlSize = rsi.packedCtrlSize;
|
||||
u32 subStreamStateSize = verify_u32(rsi.packedCtrlSize + rsi.stateSize);
|
||||
|
||||
// Handle stream/scratch space alloc for exclusive case differently.
|
||||
if (contains(groupId, i)) {
|
||||
u32 id = groupId.at(i);
|
||||
maxStreamSize[id] = MAX(maxStreamSize[id], rsi.packedCtrlSize);
|
||||
maxStreamSize[id] = max(maxStreamSize[id], subStreamStateSize);
|
||||
// SubCastle full/stream state offsets are written in for the group
|
||||
// below.
|
||||
} else {
|
||||
subScratchStateSize = verify_u32(sizeof(RepeatControl));
|
||||
subStreamStateSize = verify_u32(rsi.packedCtrlSize + rsi.stateSize);
|
||||
|
||||
info.packedCtrlSize = rsi.packedCtrlSize;
|
||||
sub.fullStateOffset = scratchStateSize;
|
||||
sub.streamStateOffset = streamStateSize;
|
||||
|
||||
scratchStateSize += subScratchStateSize;
|
||||
scratchStateSize += verify_u32(sizeof(RepeatControl));
|
||||
streamStateSize += subStreamStateSize;
|
||||
}
|
||||
|
||||
@@ -420,8 +417,6 @@ void buildSubcastles(const CastleProto &proto, vector<SubCastle> &subs,
|
||||
u32 top = j.first;
|
||||
u32 id = j.second;
|
||||
SubCastle &sub = subs[top];
|
||||
RepeatInfo &info = infos[top];
|
||||
info.packedCtrlSize = maxStreamSize[id];
|
||||
if (!scratchOffset[id]) {
|
||||
sub.fullStateOffset = scratchStateSize;
|
||||
sub.streamStateOffset = streamStateSize;
|
||||
|
Reference in New Issue
Block a user