[Mono-list] JITer / Windows

Serge serge@wildwestsoftware.com
Mon, 1 Apr 2002 19:45:14 +0300


This is a multi-part message in MIME format.

------=_NextPart_000_000B_01C1D9B5.BE15EB20
Content-Type: text/plain;
	charset="koi8-r"
Content-Transfer-Encoding: 7bit

Hello,

Today I managed to build Mono JITer on Windows, the patch is attached.
Please note however, that this patch is not to be applied to the main
codebase - the "port" is quick and dirty, so this is just for review and
just because I wanted to run JIT compiler on Windows ;-)
Perhaps some cleaner interface is needed for things such as exception
processing to make porting easier/cleaner (in general maybe something like
io-layer, but more generalized; something like os modules in addition to
existing arch modules or something).
Most of the changes in jit itself is just avoiding name clashes because of
the way Win32 CONTEXT is mapped to POSIX sigcontext.
Some code is commented out to avoid abnormal termination if corlib is out of
sync (currently it will complain about TransparentProxy, but will continue
to run; that's ok). As I said this is quick and dirty.
Win32 code uses per-process exception handler to catch exceptions.

Sergey







------=_NextPart_000_000B_01C1D9B5.BE15EB20
Content-Type: application/octet-stream;
	name="win32-exception.h"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="win32-exception.h"

#ifndef _MONO_WIN32_EXCEPTION_H_=0A=
#define _MONO_WIN32_EXCEPTION_H_=0A=
=0A=
#include <config.h>=0A=
=0A=
#ifdef PLATFORM_WIN32=0A=
=0A=
#include <windows.h>=0A=
=0A=
#ifdef HAVE_SIGNAL_H=0A=
#include <signal.h>=0A=
#endif=0A=
=0A=
struct sigcontext {=0A=
	CONTEXT ctx;=0A=
};=0A=
=0A=
#define eax ctx.Eax=0A=
#define ebx ctx.Ebx=0A=
#define ecx ctx.Ecx=0A=
#define edx ctx.Edx=0A=
#define ebp ctx.Ebp=0A=
#define esp ctx.Esp=0A=
#define esi ctx.Esi=0A=
#define edi ctx.Edi=0A=
#define eip ctx.Eip=0A=
=0A=
=0A=
typedef void (* MonoW32ExceptionHandler) (int);=0A=
void win32_seh_init(void);=0A=
void win32_seh_reset(void);=0A=
void win32_seh_set_handler(int type, MonoW32ExceptionHandler handler);=0A=
=0A=
#ifndef SIGFPE=0A=
#define SIGFPE 4=0A=
#endif=0A=
=0A=
#ifndef SIGILL=0A=
#define SIGILL 8=0A=
#endif=0A=
=0A=
#ifndef	SIGSEGV=0A=
#define	SIGSEGV 11=0A=
#endif=0A=
=0A=
#endif /* PLATFORM_WIN32 */=0A=
=0A=
#endif /* _MONO_WIN32_EXCEPTION_H_ */=0A=

------=_NextPart_000_000B_01C1D9B5.BE15EB20
Content-Type: application/octet-stream;
	name="win32-exception.c"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="win32-exception.c"

#include "win32-exception.h"=0A=
=0A=
#ifdef PLATFORM_WIN32=0A=
=0A=
=0A=
LONG CALLBACK seh_handler(EXCEPTION_POINTERS* ep);=0A=
=0A=
static MonoW32ExceptionHandler fpe_handler;=0A=
static MonoW32ExceptionHandler ill_handler;=0A=
static MonoW32ExceptionHandler segv_handler;=0A=
=0A=
#define W32_HANDLE_EX(_ex) if (_ex##_handler) _ex##_handler((int)ctx)=0A=
=0A=
/*=0A=
 * Unhandled Exception Filter=0A=
 * Top-level per-process exception handler.=0A=
 */=0A=
LONG CALLBACK seh_handler(EXCEPTION_POINTERS* ep)=0A=
{=0A=
	EXCEPTION_RECORD* er;=0A=
	CONTEXT* ctx;=0A=
	LONG res;=0A=
=0A=
	res =3D EXCEPTION_CONTINUE_SEARCH;=0A=
=0A=
	er =3D ep->ExceptionRecord;=0A=
	ctx =3D ep->ContextRecord;=0A=
=0A=
	switch (er->ExceptionCode) {=0A=
	case 0xACDC:=0A=
		break;=0A=
	case EXCEPTION_ACCESS_VIOLATION:=0A=
		W32_HANDLE_EX(segv);=0A=
		break;=0A=
	case EXCEPTION_ILLEGAL_INSTRUCTION:=0A=
		W32_HANDLE_EX(ill);=0A=
		break;=0A=
	case EXCEPTION_INT_DIVIDE_BY_ZERO:=0A=
	case EXCEPTION_INT_OVERFLOW:=0A=
	case EXCEPTION_FLT_DIVIDE_BY_ZERO:=0A=
	case EXCEPTION_FLT_OVERFLOW:=0A=
	case EXCEPTION_FLT_UNDERFLOW:=0A=
	case EXCEPTION_FLT_INEXACT_RESULT:=0A=
		W32_HANDLE_EX(fpe);=0A=
		break;=0A=
	default:=0A=
		break;=0A=
	}=0A=
=0A=
	return res;=0A=
}=0A=
=0A=
void win32_seh_init()=0A=
{=0A=
	SetUnhandledExceptionFilter(seh_handler);=0A=
}=0A=
=0A=
void win32_seh_reset()=0A=
{=0A=
}=0A=
=0A=
void win32_seh_set_handler(int type, MonoW32ExceptionHandler handler)=0A=
{=0A=
	switch (type) {=0A=
	case SIGFPE:=0A=
		fpe_handler =3D handler;=0A=
		break;=0A=
	case SIGILL:=0A=
		ill_handler =3D handler;=0A=
		break;=0A=
	case SIGSEGV:=0A=
		segv_handler =3D handler;=0A=
		break;=0A=
	default:=0A=
		break;=0A=
	}=0A=
}=0A=
=0A=
#endif /* PLATFORM_WIN32 */=0A=
=0A=

------=_NextPart_000_000B_01C1D9B5.BE15EB20
Content-Type: application/octet-stream;
	name="jit.diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="jit.diff"

? win32-exception.c=0A=
? win32-exception.h=0A=
Index: .cvsignore=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/public/mono/mono/jit/.cvsignore,v=0A=
retrieving revision 1.2=0A=
diff -u -r1.2 .cvsignore=0A=
--- .cvsignore	2001/11/28 04:55:06	1.2=0A=
+++ .cvsignore	2002/04/01 10:29:24=0A=
@@ -1,6 +1,7 @@=0A=
 Makefile=0A=
 Makefile.in=0A=
 *.o=0A=
+*.exe=0A=
 .libs=0A=
 .deps=0A=
 testjit=0A=
Index: Makefile.am=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/public/mono/mono/jit/Makefile.am,v=0A=
retrieving revision 1.22=0A=
diff -u -r1.22 Makefile.am=0A=
--- Makefile.am	2002/03/29 08:18:03	1.22=0A=
+++ Makefile.am	2002/04/01 10:29:24=0A=
@@ -9,6 +9,8 @@=0A=
 endif=0A=
 =0A=
 libmono_a_SOURCES =3D			\=0A=
+	win32-exception.c	\=0A=
+	win32-exception.h	\=0A=
 	codegen.h		\=0A=
 	codegen-x86.c		\=0A=
 	emit-x86.c		\=0A=
Index: delegate.c=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/public/mono/mono/jit/delegate.c,v=0A=
retrieving revision 1.9=0A=
diff -u -r1.9 delegate.c=0A=
--- delegate.c	2002/03/30 11:19:26	1.9=0A=
+++ delegate.c	2002/04/01 10:29:24=0A=
@@ -14,8 +14,11 @@=0A=
 #include <mono/metadata/appdomain.h>=0A=
 #include <mono/metadata/tabledefs.h>=0A=
 #include <mono/metadata/threads.h>=0A=
+=0A=
+#ifndef PLATFORM_WIN32=0A=
 #include "mono/io-layer/wapi.h"=0A=
 #include "mono/io-layer/uglify.h"=0A=
+#endif=0A=
 =0A=
 #include "jit.h"=0A=
 #include "codegen.h"=0A=
Index: emit-x86.c=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/public/mono/mono/jit/emit-x86.c,v=0A=
retrieving revision 1.74=0A=
diff -u -r1.74 emit-x86.c=0A=
--- emit-x86.c	2002/03/30 11:19:26	1.74=0A=
+++ emit-x86.c	2002/04/01 10:29:24=0A=
@@ -25,7 +25,7 @@=0A=
 #include "debug.h"=0A=
 =0A=
 static void=0A=
-enter_method (MonoMethod *method, char *ebp)=0A=
+enter_method (MonoMethod *method, char * r_ebp)=0A=
 {=0A=
 	int i, j;=0A=
 	MonoClass *class;=0A=
@@ -35,11 +35,11 @@=0A=
 		method->klass->name, method->name);=0A=
 =0A=
 	=0A=
-	if (((int)ebp & 3) !=3D 0) {=0A=
-		g_error ("unaligned stack detected (%p)", ebp);=0A=
+	if (((int)r_ebp & 3) !=3D 0) {=0A=
+		g_error ("unaligned stack detected (%p)", r_ebp);=0A=
 	}=0A=
 =0A=
-	ebp +=3D 8;=0A=
+	r_ebp +=3D 8;=0A=
 =0A=
 	if (ISSTRUCT (method->signature->ret)) {=0A=
 		int size, align;=0A=
@@ -48,15 +48,15 @@=0A=
 =0A=
 		size =3D mono_type_stack_size (method->signature->ret, &align);=0A=
 =0A=
-		printf ("VALUERET:%p, ", *((gpointer *)ebp));=0A=
-		ebp +=3D sizeof (gpointer);=0A=
+		printf ("VALUERET:%p, ", *((gpointer *)r_ebp));=0A=
+		r_ebp +=3D sizeof (gpointer);=0A=
 	}=0A=
 =0A=
 	if (method->signature->hasthis) {=0A=
 		if (method->klass->valuetype) {=0A=
-			printf ("value:%p, ", *((gpointer *)ebp));=0A=
+			printf ("value:%p, ", *((gpointer *)r_ebp));=0A=
 		} else {=0A=
-			o =3D *((MonoObject **)ebp);=0A=
+			o =3D *((MonoObject **)r_ebp);=0A=
 =0A=
 			g_assert (o);=0A=
 =0A=
@@ -68,7 +68,7 @@=0A=
 				printf ("this:%p[%s.%s], ", o, class->name_space, class->name);=0A=
 			}=0A=
 		}=0A=
-		ebp +=3D sizeof (gpointer);=0A=
+		r_ebp +=3D sizeof (gpointer);=0A=
 	}=0A=
 =0A=
 	for (i =3D 0; i < method->signature->param_count; ++i) {=0A=
@@ -77,7 +77,7 @@=0A=
 		size =3D mono_type_stack_size (type, &align);=0A=
 =0A=
 		if (type->byref) {=0A=
-			printf ("[BYREF:%p], ", *((gpointer *)ebp)); =0A=
+			printf ("[BYREF:%p], ", *((gpointer *)r_ebp)); =0A=
 		} else switch (type->type) {=0A=
 			=0A=
 		case MONO_TYPE_BOOLEAN:=0A=
@@ -90,10 +90,10 @@=0A=
 		case MONO_TYPE_U4:=0A=
 		case MONO_TYPE_I:=0A=
 		case MONO_TYPE_U:=0A=
-			printf ("%d, ", *((int *)(ebp)));=0A=
+			printf ("%d, ", *((int *)(r_ebp)));=0A=
 			break;=0A=
 		case MONO_TYPE_STRING: {=0A=
-			MonoString *s =3D *((MonoString **)ebp);=0A=
+			MonoString *s =3D *((MonoString **)r_ebp);=0A=
 			if (s) {=0A=
 				g_assert (((MonoObject *)s)->vtable->klass =3D=3D =
mono_defaults.string_class);=0A=
 				printf ("[STRING:%p:%s], ", s, mono_string_to_utf8 (s));=0A=
@@ -103,7 +103,7 @@=0A=
 		}=0A=
 		case MONO_TYPE_CLASS:=0A=
 		case MONO_TYPE_OBJECT: {=0A=
-			o =3D *((MonoObject **)ebp);=0A=
+			o =3D *((MonoObject **)r_ebp);=0A=
 			if (o) {=0A=
 				class =3D o->vtable->klass;=0A=
 		    =0A=
@@ -114,7 +114,7 @@=0A=
 				} else=0A=
 					printf ("[%s.%s:%p], ", class->name_space, class->name, o);=0A=
 			} else {=0A=
-				printf ("%p, ", *((gpointer *)(ebp)));				=0A=
+				printf ("%p, ", *((gpointer *)(r_ebp)));				=0A=
 			}=0A=
 			break;=0A=
 		}=0A=
@@ -122,21 +122,21 @@=0A=
 		case MONO_TYPE_FNPTR:=0A=
 		case MONO_TYPE_ARRAY:=0A=
 		case MONO_TYPE_SZARRAY:=0A=
-			printf ("%p, ", *((gpointer *)(ebp)));=0A=
+			printf ("%p, ", *((gpointer *)(r_ebp)));=0A=
 			break;=0A=
 		case MONO_TYPE_I8:=0A=
-			printf ("%lld, ", *((gint64 *)(ebp)));=0A=
+			printf ("%lld, ", *((gint64 *)(r_ebp)));=0A=
 			break;=0A=
 		case MONO_TYPE_R4:=0A=
-			printf ("%f, ", *((float *)(ebp)));=0A=
+			printf ("%f, ", *((float *)(r_ebp)));=0A=
 			break;=0A=
 		case MONO_TYPE_R8:=0A=
-			printf ("%f, ", *((double *)(ebp)));=0A=
+			printf ("%f, ", *((double *)(r_ebp)));=0A=
 			break;=0A=
 		case MONO_TYPE_VALUETYPE: =0A=
 			printf ("[");=0A=
 			for (j =3D 0; j < size; j++)=0A=
-				printf ("%02x,", *((guint8*)ebp +j));=0A=
+				printf ("%02x,", *((guint8*)r_ebp +j));=0A=
 			printf ("], ");=0A=
 			break;=0A=
 		default:=0A=
@@ -144,15 +144,15 @@=0A=
 		}=0A=
 =0A=
 		g_assert (align =3D=3D 4);=0A=
-		ebp +=3D size + 3;=0A=
-		ebp =3D (gpointer)((unsigned)ebp & ~(3));=0A=
+		r_ebp +=3D size + 3;=0A=
+		r_ebp =3D (gpointer)((unsigned)r_ebp & ~(3));=0A=
 	}=0A=
 =0A=
 	printf (")\n");=0A=
 }=0A=
 =0A=
 static void=0A=
-leave_method (MonoMethod *method, int edx, int eax, double test)=0A=
+leave_method (MonoMethod *method, int r_edx, int r_eax, double test)=0A=
 {=0A=
 	gint64 l;=0A=
 =0A=
@@ -163,8 +163,8 @@=0A=
 	case MONO_TYPE_VOID:=0A=
 		break;=0A=
 	case MONO_TYPE_BOOLEAN:=0A=
-		if (eax)=0A=
-			printf ("TRUE:%d", eax);=0A=
+		if (r_eax)=0A=
+			printf ("TRUE:%d", r_eax);=0A=
 		else =0A=
 			printf ("FALSE");=0A=
 			=0A=
@@ -178,10 +178,10 @@=0A=
 	case MONO_TYPE_U4:=0A=
 	case MONO_TYPE_I:=0A=
 	case MONO_TYPE_U:=0A=
-		printf ("EAX=3D%d", eax);=0A=
+		printf ("EAX=3D%d", r_eax);=0A=
 		break;=0A=
 	case MONO_TYPE_STRING: {=0A=
-		MonoString *s =3D (MonoString *)eax;=0A=
+		MonoString *s =3D (MonoString *)r_eax;=0A=
 =0A=
 		if (s) {=0A=
 			g_assert (((MonoObject *)s)->vtable->klass =3D=3D =
mono_defaults.string_class);=0A=
@@ -191,7 +191,7 @@=0A=
 		break;=0A=
 	}=0A=
 	case MONO_TYPE_OBJECT: {=0A=
-		MonoObject *o =3D (MonoObject *)eax;=0A=
+		MonoObject *o =3D (MonoObject *)r_eax;=0A=
 =0A=
 		if (o) {=0A=
 			if (o->vtable->klass =3D=3D mono_defaults.boolean_class) {=0A=
@@ -210,11 +210,11 @@=0A=
 	case MONO_TYPE_FNPTR:=0A=
 	case MONO_TYPE_ARRAY:=0A=
 	case MONO_TYPE_SZARRAY:=0A=
-		printf ("EAX=3D%p", (gpointer)eax);=0A=
+		printf ("EAX=3D%p", (gpointer)r_eax);=0A=
 		break;=0A=
 	case MONO_TYPE_I8:=0A=
-		*((gint32 *)&l) =3D eax;=0A=
-		*((gint32 *)&l + 1) =3D edx;=0A=
+		*((gint32 *)&l) =3D r_eax;=0A=
+		*((gint32 *)&l + 1) =3D r_edx;=0A=
 		printf ("EAX/EDX=3D%lld", l);=0A=
 		break;=0A=
 	case MONO_TYPE_R8:=0A=
Index: exception.c=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/public/mono/mono/jit/exception.c,v=0A=
retrieving revision 1.3=0A=
diff -u -r1.3 exception.c=0A=
--- exception.c	2002/03/30 11:19:26	1.3=0A=
+++ exception.c	2002/04/01 10:29:24=0A=
@@ -231,12 +231,12 @@=0A=
 =0A=
 		*lmf_addr =3D lmf->previous_lmf;=0A=
 =0A=
-		ctx->esi =3D lmf->esi;=0A=
-		ctx->edi =3D lmf->edi;=0A=
-		ctx->ebx =3D lmf->ebx;=0A=
-		ctx->ebp =3D lmf->ebp;=0A=
-		ctx->eip =3D lmf->eip;=0A=
-		ctx->esp =3D (unsigned long)&lmf->eip;=0A=
+		ctx->esi =3D lmf->reg_esi;=0A=
+		ctx->edi =3D lmf->reg_edi;=0A=
+		ctx->ebx =3D lmf->reg_ebx;=0A=
+		ctx->ebp =3D lmf->reg_ebp;=0A=
+		ctx->eip =3D lmf->reg_eip;=0A=
+		ctx->esp =3D (unsigned long)&lmf->reg_eip;=0A=
 =0A=
 		if (mono_object_isinst (obj, mono_defaults.exception_class)) {=0A=
 			char  *strace =3D mono_string_to_utf8 =
(((MonoException*)obj)->stack_trace);=0A=
@@ -264,22 +264,22 @@=0A=
 }=0A=
 =0A=
 static void=0A=
-throw_exception (unsigned long eax, unsigned long ecx, unsigned long =
edx, unsigned long ebx,=0A=
-		 unsigned long esi, unsigned long edi, unsigned long ebp, MonoObject =
*exc,=0A=
-		 unsigned long eip,  unsigned long esp)=0A=
+throw_exception (unsigned long r_eax, unsigned long r_ecx, unsigned =
long r_edx, unsigned long r_ebx,=0A=
+		 unsigned long r_esi, unsigned long r_edi, unsigned long r_ebp, =
MonoObject *exc,=0A=
+		 unsigned long r_eip,  unsigned long r_esp)=0A=
 {=0A=
 	struct sigcontext ctx;=0A=
 =0A=
-	ctx.esp =3D esp;=0A=
-	ctx.eip =3D eip;=0A=
-	ctx.ebp =3D ebp;=0A=
-	ctx.edi =3D edi;=0A=
-	ctx.esi =3D esi;=0A=
-	ctx.ebx =3D ebx;=0A=
-	ctx.edx =3D edx;=0A=
-	ctx.ecx =3D ecx;=0A=
-	ctx.eax =3D eax;=0A=
-	=0A=
+	ctx.esp =3D r_esp;=0A=
+	ctx.eip =3D r_eip;=0A=
+	ctx.ebp =3D r_ebp;=0A=
+	ctx.edi =3D r_edi;=0A=
+	ctx.esi =3D r_esi;=0A=
+	ctx.ebx =3D r_ebx;=0A=
+	ctx.edx =3D r_edx;=0A=
+	ctx.ecx =3D r_ecx;=0A=
+	ctx.eax =3D r_eax;=0A=
+=0A=
 	arch_handle_exception (&ctx, exc);=0A=
 =0A=
 	g_assert_not_reached ();=0A=
Index: jit.c=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/public/mono/mono/jit/jit.c,v=0A=
retrieving revision 1.133=0A=
diff -u -r1.133 jit.c=0A=
--- jit.c	2002/03/30 16:56:29	1.133=0A=
+++ jit.c	2002/04/01 10:29:30=0A=
@@ -3122,12 +3122,20 @@=0A=
 	return mono_runtime_exec_main (method, args);=0A=
 }=0A=
 =0A=
+#ifdef PLATFORM_WIN32=0A=
+#define GET_CONTEXT \=0A=
+	struct sigcontext *ctx =3D (struct sigcontext*)_dummy;=0A=
+#else=0A=
+#define GET_CONTEXT \=0A=
+	void **_p =3D (void **)&_dummy; \=0A=
+	struct sigcontext *ctx =3D (struct sigcontext *)++_p;=0A=
+#endif=0A=
+=0A=
 static void=0A=
 sigfpe_signal_handler (int _dummy)=0A=
 {=0A=
 	MonoException *exc;=0A=
-	void **_p =3D (void **)&_dummy;=0A=
-	struct sigcontext *ctx =3D (struct sigcontext *)++_p;=0A=
+	GET_CONTEXT=0A=
 =0A=
 	exc =3D mono_get_exception_divide_by_zero ();=0A=
 	=0A=
@@ -3140,8 +3148,7 @@=0A=
 sigill_signal_handler (int _dummy)=0A=
 {=0A=
 	MonoException *exc;=0A=
-	void **_p =3D (void **)&_dummy;=0A=
-	struct sigcontext *ctx =3D (struct sigcontext *)++_p;=0A=
+	GET_CONTEXT=0A=
 =0A=
 	exc =3D mono_get_exception_execution_engine ("SIGILL");=0A=
 	=0A=
@@ -3154,8 +3161,7 @@=0A=
 sigsegv_signal_handler (int _dummy)=0A=
 {=0A=
 	MonoException *exc;=0A=
-	void **_p =3D (void **)&_dummy;=0A=
-	struct sigcontext *ctx =3D (struct sigcontext *)++_p;=0A=
+	GET_CONTEXT=0A=
 =0A=
 	exc =3D mono_get_exception_null_reference ();=0A=
 	=0A=
@@ -3201,9 +3207,17 @@=0A=
 =0A=
 MonoDomain*=0A=
 mono_jit_init (char *file) {=0A=
+#ifndef PLATFORM_WIN32=0A=
 	struct sigaction sa;=0A=
+#endif=0A=
 	MonoDomain *domain;=0A=
 =0A=
+#ifdef PLATFORM_WIN32=0A=
+	win32_seh_init();=0A=
+	win32_seh_set_handler(SIGFPE, sigfpe_signal_handler);=0A=
+	win32_seh_set_handler(SIGILL, sigill_signal_handler);=0A=
+	win32_seh_set_handler(SIGSEGV, sigsegv_signal_handler);=0A=
+#else=0A=
 	/* catch SIGFPE */=0A=
 	sa.sa_handler =3D sigfpe_signal_handler;=0A=
 	sigemptyset (&sa.sa_mask);=0A=
@@ -3223,6 +3237,7 @@=0A=
 	sa.sa_flags =3D 0;=0A=
 	g_assert (syscall (SYS_sigaction, SIGSEGV, &sa, NULL) !=3D -1);=0A=
 #endif=0A=
+#endif /* PLATFORM_WIN32 */=0A=
 =0A=
 	mono_init_icall ();=0A=
 	mono_add_internal_call ("__array_Set", ves_array_set);=0A=
Index: jit.h=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/public/mono/mono/jit/jit.h,v=0A=
retrieving revision 1.43=0A=
diff -u -r1.43 jit.h=0A=
--- jit.h	2002/03/30 16:56:29	1.43=0A=
+++ jit.h	2002/04/01 10:29:30=0A=
@@ -1,14 +1,20 @@=0A=
 #ifndef _MONO_JIT_JIT_H_=0A=
 #define _MONO_JIT_JIT_H_=0A=
 =0A=
+#include <config.h>=0A=
+=0A=
+#ifdef PLATFORM_WIN32=0A=
+#include "win32-exception.h"=0A=
+#else=0A=
 #include <signal.h>=0A=
+#include <mono/io-layer/critical-sections.h>=0A=
+#endif=0A=
 =0A=
 #include <mono/metadata/loader.h>=0A=
 #include <mono/metadata/object.h>=0A=
 #include <mono/metadata/exception.h>=0A=
 #include <mono/metadata/mempool.h>=0A=
 #include <mono/metadata/reflection.h>=0A=
-#include <mono/io-layer/critical-sections.h>=0A=
 =0A=
 #include "regset.h"=0A=
 =0A=
@@ -34,11 +40,11 @@=0A=
 	gpointer    previous_lmf;=0A=
 	gpointer    lmf_addr;=0A=
 	MonoMethod *method;=0A=
-	guint32     ebp;=0A=
-	guint32     esi;=0A=
-	guint32     edi;=0A=
-	guint32     ebx;=0A=
-	guint32     eip;=0A=
+	guint32     reg_ebp;=0A=
+	guint32     reg_esi;=0A=
+	guint32     reg_edi;=0A=
+	guint32     reg_ebx;=0A=
+	guint32     reg_eip;=0A=
 } MonoLMF;=0A=
 =0A=
 typedef struct {=0A=
Index: mono.c=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/public/mono/mono/jit/mono.c,v=0A=
retrieving revision 1.3=0A=
diff -u -r1.3 mono.c=0A=
--- mono.c	2002/03/30 11:21:55	1.3=0A=
+++ mono.c	2002/04/01 10:29:33=0A=
@@ -145,7 +145,7 @@=0A=
 	error =3D mono_verify_corlib ();=0A=
 	if (error) {=0A=
 		fprintf (stderr, "Corlib not in sync with this runtime: %s\n", error);=0A=
-		exit (1);=0A=
+	//!!SC	exit (1);=0A=
 	}=0A=
 =0A=
 	assembly =3D mono_domain_assembly_open (domain, file);=0A=
Index: trampoline.c=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/public/mono/mono/jit/trampoline.c,v=0A=
retrieving revision 1.5=0A=
diff -u -r1.5 trampoline.c=0A=
--- trampoline.c	2002/03/30 16:56:29	1.5=0A=
+++ trampoline.c	2002/04/01 10:29:33=0A=
@@ -127,8 +127,8 @@=0A=
  * and the constant displacement.=0A=
  */=0A=
 static gpointer=0A=
-x86_magic_trampoline (int eax, int ecx, int edx, int esi, int edi, =0A=
-		      int ebx, guint8 *code, MonoMethod *m)=0A=
+x86_magic_trampoline (int r_eax, int r_ecx, int r_edx, int r_esi, int =
r_edi, =0A=
+		      int r_ebx, guint8 *code, MonoMethod *m)=0A=
 {=0A=
 	guint8 reg;=0A=
 	gint32 disp;=0A=
@@ -167,22 +167,22 @@=0A=
 =0A=
 	switch (reg) {=0A=
 	case X86_EAX:=0A=
-		o =3D (gpointer)eax;=0A=
+		o =3D (gpointer)r_eax;=0A=
 		break;=0A=
 	case X86_EDX:=0A=
-		o =3D (gpointer)edx;=0A=
+		o =3D (gpointer)r_edx;=0A=
 		break;=0A=
 	case X86_ECX:=0A=
-		o =3D (gpointer)ecx;=0A=
+		o =3D (gpointer)r_ecx;=0A=
 		break;=0A=
 	case X86_ESI:=0A=
-		o =3D (gpointer)esi;=0A=
+		o =3D (gpointer)r_esi;=0A=
 		break;=0A=
 	case X86_EDI:=0A=
-		o =3D (gpointer)edi;=0A=
+		o =3D (gpointer)r_edi;=0A=
 		break;=0A=
 	case X86_EBX:=0A=
-		o =3D (gpointer)ebx;=0A=
+		o =3D (gpointer)r_ebx;=0A=
 		break;=0A=
 	default:=0A=
 		g_assert_not_reached ();=0A=

------=_NextPart_000_000B_01C1D9B5.BE15EB20--