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

Vendor org.graalvm.collections #795

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

translatenix
Copy link
Contributor

@translatenix translatenix commented Nov 10, 2024

Motivation:
Package org.graalvm.collections is used throughout the Pkl codebase. It is most heavily used in the Truffle interpreter, which requires putting most collection methods behind @TruffleBoundary. At the moment, this is done by wrapping collection methods with static methods declared in classes EconomicMaps and EconomicSets. However, static wrapper methods are inconvenient to use, decrease code readability, add some overhead, and are easy to forget about.

Changes:

  • vendor package org.graalvm.collections into org.pkl.core.collection
  • inline and remove EconomicMaps/Sets wrapper methods
  • replace usages of EconomicMaps.equals/hashCode with EconomicMapUtil.equals/hashCode
  • fix ProjectDeps.hashCode()

Result:
Cleaner, safer, and more efficient code.

Motivation:
Package org.graalvm.collections is used throughout the Pkl codebase.
It is most heavily used in the Truffle interpreter,
which requires putting most collection methods behind @TruffleBoundary.
At the moment, this is done by wrapping collection methods
with static methods declared in classes EconomicMaps and EconomicSets.
However, static wrapper methods are inconvenient to use,
decrease code readability, add some overhead, and are easy to forget about.

Changes:
- vendor package org.graalvm.collections into org.pkl.core.collection
  - org.graalvm.collections is licensed under:
    The Universal Permissive License (UPL), Version 1.0
  - vendored version:
    https://github.com/oracle/graal/tree/graal-23.0.3/sdk/src/org.graalvm.collections/src/org/graalvm/collections
  - add package-info.java with original license
  - annotate most public methods with @TruffleBoundary
  - add @nullable annotations
    - switching to JSpecify will enable more accurate nullability checks
  - remove prefix tree classes (not used in Pkl)
  - make no other code changes to simplify review/updates
- inline and remove EconomicMaps/Sets wrapper methods
- replace usages of EconomicMaps.equals/hashCode with EconomicMapUtil.equals/hashCode
- fix ProjectDeps.hashCode()

Result:
Cleaner, safer, and more efficient code.
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