Skip to content
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

Change inner loops to use int not YY_CHAR, removing need for separate NUL table #1

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/cpp-flex.skl
Original file line number Diff line number Diff line change
Expand Up @@ -1778,8 +1778,17 @@ m4_ifdef([[M4_MODE_NO_FULLSPD]], [[
]])
]])

%# yy_c was formerly YY_CHAR, changed to int because table can now
%# have up to 0x101 entries, since we no longer generate a separate
%# NUL table.
%#
%# Note: on x86-64 architecture with gcc -O2, we save an instruction
%# in the main loop, since the character can now be zero-extended in
%# the process of retrieving it from the input stream or the yy_ec[]
%# or yy_meta[] arrays, whereas previously it was zero-extended by a
%# register-to-register move just prior to the yy_chk[] table lookup
m4_define([[M4_GEN_NEXT_COMPRESSED_STATE]], [[
YY_CHAR yy_c = $1;
int yy_c = $1;
/* Save the backing-up info \before/ computing the next state
* because we always compute one more state than needed - we
* always proceed until we reach a jam state
Expand Down
29 changes: 5 additions & 24 deletions src/dfa.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,31 +455,12 @@ size_t ntod (void)

/* Note that the test for ecgroup[0] == numecs below accomplishes
* both (1) and (2) above
*
* New way: we will only use NUL table for fulltbl, because the
* scanner will use an integer instead of YY_CHAR as noted above
*/
if (!ctrl.fullspd && ecgroup[0] == numecs) {
/* NUL is alone in its equivalence class, which is the
* last one.
*/
int use_NUL_table = (numecs == ctrl.csize);

if (ctrl.fulltbl && !use_NUL_table) {
/* We still may want to use the table if numecs
* is a power of 2.
*/
if (numecs <= ctrl.csize && is_power_of_2(numecs)) {
use_NUL_table = true;
}
}

if (use_NUL_table)
nultrans =
allocate_integer_array (current_max_dfas);

/* From now on, nultrans != nil indicates that we're
* saving null transitions for later, separate encoding.
*/
}

if (ctrl.fulltbl && ecgroup[0] == numecs && is_power_of_2(numecs))
nultrans = allocate_integer_array (current_max_dfas);

if (ctrl.fullspd) {
for (i = 0; i <= numecs; ++i)
Expand Down