-
Notifications
You must be signed in to change notification settings - Fork 39
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
Split really large methods #19
Comments
There's some kind of bug that still exists here that is not setting the stack properly. Still working... |
Ok, I think I need to change tack here. Currently this runs a de-dupe algorithm which can also reduce overall size among other things. However, it is quite complicated. To solve this specific problem, I need to just find the largest non-jumping section of code I can (but still within some % of overall size), save off the stack and locals, call the fn, restore the stack and locals and go from there. |
I created a new algorithm to do this: https://github.com/cretz/msplit. I plan on embedding that code in here, using |
Decided to just react to MethodTooLargeException instead of using the code size evaluator. Will run some more tests before closing this.. |
Yay, another fun algorithm. Currently on the JVM a method size cannot exceed 65535 bytes. Otherwise, with ASM at least, you get the dreaded
Method code too large!
. Some other JVM languages don't implement code splitting because it's too rare/complex, but we probably need to. At least one generic impl is here (see specifically this package and these tests) but I think I can do better.I need to decide whether I want to split at the WASM level or the JVM level. Probably the former since we have an insn reworking step that counts stack depth anyways. Either way, I figure while the method is too large, we'll just walk the insns finding a large enough section to pull out. Then pull it out to a synthetic method w/ the params as the stack and the result set if needed. The rules for a section to find is probably where many stack values come down to one/zero, no locals are accessed, and all contained within a block.
While this might not be good enough for generic JVM uses, it should be good enough for me.
The text was updated successfully, but these errors were encountered: