Right ... I was focusing my attention only on the regexp $~ family of vars. So, your mail confirms my impression that the only way to access $~ family of vars is via Ruby code based on my first cut browse of RubyString and RubyRegexp implementations. If we do some more verification that this is accurate, then my proposal for encoding these operands/instructions coud be attempted in IR -- and possibly enabled in AST mode as well even before IR version takes effect.
To take full advantage of this functionality, however, you need 2 other things: -> a way to set a flag somewhere (frame/scope/etc.) that regexp methods can query to know that they can omit all updateBackRef -> updating RubyString and RubyRegexp so that they check the flag and not attempt to updateBackRef. I hadn't investigated $_, but you seem to think that this is subject to the same technique, which is worth investigating to see how far it can be pushed. Subbu. On Fri, May 4, 2012 at 12:39 AM, Charles Oliver Nutter <head...@headius.com>wrote: > On Fri, May 4, 2012 at 6:27 AM, Subramanya Sastry <sss.li...@gmail.com> > wrote: > > I was making my case on the assumption that access to $~ is always > through > > Ruby code, and that if there is no reference to it in Ruby code, it is > not > > needed. > > So I can think about this more concretely, can you give me example Ruby > code > > where this is the case (use of $~ outside Ruby code itself)? > > Here's one case for $_: > > ``` > def foo > p gets # sets $_ > p split # splits $_ > end > > foo > ``` > > However...the methods that read $_ appear to only be 1.8-mode methods. > > There are methods that read $~ as well, but as far as I could tell > they only do so to return nil if it is nil or re-use it if it hasn't > been referenced yet. So for 1.9 mode there may be no cases where > native methods read lastline or backref. > > If that's the case, it would be a huge coup for us. JRuby 1.7 could > turn off the "backref/lastline method hinting" it currently does and > speed up many methods considerably. > > We need to confirm this. > > - Charlie > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > >