* src/vm/class.c [ENABLE_JAVASE] (arrayclass_java_lang_Object): Added
[cacao.git] / src / vm / exceptions.h
index 29279bcfeee3e6e2e4d03dd0e2ef1bfb72d1beae..2996d7105a2c5e617ed73e0abd9a6857365e1800 100644 (file)
    Contact: cacao@cacaojvm.org
 
    Authors: Christian Thalinger
+            Edwin Steiner
 
-   Changes: Edwin Steiner
-
-   $Id: exceptions.h 4357 2006-01-22 23:33:38Z twisti $
+   $Id: exceptions.h 6251 2006-12-27 23:15:56Z twisti $
 
 */
 
 
 /* forward typedefs ***********************************************************/
 
-typedef struct exceptionentry exceptionentry;
-
 #include "config.h"
 #include "vm/types.h"
 
 #include "vm/global.h"
+#include "native/jni.h"
 #include "native/include/java_lang_String.h"
 #include "native/include/java_lang_Throwable.h"
 #include "vm/builtin.h"
@@ -51,30 +49,36 @@ typedef struct exceptionentry exceptionentry;
 #include "vm/method.h"
 
 
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
-#define exceptionptr    builtin_get_exceptionptrptr()
-#else
-#define exceptionptr    &_no_threads_exceptionptr
-#endif
+/* hardware-exception defines **************************************************
 
-#if !defined(USE_THREADS) || !defined(NATIVE_THREADS)
-extern java_objectheader *_no_threads_exceptionptr;
-#endif
+   These defines define the load-offset which indicates the given
+   exception.
 
+   ATTENTION: These offsets need NOT to 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.
 
-/* exceptionentry **************************************************************
+*******************************************************************************/
 
-   Datastructure which represents an exception entry in the exception
-   table residing in the data segment.
+#define EXCEPTION_LOAD_DISP_NULLPOINTER              0
+#define EXCEPTION_LOAD_DISP_ARITHMETIC               1
+#define EXCEPTION_LOAD_DISP_ARRAYINDEXOUTOFBOUNDS    2
+#define EXCEPTION_LOAD_DISP_CLASSCAST                3
 
-*******************************************************************************/
+#define EXCEPTION_LOAD_DISP_PATCHER                  5
 
-struct exceptionentry {
-       classref_or_classinfo  catchtype;
-       u1                    *handlerpc;
-       u1                    *endpc;
-       u1                    *startpc;
-};
+
+/* exception pointer **********************************************************/
+
+#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
 
 
 /* function prototypes ********************************************************/
@@ -118,16 +122,37 @@ java_objectheader *new_exception_int(const char *classname, s4 i);
 
 /* functions to generate compiler exceptions */
 
+#if defined(ENABLE_JAVASE)
+java_objectheader *exceptions_new_abstractmethoderror(void);
+void               exceptions_throw_abstractmethoderror(void);
+#endif
+
+java_objectheader *exceptions_asm_new_abstractmethoderror(u1 *sp, u1 *ra);
+
 java_objectheader *new_classformaterror(classinfo *c, const char *message, ...);
 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);
+
+#if defined(ENABLE_JAVASE)
 java_objectheader *exceptions_new_nosuchmethoderror(classinfo *c,
                                                                                                        utf *name, utf *desc);
+void exceptions_throw_nosuchmethoderror(classinfo *c, utf *name, utf *desc);
+#endif
+
 java_objectheader *new_internalerror(const char *message, ...);
-java_objectheader *new_verifyerror(methodinfo *m, const char *message, ...);
+void exceptions_throw_internalerror(const char *message, ...);
+
+java_objectheader *exceptions_new_verifyerror(methodinfo *m,
+                                                                                         const char *message, ...);
+void exceptions_throw_verifyerror(methodinfo *m, const char *message, ...);
+void exceptions_throw_verifyerror_for_stack(methodinfo *m, int type);
+
+java_objectheader *exceptions_new_virtualmachineerror(void);
+void               exceptions_throw_virtualmachineerror(void);
+
 java_objectheader *new_unsupportedclassversionerror(classinfo *c,
                                                                                                        const char *message, ...);
 
@@ -136,22 +161,30 @@ java_objectheader *new_arithmeticexception(void);
 java_objectheader *new_arrayindexoutofboundsexception(s4 index);
 void exceptions_throw_arrayindexoutofboundsexception(void);
 
-java_objectheader *new_arraystoreexception(void);
-java_objectheader *new_classcastexception(void);
+java_objectheader *exceptions_new_arraystoreexception(void);
+void exceptions_throw_arraystoreexception(void);
+
+java_objectheader *exceptions_new_classcastexception(java_objectheader *o);
 
 java_objectheader *new_illegalargumentexception(void);
 void exceptions_throw_illegalargumentexception(void);
 
-java_objectheader *new_illegalmonitorstateexception(void);
+java_objectheader *exceptions_new_illegalmonitorstateexception(void);
+void               exceptions_throw_illegalmonitorstateexception(void);
 
 java_objectheader *new_negativearraysizeexception(void);
 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);
+
 void classnotfoundexception_to_noclassdeffounderror(void);
 
+java_objectheader *exceptions_get_and_clear_exception(void);
+
 void exceptions_print_exception(java_objectheader *xptr);
 
 #endif /* _EXCEPTIONS_H */
@@ -168,4 +201,5 @@ void exceptions_print_exception(java_objectheader *xptr);
  * c-basic-offset: 4
  * tab-width: 4
  * End:
+ * vim:noexpandtab:sw=4:ts=4:
  */