-
Notifications
You must be signed in to change notification settings - Fork 26
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
Fix TypeCheckingDomain #254
base: develop
Are you sure you want to change the base?
Conversation
/it:test |
Thanks for working on this! I checked the original case where we encountered the exception (as seen in #242) and i can confirm that that particular issue seems to be fixed now. However, when performing the rountrip for all methods of the JAR i ran into other instances of the TypeCheckingDomain thinking there is dead code which (to me) is not really dead. One example is this (more context):
where the OPAL exception reports PC 2039 (corresponding to
Here we see at PC 2003 that there is an In yet another example i found,
Here, PC 61 is reported to be dead - the code seems to me like code relating to the handling of try-with-resources, although i am not completely sure:
Here it is worth noting that PC 61 is installed as an exception handler, but there is another handler ( |
Thank you. If you find the time, any help in locating the new error would be helpful. |
I'll have a look 👍 |
I do have some updates on this. I was able to fix the first issue from my previous comment: The problem was that The other issue (wich arose when handling
@errt Do you have a preference? Do you see any other way of going about it? |
Had a glance at your changes and they seem fine, even if quite complex. I don't have an answer for the other one. Not computing this for dead code seems logical and would probably be easier to do and more performant. On the other hand, we might have more such situations, and while the first solution would only fix this one, the second solution would probably solve it for good. Also, I'm not sure Java's bytecode verifier would even accept the bytecode if it didn't include those stack frames? Note also that the TypeCheckingDomain already is a dumb special purpose domain used only for the computation of StackMapTables, so changing this to not ignore dead code might not have too many repercussions. But I'm not sure how difficult this would be. |
I'm also leaning towards the second solution .. maybe just making all object values involved have |
…andling more robust to match stack frame generation in java compiler
…main now defines that nullness is unknown. Formatting
I reverted my previous changes and implemented a solution that simply returns One method still failed because of certain array-related operations that result from obscure unreachable code, see this example. Here, elements of a varargs parameter array are being After implementing the second fix, all roundtrips i tried were successful. Granted, the domain now does not do very much, it does not enforce nullness and not even type compatibility on array operations ... but if we want to take the Java compiler as a ground truth, i think this is necessary. EDIT: I see the test are failing, i'll have a look into that tomorrow. EDIT2: Seems like the tests are failing because the old assumptions for the |
The tests failing don't seem related to the l0.TypeCheckingDomain, which worries me. They might come from the TypeLevelReferenceValues, which is a whole different beast. |
I managed to fix those issues. The problem was that:
My current solution is to override the changed behavior from L0 wherever it is necessary. This is not the most elegant solution though, and i have not yet seen the results of IT tests. Maybe it would be better to revert L0 back to the way it was (plus your initial fix for fields) and create a dedicated domain class only for computing stack frame tables - as the things we changed here (running all branches, accepting all objects for array operations, etc) are only relevant to this one particular use-case. What do you think? |
/it:test |
Which is exactly what the TypeCheckingDomain is |
I was about to say "that's not its only purpose, as L1 and some tests depend on it", but i realize now the others only depend on particular traits that are mixed into the |
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.
To me this now looks good, the changes are minimal and all tests pass, yet all issues i had with rountrip modifications to bytecode are resolved. The only real change in API is that isValueASubtypeOf
and refIsNull
are no longer final in TypeLevelReferenceValues
, but i do not see a way around that as TypeCheckingDomain
needs to override them.
/it:test |
Are those thrown exceptions necessary? Wouldn't it be sensible to just do nothing in that case, since the code must be dead? |
Yes they are necessary, because otherwise the AI will not visit the |
The integration test failure indicates that there are now some illegal values after performing AI on the JRE classes. The test requires that we can access the |
Fixes #242