# HG changeset patch # User Thomas Wuerthinger # Date 1305130561 -7200 # Node ID 440ceca8e3d712b387f1d52fbecf4ac0305c8592 # Parent 194d93d089bd68c7da128f6db067c9676f951fd6 Add exception handlers only to Invoke and Throw instructions. Deoptimize if there is an exception in a HotSpot runtime call. diff -r 194d93d089bd -r 440ceca8e3d7 graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java --- 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)); } diff -r 194d93d089bd -r 440ceca8e3d7 graal/GraalCompiler/src/com/sun/c1x/ir/ArithmeticOp.java --- 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); diff -r 194d93d089bd -r 440ceca8e3d7 graal/GraalCompiler/src/com/sun/c1x/ir/NewArray.java --- 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; } diff -r 194d93d089bd -r 440ceca8e3d7 graal/GraalCompiler/src/com/sun/c1x/ir/NewInstance.java --- 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); } diff -r 194d93d089bd -r 440ceca8e3d7 graal/GraalCompiler/src/com/sun/c1x/ir/NullCheck.java --- 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)"); - } } } diff -r 194d93d089bd -r 440ceca8e3d7 graal/GraalCompiler/src/com/sun/c1x/ir/StateSplit.java --- 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; } diff -r 194d93d089bd -r 440ceca8e3d7 graal/GraalCompiler/src/com/sun/c1x/ir/Throw.java --- 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); diff -r 194d93d089bd -r 440ceca8e3d7 graal/GraalCompiler/src/com/sun/c1x/ir/Value.java --- 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 */ diff -r 194d93d089bd -r 440ceca8e3d7 src/cpu/x86/vm/c1_Runtime1_x86.cpp --- 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);