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

Detect atomic primitive method calls dynamically #336

Merged
merged 11 commits into from
Jun 28, 2024

Conversation

eupp
Copy link
Collaborator

@eupp eupp commented Jun 27, 2024

Currently, we have two injection methods to handle method calls: beforeMethodCall and beforeAtomicMethodCall.
This solution has several problems:

  1. Code duplication.

  2. We do not handle classes inheriting from Atomic* classes propertly, because their methods are not detected as "atomic" statically by the MethodCallTransformer bytecode transformer that injects beforeMethodCall and beforeAtomicMethodCall invocations. This is because this transformer decides what method to insert statically based on the class name of the invoked method. It checks only for j.u.c.Atomic* method names, and do not handles subclasses of atomics.

This PR removes beforeAtomicMethodCall injection, letting the managed strategy to decide how to handle the method dynamically at runtime, based on the actual type of the method receiver.

I've also added a new test AtomicSubclassTest.kt checking that subclasses of Atomic* classes are properly supported.

Please note, that with this PR the memory access methods of Atomic*, Atomic*FieldUpdater, VarHandle and Unsafe APIs are treated as atomic. Therefore, this PR also closes #288.

The latter also implies that Atomic*Array::length() method is no longer considered to be atomic method.
Because of this, it has disappeared from the trace output of some tests.

@eupp eupp requested a review from ndkoval June 27, 2024 20:52
eupp added 3 commits June 28, 2024 14:26
Signed-off-by: Evgeniy Moiseenko <[email protected]>
Signed-off-by: Evgeniy Moiseenko <[email protected]>
@eupp eupp requested a review from ndkoval June 28, 2024 13:39
@ndkoval ndkoval merged commit 11eefac into develop Jun 28, 2024
15 checks passed
@ndkoval ndkoval deleted the uniform-method-call-instrumentation branch June 28, 2024 14:43
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