* Removed all Id tags.
[cacao.git] / src / vm / exceptions.h
index c30d0f4900970edd563cdcac6225871e0f92aa81..6c60a2793bf49f3fde324ba492a396f86f6b0b0c 100644 (file)
@@ -1,9 +1,9 @@
-/* exceptions.h - exception related functions prototypes
+/* src/vm/exceptions.h - exception related functions prototypes
 
-   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
-   R. Grafl, A. Krall, C. Kruegel, C. Oates, R. Obermaisser,
-   M. Probst, S. Ring, E. Steiner, C. Thalinger, D. Thuernbeck,
-   P. Tomsich, J. Wenninger
+   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.
 
 
    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.
-
-   Contact: cacao@complang.tuwien.ac.at
-
-   Authors: Christian Thalinger
-
-   $Id: exceptions.h 1410 2004-08-17 13:01:24Z twisti $
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
 
 */
 
 #ifndef _EXCEPTIONS_H
 #define _EXCEPTIONS_H
 
+/* forward typedefs ***********************************************************/
 
-#include "global.h"
-#include "nat/java_lang_String.h"
-#include "nat/java_lang_Throwable.h"
-
-
-/* system exception classes required in cacao */
-
-extern classinfo *class_java_lang_Throwable;
-extern classinfo *class_java_lang_Exception;
-extern classinfo *class_java_lang_Error;
-extern classinfo *class_java_lang_OutOfMemoryError;
+#include "config.h"
+#include "vm/types.h"
 
+#include "vm/global.h"
 
-/* exception/error super class */
+#include "vm/jit/stacktrace.h"
 
-extern char *string_java_lang_Throwable;
+#include "vmcore/references.h"
+#include "vmcore/method.h"
 
 
-/* specify some exception strings for code generation */
+/* hardware-exception defines **************************************************
 
-extern char *string_java_lang_ArithmeticException;
-extern char *string_java_lang_ArithmeticException_message;
-extern char *string_java_lang_ArrayIndexOutOfBoundsException;
-extern char *string_java_lang_ArrayStoreException;
-extern char *string_java_lang_ClassCastException;
-extern char *string_java_lang_ClassNotFoundException;
-extern char *string_java_lang_CloneNotSupportedException;
-extern char *string_java_lang_Exception;
-extern char *string_java_lang_IllegalArgumentException;
-extern char *string_java_lang_IllegalMonitorStateException;
-extern char *string_java_lang_IndexOutOfBoundsException;
-extern char *string_java_lang_InterruptedException;
-extern char *string_java_lang_NegativeArraySizeException;
-extern char *string_java_lang_NoSuchFieldException;
-extern char *string_java_lang_NoSuchMethodException;
-extern char *string_java_lang_NullPointerException;
+   These defines define an internal number for the various hardware
+   exceptions.
 
+   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.
 
-/* specify some error strings for code generation */
+   NOTE: In exceptions_init() we have a check whether the offset of
+   java_arrayheader.data[0] is greater than the largest displacement
+   defined below.  Otherwise normal array loads/stores could trigger
+   an exception.
 
-extern char *string_java_lang_AbstractMethodError;
-extern char *string_java_lang_ClassCircularityError;
-extern char *string_java_lang_ClassFormatError;
-extern char *string_java_lang_Error;
-extern char *string_java_lang_ExceptionInInitializerError;
-extern char *string_java_lang_IncompatibleClassChangeError;
-extern char *string_java_lang_InternalError;
-extern char *string_java_lang_LinkageError;
-extern char *string_java_lang_NoClassDefFoundError;
-extern char *string_java_lang_NoSuchFieldError;
-extern char *string_java_lang_NoSuchMethodError;
-extern char *string_java_lang_OutOfMemoryError;
-extern char *string_java_lang_UnsupportedClassVersionError;
-extern char *string_java_lang_VerifyError;
-extern char *string_java_lang_VirtualMachineError;
+*******************************************************************************/
 
+#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
+#define EXCEPTION_HARDWARE_PATCHER                  6
+#define EXCEPTION_HARDWARE_COMPILER                 7
 
-/* load, link and compile exceptions used in the system */
+#define EXCEPTION_HARDWARE_LARGEST                  7
 
-void init_system_exceptions();
 
+/* function prototypes ********************************************************/
 
-/* exception throwing functions */
+bool           exceptions_init(void);
 
-void throw_exception();
-void throw_exception_exit();
+java_handle_t *exceptions_get_exception(void);
+void           exceptions_set_exception(java_handle_t *o);
+void           exceptions_clear_exception(void);
+java_handle_t *exceptions_get_and_clear_exception(void);
 
-void throw_main_exception();
-void throw_main_exception_exit();
-
-void throw_cacao_exception_exit(char *exception, char *message);
-
-
-/* initialize new exceptions */
-
-java_objectheader *new_exception(char *classname);
-java_objectheader *new_exception_message(char *classname, char *message);
-java_objectheader *new_exception_throwable(char *classname, java_lang_Throwable *cause);
-java_objectheader *new_exception_utfmessage(char *classname, utf *message);
-java_objectheader *new_exception_javastring(char *classname, java_lang_String *message);
-java_objectheader *new_exception_int(char *classname, s4 i);
+java_handle_t *new_exception_utfmessage(const char *classname,
+                                                                                       utf *message);
 
 
 /* functions to generate compiler exceptions */
 
-java_objectheader *new_classformaterror(classinfo *c, char *message, ...);
-java_objectheader *new_verifyerror(methodinfo *m, char *message);
-java_objectheader *new_unsupportedclassversionerror(classinfo *c, char *message, ...);
-
-java_objectheader *new_arithmeticexception();
-java_objectheader *new_arrayindexoutofboundsexception(s4 index);
-java_objectheader *new_classcastexception();
-java_objectheader *new_negativearraysizeexception();
-java_objectheader *new_nullpointerexception();
+java_handle_t *exceptions_new_abstractmethoderror(void);
+java_handle_t *exceptions_asm_new_abstractmethoderror(u1 *sp, u1 *ra);
+java_handle_t *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_handle_t *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_handle_t *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_handle_t *exceptions_new_arithmeticexception(void);
+
+java_handle_t *exceptions_new_arrayindexoutofboundsexception(s4 index);
+void exceptions_throw_arrayindexoutofboundsexception(void);
+void exceptions_throw_arraystoreexception(void);
+
+java_handle_t *exceptions_new_classcastexception(java_handle_t *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_handle_t *cause);
+void exceptions_throw_negativearraysizeexception(void);
+
+java_handle_t *exceptions_new_nullpointerexception(void);
+void exceptions_throw_nullpointerexception(void);
+void exceptions_throw_privilegedactionexception(java_handle_t *cause);
+void exceptions_throw_stringindexoutofboundsexception(void);
+
+void exceptions_classnotfoundexception_to_noclassdeffounderror(void);
+
+java_handle_t *exceptions_fillinstacktrace(void);
+
+void exceptions_print_exception(java_handle_t *xptr);
+void exceptions_print_current_exception(void);
+void exceptions_print_stacktrace(void);
 
 #endif /* _EXCEPTIONS_H */
 
@@ -146,4 +154,5 @@ java_objectheader *new_nullpointerexception();
  * c-basic-offset: 4
  * tab-width: 4
  * End:
+ * vim:noexpandtab:sw=4:ts=4:
  */