# HG changeset patch # User Tom Rodriguez # Date 1443055106 25200 # Node ID 45a23196c66b5235fc58505f19fd9006955fb844 # Parent 41da626860a391e3acc03b01e5d462e980ded5c0 Expose hasBalancedMonitors diff -r 41da626860a3 -r 45a23196c66b jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotResolvedJavaMethodImpl.java --- 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. diff -r 41da626860a3 -r 45a23196c66b jvmci/jdk.internal.jvmci.meta/src/jdk/internal/jvmci/meta/ResolvedJavaMethod.java --- 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}. diff -r 41da626860a3 -r 45a23196c66b jvmci/jdk.internal.jvmci.runtime.test/src/jdk/internal/jvmci/runtime/test/TestResolvedJavaMethod.java --- 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 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());