New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ZSuper does not require caller's binding/scope. #3909
Conversation
http://dev.jruby.codehaus.narkive.com/VK4b7dEd/jruby-dev-eliminating-block-as-binding-as-a-potential-deoptimizer and your comment there is how CAN_CAPTURE_CALLERS_BINDING flag was set up in ZSuper. I had set it way back in the day and it just propagated forward through all the code refactoring. As for USES_ZSUPER and requiring dynscope, I think ec25a24 is where the link probably got severed. Till that time the dynscope nesting was walked up to determine call args. |
That said, f67e618 made additional changes and added https://github.com/jruby/jruby/blob/915993886ae6663586d893b7d237f750068aceb5/core/src/main/java/org/jruby/ir/instructions/ArgScopeDepthInstr.java which uses jruby/core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java Lines 1512 to 1520 in 9159938
|
Additionally, we have a more consistent semantics for define_method and zsuper whereas MRI has more restricted semantics. So, worth also checking if implementing those restricted semantics of MRI changes any of this. /cc @enebo |
@subbuss I think the use of DynamicScope in the old logic was more because we had no easy way to get at the current scope's StaticScope. If we didn't actually need the DynamicScope, we'd still push a dummy scope. With these paths modified in this PR to just use the current StaticScope directly, I think we're ok. What semantics of MRI are you referring to as "restricted semantics"? define_method obviously has more need for bindings and scopes, but I still don't think zsuper needs anything beyond StaticScope. |
Okay, I'll trust your and @enebo 's judgment on this since it has been a while and I don't remember all the details .. but, worth checking if the flags set for ArgScopeDepthInstr are correct. |
@subbuss ArgScopeDepthInstr appears to only use the StaticScope, and sets no flags. I think that's correct...for zsuper we really just need to walk up to the proper "method" scope so we can see what the arg structure was. |
The one failure is known to fail sporadically, and that will hopefully be improved by #3929. Proceeding with merge. |
This appears to pass all tests, and I could find no path from ZSuper's interpret method to anything requiring DynamicScope.