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

8330465: Stable Values and Collections (Internal) #18794

Closed
wants to merge 194 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
194 commits
Select commit Hold shift + click to select a range
736c1d0
Add Monotonic
minborg Mar 4, 2024
adbf658
Merge branch 'master' into monotonic
minborg Mar 4, 2024
d866efd
Fix failing test
minborg Mar 4, 2024
8b7e701
Add method
minborg Mar 4, 2024
2422c40
Add computeIfUnbound(MH)
minborg Mar 4, 2024
2352c7b
Add various variants
minborg Mar 4, 2024
5d6b25f
Use List<V> directly
minborg Mar 5, 2024
1a82c01
Improve List implementation
minborg Mar 5, 2024
931a3bd
Add benchmaks and more
minborg Mar 6, 2024
9c6ee52
Clean up
minborg Mar 7, 2024
91e6110
Fix javadocs
minborg Mar 7, 2024
536685a
Add tests and fix failing tests
minborg Mar 7, 2024
b798c1c
Remove special types and add a Monotonics class
minborg Mar 8, 2024
d7e78fe
Update JEP examples
minborg Mar 8, 2024
42baadb
Fix JepDemo issue
minborg Mar 13, 2024
f6bea1d
Refactor
minborg Mar 18, 2024
a1f5772
Update specifications
minborg Mar 18, 2024
83e872c
Merge branch 'master' into monotonic4
minborg Mar 18, 2024
f3b2313
Use static imports for Util class
minborg Mar 18, 2024
a83ab90
Improve tests and fix issues
minborg Mar 18, 2024
8ce0b8e
Add tests
minborg Mar 18, 2024
0b281d9
Rework Monotonics
minborg Mar 19, 2024
69b6c77
Update Monotonics specifications
minborg Mar 19, 2024
32f1e73
Update specifications for Monotonic
minborg Mar 19, 2024
95fd727
Fix snippets
minborg Mar 19, 2024
3d7bd9c
Fix javadoc
minborg Mar 19, 2024
6b3fa81
Fix additional JavaDoc
minborg Mar 19, 2024
616562c
Improve performance by duplicating code
minborg Mar 19, 2024
da17443
Try to improve list perfomance
minborg Mar 19, 2024
0df725f
Update list benchmarks
minborg Mar 19, 2024
bf36937
Update Monotonics::asMemoized docs
minborg Mar 20, 2024
1b5aa66
Merge branch 'master' into monotonic4
minborg Mar 20, 2024
2f9f45f
Add annotation to benchmarks
minborg Mar 21, 2024
d20a44a
Update JEP
minborg Mar 21, 2024
68b7d04
Update JEP
minborg Mar 21, 2024
9c84115
More updates to the JEP
minborg Mar 21, 2024
109f9c3
Update JEP
minborg Mar 21, 2024
2ede3f6
Fix typos in Jep
minborg Mar 21, 2024
851ea0f
Update API and JEP after discussion
minborg Mar 21, 2024
708416d
Update methods and JEP
minborg Mar 22, 2024
0c25010
Update API slighly
minborg Mar 22, 2024
bd4f714
Fix failing tests
minborg Mar 22, 2024
5495d18
Update JEP
minborg Mar 25, 2024
c8f9f27
Merge branch 'master' into monotonic4
minborg Mar 25, 2024
045f2f7
Rename to Lazy
minborg Mar 27, 2024
b108a2b
Update JEP
minborg Mar 27, 2024
3aba33f
Improve on the JEP
minborg Mar 27, 2024
ffc32c4
Improve JEP
minborg Mar 27, 2024
1b805e7
Improve JEP
minborg Mar 27, 2024
653000c
Refine JEP
minborg Mar 27, 2024
94c7870
Update Lazy description
minborg Mar 27, 2024
1fff88c
Update Javadocs
minborg Mar 27, 2024
544ad9e
Update preview feature name
minborg Mar 27, 2024
9408a0d
Update JEP links
minborg Mar 27, 2024
1f2d27a
Clarify methods
minborg Mar 27, 2024
4bded05
Update JEP
minborg Apr 2, 2024
a20c33d
Update link in JEP
minborg Apr 2, 2024
4d11ffe
Merge branch 'master' into monotonic5
minborg Apr 2, 2024
9da90d3
Add benchmark figures
minborg Apr 2, 2024
855d18c
Rename and move factories
minborg Apr 3, 2024
8f15ec6
Improve JEP
minborg Apr 3, 2024
2fe5b42
Update spec and JEP
minborg Apr 3, 2024
be7411d
Update final text in JEP
minborg Apr 3, 2024
dd047d9
Update JEP
minborg Apr 3, 2024
76c0c25
Update the first example in the JEP
minborg Apr 4, 2024
efb2016
Update text after example change
minborg Apr 4, 2024
6d15410
Update invoke-at-once text
minborg Apr 5, 2024
21fa6b3
Change to blocking Lazy
minborg Apr 5, 2024
7532c15
Tidy up
minborg Apr 5, 2024
86b8266
Update JEP
minborg Apr 5, 2024
152c028
Update benchmark
minborg Apr 5, 2024
da73f66
Add a delegated lazy and update benchmarks
minborg Apr 8, 2024
777d0f5
Update benchmarks
minborg Apr 8, 2024
aba54b3
Refactor to L<L<V>>
minborg Apr 8, 2024
4482099
Fix lazy map
minborg Apr 8, 2024
5bc48da
Add lazy enum map
minborg Apr 9, 2024
c0b9ab5
Improve JEP
minborg Apr 9, 2024
b721920
Merge master
minborg Apr 9, 2024
9c0d9d9
Update JEP
minborg Apr 9, 2024
13fcdb2
Fix missing parentheses
minborg Apr 9, 2024
66ecc0f
Remove unused factories in JEP
minborg Apr 9, 2024
c9bd25d
Pretty JEP
minborg Apr 9, 2024
62d5685
Rename to LazyValue
minborg Apr 9, 2024
4868103
Fix benchmark
minborg Apr 9, 2024
04fb7cb
Update JEP
minborg Apr 9, 2024
0ad2af5
Fix language issues in JEP
minborg Apr 9, 2024
ac46e7a
Update tests and JEP
minborg Apr 10, 2024
d777abc
Add note on production environments
minborg Apr 10, 2024
4107f64
Rename to StableValue
minborg Apr 16, 2024
a124b7c
Merge branch 'master' into stable-value
minborg Apr 16, 2024
7493afb
Merge branch 'master' into stable-value
minborg Apr 16, 2024
9e41db8
Clean up
minborg Apr 16, 2024
44062da
Do additional clean up operations
minborg Apr 16, 2024
d29a761
Rename constant in ciField.cpp
minborg Apr 16, 2024
5a7846e
Fix tests and benchmarks
minborg Apr 16, 2024
53679fa
Tighten up accessability
minborg Apr 16, 2024
991abf7
Rename internal interface
minborg Apr 16, 2024
361d211
Clean up
minborg Apr 16, 2024
c2c7968
Remove commented code
minborg Apr 16, 2024
8ee1676
Change klass name to internal
minborg Apr 17, 2024
539ae47
Revert change in AccessibleObject
minborg Apr 17, 2024
568d58a
Reinstate method
minborg Apr 17, 2024
2ce301b
Improve comments and use a zero lenght List if size is zero
minborg Apr 17, 2024
93a3d2b
Remove trailing spaces
minborg Apr 17, 2024
0067bab
Add memoized factories and fix error in a test
minborg Apr 17, 2024
02a347b
Remove trailing space
minborg Apr 17, 2024
a776ba8
Update JepDemo
minborg Apr 17, 2024
ec9a90c
Merge branch 'master' into stable-value
minborg Apr 17, 2024
d76c4d4
Update JepExamples and fix two bugs
minborg Apr 18, 2024
fbbf869
Ensure invoke-at-most-once invariants
minborg Apr 18, 2024
9f9d54e
Update src/java.base/share/classes/java/lang/reflect/AccessibleObject…
minborg Apr 18, 2024
7211d3c
Add freeze operations
minborg Apr 18, 2024
e5ba63d
Merge branch 'stable-value' of https://github.com/minborg/jdk into st…
minborg Apr 18, 2024
718d41e
Fix thread issue
minborg Apr 19, 2024
67db32b
Merge branch 'master' into stable-value
minborg Apr 22, 2024
a59e0f8
Use 8 threads for accessing in a benchmark
minborg Apr 22, 2024
008f040
Remove benchmark figures
minborg Apr 22, 2024
d8a9f33
Add BiFunction to lambdas
minborg Apr 22, 2024
e73b154
Break out tests in separate classes
minborg Apr 23, 2024
11b3258
Try improving performance and rename fields
minborg Apr 23, 2024
31051ac
Use pattern matching instead of applying functions
minborg Apr 23, 2024
77759d5
Rename variable and simplify type parameter
minborg Apr 23, 2024
4d106db
Use internal mutex
minborg Apr 23, 2024
7d177ca
Fix typo
minborg Apr 23, 2024
59b6748
Always check final fields of type StableValue
minborg Apr 23, 2024
0c17887
Use BlackHole and always use int values
minborg Apr 23, 2024
f2e5f3e
Make StableValue a bit more vague about VM optimizations
minborg Apr 23, 2024
4a1040d
Make promises vaguer for stable collections too
minborg Apr 23, 2024
5237df9
Use a ThreadFactory to create new background threads
minborg Apr 23, 2024
cdb728d
Actually benchmark under contention
minborg Apr 23, 2024
ff3d776
Improve StableValueElement performance
minborg Apr 24, 2024
5eea3bb
Create separate benchmarks for stable value
minborg Apr 24, 2024
0da5095
Update benchmarks
minborg Apr 24, 2024
eb361d7
Merge branch 'master' into stable-value
minborg Apr 24, 2024
c73ad3a
Rename benchmarks
minborg Apr 24, 2024
8529927
Use loops for benchmarks
minborg Apr 25, 2024
a5c9e22
Update docs for ofBackground()
minborg Apr 25, 2024
7a16dde
Add benchmark for stable holding an immutable list
minborg Apr 25, 2024
233e5e7
Reduce the number of loops in a benchmark
minborg Apr 25, 2024
441098a
Check for recursive invocation
minborg Apr 25, 2024
015a9e8
Correct recrursive docs and add recursive test
minborg Apr 25, 2024
78cc2e2
Add array abstraction
minborg Apr 29, 2024
8209e79
Add test
minborg Apr 29, 2024
e2b0d60
Wip
viktorklang-ora Apr 29, 2024
c189307
Merge pull request #5 from viktorklang-ora/stable-value
minborg Apr 29, 2024
e854488
Merge branch 'master' into stable-value
minborg Apr 29, 2024
10dea16
Update docs for trySet
minborg Apr 29, 2024
9a12066
Add state ERROR for compute errors
minborg Apr 29, 2024
3dff727
Remove mutex after use
minborg Apr 29, 2024
21cf963
Use final declarations
minborg Apr 29, 2024
493c5e7
Improve benchmarks
minborg Apr 30, 2024
400b1b9
Abstract aux arrays
minborg Apr 30, 2024
f6a5652
wip Arrays
minborg May 6, 2024
6196fe4
Merge branch 'master' into stable-value
minborg May 9, 2024
3ebd886
Merge branch 'master' into stable-value
minborg May 13, 2024
e8e0b3f
Update after comments
minborg May 13, 2024
95a33e7
Update affter additional code comments
minborg May 13, 2024
4ed9c06
Add linked list with record test
minborg May 13, 2024
ee5fb04
Make arrays trusted too
minborg May 13, 2024
8848e5d
Change benchmarks to throughput
minborg May 13, 2024
431cf30
Record errors
minborg May 13, 2024
317df1c
Swap parameter order and add tests
minborg May 14, 2024
48fe8cd
Add tests
minborg May 14, 2024
df17bc5
Clean up tests
minborg May 14, 2024
4d37870
Improve array test
minborg May 14, 2024
14b04dc
Add a marker interface TrustedFieldType
minborg May 14, 2024
752b9da
Change class types
minborg May 14, 2024
d57e4d7
Add methods to create generic arrays
minborg May 14, 2024
ec6da51
Fix error in hash code
minborg May 14, 2024
946d89e
Update sun.misc.Unsafe
minborg May 14, 2024
ed2ea70
Rework the creation of StableEnumMaps
minborg May 14, 2024
5d5dcce
Merge branch 'master' into stable-value
minborg May 14, 2024
d7c3158
Remove text in public class that references an internal class
minborg May 14, 2024
7db1101
Add delegation to the thread's exception handler
minborg May 15, 2024
c92b16c
Revise docs for ofBackground()
minborg May 15, 2024
2b840e0
Switch to monomorphic StableValue and use lazy arrays
minborg May 15, 2024
befb275
Simplify exception handling and add benchmarks
minborg May 16, 2024
b845c58
Rename memoized factories
minborg May 16, 2024
d8875db
Rework the way compute invocation is recorded
minborg May 16, 2024
5a1d3b9
Share code paths
minborg May 16, 2024
058cfdd
Add comment on security precaution
minborg May 16, 2024
80b7e08
Use byte for storing state and compute flags
minborg May 16, 2024
923e187
Update src/java.base/share/classes/jdk/internal/lang/stable/StableAcc…
minborg May 16, 2024
b40ebfa
Clean up
minborg May 16, 2024
2a9043e
Update null benchmarks
minborg May 16, 2024
dbbefea
Cleanup switch rakes
minborg May 16, 2024
3e1ab5e
Improve toString and simplify offset calculations
minborg May 16, 2024
2af0168
Simplify background thread handling
minborg May 16, 2024
ec7c92c
Fix copyringht issues
minborg May 16, 2024
35c9252
Declare field final
minborg May 17, 2024
0f798a7
Simplify StableList
minborg May 17, 2024
dd0ceaf
Update ofList and ofMap docs
minborg May 17, 2024
7ecf512
Add benchmark for memoized supplier
minborg May 17, 2024
7beab36
Add benchmarks for memoized IntFunction and Function
minborg May 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/java.base/share/classes/jdk/internal/lang/StableValue.java
minborg marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -381,7 +381,7 @@ static <K, V> V computeIfUnset(Map<K, StableValue<V>> map,
* @param original the original Suppler to convert to a memoized Supplier
* @param <T> the memoized type
*/
static <T> Supplier<T> ofSupplier(Supplier<? extends T> original) {
static <T> Supplier<T> memoizedSupplier(Supplier<? extends T> original) {
Objects.requireNonNull(original);
StableValue<T> stable = StableValue.of();
return StableAccess.ofSupplier(stable, original);
@@ -403,8 +403,8 @@ static <T> Supplier<T> ofSupplier(Supplier<? extends T> original) {
* @param original the original IntFunction to convert to a memoized IntFunction
* @param <R> the return type of the IntFunction
*/
static <R> IntFunction<R> ofIntFunction(int size,
IntFunction<? extends R> original) {
static <R> IntFunction<R> memoizedIntFunction(int size,
IntFunction<? extends R> original) {
if (size < 0) {
throw new IllegalArgumentException();
}
@@ -431,8 +431,8 @@ static <R> IntFunction<R> ofIntFunction(int size,
* @param <T> the type of input values
* @param <R> the return type of the function
*/
static <T, R> Function<T, R> ofFunction(Set<? extends T> inputs,
Function<? super T, ? extends R> original) {
static <T, R> Function<T, R> memoizedFunction(Set<? extends T> inputs,
Function<? super T, ? extends R> original) {
Objects.requireNonNull(inputs);
Objects.requireNonNull(original);
Map<T, StableValue<R>> stableMap = StableValue.ofMap(inputs);
10 changes: 5 additions & 5 deletions test/jdk/java/lang/StableValue/JepDemo.java
Original file line number Diff line number Diff line change
@@ -133,7 +133,7 @@ class Bar4 {

// 1. Declare a memoized (cached) Supplier backed by a stable value
private static final Supplier<Logger> LOGGER =
StableValue.ofSupplier( () -> Logger.getLogger("com.foo.Bar") );
StableValue.memoizedSupplier( () -> Logger.getLogger("com.foo.Bar") );

static Logger logger() {
// 2. Access the memoized suppler with as-declared-final performance
@@ -304,7 +304,7 @@ class ListDemo3 {

// 1. Declare a memoized IntFunction backed by the stable list
private static final IntFunction<String> ERROR_FUNCTION =
StableValue.ofIntFunction(SIZE, ListDemo3::readFromFile);
StableValue.memoizedIntFunction(SIZE, ListDemo3::readFromFile);

// 2. Define a function that is to be called the first
// time a particular message number is referenced
@@ -352,7 +352,7 @@ class Fibonacci1 implements Fibonacci {
private final IntFunction<Integer> fibFunction;

public Fibonacci1(int upperBound) {
fibFunction = StableValue.ofIntFunction(upperBound, this::fib);
fibFunction = StableValue.memoizedIntFunction(upperBound, this::fib);
}

@Override
@@ -398,7 +398,7 @@ record Fibonacci3(StableValue<IntFunction<Integer>> fibFunction) implements Fibo
public Fibonacci3(int upperBound) {
this(StableValue.of());
fibFunction.trySet(
StableValue.ofIntFunction(upperBound, this::fib));
StableValue.memoizedIntFunction(upperBound, this::fib));
}

@Override
@@ -497,7 +497,7 @@ class Memoized2 {

// 1. Declare a memoized (cached) function backed by a lazily computed map
private static final Function<String, Logger> MAPPER =
StableValue.ofFunction(
StableValue.memoizedFunction(
Set.of("com.foo.Bar", "com.foo.Baz"),
Logger::getLogger);

2 changes: 1 addition & 1 deletion test/jdk/java/lang/StableValue/MemoizedFunctionTest.java
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ final class MemoizedFunctionTest {
@Test
void memoized() {
StableTestUtil.CountingFunction<Integer, Integer> counting = new StableTestUtil.CountingFunction<>(Function.identity());
Function<Integer, Integer> memoized = StableValue.ofFunction(Set.of(0, 1, FIRST), counting);
Function<Integer, Integer> memoized = StableValue.memoizedFunction(Set.of(0, 1, FIRST), counting);
assertEquals(FIRST, memoized.apply(FIRST));
assertEquals(1, counting.cnt());
// Make sure the original supplier is not invoked more than once
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ final class MemoizedIntFunctionTest {
@Test
void memoized() {
StableTestUtil.CountingIntFunction<Integer> counting = new StableTestUtil.CountingIntFunction<>(i -> i);
IntFunction<Integer> memoized = StableValue.ofIntFunction(FIRST + 1, counting);
IntFunction<Integer> memoized = StableValue.memoizedIntFunction(FIRST + 1, counting);
assertEquals(FIRST, memoized.apply(FIRST));
assertEquals(1, counting.cnt());
// Make sure the original supplier is not invoked more than once
2 changes: 1 addition & 1 deletion test/jdk/java/lang/StableValue/MemoizedSupplierTest.java
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ final class MemoizedSupplierTest {
@Test
void memoized() {
StableTestUtil.CountingSupplier<Integer> counting = new StableTestUtil.CountingSupplier<>(() -> FIRST);
Supplier<Integer> memoized = StableValue.ofSupplier(counting);
Supplier<Integer> memoized = StableValue.memoizedSupplier(counting);
assertEquals(FIRST, memoized.get());
assertEquals(1, counting.cnt());
// Make sure the original supplier is not invoked more than once