Skip to content

Conversation

@graalvmbot
Copy link
Collaborator

Overview

This PR extends the registrations that are performed by TruffleFeature.beforeAnalysis to make sure that even small test images or non-standard usages of Truffle still end up having the core Truffle classes reachable and included in the image.

Reasoning behing the new registrations

Overall, the goal is to make a few key Truffle classes always reachable. The way we currently do it is via various registrations in TruffleFeature.beforeAnalysis.

TruffleSupport.singleton().createOptimizedCallTarget root method

This method calls a constructor of a subclass of OptimizedCallTarget. TruffleFeature already marked that class as in the heap, but without making the analysis see the constructor, its fields remain with empty typestate. As soon as there is a null check or a type check somewhere, WP SCCP will see that the predicates of both branches are empty and therefore all the rest of the flows in those method remain disabled. This is problematic especially because the fields rootNode and engineare acesssed often before anything else is done, so this effectively makes the analysis of most of methods on OptimizedCallTarget to stop very early and conclude that the rest is unreachable (including methods that could be transitively reachable from the methods on OptimizedRootNode) .

Marking TruffleSupport.singleton().getClass() as in the heap

Since createOptimizedCallTarget is not static, to analysis has to see a potential receiver object on which the given method can be called.

Conclusion

These two registrations are enough to fix the issues we care about and and morever, the code elements in question are already made reachable by the original analysis for any 'real' Truffle image anyways, so nothing new should be included by this change.

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Oct 29, 2024
@graalvmbot graalvmbot closed this Oct 31, 2024
@graalvmbot graalvmbot deleted the d-kozak/GR-58968/truffle-feature-register-more branch October 31, 2024 02:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Verified All contributors have signed the Oracle Contributor Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants