-
Notifications
You must be signed in to change notification settings - Fork 25
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
Map-held computed constants #2
Conversation
👋 Welcome back liach! A progress list of the required criteria for merging this PR into |
@liach This pull request has been inactive for more than 8 weeks and will be automatically closed if another 8 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
|
||
@SuppressWarnings("unchecked") | ||
public IndexedComputedConstantMap(int size, | ||
IntFunction<? extends K> keyMapper, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want an enum map, we could just provide:
ICCM(Foo.values().length,
Foo:ordinal,
k -> e.values[k],
Maybe there should be a convenience method for this (that might be a bit optimized too).
private final ComputedConstant<V>[] values; | ||
|
||
@SuppressWarnings("unchecked") | ||
public IndexedComputedConstantMap(int size, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In theory, it would be possible to assert the invariant that the keyMapper and keyUnmapper match. However, this might defeat the purpose of the construct.
I have made several prototypes of similar map implementations but was a bit reluctant to add them in the beginning. |
@liach this pull request can not be integrated into git checkout cc/map
git fetch https://git.openjdk.org/leyden.git computed-constants
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge computed-constants"
git push |
@liach Could you please fix the merge conflicts and I will be able to merge this PR. |
@liach This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
Keep alive |
❗ This change is not yet ready to be integrated. |
@liach This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
Keep alive. |
@liach This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
Should I close this in favor of the stable values PR in jdk? |
Yes. Please do that. Thanks for your effort with this PR! |
This is an outline of the 2 computed-constant maps I proposed on leyden-dev list; they are copied from existing cc list and immutable map. They should be constant-foldable in theory but need to be confirmed by testing.
During implementation, I feel that the current CC-list impl can be improved by changing the CAS to CAE, so we just take the witness value instead of calling volatile get explicitly again.
I don't see where the condensers are; can probably think about how these maps can be precomputed by condensers too.
Progress
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/leyden.git pull/2/head:pull/2
$ git checkout pull/2
Update a local copy of the PR:
$ git checkout pull/2
$ git pull https://git.openjdk.org/leyden.git pull/2/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 2
View PR using the GUI difftool:
$ git pr show -t 2
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/leyden/pull/2.diff