truffleruby
truffleruby copied to clipboard
[GR-28711] Implement context independent method lookup
See Jira issue.
See Jira issue.
We can't!
The mirroring simply copies the description from the PR.
In short, there is a SharedIndicesMap per class, and that SharedIndicesMap is shared for corresponding classes (e.g., by where they are defined first, e.g. a class Foo; end) between contexts. A bit like a Shape, but it grows in-place without needing a new instance.
So then method lookup is: get the class, check the SharedIndicesMap of that class is the one we expect in the inline cache, if so use the cached index to read from the array of methods (vtable) and lookup is done. In practice, more things are needed like visibility checks, etc in multi-contexts.
The additional complexity lies in those arrays of methods (1 per RubyClass instance) being up-to-date with redefinitions anywhere in the hierarchy, but we kind of already handle that since https://medium.com/graalvm/precise-method-and-constant-invalidation-in-truffleruby-4dd56c6bac1a.
Oracle requires that contributors to all of its open-source projects sign the Oracle Contributor Agreement (OCA). The following contributors of this PR have not signed the OCA:
- PR author: @graalvmbot
In order to sign the OCA, you need to create an Oracle account and sign the OCA in the Oracle's Contributor Agreement Application by following the steps on the homepage.
When singing the OCA, please provide your GitHub username. By doing so, this PR will be automatically updated once the signed OCA was approved by Oracle.
This would be nice for context-independent code, but since that's not a priority currently and it seems tricky to rebase I think best to close for now.