changeset 22741:e9424bc1e288

bug fix for 8143730
author Doug Simon <doug.simon@oracle.com>
date Thu, 26 Nov 2015 02:28:38 +0100
parents 22110ef74a40
children 8a91781d5afc
files jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCompiledCode.java
diffstat 1 files changed, 24 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCompiledCode.java	Thu Nov 26 00:47:01 2015 +0100
+++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCompiledCode.java	Thu Nov 26 02:28:38 2015 +0100
@@ -45,6 +45,7 @@
 import jdk.vm.ci.code.CompilationResult.Site;
 import jdk.vm.ci.code.DataSection;
 import jdk.vm.ci.code.InfopointReason;
+import jdk.vm.ci.common.JVMCIError;
 import jdk.vm.ci.meta.Assumptions.Assumption;
 import jdk.vm.ci.meta.ResolvedJavaMethod;
 
@@ -158,18 +159,30 @@
         /**
          * Defines an order for sorting {@link Infopoint}s based on their
          * {@linkplain Infopoint#reason reasons}. This is used to choose which infopoint to preserve
-         * when multiple infopoints collide on the same PC offset.
+         * when multiple infopoints collide on the same PC offset. A negative order value implies a
+         * non-optional infopoint (i.e., must be preserved).
          */
         static final Map<InfopointReason, Integer> HOTSPOT_INFOPOINT_SORT_ORDER = new EnumMap<>(InfopointReason.class);
         static {
-            int order = 0;
-            HOTSPOT_INFOPOINT_SORT_ORDER.put(InfopointReason.SAFEPOINT, ++order);
-            HOTSPOT_INFOPOINT_SORT_ORDER.put(InfopointReason.CALL, ++order);
-            HOTSPOT_INFOPOINT_SORT_ORDER.put(InfopointReason.IMPLICIT_EXCEPTION, ++order);
-            HOTSPOT_INFOPOINT_SORT_ORDER.put(InfopointReason.METHOD_START, ++order);
-            HOTSPOT_INFOPOINT_SORT_ORDER.put(InfopointReason.METHOD_END, ++order);
-            HOTSPOT_INFOPOINT_SORT_ORDER.put(InfopointReason.BYTECODE_POSITION, ++order);
-            HOTSPOT_INFOPOINT_SORT_ORDER.put(InfopointReason.SAFEPOINT, ++order);
+            HOTSPOT_INFOPOINT_SORT_ORDER.put(InfopointReason.SAFEPOINT, -4);
+            HOTSPOT_INFOPOINT_SORT_ORDER.put(InfopointReason.CALL, -3);
+            HOTSPOT_INFOPOINT_SORT_ORDER.put(InfopointReason.IMPLICIT_EXCEPTION, -2);
+            HOTSPOT_INFOPOINT_SORT_ORDER.put(InfopointReason.METHOD_START, 2);
+            HOTSPOT_INFOPOINT_SORT_ORDER.put(InfopointReason.METHOD_END, 3);
+            HOTSPOT_INFOPOINT_SORT_ORDER.put(InfopointReason.BYTECODE_POSITION, 4);
+        }
+
+        static int ord(Infopoint info) {
+            return HOTSPOT_INFOPOINT_SORT_ORDER.get(info.reason);
+        }
+
+        static int checkCollision(Infopoint i1, Infopoint i2) {
+            int o1 = ord(i1);
+            int o2 = ord(i2);
+            if (o1 < 0 && o2 < 0) {
+                throw new JVMCIError("Non optional infopoints cannot collide: %s and %s", i1, i2);
+            }
+            return o1 - o2;
         }
 
         /**
@@ -197,11 +210,8 @@
                 }
 
                 if (s1IsInfopoint) {
-                    assert s2IsInfopoint;
-                    Infopoint s1Info = (Infopoint) s1;
-                    Infopoint s2Info = (Infopoint) s2;
                     sawCollidingInfopoints = true;
-                    return HOTSPOT_INFOPOINT_SORT_ORDER.get(s1Info.reason) - HOTSPOT_INFOPOINT_SORT_ORDER.get(s2Info.reason);
+                    return checkCollision((Infopoint) s1, (Infopoint) s2);
                 }
             }
             return s1.pcOffset - s2.pcOffset;
@@ -239,7 +249,7 @@
                         copy.add(info);
                     } else {
                         // Omit this colliding infopoint
-                        assert lastInfopoint.reason.compareTo(info.reason) < 0;
+                        assert lastInfopoint.reason.compareTo(info.reason) <= 0;
                     }
                 } else {
                     copy.add(result[i]);