This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Teach regex optimizer to handle above-Latin1
authorKarl Williamson <public@khwilliamson.com>
Mon, 23 Sep 2013 03:36:29 +0000 (21:36 -0600)
committerKarl Williamson <public@khwilliamson.com>
Tue, 24 Sep 2013 17:36:19 +0000 (11:36 -0600)
commitcdd87c1d4df41f9a54cccff996fa64d291adcee8
tree433feb19de18b9fb38c9a4dc8c1830ad3ae4be6c
parentfb38762fa113a105b623d0eb7681d2cc03b0c161
Teach regex optimizer to handle above-Latin1

Until this commit, the regular expression optimizer has essentially
punted on above-Latin1 code points.  Under some circumstances, they
would be taken into account, more or less, but often, the generated
synthetic start class would end up matching all above-Latin1 code
points.  With the advent of inversion lists, it becomes feasible to
actually fully handle such code points, as inversion lists are a
convenient way to express arbitrary lists of code points and take their
union, intersection, etc.  This commit changes the optimizer to use
inversion lists for operating on the code points the synthetic start
class can match.

I don't much understand the overall operation of the optimizer.  I'm
told that previous porters found that perturbing it caused unexpected
behaviors.  I had promised to get this change in 5.18, but didn't.  I'm
trying to get it in early enough into the 5.20 preliminary series that
any problems will surface before 5.20 ships.

This commit doesn't change the macro level logic, but does significantly
change various micro level things.  Thus the 'and' and 'or' subroutines
have been rewritten to use inversion lists.  I'm pretty confident that
they do what their names suggest.  I re-derived the equations for what
these operations should do, getting the same results in some cases, but
extending others where the previous code mostly punted.  The derivations
are given in comments in the respective routines.

Some of the code is greatly simplified, as it no longer has to treat
above-Latin1 specially.

It is now feasible for /i matching of above-Latin1 code points to know
explicitly the folds that should be in the synthetic start class.  But
more prepatory work needs to be done before putting that into place.
...
embed.fnc
embed.h
proto.h
regcomp.c
regcomp.h