changeset 13490:fdff5cf44b52

8185950: [JVMCI] fix NPE possibility in HotSpotSpeculationLog.speculate Reviewed-by: thartmann, kvn
author dnsimon
date Thu, 10 Aug 2017 10:38:17 -0700
parents cce66cb38028
children b67f6e18cf5f
files 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/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/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);
     }