[15/18] argv_ref speedup: collect $@ reference in one go
Eric Blake <[email protected]>
| Newsgroups | gmane.comp.gnu.m4.patches |
|---|---|
| Message-ID | <[email protected]> |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Next in the series. The big change here was teaching the input engine how to handle an entire $@ series as a single token, which collect_arguments then drops in place occupying a single array slot but conceptually multiple arguments. All the accessors through the macro_arguments opaque type then simply drill through the nested $@ reference as appropriate. As a result, a recursive macro occupies a lot less memory when it shares arguments from a prior macro invocation. This patch gives dramatic improvements to both memory and execution speed on unboxed recursion (it is much faster to pass the arguments in one go than to visit them one at a time); however, it still remains quadratic in both memory and in speed since n iterations of a recursive algorithm build an argv struct with n nested $@ references to drill through, and since $@ inside quoted contexts are still flattened in place rather than shared. I also added a few testsuite improvements. 2008-02-16 Eric Blake <[email protected]> Stage 15: return argv refs back to collect_arguments. Collect an entire $@ reference at once rather than one argument at a time, outside of quotes (but inside quotes, $@ is still flattened for now). The skip_last field allows concatenation of $@ with other text when collecting arguments. Memory impact: noticeable improvement, due to better reuse of $@. Speed impact: noticeable improvement, due to less parsing. * src/m4.h (enum token_type): Add TOKEN_ARGV. (struct token_chain): Add skip_last member to argv link. (next_token): Update prototype. * src/input.c (CHAR_ARGV): New placeholder input character. (peek_input): Add parameter, to pass $@ at once. (next_char_1, append_quote_token): Handle $@ inside quotes. (init_argv_token): New function. (push_token, match_input, next_token, peek_token, lex_debug): Update callers. * src/macro.c (expand_input, collect_arguments): Likewise. (expand_argument): Handle incoming $@ token. (arg_adjust_refcount, arg_token, arg_text, make_argv_ref_token): Handle nested $@ refs. * src/symtab.c (symtab_debug): Update caller. * examples/null.m4: Document more tests that are needed. Add tests for NUL with divert, patsubst, and regexp. * examples/null.out: Update for new tests. * doc/m4.texinfo (Syntax): Add test for m4exit and NUL. * checks/get-them (AWK): Give a default value. * checks/check-them: Allow tests to invoke child processes with same include path. Perform message normalization on stderr. - -- Don't work too hard, make some time for fun as well! Eric Blake [email protected] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHtuuE84KuGfSFAYARAov4AJ4nmHozA+Sf/+yt+0MLcQR4GsMfKgCfcAis 6QjWQVAEHR4dwGbo22GU2ZU= =IvaX -----END PGP SIGNATURE----- _______________________________________________ M4-patches mailing list [email protected] http://lists.gnu.org/mailman/listinfo/m4-patches
m4.patch318
(text/plain, 67.3 KB) - not displayed