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

FieldProbes should make use of VarHandles #25528

Open
JackPGreen opened this issue Sep 25, 2023 · 3 comments
Open

FieldProbes should make use of VarHandles #25528

JackPGreen opened this issue Sep 25, 2023 · 3 comments

Comments

@JackPGreen
Copy link
Contributor

          Once the type system is enriched with the other primitive types, you can use a VarHandle and use the same technique to prevent litter as with the MethodProbe.

Originally posted by @pveentjer in #25279 (comment)

@JackPGreen
Copy link
Contributor Author

JackPGreen commented Sep 25, 2023

Basic implementation started, but performs slower (4.2 vs 1.7ns) than the current reflection implementation.

Raised on Stackoverflow.

@JackPGreen
Copy link
Contributor Author

After further investigation, I'm not sure that VarHandles on their own are a good idea without additional supporting frameworks due to performance concerns.

@liach
Copy link

liach commented May 29, 2024

An alternative solution to non-static-final VarHandle slowness would be to add -XX:+TrustFinalNonStaticFields (unrealistic for production) or to keep the var handle in records (not applicable to your usage too), just in case you are interested. https://shipilev.net/jvm/anatomy-quarks/17-trust-nonstatic-final-fields/ https://minborgsjavapot.blogspot.com/2023/09/java-records-are-trusted-and.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants