Skip to content
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 byte array element type in the bytecode transformation code #357

Merged
merged 4 commits into from
Aug 8, 2024

Conversation

eupp
Copy link
Collaborator

@eupp eupp commented Aug 7, 2024

In JVM, baload and bastore instructions are used to access both byte arrays and boolean arrays.
In the SharedMemoryTransformer class, the instruction is used to determine the type of elements read from an array.
This type is then used to box the read value and pass it into the injected method afterRead(value), which, in turn, stores the value into trace to display it later.

For baload and bastore instructions, the BOOLEAN_TYPE was used. Because of this, in the trace the byte values could have been displayed as boolean, i.e. narrowed to true/false. This PR fixes this problem by using BYTE_TYPE instead.

However, now boolean values are represented in the trace as byte values 0 or 1. This is a lesser problem.
It is unclear how to distinguish byte/boolean in this situation, due to a dynamic nature of baload/bastore instructions which are used for both these types.

@eupp eupp requested a review from ndkoval August 7, 2024 22:35
@ndkoval
Copy link
Collaborator

ndkoval commented Aug 8, 2024

I would assume that boolean is used much more often than byte, and presenting it correctly is critical. We probably can access the array type in the transformer.

@eupp
Copy link
Collaborator Author

eupp commented Aug 8, 2024

We probably can access the array type in the transformer.

@ndkoval you right. I pushed the required fixes, now BYTE_TYPE and BOOLEAN_TYPE are properly distinguished. Please have a look.

Signed-off-by: Evgeniy Moiseenko <[email protected]>
Copy link
Collaborator

@ndkoval ndkoval left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super, thank you! I've approved the changes.

@ndkoval ndkoval merged commit 49454e7 into develop Aug 8, 2024
15 checks passed
@ndkoval ndkoval deleted the fix-byte-array-elem-type branch August 8, 2024 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants