changeset 22607:45a23196c66b

Expose hasBalancedMonitors
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Wed, 23 Sep 2015 17:38:26 -0700
parents 41da626860a3
children 3395128f3aef
files jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotResolvedJavaMethodImpl.java jvmci/jdk.internal.jvmci.meta/src/jdk/internal/jvmci/meta/ResolvedJavaMethod.java jvmci/jdk.internal.jvmci.runtime.test/src/jdk/internal/jvmci/runtime/test/TestResolvedJavaMethod.java
diffstat 3 files changed, 22 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotResolvedJavaMethodImpl.java	Wed Sep 23 17:38:06 2015 -0700
+++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotResolvedJavaMethodImpl.java	Wed Sep 23 17:38:26 2015 -0700
@@ -326,13 +326,14 @@
         return compilerToVM().methodIsIgnoredBySecurityStackWalk(this);
     }
 
+    @Override
     public boolean hasBalancedMonitors() {
         HotSpotVMConfig config = config();
         final int modifiers = getAllModifiers();
 
         // Method has no monitorenter/exit bytecodes.
         if ((modifiers & config.jvmAccHasMonitorBytecodes) == 0) {
-            return false;
+            return true;
         }
 
         // Check to see if a previous compilation computed the monitor-matching analysis.
--- a/jvmci/jdk.internal.jvmci.meta/src/jdk/internal/jvmci/meta/ResolvedJavaMethod.java	Wed Sep 23 17:38:06 2015 -0700
+++ b/jvmci/jdk.internal.jvmci.meta/src/jdk/internal/jvmci/meta/ResolvedJavaMethod.java	Wed Sep 23 17:38:26 2015 -0700
@@ -244,6 +244,14 @@
     LocalVariableTable getLocalVariableTable();
 
     /**
+     * Check if the monitor operations are properly block structured with monitorexits for every
+     * monitorenter and the exits performed in the same order as the enters.
+     *
+     * @return true if monitor operations are balanced.
+     */
+    boolean hasBalancedMonitors();
+
+    /**
      * Invokes the underlying method represented by this object, on the specified object with the
      * specified parameters. This method is similar to a reflective method invocation by
      * {@link Method#invoke}.
--- a/jvmci/jdk.internal.jvmci.runtime.test/src/jdk/internal/jvmci/runtime/test/TestResolvedJavaMethod.java	Wed Sep 23 17:38:06 2015 -0700
+++ b/jvmci/jdk.internal.jvmci.runtime.test/src/jdk/internal/jvmci/runtime/test/TestResolvedJavaMethod.java	Wed Sep 23 17:38:26 2015 -0700
@@ -370,6 +370,18 @@
     }
 
     @Test
+    public void hasBalancedMonitorsTest() {
+        // Everything normally seen should have balanced monitors.
+        for (Map.Entry<Method, ResolvedJavaMethod> e : methods.entrySet()) {
+            ResolvedJavaMethod m = e.getValue();
+            if (!m.hasBalancedMonitors()) {
+                System.err.println(m.hasBalancedMonitors());
+            }
+            assertTrue(m.toString(), m.hasBalancedMonitors());
+        }
+    }
+
+    @Test
     public void isJavaLangObjectInitTest() throws NoSuchMethodException {
         ResolvedJavaMethod method = metaAccess.lookupJavaMethod(Object.class.getConstructor());
         assertTrue(method.isJavaLangObjectInit());