// Functions for Exception Support for Java.
-/* Copyright (C) 1998, 1999 Cygnus Solutions
+/* Copyright (C) 1998, 1999 Free Software Foundation
This file is part of libgcj.
#include <config.h>
-#include "exception"
#include <stddef.h>
+#include <stdlib.h>
#include <java/lang/Class.h>
#include <java/lang/NullPointerException.h>
extern "C" java_eh_info **__get_eh_info ();
extern "C" void __throw () __attribute__ ((__noreturn__));
+extern "C" void __sjthrow () __attribute__ ((__noreturn__));
extern "C" short __get_eh_table_version (void *table);
extern "C" short __get_eh_table_language (void *table);
-
-
-extern "C" void * malloc (size_t);
-extern "C" void free (void *);
-
+extern "C" void *__get_eh_context ();
extern "C" void *
_Jv_type_matcher (java_eh_info *info, void* match_info,
void *exception_table)
{
- if (__get_eh_table_language (exception_table) != EH_LANG_Java)
+#ifndef SJLJ_EXCEPTIONS
+ /* No exception table implies the old style mechanism, so don't check. */
+ if (exception_table != NULL
+ && __get_eh_table_language (exception_table) != EH_LANG_Java)
return NULL;
+#endif
/* we don't worry about version info yet, there is only one version! */
apparently can sometimes free() this value itself. */
java_eh_info *p = (java_eh_info *) malloc (sizeof (java_eh_info));
if (p == 0)
- terminate ();
+ abort ();
p->value = 0;
java_eh_info ** info_ptr = __get_eh_info ();
*info_ptr = NULL;
}
-/* Perform a throw, Java style. Throw will unwind through this call, so
- there better not be any handlers or exception thrown here. */
-
-
/* Initialize an __eh_info structure with this libraries matching info. */
extern "C" void
{
}
+/* Perform a throw, Java style. Throw will unwind through this call,
+ so there better not be any handlers or exception thrown here. */
+
extern "C" void
_Jv_Throw (void *value)
{
ehinfo->eh_info.language = EH_LANG_Java;
ehinfo->eh_info.version = 1;
ehinfo->value = value;
- __throw();
+
+/* We're happy with setjmp/longjmp exceptions or region-based
+ exception handlers: entry points are provided here for both. */
+#ifdef SJLJ_EXCEPTIONS
+ __sjthrow ();
+#else
+ __throw ();
+#endif
+}
+
+#ifdef USE_WIN32_SIGNALLING
+
+// This is a mangled version of _Jv_Throw and __sjthrow except
+// rather than calling longjmp, it returns a pointer to the jmp buffer
+
+extern "C" int *
+win32_get_restart_frame (void *value)
+{
+ struct eh_context *eh = (struct eh_context *)__get_eh_context ();
+ void ***dhc = &eh->dynamic_handler_chain;
+
+ java_eh_info *ehinfo = *(__get_eh_info ());
+ if (ehinfo == NULL)
+ {
+ _Jv_eh_alloc ();
+ ehinfo = *(__get_eh_info ());
+ }
+ ehinfo->eh_info.match_function = (__eh_matcher) _Jv_type_matcher;
+ ehinfo->eh_info.language = EH_LANG_Java;
+ ehinfo->eh_info.version = 1;
+ ehinfo->value = value;
+
+ // FIXME: Run clean ups?
+
+ int *jmpbuf = (int*)&(*dhc)[2];
+
+ *dhc = (void**)(*dhc)[0];
+
+ return jmpbuf;
}
+
+#endif /* USE_WIN32_SIGNALLING */