# HG changeset patch # User Thomas Wuerthinger # Date 1371995341 -7200 # Node ID 40b8c383bc31b1054e163265d9f766d64d2b89c2 # Parent dd3333e4f182b03641bdb4ba99634f5d782a240d Throw InvalidInstalledCodeException directly in the stubs. diff -r dd3333e4f182 -r 40b8c383bc31 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotNmethod.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotNmethod.java Sun Jun 23 15:27:39 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotNmethod.java Sun Jun 23 15:49:01 2013 +0200 @@ -87,11 +87,7 @@ assert method.getSignature().getParameterKind(0) == Kind.Object; assert method.getSignature().getParameterKind(1) == Kind.Object; assert !Modifier.isStatic(method.getModifiers()) || method.getSignature().getParameterKind(2) == Kind.Object; - Object result = graalRuntime().getCompilerToVM().executeCompiledMethod(arg1, arg2, arg3, this); - if (isValid()) { - return result; - } - throw new InvalidInstalledCodeException(); + return graalRuntime().getCompilerToVM().executeCompiledMethod(arg1, arg2, arg3, this); } private boolean checkArgs(Object... args) { @@ -111,11 +107,7 @@ @Override public Object executeVarargs(Object... args) throws InvalidInstalledCodeException { assert checkArgs(args); - Object result = graalRuntime().getCompilerToVM().executeCompiledMethodVarargs(args, this); - if (isValid()) { - return result; - } - throw new InvalidInstalledCodeException(); + return graalRuntime().getCompilerToVM().executeCompiledMethodVarargs(args, this); } @Override diff -r dd3333e4f182 -r 40b8c383bc31 src/cpu/sparc/vm/stubGenerator_sparc.cpp --- a/src/cpu/sparc/vm/stubGenerator_sparc.cpp Sun Jun 23 15:27:39 2013 +0200 +++ b/src/cpu/sparc/vm/stubGenerator_sparc.cpp Sun Jun 23 15:49:01 2013 +0200 @@ -3412,6 +3412,7 @@ // These entry points require SharedInfo::stack0 to be set up in non-core builds StubRoutines::_throw_AbstractMethodError_entry = generate_throw_exception("AbstractMethodError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_AbstractMethodError)); StubRoutines::_throw_IncompatibleClassChangeError_entry= generate_throw_exception("IncompatibleClassChangeError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_IncompatibleClassChangeError)); + StubRoutines::_throw_InvalidInstalledCodeException_entry= generate_throw_exception("InvalidInstalledCodeException throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_InvalidInstalledCodeException)); StubRoutines::_throw_NullPointerException_at_call_entry= generate_throw_exception("NullPointerException at call throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_NullPointerException_at_call)); StubRoutines::_handler_for_unsafe_access_entry = diff -r dd3333e4f182 -r 40b8c383bc31 src/cpu/x86/vm/sharedRuntime_x86_64.cpp --- a/src/cpu/x86/vm/sharedRuntime_x86_64.cpp Sun Jun 23 15:27:39 2013 +0200 +++ b/src/cpu/x86/vm/sharedRuntime_x86_64.cpp Sun Jun 23 15:49:01 2013 +0200 @@ -1691,8 +1691,8 @@ __ jmp(Address(j_rarg3, nmethod::verified_entry_point_offset())); __ bind(invalid_nmethod); - __ xorq(rax, rax); - __ ret(0); + + __ jump(RuntimeAddress(StubRoutines::throw_InvalidInstalledCodeException_entry())); return; } #endif diff -r dd3333e4f182 -r 40b8c383bc31 src/cpu/x86/vm/stubGenerator_x86_32.cpp --- a/src/cpu/x86/vm/stubGenerator_x86_32.cpp Sun Jun 23 15:27:39 2013 +0200 +++ b/src/cpu/x86/vm/stubGenerator_x86_32.cpp Sun Jun 23 15:49:01 2013 +0200 @@ -2897,6 +2897,7 @@ // and need to be relocatable, so they each fabricate a RuntimeStub internally. StubRoutines::_throw_AbstractMethodError_entry = generate_throw_exception("AbstractMethodError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_AbstractMethodError)); StubRoutines::_throw_IncompatibleClassChangeError_entry= generate_throw_exception("IncompatibleClassChangeError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_IncompatibleClassChangeError)); + StubRoutines::_throw_InvalidInstalledCodeException_entry = generate_throw_exception("InvalidInstalledCodeException throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_InvalidInstalledCodeException)); StubRoutines::_throw_NullPointerException_at_call_entry= generate_throw_exception("NullPointerException at call throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_NullPointerException_at_call)); //------------------------------------------------------------------------------------------------------------------------ diff -r dd3333e4f182 -r 40b8c383bc31 src/cpu/x86/vm/stubGenerator_x86_64.cpp --- a/src/cpu/x86/vm/stubGenerator_x86_64.cpp Sun Jun 23 15:27:39 2013 +0200 +++ b/src/cpu/x86/vm/stubGenerator_x86_64.cpp Sun Jun 23 15:49:01 2013 +0200 @@ -3756,6 +3756,12 @@ SharedRuntime:: throw_IncompatibleClassChangeError)); + StubRoutines::_throw_InvalidInstalledCodeException_entry = + generate_throw_exception("InvalidInstalledCodeException throw_exception", + CAST_FROM_FN_PTR(address, + SharedRuntime:: + throw_InvalidInstalledCodeException)); + StubRoutines::_throw_NullPointerException_at_call_entry = generate_throw_exception("NullPointerException at call throw_exception", CAST_FROM_FN_PTR(address, diff -r dd3333e4f182 -r 40b8c383bc31 src/cpu/x86/vm/templateInterpreter_x86_64.cpp --- a/src/cpu/x86/vm/templateInterpreter_x86_64.cpp Sun Jun 23 15:27:39 2013 +0200 +++ b/src/cpu/x86/vm/templateInterpreter_x86_64.cpp Sun Jun 23 15:49:01 2013 +0200 @@ -934,8 +934,10 @@ __ jmp(Address(j_rarg3, nmethod::verified_entry_point_offset())); __ bind(invalid_nmethod); - __ xorq(rax, rax); - __ ret(0); + + __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_InvalidInstalledCodeException)); + // the call_VM checks for exception, so we should never return here. + __ should_not_reach_here(); return entry_point; } diff -r dd3333e4f182 -r 40b8c383bc31 src/share/vm/interpreter/interpreterRuntime.cpp --- a/src/share/vm/interpreter/interpreterRuntime.cpp Sun Jun 23 15:27:39 2013 +0200 +++ b/src/share/vm/interpreter/interpreterRuntime.cpp Sun Jun 23 15:49:01 2013 +0200 @@ -501,6 +501,10 @@ IRT_END +IRT_ENTRY(void, InterpreterRuntime::throw_InvalidInstalledCodeException(JavaThread* thread)) + THROW(vmSymbols::com_oracle_graal_api_code_InvalidInstalledCodeException()); +IRT_END + //------------------------------------------------------------------------------------------------------------------------ // Fields // diff -r dd3333e4f182 -r 40b8c383bc31 src/share/vm/interpreter/interpreterRuntime.hpp --- a/src/share/vm/interpreter/interpreterRuntime.hpp Sun Jun 23 15:27:39 2013 +0200 +++ b/src/share/vm/interpreter/interpreterRuntime.hpp Sun Jun 23 15:49:01 2013 +0200 @@ -89,6 +89,7 @@ // Exceptions thrown by the interpreter static void throw_AbstractMethodError(JavaThread* thread); static void throw_IncompatibleClassChangeError(JavaThread* thread); + static void throw_InvalidInstalledCodeException(JavaThread* thread); static void throw_StackOverflowError(JavaThread* thread); static void throw_ArrayIndexOutOfBoundsException(JavaThread* thread, char* name, jint index); static void throw_ClassCastException(JavaThread* thread, oopDesc* obj); diff -r dd3333e4f182 -r 40b8c383bc31 src/share/vm/runtime/sharedRuntime.cpp --- a/src/share/vm/runtime/sharedRuntime.cpp Sun Jun 23 15:27:39 2013 +0200 +++ b/src/share/vm/runtime/sharedRuntime.cpp Sun Jun 23 15:49:01 2013 +0200 @@ -752,6 +752,11 @@ throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_IncompatibleClassChangeError(), "vtable stub"); JRT_END +JRT_ENTRY(void, SharedRuntime::throw_InvalidInstalledCodeException(JavaThread* thread)) + // These errors occur only at call sites + throw_and_post_jvmti_exception(thread, vmSymbols::com_oracle_graal_api_code_InvalidInstalledCodeException()); +JRT_END + JRT_ENTRY(void, SharedRuntime::throw_ArithmeticException(JavaThread* thread)) throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_ArithmeticException(), "/ by zero"); JRT_END diff -r dd3333e4f182 -r 40b8c383bc31 src/share/vm/runtime/sharedRuntime.hpp --- a/src/share/vm/runtime/sharedRuntime.hpp Sun Jun 23 15:27:39 2013 +0200 +++ b/src/share/vm/runtime/sharedRuntime.hpp Sun Jun 23 15:49:01 2013 +0200 @@ -186,6 +186,7 @@ }; static void throw_AbstractMethodError(JavaThread* thread); static void throw_IncompatibleClassChangeError(JavaThread* thread); + static void throw_InvalidInstalledCodeException(JavaThread* thread); static void throw_ArithmeticException(JavaThread* thread); static void throw_NullPointerException(JavaThread* thread); static void throw_NullPointerException_at_call(JavaThread* thread); diff -r dd3333e4f182 -r 40b8c383bc31 src/share/vm/runtime/stubRoutines.cpp --- a/src/share/vm/runtime/stubRoutines.cpp Sun Jun 23 15:27:39 2013 +0200 +++ b/src/share/vm/runtime/stubRoutines.cpp Sun Jun 23 15:49:01 2013 +0200 @@ -51,6 +51,7 @@ address StubRoutines::_forward_exception_entry = NULL; address StubRoutines::_throw_AbstractMethodError_entry = NULL; address StubRoutines::_throw_IncompatibleClassChangeError_entry = NULL; +address StubRoutines::_throw_InvalidInstalledCodeException_entry = NULL; address StubRoutines::_throw_NullPointerException_at_call_entry = NULL; address StubRoutines::_throw_StackOverflowError_entry = NULL; address StubRoutines::_handler_for_unsafe_access_entry = NULL; diff -r dd3333e4f182 -r 40b8c383bc31 src/share/vm/runtime/stubRoutines.hpp --- a/src/share/vm/runtime/stubRoutines.hpp Sun Jun 23 15:27:39 2013 +0200 +++ b/src/share/vm/runtime/stubRoutines.hpp Sun Jun 23 15:49:01 2013 +0200 @@ -128,6 +128,7 @@ static address _catch_exception_entry; static address _throw_AbstractMethodError_entry; static address _throw_IncompatibleClassChangeError_entry; + static address _throw_InvalidInstalledCodeException_entry; static address _throw_NullPointerException_at_call_entry; static address _throw_StackOverflowError_entry; static address _handler_for_unsafe_access_entry; @@ -261,6 +262,7 @@ // Implicit exceptions static address throw_AbstractMethodError_entry() { return _throw_AbstractMethodError_entry; } static address throw_IncompatibleClassChangeError_entry(){ return _throw_IncompatibleClassChangeError_entry; } + static address throw_InvalidInstalledCodeException_entry(){ return _throw_InvalidInstalledCodeException_entry; } static address throw_NullPointerException_at_call_entry(){ return _throw_NullPointerException_at_call_entry; } static address throw_StackOverflowError_entry() { return _throw_StackOverflowError_entry; }