-
Notifications
You must be signed in to change notification settings - Fork 589
Add ability to specify assert() calls in embed.fnc #23529
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
base: blead
Are you sure you want to change the base?
Conversation
In addition to the requested changes, I added a \b to the matching of assert( in HeaderParser, so that it won't match something just ending in assert And I added, moved some comments in embed.fnc about this new feature |
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.
These changes look good, but it'd be useful to squash the commits down a bit. We don't need all 11 distinct ones.
Maybe one commit to add the new assert ability, one to swap the existing uses of the G
flag and custom macros, and one final one to remove support for that G
flag.
What I would personally do is merge it with a merge-commit so that it's clear it's one block of related changes. |
I would appreciate some squashing along the lines suggested by @leonerd because it would reduce slightly the number of commits that need to be traversed in a bisection used to diagnose bugs in the future.
Fewer than 1% of all commits in the last 365 days -- but almost all of them were the culmination of projects long in development and were performed by major contributors. Even within such merges, however, some squashing can be beneficial. |
It would not make any significant different on the number of bisect runs. (It's a binary search: it reduces the search space by half each time. So bisecting 900 commits should take 10 builds. Bisecting 1000 commits should also take 10 builds. (2 ** 10 =1024)). Having clear, small and obvious commits with clear explanation will make viewing history a whole lot easier. (And it will help when you do end up with the bisect on a small commit rather the one large commit.) I went through the commits and personally I wouldn't squash any of them. I find all of them split reasonably well.
Because the option is disabled in the GitHub UI. Not because it wouldn't be handy - at least in my opinion. |
I've done a few bisections recently. We're at 40K commits when the bisect kicks in. We don't need an extra step until we reach 65536 commits. That's more than half again as many as we've ever done. That means that trying to conserve commits won't help bisecting. Anything we can do to save human time helps us. Bite-sized commits are helpful in this regard. |
warn "$func: $arg needs NN or NULLOK\n"; | ||
++$unflagged_pointers; |
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.
Commit regen/embed.pl: Improve error checking
This commit needs rechecking;.
Same commit in the previous push: a281942
--> it removed the block on line 259-265:
- if ( $args_assert_line
- && $arg =~ /\*/
- && $arg !~ /\b(NN|NULLOK)\b/ )
- {
- warn "$func: $arg needs NN or NULLOK\n";
- ++$unflagged_pointers;
- }
-
In this commit it's kept..
I believe the block on lines 259-265 should be removed because the same check is now done here.
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.
This was a rebase -i error. I'm not sure if it was me or rere. Both possibilities are scary (that I missed it)
my ($flags, $retval, $plain_func, $args, $assertions ) = | ||
@{$embed}{qw(flags return_type name args assertions)}; |
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.
Commit embed.fnc: Add ability to customize ARGS_ASSERT macros
Just a side note: this is a value slice of a hash ref, it can also be written using postderef as:
my ($flags, $retval, $plain_func, $args, $assertions ) = $embed->@{qw(flags return_type name args assertions)};
(Not asking for a change; just offering it as hint, feel free to ignore it.)
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.
These lines at the beginning explain why not:
require 5.004; # keep this compatible, an old perl is all we may have before
# we build the new one
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.
(That's not to say that that dictum has been obeyed in all commits; and maybe the number should be changed to more recent.)
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.
In that case you should update the line:
push @asserts, $assertions->@* if $assertions;
which you added since that too is using post-deref.
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.
Yeah; I imagine there are others that have crept in.
I have now added a perldelta entry |
@leonerd , Both @bram-perl and I think these commits are a reasonable minimal set. But the series should be added as a merge commit so that they can be considered as a whole, as is our policy in perlgit. I have filed #23547 to either make that easier or to make it harder to do a "Rebase and merge" from GH for series of commits. |
My rules for what needs to be separate commits, is "Would it ever be better to keep this change if we needed to revert the rest?" And sometimes for indentation changes, "Does this change make another change's difference listing easier enough to grok to be worth it?" |
If an argument is a literal string, it's not going to be anything else, so convert an elsif to an else.
Indent newly formed block from the previous commit
@bram-perl found this example of how it could be broken before this commit: initial : $arg is "NULLOK NN SV *msg_sv after s//: $arg is "NULLOKSV *msg_sv
This commit verifies that only one of the mutually exclusive argument modifiers, like NN, is present, and that NZ isn't used for a pointer argument.
This generalizes the previous code to make sure all non-word flags are sorted after the word ones. Previously it checked for just '#' All but '#' not being in column 1 is just for aesthetics. If '#' were in column 1 it would be a preprocessor directive that likely would fail to compile.
This enhances embed.fnc entries to contain arbitrary assert() calls, which will be added to the corresponding generated ARGS_ASSERT macros. The next commit will use it.
These existed because they exceeded the rudimentary capabilities of the generated ARGS_ASSERT macros. But the previous commit generalized that capability, so they can change to use that. This moves the three extant customized macros to use the new facility, removing the need for overriding things The customized PERL_ARGS_ASSERT_ISA_LOOKUP was out-of-date, missing an assertion that got added, without the macro getting updated. This new scheme will prevent that from happening in the future.
This prevented an empty PERL_ARGS_ASSERT macro from being generated here, but those are optional to use, so there is no advantage to suppressing it.
The purpose of this flag has been removed in the past few commits
You can't allocate a zero length array using this function; this uses the new assert() functionality in embed.fnc introduced in the previous few commits to cause the assertion to be placed in PERL_ARGS_ASSERT_AV_NEW_ALLOC rather than be in the function. There is no particular need to do this; this is mostly a demonstration of how it can be done.
This allows the removal of the G flag, and the removal of three customized PERL_ARGS_ASSERT macros. One of these showed the brittleness of the old scheme, as after it was written, code was added to improve the generic versions of these macros, but no one realized to update the custom one. This can no longer happen with this pull request
This commit also improves the error checking of embed.fnc entries; adds comments and white space