-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize validation of arrays #151
Conversation
…e unconstrained
…g a blocked compile-time specialization
…ize array validation when the payload has an action
BOOLEAN hasEnoughBytes0 = (uint64_t)(uint32_t)10U <= (InputLength - StartPosition); | ||
uint64_t positionAfterT; | ||
if (!hasEnoughBytes0) | ||
BOOLEAN hasBytes0 = (uint64_t)10U <= (InputLength - StartPosition); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NB: This is generated code from this PR branch. The while loops are gone in favor of a simple arithmetic check
this oversight would have been let through, since we don't have functional correctness of actions
3D: optimize total compile-time constant-size pairs without actions
…ication to avoid a branch on their trivial (true) result
@tahina-pro, I merged in your PR for pairs and also for fixed size arrays (fixing one small bug, see 688122f) But, still I don't see tuples like { UINT8 fst; UINT8 snd[7]} getting optimized into a single check I think the issue is that |
hi @tahina-pro, I don't think coalescing checking a pair let kind_nlist
: parser_kind false WeakKindStrongPrefix
= let open LP in
{
parser_kind_low = 0;
parser_kind_high = None;
parser_kind_subkind = Some ParserStrong;
parser_kind_metadata = None
} |
…with correct modulo
In Issue #125, we note that validation for arrays like
T f[:byte-size n]
should be optimized in case:T
is of a fixed sizek
that dividesn
T
always succeeds and does not involve any actionsinstead of generating a loop to validate the array element-wise, the entire array can be checked with a single arithmetic check.
This PR achieves this by first:
validate_nlist_constant_size_without_actions
combinator, in case the element type of the array has no actions.T
is a compile-time constant (in which case, the modulus check can be statically evaluated way).Along the way, I migrated LowParse and 3D to use the F* option
--ext context_pruning
and simplified away the use of various settings, including the use of--using_facts_from
in generated 3D code.