-
Enhancement
-
Resolution: Unresolved
-
P4
-
9, 10
This is a compiler-side follow-up for JDK-6736490.
class A {
volatile int x;
}
class B {
volatile int x = 0;
}
These two classes appear different, but they have the same semantics in both single-threaded and multi-threaded cases:
http://cs.oswego.edu/pipermail/concurrency-interest/2015-December/014767.html
However, class B would be much slower to initialize, because the volatile field init would be present in constructor generated code. We may want to elide that volatile store to improve performance for all existing code.
Benchmark, performance data, and generated code:
http://cr.openjdk.java.net/~shade/8145948/InitStores.java
http://cr.openjdk.java.net/~shade/8145948/benchmarks.jar
class A {
volatile int x;
}
class B {
volatile int x = 0;
}
These two classes appear different, but they have the same semantics in both single-threaded and multi-threaded cases:
http://cs.oswego.edu/pipermail/concurrency-interest/2015-December/014767.html
However, class B would be much slower to initialize, because the volatile field init would be present in constructor generated code. We may want to elide that volatile store to improve performance for all existing code.
Benchmark, performance data, and generated code:
http://cr.openjdk.java.net/~shade/8145948/InitStores.java
http://cr.openjdk.java.net/~shade/8145948/benchmarks.jar
- relates to
-
JDK-6736490 Remove unnecessary explicit initialization of volatile variables
-
- Open
-