ruby / spec

The Ruby Spec Suite aka ruby/spec
MIT License
588 stars 384 forks source link

Eval into a method, so method JITs can compile #1153

Closed headius closed 1 month ago

headius commented 1 month ago

This replaces most evals of patterns with evaluation into and invoking of a temporary method. The remaining cases depend on surrounding state that would need to be moved into the eval string to work properly.

Partially addresses #1152

headius commented 1 month ago

This allows JRuby's JIT set at a compilation threshold of 0 to exercise these specs, and showed several failures all the same cause as jruby/jruby#8283 (fixed by jruby/jruby#8284).

eregon commented 1 month ago

(see https://github.com/ruby/spec/issues/1152#issuecomment-2150845561)

headius commented 1 month ago

Closing in favor of removing the evals.

headius commented 1 month ago

See #1155 for the actual fix.

eregon commented 1 month ago

Another thought on this is there will likely always be a few eval's in ruby/spec for syntax which is not supported by the oldest supported Ruby version in ruby/spec. These evals should almost always be literal strings though, so one way to compile them would be to actually remove the eval at parse time, but it's certainly hacky (e.g. hard to prove it's a call to Kernel#eval) and when we can remove the eval's like here, the better. I'm mentioning it because this also applies e.g. for other usages of ruby/spec like testing parsers, rubocop, etc.