* Merged in twisti-branch.
[cacao.git] / src / vm / exceptions.h
index 1a9ba062c5673841bef3dfb06bc59495bb2ece9a..1c48b98e15c7ad2f802c07f7870f95b6a6929c13 100644 (file)
@@ -1,6 +1,6 @@
 /* src/vm/exceptions.h - exception related functions prototypes
 
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   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
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Christian Thalinger
-
-   Changes: Edwin Steiner
-
-   $Id: exceptions.h 5166 2006-07-21 10:09:33Z twisti $
+   $Id: exceptions.h 7596 2007-03-28 21:05:53Z twisti $
 
 */
 
 
 /* forward typedefs ***********************************************************/
 
-typedef struct exceptionentry exceptionentry;
-
 #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/references.h"
-#include "vm/method.h"
 
+#include "vmcore/references.h"
+#include "vmcore/method.h"
 
-#if defined(ENABLE_THREADS)
-#define exceptionptr    &(THREADOBJECT->_exceptionptr)
-#else
-#define exceptionptr    &_no_threads_exceptionptr
-#endif
-
-#if !defined(ENABLE_THREADS)
-extern java_objectheader *_no_threads_exceptionptr;
-#endif
 
+/* hardware-exception defines **************************************************
 
-/* exceptionentry **************************************************************
+   These defines define an internal number for the various hardware
+   exceptions.
 
-   Datastructure which represents an exception entry in the exception
-   table residing in the data segment.
+   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.
 
 *******************************************************************************/
 
-struct exceptionentry {
-       classref_or_classinfo  catchtype;
-       u1                    *handlerpc;
-       u1                    *endpc;
-       u1                    *startpc;
-};
-
+#define EXCEPTION_HARDWARE_NULLPOINTER              0
+#define EXCEPTION_HARDWARE_ARITHMETIC               1
+#define EXCEPTION_HARDWARE_ARRAYINDEXOUTOFBOUNDS    2
+#define EXCEPTION_HARDWARE_CLASSCAST                3
 
-/* function prototypes ********************************************************/
+#define EXCEPTION_HARDWARE_EXCEPTION                5
 
-/* load and link exceptions used in the system */
-bool exceptions_init(void);
+#define EXCEPTION_HARDWARE_PATCHER                  6
 
 
-/* exception throwing functions */
+/* exception pointer **********************************************************/
 
-void throw_exception(void);
-void throw_exception_exit(void);
+#if defined(ENABLE_THREADS)
+#define exceptionptr    &(THREADOBJECT->_exceptionptr)
+#else
+#define exceptionptr    &_no_threads_exceptionptr
+#endif
 
-void throw_main_exception(void);
-void throw_main_exception_exit(void);
+#if !defined(ENABLE_THREADS)
+extern java_objectheader *_no_threads_exceptionptr;
+#endif
 
-void throw_cacao_exception_exit(const char *exception,
-                                                               const char *message, ...);
 
-void exceptions_throw_outofmemory_exit(void);
+/* function prototypes ********************************************************/
 
+/* load and link exceptions used in the system */
+bool exceptions_init(void);
 
 /* 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 *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);
 
 
@@ -120,55 +93,63 @@ java_objectheader *new_exception_int(const char *classname, s4 i);
 
 java_objectheader *exceptions_new_abstractmethoderror(void);
 java_objectheader *exceptions_asm_new_abstractmethoderror(u1 *sp, u1 *ra);
-void exceptions_throw_abstractmethoderror(void);
+java_objectheader *exceptions_new_arraystoreexception(void);
 
-java_objectheader *new_classformaterror(classinfo *c, const char *message, ...);
+void exceptions_throw_abstractmethoderror(void);
+void exceptions_throw_classcircularityerror(classinfo *c);
 void exceptions_throw_classformaterror(classinfo *c, const char *message, ...);
-
-java_objectheader *new_classnotfoundexception(utf *name);
-java_objectheader *new_noclassdeffounderror(utf *name);
-java_objectheader *exceptions_new_linkageerror(const char *message,classinfo *c);
-java_objectheader *exceptions_new_nosuchmethoderror(classinfo *c,
-                                                                                                       utf *name, utf *desc);
+void exceptions_throw_classnotfoundexception(utf *name);
+void exceptions_throw_noclassdeffounderror(utf *name);
+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);
-
-java_objectheader *new_internalerror(const char *message, ...);
-
-java_objectheader *exceptions_new_verifyerror(methodinfo *m,
-                                                                                         const char *message, ...);
+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 *new_unsupportedclassversionerror(classinfo *c,
-                                                                                                       const char *message, ...);
-
-java_objectheader *new_arithmeticexception(void);
+java_objectheader *exceptions_new_arithmeticexception(void);
 
-java_objectheader *new_arrayindexoutofboundsexception(s4 index);
+java_objectheader *exceptions_new_arrayindexoutofboundsexception(s4 index);
 void exceptions_throw_arrayindexoutofboundsexception(void);
+void exceptions_throw_arraystoreexception(void);
 
-java_objectheader *new_arraystoreexception(void);
 java_objectheader *exceptions_new_classcastexception(java_objectheader *o);
 
-java_objectheader *new_illegalargumentexception(void);
+void exceptions_throw_clonenotsupportedexception(void);
+void exceptions_throw_illegalaccessexception(classinfo *c);
 void exceptions_throw_illegalargumentexception(void);
-
-java_objectheader *new_illegalmonitorstateexception(void);
-
-java_objectheader *new_negativearraysizeexception(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 *new_nullpointerexception(void);
+java_objectheader *exceptions_new_nullpointerexception(void);
 void exceptions_throw_nullpointerexception(void);
-
-java_objectheader *exceptions_new_stringindexoutofboundsexception(void);
 void exceptions_throw_stringindexoutofboundsexception(void);
 
+java_objectheader *exceptions_fillinstacktrace(void);
+
 void classnotfoundexception_to_noclassdeffounderror(void);
 
+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 *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 */