-
-
Notifications
You must be signed in to change notification settings - Fork 925
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
Parallel value assignment broken in IR builder (multi-value literals, calls, attr-assign, etc.) #2574
Comments
Interesting bug :-) .. Looks like our IR builder is not respecting ordering here .. Generated instrs:
So, clearly broken. |
This was a "2 bugs for the price of 1" issue :-). See eb3740c |
Good job in finding the problem and fixing it so fast. I've confirmed that your fix indeed solves the array construction issue, but it seems that the rabbit hole is even deeper; the same behavior is observed in hash construction as well, for both keys and values. a = 0
{ a => a, (a = 1) => a } # => { 1 => 1 } (MRI: {0=>0, 1=>1})
{ a => a, a => (a = 2) } # => { 2 => 2 } (MRI: {1=>2}) This has been observed on cc00fd4. |
Yes, I was going to audit the other literals and fix them. But, good to get confirmation that others might be broken similarly. |
The fix is fairly trivial .. just have to systematically go through all literals and fix the ones that need fixing. |
* Hash literals were broken similarly as array literals. * Updated the spec for #2574.
I don't see any other multi-valued literal besides arrays and hashes. If I missed any, please update this issue. |
Will check call args and masgns next. |
You unearthed a gold mine of a bug here! :) A lot of parallel value construction in many call scenarios are broken. Interesting that this kind of bug never surfaced in mri tests or rubyspec. a = 10 OR a = "xyz" @enebo @headius fyi .. so, the real brain dead fix would be to just force all build values to go through 'copyAndReturnValue' and let OptimizeTempVarsPass, LocalOptPass, etc. propagate useless copies (which there will be lots of now). Otherwise, we'll have to look at all parallel value construction in calls, attr assign, etc. and fix up where required (even so, there will be lots of copies). For the array and hash literal construction cases, after those passes and DCE runs, the output is:
So, those passes will take care of killing useless instrs. but will defer fixing this till we've had a chance to chat about this. |
…/dvars. Use this new knowledge in IRBuilder to fix GH #2574. Still some other cases to fix.
I am resolving this. I covered the cases apparent where we have a list of arguments which must be processed. It is possible some cases were missed (regression spec should cover broad cases known), but if any new cases are found a new issue should be opened. |
It appears as if variables in expressions are evaluated at a later stage in jruby-head than in MRI and JRuby 1.7.19, as shown in the example below.
Or more readable
This is as minimal an example as I've been able to produce, and I don't really know where to continue the investigation.
The text was updated successfully, but these errors were encountered: