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
Change the OFFSETCLOSURE(2|M2) bytecode instructions to use an offset of 3 instead #10050
Conversation
…ch the change of representation of closures
The change looks obviously correct. There was a special opcode for a common case of field-access-in-a-closure that was detected and generated on the fly. The new closure representation means that the offset-of-interest is 3, not 2 anymore, but the code was not changed when this happened. There was no bug, but the optimization would (probably) not apply anymore so the special opcode was useless. The PR changes the special opcode to apply to offsets of 3 instead of 2, to re-enable the specialized encoding in the same situations. Questions (not necessarily for @Ekdohibs):
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well spotted, and thanks for the patch. It looks good to me.
Concerning spotting the un-optimization, there are two testcases that seem to be designed those opcodes ( |
Presumably, although it may be hard to measure. But I guess the code size of the bootstrap compiler (boot/ocamlc) increased when bootstrapping the change of closure representation, as the +2/-2 instructions were no longer generated because the offsets jumped to +3/-3.
Good question. Who is our liaison agent with js_of_ocaml, again?
That's the general issue of CI to monitor performance. There are more egregious cases of performance regression.
No, this sounds too specific to me. We test for functional correctness first and foremost, and for overall performance if only we knew how to test for that. Testing whether a specific optimization triggers comes as a distant third or fourth. |
cc @hhugo |
You're right. I think these tests are supposed to exercise all opcodes, but they are "only" checked for functional correctness (does the generated bytecode work?). |
Would it be hard/costly/annoying to just add dynamic checks that the testsuite tests are really generating the opcodes we expect them to? This would catch similar potential issues with the opcodes that are only generated by peephole-style detection. |
@Octachron : are you OK with having this change in 4.12? It's not really a bug fix but it corrects an omission in the implementation of the new closure format. |
It sounds indeed better in term of maintenance complexity to not have a gap between the change between the closure format and the associated bytecode instructions. |
OK, I'll put it in the 4.12 section of Changes and cherry-pick. |
…instead of 2 (ocaml#10050) Replace (PUSH)OFFSETCLOSURE(2|M2) by (PUSH)OFFSETCLOSURE(3|M3) to match the change of representation of closures.
This change is to match the new representation of closures, which has a step of 3 instead of 2.