dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[dotgnu-pnet-commits] pnet ./ChangeLog engine/jitc.c engine/jitc.h en...


From: Klaus Treichel
Subject: [dotgnu-pnet-commits] pnet ./ChangeLog engine/jitc.c engine/jitc.h en...
Date: Sun, 12 Mar 2006 17:57:06 +0000

CVSROOT:        /cvsroot/dotgnu-pnet
Module name:    pnet
Branch:         
Changes by:     Klaus Treichel <address@hidden> 06/03/12 17:57:06

Modified files:
        .              : ChangeLog 
        engine         : jitc.c jitc.h jitc_branch.c jitc_except.c 
                         thread.c 

Log message:
        2006-03-12  Klaus Treichel  <address@hidden>
        
        * engine/jitc.c: Add the exceptionhandler and some exception stuff.
        
        * engine/jitc.h: Add the prototype for the exceptionhandler.
        
        * engine/jitc_branch.c, engine/jitc_except.c: Add some exception stuff.
        
        * engine/thread.c: Register the exceptionhandler for the thread when the
        thread is registered for managed execution.
        
        Thanks krokas for the help.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/ChangeLog.diff?tr1=1.3305&tr2=1.3306&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc.c.diff?tr1=1.24&tr2=1.25&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc.h.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc_branch.c.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc_except.c.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/thread.c.diff?tr1=1.40&tr2=1.41&r1=text&r2=text

Patches:
Index: pnet/ChangeLog
diff -u pnet/ChangeLog:1.3305 pnet/ChangeLog:1.3306
--- pnet/ChangeLog:1.3305       Sat Mar 11 13:18:33 2006
+++ pnet/ChangeLog      Sun Mar 12 17:57:06 2006
@@ -1,3 +1,16 @@
+2006-03-12  Klaus Treichel  <address@hidden>
+
+       * engine/jitc.c: Add the exceptionhandler and some exception stuff.
+
+       * engine/jitc.h: Add the prototype for the exceptionhandler.
+
+       * engine/jitc_branch.c, engine/jitc_except.c: Add some exception stuff.
+
+       * engine/thread.c: Register the exceptionhandler for the thread when the
+       thread is registered for managed execution.
+
+       Thanks krokas for the help.
+
 2006-03-11  Klaus Treichel  <address@hidden>
 
        * configure.in: Add new configure switch --with-cvm which defines
Index: pnet/engine/jitc.c
diff -u pnet/engine/jitc.c:1.24 pnet/engine/jitc.c:1.25
--- pnet/engine/jitc.c:1.24     Thu Mar  9 19:09:29 2006
+++ pnet/engine/jitc.c  Sun Mar 12 17:57:06 2006
@@ -147,6 +147,11 @@
 static ILJitType _ILJitSignature_JitExceptionBuiltin = 0;
 
 /*
+ * void jit_exception_clear_last()
+ */
+static ILJitType _ILJitSignature_JitExceptionClearLast = 0;
+
+/*
  * Define offsetof macro if not present.
  */
 #ifndef offsetof
@@ -157,8 +162,9 @@
 /*
  * declaration of the different label types.
  */
-#define _IL_JIT_LABEL_NORMAL 0
-#define _IL_JIT_LABEL_STARTFINALLY 1
+#define _IL_JIT_LABEL_NORMAL 1
+#define _IL_JIT_LABEL_STARTCATCH 2
+#define _IL_JIT_LABEL_STARTFINALLY 4
 
 /*
  * Define the structure of a JIT label.
@@ -254,6 +260,8 @@
 
        /* Flag if the catcher is started. */
        int                             isInCatcher;
+       jit_label_t     nextBlock;
+       jit_label_t     rethrowBlock;
 };
 
 /*
@@ -1007,7 +1015,7 @@
 }
 
 /*
- * Get the jit typee from an ILClass.
+ * Get the jit type from an ILClass.
  */
 static ILJitType _ILJitGetTypeFromClass(ILClass *info)
 {
@@ -1095,15 +1103,91 @@
 }
 
 /*
+ * The exception handler which converts libjit inbuilt exceptions
+ * into clr exceptions.
+ */
+void *_ILJitExceptionHandler(int exception_type)
+{
+    ILExecThread *thread = ILExecThreadCurrent();
+    void *object = 0;
+
+    switch(exception_type)
+    {
+               case(JIT_RESULT_OVERFLOW):
+               {
+                       object = _ILSystemException(thread, 
"System.OverflowException");
+               }
+               break;
+
+               case(JIT_RESULT_ARITHMETIC):
+               {
+                       object = _ILSystemException(thread, 
"System.ArithmeticException");
+               }
+               break;
+
+               case(JIT_RESULT_DIVISION_BY_ZERO):
+               {
+                       object = _ILSystemException(thread, 
"System.DivideByZeroException");
+               }
+               break;
+
+               case(JIT_RESULT_COMPILE_ERROR):
+               {
+                       object = _ILSystemException(thread, 
"System.ExecutionEngineException");
+               }
+               break;
+
+               case(JIT_RESULT_OUT_OF_MEMORY):
+               {
+                       object = _ILSystemException(thread, 
"System.OutOfMemoryException");
+               }    
+               break;
+
+               case(JIT_RESULT_NULL_REFERENCE):
+               {
+                       object = _ILSystemException(thread, 
"System.NullReferenceException");
+               }
+               break;
+
+               case(JIT_RESULT_NULL_FUNCTION):
+               {
+                       object = _ILSystemException(thread, 
"System.MissingMethodException");
+               }
+               break;
+
+               case(JIT_RESULT_CALLED_NESTED):
+               {
+                       object = _ILSystemException(thread, 
"System.MissingMethodException");
+               }
+               break;
+
+               case(JIT_RESULT_OUT_OF_BOUNDS):
+               {
+                       object = _ILSystemException(thread, 
"System.IndexOutOfRangeException");
+               }
+               break;
+
+               default:
+               {
+                       object = _ILSystemException(thread, "System.Exception");
+               }
+               break;
+       }
+       thread->thrownException = object;
+       return object;
+}
+
+/*
  * Generate the code to throw the current exception in the thread in libjit.
  */
 static void _ILJitThrowCurrentException(ILJITCoder *coder)
 {
        ILJitValue thread = jit_value_get_param(coder->jitFunction,0);
-       ILJitValue currentException = 
jit_insn_load_relative(coder->jitFunction, thread,
-                                                                       
offsetof(ILExecThread, currentException), 
+       ILJitValue thrownException = jit_insn_load_relative(coder->jitFunction,
+                                                                       thread,
+                                                                       
offsetof(ILExecThread, thrownException), 
                                                                        
jit_type_void_ptr);
-       jit_insn_throw(coder->jitFunction, currentException);
+       jit_insn_throw(coder->jitFunction, thrownException);
 }
 
 /*
@@ -1218,6 +1302,13 @@
                return 0;
        }
 
+       returnType = _IL_JIT_TYPE_VOID;
+       if(!(_ILJitSignature_JitExceptionClearLast =
+               jit_type_create_signature(IL_JIT_CALLCONV_CDECL, returnType, 0, 
0, 1)))
+       {
+               return 0;
+       }
+
        return 1;
 }
 /*
@@ -1240,6 +1331,7 @@
        }
        coder->debugEnabled = 0;
        coder->flags = 0;
+
        /* Initialize the stack management. */
        coder->jitStack = 0;
        coder->stackTop = -1;
@@ -1491,13 +1583,18 @@
  */
 static int _ILJitCompileInternal(jit_function_t func, ILMethod *method, void 
*nativeFunction)
 {
+       ILType *ilSignature = ILMethod_Signature(method);
+       ILType *type = ILTypeGetEnumType(ILTypeGetParam(ilSignature, 0));
        ILJitType signature = jit_function_get_signature(func);
        unsigned int numParams = jit_type_num_params(signature);
        unsigned int totalParams = numParams;
+       ILJitValue thread = jit_value_get_param(func, 0);
        ILJitType returnType = jit_type_get_return(signature);;
        ILJitValue returnValue = 0;
        int hasStructReturn = 0;
        char *methodName = 0;
+       jit_label_t label = jit_label_undefined;
+       ILJitValue thrownException = 0;
 
 #if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS) && 
defined(_IL_JIT_ENABLE_DEBUG)
        methodName = _ILJitFunctionGetMethodName(func);
@@ -1506,19 +1603,20 @@
        ILMutexUnlock(globalTraceMutex);
 #endif
 
-       if(jit_type_is_struct(returnType))
+       if(ILType_IsValueType(type))
        {
                /* We need to create a new Signature for the native Call with */
-               /* a pointer to the return value as last arg. */
+               /* a pointer to the return value as second arg after the 
ILExecThread. */
                ++totalParams;
                ILJitType jitParamTypes[totalParams];
                ILUInt32 current;
                
-               for(current = 0; current < numParams; current++)
+               jitParamTypes[0] = jit_type_get_param(signature, 0); 
+               jitParamTypes[1] = _IL_JIT_TYPE_VPTR;
+               for(current = 1; current < numParams; current++)
                {
-                       jitParamTypes[current] = jit_type_get_param(signature, 
current); 
+                       jitParamTypes[current + 1] = 
jit_type_get_param(signature, current); 
                }
-               jitParamTypes[totalParams -1] = _IL_JIT_TYPE_VPTR;
                signature = jit_type_create_signature(IL_JIT_CALLCONV_CDECL,
                                                                                
          _IL_JIT_TYPE_VOID,
                                                                                
          jitParamTypes,
@@ -1532,13 +1630,22 @@
        {
                ILJitValue jitParams[totalParams];
                ILUInt32 current;
+               ILUInt32 param = 1;
                
-               for(current = 0; current < numParams; current++)
+               jitParams[0] = jit_value_get_param(func, 0);
+               if(hasStructReturn)
+               {
+                       jitParams[1] = jit_insn_address_of(func, returnValue);
+                       ++param;
+
+               }
+               for(current = 1; current < numParams; current++)
                {
-                       if(!(jitParams[current] = jit_value_get_param(func, 
current)))
+                       if(!(jitParams[param] = jit_value_get_param(func, 
current)))
                        {
                                return JIT_RESULT_OUT_OF_MEMORY;
                        }
+                       ++param;
                }
                _ILJitSetMethodInThread(func, jitParams[0], method);
                if(!hasStructReturn)
@@ -1549,7 +1656,6 @@
                }
                else
                {
-                       jitParams[totalParams - 1] = jit_insn_address_of(func, 
returnValue);
                        jit_insn_call_native(func, methodName, nativeFunction,
                                                                 signature,
                                                                 jitParams, 
totalParams, 0);
@@ -1559,7 +1665,13 @@
        {
                returnValue = jit_insn_call_native(func, methodName, 
nativeFunction, signature, 0, 0, 0);
        }
+       thrownException = jit_insn_load_relative(func, thread,
+                                                                       
offsetof(ILExecThread, thrownException),
+                                                                       
_IL_JIT_TYPE_VPTR);
+       jit_insn_branch_if(func, thrownException, &label);
        jit_insn_return(func, returnValue);     
+       jit_insn_label(func, &label);
+       jit_insn_throw(func, thrownException);
        return JIT_RESULT_OK;
 }
 
Index: pnet/engine/jitc.h
diff -u pnet/engine/jitc.h:1.9 pnet/engine/jitc.h:1.10
--- pnet/engine/jitc.h:1.9      Sun Feb 19 18:31:11 2006
+++ pnet/engine/jitc.h  Sun Mar 12 17:57:06 2006
@@ -188,6 +188,12 @@
  */
 #define ILJitTypeGetSize(jitType)      jit_type_get_size((jitType))
 
+/*
+ * The exception handler which converts libjit inbuilt exceptions
+ * into clr exceptions.
+ */
+void *_ILJitExceptionHandler(int exception_type);
+
 #endif  /* IL_USE_JIT */
 
 #endif /* _ENGINE_JITC_H */
Index: pnet/engine/jitc_branch.c
diff -u pnet/engine/jitc_branch.c:1.9 pnet/engine/jitc_branch.c:1.10
--- pnet/engine/jitc_branch.c:1.9       Wed Mar  8 21:03:52 2006
+++ pnet/engine/jitc_branch.c   Sun Mar 12 17:57:06 2006
@@ -26,7 +26,9 @@
  */
 static int _ILJitLabelSaveStack(ILJITCoder *coder, ILJITLabel *label)
 {
-       if((label->labelType == _IL_JIT_LABEL_NORMAL) && (coder->stackTop > 0))
+       if(((label->labelType & (_IL_JIT_LABEL_NORMAL |
+                                                        
_IL_JIT_LABEL_STARTCATCH)) != 0) &&
+               (coder->stackTop > 0))
        {
                int current = 0;
                ILJitValue *stack = ILMemStackAllocItem(&(coder->stackStates),
@@ -72,7 +74,7 @@
  */
 static int _ILJitLabelMergeStack(ILJITCoder *coder, ILJITLabel *label)
 {
-       if(label->labelType == _IL_JIT_LABEL_NORMAL)
+       if(label->labelType & (_IL_JIT_LABEL_NORMAL | _IL_JIT_LABEL_STARTCATCH))
        {
                /* Verify that the stack sizes match. */
                if(coder->stackTop != label->stackSize)
@@ -122,46 +124,63 @@
 }
 
 /*
- * Look for a label for a specific IL address.  Create
- * a new label if necessary.
+ * Look for an existing label for the specified IL address.
+ * Returns 0 if there is no label for this address.
  */
-static ILJITLabel *GetLabel(ILJITCoder *coder, ILUInt32 address, int labelType)
+static ILJITLabel *FindLabel(ILJITCoder *coder, ILUInt32 address)
 {
-       ILJITLabel *label;
-       label = coder->labelList;
+       ILJITLabel *label = coder->labelList;
+
        while(label != 0)
        {
                if(label->address == address)
                {
-                       if(!_ILJitLabelMergeStack(coder, label))
+                       return label;
+               }
+               label = label->next;
+       }
+       return 0;
+}
+
+/*
+ * Look for a label for a specific IL address.  Create
+ * a new label if necessary.
+ */
+static ILJITLabel *GetLabel(ILJITCoder *coder, ILUInt32 address, int labelType)
+{
+       ILJITLabel *label = FindLabel(coder, address);
+;
+       if(!label)
+       {
+               label = ILMemPoolAlloc(&(coder->labelPool), ILJITLabel);
+               if(label)
+               {
+                       label->stackSize = 0;
+                       label->jitStack = 0;
+                       label->address = address;
+                       label->label = jit_label_undefined;
+                       label->labelType = labelType;
+                       if(!_ILJitLabelSaveStack(coder, label))
                        {
-                               /* We have a stack size mismatch!!! */
                                coder->labelOutOfMemory = 1;
                                return 0;
                        }
-                       return label;
+                       label->next = coder->labelList;
+                       coder->labelList = label;
                }
-               label = label->next;
-       }
-       label = ILMemPoolAlloc(&(coder->labelPool), ILJITLabel);
-       if(label)
-       {
-               label->stackSize = 0;
-               label->jitStack = 0;
-               label->address = address;
-               label->label = jit_label_undefined;
-               label->labelType = labelType;
-               if(!_ILJitLabelSaveStack(coder, label))
+               else
                {
                        coder->labelOutOfMemory = 1;
-                       return 0;
                }
-               label->next = coder->labelList;
-               coder->labelList = label;
        }
        else
        {
-               coder->labelOutOfMemory = 1;
+               if(!_ILJitLabelMergeStack(coder, label))
+               {
+                       /* We have a stack size mismatch!!! */
+                       coder->labelOutOfMemory = 1;
+                       return 0;
+               }
        }
        return label;
 }
Index: pnet/engine/jitc_except.c
diff -u pnet/engine/jitc_except.c:1.3 pnet/engine/jitc_except.c:1.4
--- pnet/engine/jitc_except.c:1.3       Sun Feb 12 15:10:10 2006
+++ pnet/engine/jitc_except.c   Sun Mar 12 17:57:06 2006
@@ -39,10 +39,16 @@
        }
 #endif
 
+       /* Setup the jit function to handle exceptions. */
+       jit_insn_uses_catcher(jitCoder->jitFunction);
+       jitCoder->nextBlock = jit_label_undefined;
+       jitCoder->rethrowBlock = jit_label_undefined;
+
        /* We need to setup the filally labels first. */
        while(exceptions != 0)
        {
-               if((exceptions->flags & IL_META_EXCEPTION_FINALLY) != 0)
+               if((exceptions->flags & (IL_META_EXCEPTION_FINALLY |
+                                                                
IL_META_EXCEPTION_FAULT)) != 0)
                {
                #if !defined(IL_CONFIG_REDUCE_CODE) && 
!defined(IL_WITHOUT_TOOLS)
                        if (jitCoder->flags & IL_CODER_FLAG_STATS)
@@ -57,12 +63,31 @@
                        GetLabel(jitCoder, exceptions->handlerOffset,
                                                           
_IL_JIT_LABEL_STARTFINALLY);
                }
+               else if ((exceptions->flags & IL_META_EXCEPTION_FILTER) == 0)
+               {
+                       /* Create the label for a catch block */
+                       /* We need one value on the stack for the exception 
object. */
+                       ILJitValue exception = 
jit_value_create(jitCoder->jitFunction,
+                                                                               
                        _IL_JIT_TYPE_VPTR);
+
+               #if !defined(IL_CONFIG_REDUCE_CODE) && 
!defined(IL_WITHOUT_TOOLS)
+                       if (jitCoder->flags & IL_CODER_FLAG_STATS)
+                       {
+                               ILMutexLock(globalTraceMutex);
+                               fprintf(stdout,
+                                       "AddCatchLabel for offset: %i\n", 
+                                       exceptions->handlerOffset);
+                               ILMutexUnlock(globalTraceMutex);
+                       }
+               #endif
+                       jitCoder->jitStack[0] = exception;
+                       jitCoder->stackTop = 1;
+                       GetLabel(jitCoder, exceptions->handlerOffset,
+                                                          
_IL_JIT_LABEL_STARTCATCH);
+                       jitCoder->stackTop = 0;
+               }
                exceptions = exceptions->next;
        }
-       /* Setup the jit function to handle exceptions. */
-       
-       jit_insn_uses_catcher(jitCoder->jitFunction);
-       
 }
 
 /*
@@ -71,6 +96,7 @@
 static void JITCoder_Throw(ILCoder *coder, int inCurrentMethod)
 {
        ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
+       ILJitValue thread = jit_value_get_param(jitCoder->jitFunction,0);
        ILJitValue exception = jitCoder->jitStack[jitCoder->stackTop - 1];;
 
 #if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS)
@@ -83,15 +109,15 @@
                ILMutexUnlock(globalTraceMutex);
        }
 #endif
-       /*
-       if(inCurrentMethod == 1)
+
+       if(!(jitCoder->isInCatcher))
        {
-       */
+               jit_insn_store_relative(jitCoder->jitFunction, thread,
+                                                               
offsetof(ILExecThread, thrownException), 
+                                                               exception);
                jit_insn_throw(jitCoder->jitFunction, exception);
                JITC_ADJUST(jitCoder, -1);
-       /*
        }
-       */
 }
 
 /*
@@ -163,7 +189,6 @@
                                                                         
ILUInt32 start, ILUInt32 end)
 {
        ILJITCoder *jitCoder = _ILCoderToILJITCoder(_coder);
-       ILJitValue exception;
 
 #if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS)
        if (jitCoder->flags & IL_CODER_FLAG_STATS)
@@ -185,18 +210,28 @@
                
                jitCoder->isInCatcher = 1;
        }
-
-       /* We need the exception object on top of the stack. */
-       exception = jit_insn_thrown_exception(jitCoder->jitFunction);
-       jitCoder->jitStack[jitCoder->stackTop] = exception;
-       JITC_ADJUST(jitCoder, 1);
+       /* Insert the jump target for the previous block. */
+       jit_insn_label(jitCoder->jitFunction, &(jitCoder->nextBlock));
+       /* and reset the label so that it can be used with the next block. */
+       jitCoder->nextBlock = jit_label_undefined;
 
        if(start == 0 && end == IL_MAX_UINT32)
        {
                /* This handler was the last one in the table */
-               /*
+               jit_insn_label(jitCoder->jitFunction, 
&(jitCoder->rethrowBlock));
                jit_insn_rethrow_unhandled(jitCoder->jitFunction);
-               */
+       }
+       else
+       {
+               ILJITLabel *startLabel = FindLabel(jitCoder, start);;
+               ILJITLabel *endLabel = FindLabel(jitCoder, end);
+               if(startLabel && endLabel)
+               {
+                       
jit_insn_branch_if_pc_not_in_range(jitCoder->jitFunction,
+                                                                               
           startLabel->label,
+                                                                               
           endLabel->label,
+                                                                               
           &(jitCoder->nextBlock));
+               }
        }
 }
 
@@ -216,6 +251,7 @@
                ILMutexUnlock(globalTraceMutex);
        }
 #endif
+       jit_insn_branch(jitCoder->jitFunction, &(jitCoder->rethrowBlock));
 }
 
 /*
@@ -225,35 +261,82 @@
                                                   ILClass *classInfo, int 
hasRethrow)
 {
        ILJITCoder *jitCoder = _ILCoderToILJITCoder(_coder);
+       ILJitValue thread = jit_value_get_param(jitCoder->jitFunction, 0);
+       ILJitValue classTo = 
jit_value_create_nint_constant(jitCoder->jitFunction,
+                                                                               
                                _IL_JIT_TYPE_VPTR,
+                                                                               
                                (jit_nint)classInfo);
+       ILJitValue nullException = 
jit_value_create_nint_constant(jitCoder->jitFunction,
+                                                                               
                                          _IL_JIT_TYPE_VPTR,
+                                                                               
                                      (jit_nint)0);
+       ILJitValue exceptionObject;
+       ILJitValue args[3];
+       ILJitValue returnValue;
+       ILJITLabel *catchBlock = 0;
+       jit_label_t label = jit_label_undefined;
 
 #if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS)
        if (jitCoder->flags & IL_CODER_FLAG_STATS)
        {
                ILMutexLock(globalTraceMutex);
                fprintf(stdout,
-                       "Catch: %s hasRethrow: %i\n",
+                       "Catch: %s hasRethrow: %i at %i\n",
                        ILClass_Name(classInfo),
-                       hasRethrow);
+                       hasRethrow,
+                       exception->handlerOffset);
                ILMutexUnlock(globalTraceMutex);
        }
 #endif
+
+       /* Get the current exception bject. */
+       exceptionObject = jit_insn_load_relative(jitCoder->jitFunction, thread,
+                                                                               
         offsetof(ILExecThread, thrownException),
+                                                                               
         _IL_JIT_TYPE_VPTR);
+
+       /* Push the exception object on the stack. */
+       jitCoder->jitStack[0] = exceptionObject;
+       jitCoder->stackTop = 1;
+       catchBlock = GetLabel(jitCoder, exception->handlerOffset,
+                                                                       
_IL_JIT_LABEL_STARTCATCH);
+
+       /* Look if the object can be casted to the cought exception type. */
+       args[0] = thread;
+       args[1] = exceptionObject;
+       args[2] = classTo;
+       returnValue = jit_insn_call_native(jitCoder->jitFunction,
+                                                                          
"ILRuntimeCanCastClass",
+                                                                          
ILRuntimeCanCastClass,
+                                                                          
_ILJitSignature_ILRuntimeCanCastClass,
+                                                                          
args, 3, JIT_CALL_NOTHROW);
+       jit_insn_branch_if_not(jitCoder->jitFunction, returnValue, 
&(catchBlock->label));
+       jit_insn_store_relative(jitCoder->jitFunction, thread, 
+                                                       offsetof(ILExecThread, 
thrownException),
+                                                       nullException);
+       jit_insn_call_native(jitCoder->jitFunction, "jit_exception_clear_last",
+                                                                               
                jit_exception_clear_last,
+                                                                               
                _ILJitSignature_JitExceptionClearLast,
+                                                                               
                0, 0, JIT_CALL_NOTHROW);
+       jit_insn_branch(jitCoder->jitFunction, &(catchBlock->label));
+       jit_insn_label(jitCoder->jitFunction, &label);
 }
 
 static void JITCoder_EndCatchFinally(ILCoder *coder, ILException *exception)
 {
        ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
        
-#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS)
-       if (jitCoder->flags & IL_CODER_FLAG_STATS)
+       if((exception->flags & (IL_META_EXCEPTION_FINALLY |
+                                                        
IL_META_EXCEPTION_FAULT)) != 0)
        {
-               ILMutexLock(globalTraceMutex);
-               fprintf(stdout,
-                       "EndCatchFinally: \n");
-               ILMutexUnlock(globalTraceMutex);
+       #if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS)
+               if (jitCoder->flags & IL_CODER_FLAG_STATS)
+               {
+                       ILMutexLock(globalTraceMutex);
+                       fprintf(stdout,
+                               "EndFinally: \n");
+                       ILMutexUnlock(globalTraceMutex);
+               }
+       #endif
+               jit_insn_return_from_finally(jitCoder->jitFunction);
        }
-#endif
-
-       jit_insn_return_from_finally(jitCoder->jitFunction);
 }
 
 /*
Index: pnet/engine/thread.c
diff -u pnet/engine/thread.c:1.40 pnet/engine/thread.c:1.41
--- pnet/engine/thread.c:1.40   Mon Oct 10 20:03:15 2005
+++ pnet/engine/thread.c        Sun Mar 12 17:57:06 2006
@@ -250,6 +250,12 @@
        /* Register a cleanup handler for the thread */
        ILThreadRegisterCleanup(thread, ILExecThreadCleanup);
 
+#ifdef IL_USE_JIT
+       /* Set the exception handler which converts builtin
+          libjit exceptions into clr exceptions */
+       jit_exception_set_handler(_ILJitExceptionHandler);
+#endif
+
        return execThread;
 }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]