X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=src%2Fvm%2Fexceptions.h;h=6d3e5241277a09f47f9c24f5066a19bb9a1d2e5d;hb=746ddc828bd7209ccbc267ff8a6f031c9bd44fec;hp=8bb3ab5f5f1b4834bf4bd47436d7b3f8b9949ad3;hpb=91714d080cfaa858b5ec45c005bd88f4a82346c3;p=cacao.git diff --git a/src/vm/exceptions.h b/src/vm/exceptions.h index 8bb3ab5f5..6d3e52412 100644 --- a/src/vm/exceptions.h +++ b/src/vm/exceptions.h @@ -1,9 +1,9 @@ -/* vm/exceptions.h - exception related functions prototypes +/* src/vm/exceptions.h - exception related functions prototypes - Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates, - R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner, - C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger, - Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, + C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, + E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, + J. Wenninger, Institut f. Computersprachen - TU Wien This file is part of CACAO. @@ -19,14 +19,10 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. - Contact: cacao@complang.tuwien.ac.at - - Authors: Christian Thalinger - - $Id: exceptions.h 2147 2005-03-30 16:47:35Z twisti $ + $Id: exceptions.h 8087 2007-06-14 16:01:12Z twisti $ */ @@ -34,133 +30,114 @@ #ifndef _EXCEPTIONS_H #define _EXCEPTIONS_H +/* forward typedefs ***********************************************************/ #include "config.h" +#include "vm/types.h" #include "vm/global.h" -#include "native/include/java_lang_String.h" -#include "native/include/java_lang_Throwable.h" -#include "vm/builtin.h" -#include "vm/class.h" - - -#if defined(USE_THREADS) && defined(NATIVE_THREADS) - -#define exceptionptr builtin_get_exceptionptrptr() -#define threadrootmethod builtin_get_threadrootmethod() - -#else /* defined(USE_THREADS) && defined(NATIVE_THREADS) */ -#define exceptionptr (&_exceptionptr) -#define threadrootmethod (&_threadrootmethod) +#include "vmcore/references.h" +#include "vmcore/method.h" -#endif /* defined(USE_THREADS) && defined(NATIVE_THREADS) */ -#if !defined(USE_THREADS) || !defined(NATIVE_THREADS) -extern java_objectheader *_exceptionptr; -extern methodinfo* _threadrootmethod; -#endif /* !defined(USE_THREADS) || !defined(NATIVE_THREADS) */ +/* hardware-exception defines ************************************************** + These defines define an internal number for the various hardware + exceptions. -/* global variables ***********************************************************/ + ATTENTION: These values are also used as load-displacements on some + architectures. Thus, these values must NOT be aligned to 4 or + 8-byte boundaries, since normal loads could have such offsets with + a base of NULL which should result in a NullPointerException. -/* exception/error super class */ + NOTE: In signal_init() we have a check whether the offset of + java_objectheader.data[0] is greater than the largest displacement + defined below. Otherwise normal array loads/stores could trigger + an exception. -extern const char *string_java_lang_Throwable; +*******************************************************************************/ +#define EXCEPTION_HARDWARE_NULLPOINTER 0 +#define EXCEPTION_HARDWARE_ARITHMETIC 1 +#define EXCEPTION_HARDWARE_ARRAYINDEXOUTOFBOUNDS 2 +#define EXCEPTION_HARDWARE_CLASSCAST 3 -/* specify some exception strings for code generation */ - -extern const char *string_java_lang_ArithmeticException; -extern const char *string_java_lang_ArithmeticException_message; -extern const char *string_java_lang_ArrayIndexOutOfBoundsException; -extern const char *string_java_lang_ArrayStoreException; -extern const char *string_java_lang_ClassCastException; -extern const char *string_java_lang_ClassNotFoundException; -extern const char *string_java_lang_CloneNotSupportedException; -extern const char *string_java_lang_Exception; -extern const char *string_java_lang_IllegalAccessException; -extern const char *string_java_lang_IllegalArgumentException; -extern const char *string_java_lang_IllegalMonitorStateException; -extern const char *string_java_lang_IndexOutOfBoundsException; -extern const char *string_java_lang_InstantiationException; -extern const char *string_java_lang_InterruptedException; -extern const char *string_java_lang_NegativeArraySizeException; -extern const char *string_java_lang_NoSuchFieldException; -extern const char *string_java_lang_NoSuchMethodException; -extern const char *string_java_lang_NullPointerException; - - -/* specify some error strings for code generation */ - -extern const char *string_java_lang_AbstractMethodError; -extern const char *string_java_lang_ClassCircularityError; -extern const char *string_java_lang_ClassFormatError; -extern const char *string_java_lang_Error; -extern const char *string_java_lang_ExceptionInInitializerError; -extern const char *string_java_lang_IncompatibleClassChangeError; -extern const char *string_java_lang_InternalError; -extern const char *string_java_lang_LinkageError; -extern const char *string_java_lang_NoClassDefFoundError; -extern const char *string_java_lang_NoSuchFieldError; -extern const char *string_java_lang_NoSuchMethodError; -extern const char *string_java_lang_OutOfMemoryError; -extern const char *string_java_lang_UnsupportedClassVersionError; -extern const char *string_java_lang_VerifyError; -extern const char *string_java_lang_VirtualMachineError; +#define EXCEPTION_HARDWARE_EXCEPTION 5 +#define EXCEPTION_HARDWARE_PATCHER 6 /* function prototypes ********************************************************/ -/* load and link exceptions used in the system */ - -bool exceptions_init(void); - +bool exceptions_init(void); -/* exception throwing functions */ - -void throw_exception(); -void throw_exception_exit(); - -void throw_main_exception(); -void throw_main_exception_exit(); - -void throw_cacao_exception_exit(const char *exception, const char *message, ...); - - -/* initialize new exceptions */ - -java_objectheader *new_exception(const char *classname); - -java_objectheader *new_exception_message(const char *classname, - const char *message); - -java_objectheader *new_exception_throwable(const char *classname, - java_lang_Throwable *cause); +java_objectheader *exceptions_get_exception(void); +void exceptions_set_exception(java_objectheader *o); +void exceptions_clear_exception(void); +java_objectheader *exceptions_get_and_clear_exception(void); java_objectheader *new_exception_utfmessage(const char *classname, utf *message); -java_objectheader *new_exception_javastring(const char *classname, - java_lang_String *message); - -java_objectheader *new_exception_int(const char *classname, s4 i); - /* functions to generate compiler exceptions */ -java_objectheader *new_classformaterror(classinfo *c, const char *message, ...); -java_objectheader *new_internalerror(const char *message, ...); -java_objectheader *new_verifyerror(methodinfo *m, const char *message); -java_objectheader *new_unsupportedclassversionerror(classinfo *c, - const char *message, ...); - -java_objectheader *new_arithmeticexception(); -java_objectheader *new_arrayindexoutofboundsexception(s4 index); -java_objectheader *new_arraystoreexception(); -java_objectheader *new_classcastexception(); -java_objectheader *new_negativearraysizeexception(); -java_objectheader *new_nullpointerexception(); +java_objectheader *exceptions_new_abstractmethoderror(void); +java_objectheader *exceptions_asm_new_abstractmethoderror(u1 *sp, u1 *ra); +java_objectheader *exceptions_new_arraystoreexception(void); + +void exceptions_throw_abstractmethoderror(void); +void exceptions_throw_classcircularityerror(classinfo *c); +void exceptions_throw_classformaterror(classinfo *c, const char *message, ...); +void exceptions_throw_classnotfoundexception(utf *name); +void exceptions_throw_noclassdeffounderror(utf *name); +void exceptions_throw_noclassdeffounderror_cause(java_objectheader *cause); +void exceptions_throw_noclassdeffounderror_wrong_name(classinfo *c, utf *name); +void exceptions_throw_linkageerror(const char *message, classinfo *c); +void exceptions_throw_nosuchfielderror(classinfo *c, utf *name); +void exceptions_throw_nosuchmethoderror(classinfo *c, utf *name, utf *desc); +void exceptions_throw_exceptionininitializererror(java_objectheader *cause); +void exceptions_throw_incompatibleclasschangeerror(classinfo *c, + const char *message); +void exceptions_throw_instantiationerror(classinfo *c); +void exceptions_throw_internalerror(const char *message, ...); +void exceptions_throw_outofmemoryerror(void); +void exceptions_throw_verifyerror(methodinfo *m, const char *message, ...); +void exceptions_throw_verifyerror_for_stack(methodinfo *m, int type); +void exceptions_throw_unsatisfiedlinkerror(utf *name); +void exceptions_throw_unsupportedclassversionerror(classinfo *c, u4 ma, u4 mi); + +java_objectheader *exceptions_new_arithmeticexception(void); + +java_objectheader *exceptions_new_arrayindexoutofboundsexception(s4 index); +void exceptions_throw_arrayindexoutofboundsexception(void); +void exceptions_throw_arraystoreexception(void); + +java_objectheader *exceptions_new_classcastexception(java_objectheader *o); + +void exceptions_throw_clonenotsupportedexception(void); +void exceptions_throw_illegalaccessexception(utf *message); +void exceptions_throw_illegalargumentexception(void); +void exceptions_throw_illegalmonitorstateexception(void); +void exceptions_throw_interruptedexception(void); +void exceptions_throw_instantiationexception(classinfo *c); +void exceptions_throw_invocationtargetexception(java_objectheader *cause); +void exceptions_throw_negativearraysizeexception(void); + +java_objectheader *exceptions_new_nullpointerexception(void); +void exceptions_throw_nullpointerexception(void); +void exceptions_throw_privilegedactionexception(java_objectheader *cause); +void exceptions_throw_stringindexoutofboundsexception(void); + +void exceptions_classnotfoundexception_to_noclassdeffounderror(void); + +java_objectheader *exceptions_fillinstacktrace(void); + +java_objectheader *exceptions_new_hardware_exception(u1 *pv, u1 *sp, u1 *ra, u1 *xpc, s4 type, ptrint val); + +void exceptions_print_exception(java_objectheader *xptr); +void exceptions_print_current_exception(void); +void exceptions_print_stacktrace(void); #endif /* _EXCEPTIONS_H */ @@ -176,4 +153,5 @@ java_objectheader *new_nullpointerexception(); * c-basic-offset: 4 * tab-width: 4 * End: + * vim:noexpandtab:sw=4:ts=4: */