Improve String#rindex performance for pathological cases

When the haystack string contained a non-single-byte character, code
would previously call `StringSupport.nth` for every backwards
step. `nth` walks all the way through the string from the
beginning. The combination of these caused O(n^2) behavior.

Now `rindex` follows MRI's pattern of simply walking backward until we
find the previous character.

Fixes #1140
Actually implement __dir__ using stack trace logic. Fixes #651
Merge remote-tracking branch 'github/jruby-1_7' into jruby-1_7