changeset 2660:9f557e940180

Removed exception optimization that immediately unwinds if it is guaranteed that there is no local exception handler. Reason to remove the optimization: In case of a local exception handler that has been really executed, we need a type check on the exception object and a conditional jump from the throw anyway.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Wed, 11 May 2011 16:40:22 +0200
parents 40248577d587
children 194d93d089bd
files graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java graal/GraalCompiler/src/com/sun/c1x/lir/LIRAssembler.java graal/GraalCompiler/src/com/sun/c1x/lir/LIRList.java graal/GraalCompiler/src/com/sun/c1x/lir/LIROpcode.java graal/GraalCompiler/src/com/sun/c1x/target/amd64/AMD64LIRAssembler.java
diffstat 5 files changed, 6 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java	Wed May 11 16:25:15 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java	Wed May 11 16:40:22 2011 +0200
@@ -902,36 +902,12 @@
         CiValue exceptionOpr = load(x.exception());
         LIRDebugInfo info = stateFor(x, x.stateBefore());
 
-        // check if the instruction has an xhandler in any of the nested scopes
-        boolean unwind = false;
-        if (x.exceptionHandlers().size() == 0) {
-            // this throw is not inside an xhandler
-            unwind = true;
-        } else {
-            // get some idea of the throw type
-            boolean typeIsExact = true;
-            RiType throwType = x.exception().exactType();
-            if (throwType == null) {
-                typeIsExact = false;
-                throwType = x.exception().declaredType();
-            }
-            if (throwType != null && throwType.isResolved() && throwType.isInstanceClass()) {
-                unwind = !ExceptionHandler.couldCatch(x.exceptionHandlers(), throwType, typeIsExact);
-            }
-        }
-
-        assert !currentBlock.checkBlockFlag(BlockBegin.BlockFlag.DefaultExceptionHandler) || unwind : "should be no more handlers to dispatch to";
-
         // move exception oop into fixed register
         CiCallingConvention callingConvention = compilation.frameMap().getCallingConvention(new CiKind[]{CiKind.Object}, RuntimeCall);
         CiValue argumentOperand = callingConvention.locations[0];
         lir.move(exceptionOpr, argumentOperand);
 
-        if (unwind) {
-            lir.unwindException(CiValue.IllegalValue, exceptionOpr, info);
-        } else {
-            lir.throwException(CiValue.IllegalValue, argumentOperand, info);
-        }
+        lir.throwException(CiValue.IllegalValue, argumentOperand, info);
     }
 
     private void blockDoEpilog(BlockBegin block) {
--- a/graal/GraalCompiler/src/com/sun/c1x/lir/LIRAssembler.java	Wed May 11 16:25:15 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/lir/LIRAssembler.java	Wed May 11 16:40:22 2011 +0200
@@ -367,8 +367,7 @@
                 break;
 
             case Throw:
-            case Unwind:
-                emitThrow(op.operand1(), op.operand2(), op.info, op.code == LIROpcode.Unwind);
+                emitThrow(op.operand1(), op.operand2(), op.info);
                 break;
 
             default:
@@ -465,7 +464,7 @@
 
     protected abstract void emitVolatileMove(CiValue inOpr, CiValue result, CiKind kind, LIRDebugInfo info);
 
-    protected abstract void emitThrow(CiValue inOpr1, CiValue inOpr2, LIRDebugInfo info, boolean unwind);
+    protected abstract void emitThrow(CiValue inOpr1, CiValue inOpr2, LIRDebugInfo info);
 
     protected abstract void emitLogicOp(LIROpcode code, CiValue inOpr1, CiValue inOpr2, CiValue dst);
 
--- a/graal/GraalCompiler/src/com/sun/c1x/lir/LIRList.java	Wed May 11 16:25:15 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/lir/LIRList.java	Wed May 11 16:40:22 2011 +0200
@@ -193,10 +193,6 @@
         append(new LIROp2(LIROpcode.Throw, exceptionPC, exceptionOop, CiValue.IllegalValue, info, CiKind.Illegal, true));
     }
 
-    public void unwindException(CiValue exceptionPC, CiValue exceptionOop, LIRDebugInfo info) {
-        append(new LIROp2(LIROpcode.Unwind, exceptionPC, exceptionOop, CiValue.IllegalValue, info));
-    }
-
     public void compareTo(CiValue left, CiValue right, CiValue dst) {
         append(new LIROp2(LIROpcode.CompareTo, left, right, dst));
     }
--- a/graal/GraalCompiler/src/com/sun/c1x/lir/LIROpcode.java	Wed May 11 16:25:15 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/lir/LIROpcode.java	Wed May 11 16:40:22 2011 +0200
@@ -83,7 +83,6 @@
         Shr,
         Ushr,
         Throw,
-        Unwind,
         CompareTo,
     EndOp2,
     BeginOp3,
--- a/graal/GraalCompiler/src/com/sun/c1x/target/amd64/AMD64LIRAssembler.java	Wed May 11 16:25:15 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/target/amd64/AMD64LIRAssembler.java	Wed May 11 16:40:22 2011 +0200
@@ -1392,13 +1392,13 @@
     }
 
     @Override
-    protected void emitThrow(CiValue exceptionPC, CiValue exceptionOop, LIRDebugInfo info, boolean unwind) {
+    protected void emitThrow(CiValue exceptionPC, CiValue exceptionOop, LIRDebugInfo info) {
        // exception object is not added to oop map by LinearScan
        // (LinearScan assumes that no oops are in fixed registers)
        // info.addRegisterOop(exceptionOop);
-        masm.directCall(unwind ? CiRuntimeCall.UnwindException : CiRuntimeCall.HandleException, info);
+        masm.directCall(CiRuntimeCall.HandleException, info);
         // enough room for two byte trap
-        masm.nop();
+        masm.shouldNotReachHere();
     }
 
     private void emitXIRShiftOp(LIROpcode code, CiValue left, CiValue count, CiValue dest) {