While reviewing read/write accesses for the "backref" and "lastline" special variables, I realized we can go further than current frame-eliminating optimizations.
For both variables, reads and writes are heavily weighted in one direction. Methods that read backref are rare, while methods that write it are common. The reverse is true for lastline: most methods write it but few read it.
We can narrow the scope of deoptimization when we can detect that one of these variables is only read or written within a given method; read-but-not-written will only ever see nil, and written-but-not-read never needs to actually write. In both cases, we could eliminate the frame if we can indicate to those methods that the read or write should be no-opped.
This should expand the number of cases where we can eliminate the frame, especially when there's only a single related read-or-write call and no direct access to the variable in question.
See other optimization ideas in #9169.
Reactions are currently unavailable
While reviewing read/write accesses for the "backref" and "lastline" special variables, I realized we can go further than current frame-eliminating optimizations.
For both variables, reads and writes are heavily weighted in one direction. Methods that read backref are rare, while methods that write it are common. The reverse is true for lastline: most methods write it but few read it.
We can narrow the scope of deoptimization when we can detect that one of these variables is only read or written within a given method; read-but-not-written will only ever see nil, and written-but-not-read never needs to actually write. In both cases, we could eliminate the frame if we can indicate to those methods that the read or write should be no-opped.
This should expand the number of cases where we can eliminate the frame, especially when there's only a single related read-or-write call and no direct access to the variable in question.
See other optimization ideas in #9169.