OpenJDK / jdk / hs
changeset 46793:27a0fdda79c3
8185950: [JVMCI] fix NPE possibility in HotSpotSpeculationLog.speculate
Reviewed-by: thartmann, kvn
author | dnsimon |
---|---|
date | Thu, 10 Aug 2017 10:38:17 -0700 |
parents | 1f9002906ea9 |
children | aa0b86e09f9a |
files | hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotSpeculationLog.java |
diffstat | 1 files changed, 5 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotSpeculationLog.java Wed Aug 02 10:17:14 2017 +0200 +++ b/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotSpeculationLog.java Thu Aug 10 10:38:17 2017 -0700 @@ -39,7 +39,7 @@ private Set<SpeculationReason> failedSpeculations; /** Strong references to all reasons embedded in the current nmethod. */ - private volatile Collection<SpeculationReason> speculations; + private Collection<SpeculationReason> speculations; @Override public synchronized void collectFailedSpeculations() { @@ -70,14 +70,12 @@ * reason objects that are embedded in nmethods, so we add them to the speculations * collection. */ - if (speculations == null) { - synchronized (this) { - if (speculations == null) { - speculations = new ConcurrentLinkedQueue<>(); - } + synchronized (this) { + if (speculations == null) { + speculations = new ConcurrentLinkedQueue<>(); } + speculations.add(reason); } - speculations.add(reason); return HotSpotObjectConstantImpl.forObject(reason); }