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 remapping arrays and improve test coverage #704

Closed
wants to merge 9 commits into from

Conversation

jbachorik
Copy link
Collaborator

This is a rather large work to reimplement the indy linking to avoid deadlocks between tracing and linking.

Unfortunately, this involves some hackery - we need to instrument java.lang.invoke.MethodHandleNatives and track the start and end of the linking process. The reason is that we need to hook-in deeply into the JDK linking process, otherwise we are not able to prevent BTrace probes firing while in the indy linking.

That particular instrumentation will increment thread-local value of a linking flag when the linking starts and decrement once the linking is finished. Then, the injected code needs to be adjusted such that the BTrace action invocation is guarded by a check for the linking flag, skipping the action if the linking is in progress.

Once all of this is in place, it is possible to drastically reduce the exclusion filter for 'sensitive' classes, leaving just a bunch of classes that are crucial to BTrace. Here is the minimal list of excluded classes, still allowing full functionality of BTrace

"java/lang/Integer"
"java/lang/Number"
"java/lang/Object"
"java/lang/String"
"java/lang/StringUTF16"
"java/lang/ThreadLocal"
"java/lang/ThreadLocal$ThreadLocalMap"
"java/lang/WeakPairMap"
"java/lang/WeakPairMap$Pair$Weak"
                                                                        
"java/lang/instrument/*"
"java/lang/invoke/*"
"java/lang/ref/*"
"java/util/concurrent/locks/LockSupport"
"java/util/concurrent/locks/AbstractQueuedSynchronizer"
"java/util/concurrent/locks/AbstractQueuedSynchronizer$ExclusiveNode"
"java/util/concurrent/locks/AbstractQueuedSynchronizer$Node"
"java/util/concurrent/locks/AbstractOwnableSynchronizer"
"java/util/concurrent/locks/ReentrantLock"
                                                                        
"jdk/internal/*"
"sun/invoke/*"
"org/openjdk/btrace/*"

While working on this change, the instrumentor tests were converted to parametric tests and using golden files.

Copy link

@reviewabot reviewabot bot left a comment

Choose a reason for hiding this comment

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

It looks like the pull request you're trying to review is too large to be displayed directly here. To proceed with the review, you can either:

  1. Use the 'List pull requests files' API to get a list of the files changed in the pull request and review them individually.
  2. Clone the repository locally and review the changes using a Git client.

Here are the steps to clone the repository and review the changes locally:

  1. Clone the repository:

    git clone <repository-url>
  2. Navigate to the repository directory:

    cd <repository-directory>
  3. Fetch the pull request:

    git fetch origin pull/<PR-number>/head:<local-branch-name>
  4. Checkout to the fetched branch:

    git checkout <local-branch-name>
  5. Review the changes:

    git diff main...<local-branch-name>

By following these steps, you can review the changes locally and provide feedback accordingly. If you need further assistance, please let me know!

@jbachorik jbachorik closed this Nov 9, 2024
@jbachorik jbachorik deleted the jb/improved_linking1 branch November 9, 2024 20:49
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.

1 participant