changeset 23344:32d6bceb9adc

do not install an empty SpeculationLog in an nmethod (JDK-8153439)
author Doug Simon <doug.simon@oracle.com>
date Mon, 04 Apr 2016 22:59:08 +0200
parents c8526451bb6b
children 1c4b6a7f1917
files jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCodeCacheProvider.java jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotSpeculationLog.java
diffstat 2 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCodeCacheProvider.java	Mon Apr 04 22:42:53 2016 +0200
+++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCodeCacheProvider.java	Mon Apr 04 22:59:08 2016 +0200
@@ -120,7 +120,8 @@
             resultInstalledCode = installedCode;
         }
 
-        int result = runtime.getCompilerToVM().installCode(target, (HotSpotCompiledCode) compiledCode, resultInstalledCode, (HotSpotSpeculationLog) log);
+        HotSpotSpeculationLog hsLog = (HotSpotSpeculationLog) log;
+        int result = runtime.getCompilerToVM().installCode(target, (HotSpotCompiledCode) compiledCode, resultInstalledCode, hsLog.hasSpeculations() ? hsLog : null);
         if (result != config.codeInstallResultOk) {
             String resultDesc = config.getCodeInstallResultDescription(result);
             if (compiledCode instanceof HotSpotCompiledNmethod) {
--- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotSpeculationLog.java	Mon Apr 04 22:42:53 2016 +0200
+++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotSpeculationLog.java	Mon Apr 04 22:59:08 2016 +0200
@@ -38,7 +38,7 @@
     /** All speculations that have been a deoptimization reason. */
     private Set<SpeculationReason> failedSpeculations;
 
-    /** Strong references to all reasons embededded in the current nmethod. */
+    /** Strong references to all reasons embedded in the current nmethod. */
     private volatile Collection<SpeculationReason> speculations;
 
     @Override
@@ -81,4 +81,8 @@
 
         return HotSpotObjectConstantImpl.forObject(reason);
     }
+
+    public synchronized boolean hasSpeculations() {
+        return speculations != null && !speculations.isEmpty();
+    }
 }