# HG changeset patch # User Gilles Duboscq # Date 1379515494 -7200 # Node ID f679f5411fd714701b81199b9068e3e6ccaf561b # Parent 8a3b59397044d196ea93253a9856be6972331db4 Better handling of methods which have no line number or variable name tables. Force local/stack sizes to report 0 for native and abstract methods Make TestResolvedJavaMethod getMaxStackSizeTest a bit more flexible diff -r 8a3b59397044 -r f679f5411fd7 graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestResolvedJavaMethod.java --- a/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestResolvedJavaMethod.java Tue Sep 17 18:05:11 2013 +0200 +++ b/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestResolvedJavaMethod.java Wed Sep 18 16:44:54 2013 +0200 @@ -265,7 +265,9 @@ ResolvedJavaMethod method2 = runtime.lookupJavaMethod(getClass().getDeclaredMethod("nullPointerExceptionOnFirstLine", Object.class, String.class)); assertEquals(0, method1.getMaxStackSize()); // some versions of javac produce bytecode with a stacksize of 2 for this method - assertTrue(3 == method2.getMaxStackSize() || 2 == method2.getMaxStackSize()); + // JSR 292 also sometimes need one more stack slot + int method2StackSize = method2.getMaxStackSize(); + assertTrue(2 <= method2StackSize && method2StackSize <= 4); } private Method findTestMethod(Method apiMethod) { diff -r 8a3b59397044 -r f679f5411fd7 graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaMethod.java --- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaMethod.java Tue Sep 17 18:05:11 2013 +0200 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaMethod.java Wed Sep 18 16:44:54 2013 +0200 @@ -175,12 +175,14 @@ boolean canBeInlined(); /** - * Returns the LineNumberTable of this method. + * Returns the LineNumberTable of this method or null if this method does not have a line + * numbers table. */ LineNumberTable getLineNumberTable(); /** - * Returns the localvariable table of this method. + * Returns the local variable table of this method or null if this method does not have a local + * variable table. */ LocalVariableTable getLocalVariableTable(); diff -r 8a3b59397044 -r f679f5411fd7 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java Tue Sep 17 18:05:11 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java Wed Sep 18 16:44:54 2013 +0200 @@ -218,6 +218,10 @@ @Override public int getMaxLocals() { + int modifiers = getModifiers(); + if (Modifier.isAbstract(modifiers) || Modifier.isNative(modifiers)) { + return 0; + } HotSpotVMConfig config = graalRuntime().getConfig(); long metaspaceConstMethod = unsafe.getLong(metaspaceMethod + config.methodConstMethodOffset); return unsafe.getShort(metaspaceConstMethod + config.methodMaxLocalsOffset) & 0xFFFF; @@ -225,6 +229,10 @@ @Override public int getMaxStackSize() { + int modifiers = getModifiers(); + if (Modifier.isAbstract(modifiers) || Modifier.isNative(modifiers)) { + return 0; + } HotSpotVMConfig config = graalRuntime().getConfig(); long metaspaceConstMethod = unsafe.getLong(metaspaceMethod + config.methodConstMethodOffset); return config.extraStackEntries + (unsafe.getShort(metaspaceConstMethod + config.constMethodMaxStackOffset) & 0xFFFF); @@ -407,6 +415,9 @@ @Override public LineNumberTable getLineNumberTable() { long[] values = graalRuntime().getCompilerToVM().getLineNumberTable(this); + if (values == null) { + return null; + } assert values.length % 2 == 0; int[] bci = new int[values.length / 2]; int[] line = new int[values.length / 2]; @@ -422,6 +433,9 @@ @Override public LocalVariableTable getLocalVariableTable() { Local[] locals = graalRuntime().getCompilerToVM().getLocalVariableTable(this); + if (locals == null) { + return null; + } return new LocalVariableTableImpl(locals); }