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
Inspect Local Variable Representation #93
Comments
There is a fundamental problem with completely relying on source locals, is that it's only debugging information not required to run the code. I reckon we should use a best-effort attempt to match the source locals with the bytecode local variables, in this case V3 and V12, duplicating source local information where necessary. We can create a map from bytecode local name to local metadata.
The |
So I think we can agree that The main concern I have is with Transformers adding locals. They have to do two things:
Inserting into a map can currently only be done by replacing the entire map. Is this a problem? Alternatively, we can drop the requirement that transformers should specify the descriptor. The easiest way to do this would be to recalculate the locals-map after every round. This does however mean, that locals only become visible in the locals map at the end of a round. A more complicated approach would be to lazy-evaluate map entries (or provide an intrinsic). I'm not sure if this is beneficial from an API perspective, but it could allow to get locals info even during a round. |
I don't think we should completely drop debug info, only encourage people not to use it. In other places, the signature can represent the generics of a class or a method, which are actually visible via reflection (although their format is still arbitrary). As for labels in local variables I'm not sure, maybe they can be dropped. With transformers adding locals, one other option would be to check that the local variables are well-formed during class writing (conversion back to ASM). This is not the same as class file verification as these locals are not part of the class file format, so therefore is not strictly outside the scope of chasm. But it would force transformers to write to the local type map correctly or else get transformation errors.
Not really. There is already a fairly idiomatic way of adding an entry to a map using the
The latter approach would bear no behavioural improvement over the former, as an intrinsic returning different outputs with no change to its inputs (in this case no inputs) would be a violation of chassembly's immutability and mess with semantics and the optimizer. What could be done instead is making the local variable information an intrinsic function which takes in a chasm method, which therefore is allowed to return different results if the method changes. |
No, you misunderstood: It's straightforward in Chassembly, but on a Chasm level, a |
Mixin also supports targeting by source variable name, which is fairly convenient when mixing into other mods. |
Let's have a look at the following java method:
The following is the Chasm-Internal representation of said method:
First, let's observe:
However, the debug information provided in sourceLocals is not in any way associated with said locals.
I want to investigate the possibility and usefulness of merging these representations somehow.
One problem is currently that it is very hard to impossible to match a local by it's type, which is very common with mixin.
Another possible problem is duplicate information shared between
signature
anddescriptor
.Please suggest different representations below.
The text was updated successfully, but these errors were encountered: