changeset 6455:c4d21bd7653b

made position calculation for VMErrorNode more robust when debug info is not available
author Doug Simon <doug.simon@oracle.com>
date Thu, 27 Sep 2012 16:58:01 +0200
parents 5a2c5d93f5c8
children a20c8500770c
files graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/VMErrorNode.java
diffstat 2 files changed, 14 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java	Thu Sep 27 16:56:50 2012 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java	Thu Sep 27 16:58:01 2012 +0200
@@ -127,6 +127,10 @@
         return target;
     }
 
+    public ResolvedJavaMethod method() {
+        return method;
+    }
+
     /**
      * Returns the operand that has been previously initialized by {@link #setResult(ValueNode, Value)}
      * with the result of an instruction.
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/VMErrorNode.java	Thu Sep 27 16:56:50 2012 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/VMErrorNode.java	Thu Sep 27 16:58:01 2012 +0200
@@ -51,11 +51,17 @@
     @Override
     public void generate(LIRGenerator gen) {
         long vmErrorStub = HotSpotGraalRuntime.getInstance().getConfig().vmErrorStub;
-        LIRFrameState state = gen.state();
-        BytecodePosition pos = state.topFrame;
-        String where = CodeUtil.append(new StringBuilder(100), pos).toString();
+        String where;
+        try {
+            LIRFrameState state = gen.state();
+            BytecodePosition pos = state.topFrame;
+            where = "near or " + CodeUtil.append(new StringBuilder(100), pos).toString().replace(CodeUtil.NEW_LINE, CodeUtil.NEW_LINE + "\t");
+        } catch (Throwable t) {
+            // Report a less accurate location when debug info cannot be obtained
+            where = "in compiled code for " + MetaUtil.format("%H.%n(%p)", gen.method());
+        }
         Kind[] signature = new Kind[] {Kind.Object, Kind.Object, Kind.Long};
-        gen.emitCall(vmErrorStub, Kind.Void, signature, true, Constant.forObject(where), gen.operand(format), gen.operand(value));
+        gen.emitCall(vmErrorStub, Kind.Void, signature, false, Constant.forObject(where), gen.operand(format), gen.operand(value));
     }
 
     @SuppressWarnings("unused")