changeset 2662:440ceca8e3d7

Add exception handlers only to Invoke and Throw instructions. Deoptimize if there is an exception in a HotSpot runtime call.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Wed, 11 May 2011 18:16:01 +0200
parents 194d93d089bd
children d7c0775d7e72 405e7947a940
files graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java graal/GraalCompiler/src/com/sun/c1x/ir/ArithmeticOp.java graal/GraalCompiler/src/com/sun/c1x/ir/NewArray.java graal/GraalCompiler/src/com/sun/c1x/ir/NewInstance.java graal/GraalCompiler/src/com/sun/c1x/ir/NullCheck.java graal/GraalCompiler/src/com/sun/c1x/ir/StateSplit.java graal/GraalCompiler/src/com/sun/c1x/ir/Throw.java graal/GraalCompiler/src/com/sun/c1x/ir/Value.java src/cpu/x86/vm/c1_Runtime1_x86.cpp
diffstat 9 files changed, 8 insertions(+), 58 deletions(-) [+]
line wrap: on
line diff
--- a/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java	Wed May 11 17:18:31 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java	Wed May 11 18:16:01 2011 +0200
@@ -943,7 +943,7 @@
             throw new CiBailout("Method and/or inlining is too large");
         }
 
-        if (x.canTrap()) {
+        if (x instanceof Invoke || x instanceof Throw) {
             // connect the instruction to any exception handlers
             x.setExceptionHandlers(handleException(x, bci));
         }
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/ArithmeticOp.java	Wed May 11 17:18:31 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/ArithmeticOp.java	Wed May 11 18:16:01 2011 +0200
@@ -61,16 +61,6 @@
         return isStrictFP;
     }
 
-    /**
-     * Checks whether this instruction can cause a trap. For arithmetic operations,
-     * only division and remainder operations can cause traps.
-     * @return {@code true} if this instruction can cause a trap
-     */
-    @Override
-    public boolean canTrap() {
-        return canTrap;
-    }
-
     @Override
     public void accept(ValueVisitor v) {
         v.visitArithmeticOp(this);
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/NewArray.java	Wed May 11 17:18:31 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/NewArray.java	Wed May 11 18:16:01 2011 +0200
@@ -71,11 +71,6 @@
     }
 
     @Override
-    public boolean canTrap() {
-        return true;
-    }
-
-    @Override
     public boolean needsStateAfter() {
         return false;
     }
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/NewInstance.java	Wed May 11 17:18:31 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/NewInstance.java	Wed May 11 18:16:01 2011 +0200
@@ -73,11 +73,6 @@
     }
 
     @Override
-    public boolean canTrap() {
-        return true;
-    }
-
-    @Override
     public void accept(ValueVisitor v) {
         v.visitNewInstance(this);
     }
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/NullCheck.java	Wed May 11 17:18:31 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/NullCheck.java	Wed May 11 18:16:01 2011 +0200
@@ -105,8 +105,5 @@
     @Override
     public void print(LogStream out) {
         out.print("null_check(").print(object()).print(')');
-        if (!canTrap()) {
-          out.print(" (eliminated)");
-        }
     }
 }
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/StateSplit.java	Wed May 11 17:18:31 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/StateSplit.java	Wed May 11 18:16:01 2011 +0200
@@ -86,11 +86,6 @@
         super(kind, inputCount + INPUT_COUNT, successorCount + SUCCESSOR_COUNT, graph);
     }
 
-    @Override
-    public boolean canTrap() {
-        return true;
-    }
-
     public boolean needsStateAfter() {
         return true;
     }
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/Throw.java	Wed May 11 17:18:31 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Throw.java	Wed May 11 18:16:01 2011 +0200
@@ -82,15 +82,6 @@
         setException(exception);
     }
 
-    /**
-     * Checks whether this instruction can trap.
-     * @return {@code true} because this instruction definitely throws an exception!
-     */
-    @Override
-    public boolean canTrap() {
-        return true;
-    }
-
     @Override
     public void accept(ValueVisitor v) {
         v.visitThrow(this);
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/Value.java	Wed May 11 17:18:31 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Value.java	Wed May 11 18:16:01 2011 +0200
@@ -181,17 +181,6 @@
     }
 
     /**
-     * Tests whether this instruction can trap. This is conservative; it does not take
-     * into account analysis results that may eliminate the possibility of this
-     * instruction from trapping.
-     *
-     * @return {@code true} if this instruction can cause a trap.
-     */
-    public boolean canTrap() {
-        return false;
-    }
-
-    /**
      * Checks whether this value represents the null constant.
      * @return {@code true} if this value represents the null constant
      */
--- a/src/cpu/x86/vm/c1_Runtime1_x86.cpp	Wed May 11 17:18:31 2011 +0200
+++ b/src/cpu/x86/vm/c1_Runtime1_x86.cpp	Wed May 11 18:16:01 2011 +0200
@@ -38,6 +38,7 @@
 #include "runtime/vframeArray.hpp"
 #include "vmreg_x86.inline.hpp"
 
+static void restore_live_registers(StubAssembler* sasm, bool restore_fpu_registers = true);
 
 // Implementation of StubAssembler
 
@@ -96,14 +97,11 @@
     if (oop_result2->is_valid()) {
       movptr(Address(thread, JavaThread::vm_result_2_offset()), NULL_WORD);
     }
-    if (frame_size() == no_frame_size) {
-      leave();
-      jump(RuntimeAddress(StubRoutines::forward_exception_entry()));
-    } else if (_stub_id == Runtime1::forward_exception_id) {
-      should_not_reach_here();
-    } else {
-      jump(RuntimeAddress(Runtime1::entry_for(Runtime1::forward_exception_id)));
-    }
+    // (tw) Deoptimize in case of an exception.
+    restore_live_registers(this, false);
+    movptr(Address(thread, Thread::pending_exception_offset()), NULL_WORD);
+    leave();
+    jump(RuntimeAddress(SharedRuntime::deopt_blob()->uncommon_trap()));
     bind(L);
   }
   // get oop results if there are any and reset the values in the thread
@@ -539,7 +537,7 @@
 }
 
 
-static void restore_live_registers(StubAssembler* sasm, bool restore_fpu_registers = true) {
+static void restore_live_registers(StubAssembler* sasm, bool restore_fpu_registers/* = true*/) {
   __ block_comment("restore_live_registers");
 
   restore_fpu(sasm, restore_fpu_registers);