Add caching for additional compiled regexps

This caches compiled versions of different encoded regular expressions.
This helps performance wise in cases where the same regular expression
gets used against different encodings.

In Rails this is a pretty common scenario if templates with user
generated content sometimes only contain ASCII characters, other times
binary and sometimes UTF-8.

This caches the encodings with the lowest three encoding id's, which is
US-ASCII, BINARY and UTF-8. They are also the most commonly used and
provides a compromise between additional size usage and performance.

This was also added to Rubinius before because of this being a
bottleneck in a Rails app I was testing:

https://github.com/rubinius/rubinius/commit/c8e8a8d9609232ef10ff83f1c0f495c93af139b9

On CRuby the difference in benchmark numbers on the benchmark are these:

https://github.com/rubinius/rubinius/blob/master/benchmark/core/regexp/bench_match.rb

Before

=== ruby ===
Regexp#match on same strings
                       511196.7 (±3.0%) i/s -    2554803 in   5.002666s (cycle=27471)
Regexp#match on changing string encodings
                       110397.6 (±2.7%) i/s -     552540 in   5.008837s (cycle=9209)

After

=== ruby ===
Regexp#match on same strings
                       506953.4 (±3.5%) i/s -    2550502 in   5.037530s (cycle=27133)
Regexp#match on changing string encodings
                       500990.1 (±2.0%) i/s -    2529228 in   5.050661s (cycle=27196)