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, 19 Mar 2006 11:29:11 +0000

CVSROOT:        /cvsroot/dotgnu-pnet
Module name:    pnet
Branch:         
Changes by:     Klaus Treichel <address@hidden> 06/03/19 11:29:11

Modified files:
        .              : ChangeLog 
        engine         : jitc.c jitc.h jitc_branch.c jitc_except.c 
                         jitc_ptr.c jitc_setup.c lib_diag.c Makefile.am 
Added files:
        engine         : jitc_diag.c jitc_labels.c 

Log message:
        2006-03-19  Klaus Treichel  <address@hidden>
        
        * engine/jitc.c: Add signature for _ILJitGetExceptionStackTrace. Pass
        structs by ref in _ILJitCompileInternal. Include the new files 
jitc_diag.c
        and jitc_labels.c. Move _ILJitGetCallingMethod to jitc_diag.c.
        
        * engine/jitc.h: Add the prototypes for the new functions in jitc_diag.c
        and include lib_defs.h.
        
        * engine/jitc_branch.c: Mobe the stack management functions to
        jitc_labels.c and rename GetLabel to _ILJitLabelGet and FindLabel to
        _ILJitLabelFind.
        
        * engine/jitc_except.c: Add support for filling the stack trace in the
        exception object and rename GetLabel to _ILJitLabelGet and FindLabel to
        _ILJitLabelFind. Fix a bug in the exception catcher.
        
        * engine/jitc_ptr.c: Fix getting the base of the array data.
        
        * engine/jitc_setup.c: Dump the functions only when argument -Z was 
passed
        to ilrun. Add a label for offset 0 at the start of the function to fix 
an
        exception bug.
        
        * engine/lib_diag.c: Add some stack support for the jit coder.
        
        * engine/Makefile.am: Add jitc_diag.c and jitc_labels.c as jitc sources.
        
        * engine/jitc_diag.c, engine/jitc_labels.c: Added.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/ChangeLog.diff?tr1=1.3307&tr2=1.3308&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc.c.diff?tr1=1.25&tr2=1.26&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc.h.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc_branch.c.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc_diag.c?rev=1.1
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc_except.c.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc_labels.c?rev=1.1
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc_ptr.c.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc_setup.c.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/lib_diag.c.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/Makefile.am.diff?tr1=1.82&tr2=1.83&r1=text&r2=text

Patches:
Index: pnet/ChangeLog
diff -u pnet/ChangeLog:1.3307 pnet/ChangeLog:1.3308
--- pnet/ChangeLog:1.3307       Fri Mar 17 10:40:32 2006
+++ pnet/ChangeLog      Sun Mar 19 11:29:11 2006
@@ -1,3 +1,32 @@
+2006-03-19  Klaus Treichel  <address@hidden>
+
+       * engine/jitc.c: Add signature for _ILJitGetExceptionStackTrace. Pass
+       structs by ref in _ILJitCompileInternal. Include the new files 
jitc_diag.c
+       and jitc_labels.c. Move _ILJitGetCallingMethod to jitc_diag.c.
+
+       * engine/jitc.h: Add the prototypes for the new functions in jitc_diag.c
+       and include lib_defs.h.
+
+       * engine/jitc_branch.c: Mobe the stack management functions to
+       jitc_labels.c and rename GetLabel to _ILJitLabelGet and FindLabel to
+       _ILJitLabelFind.
+
+       * engine/jitc_except.c: Add support for filling the stack trace in the
+       exception object and rename GetLabel to _ILJitLabelGet and FindLabel to
+       _ILJitLabelFind. Fix a bug in the exception catcher.
+ 
+       * engine/jitc_ptr.c: Fix getting the base of the array data.
+
+       * engine/jitc_setup.c: Dump the functions only when argument -Z was 
passed
+       to ilrun. Add a label for offset 0 at the start of the function to fix 
an
+       exception bug.
+
+       * engine/lib_diag.c: Add some stack support for the jit coder.
+
+       * engine/Makefile.am: Add jitc_diag.c and jitc_labels.c as jitc sources.
+
+       * engine/jitc_diag.c, engine/jitc_labels.c: Added.
+
 2006-03-17  Klaus Treichel  <address@hidden>
 
        * engine/lib_gc.c : fixed weak references
Index: pnet/engine/Makefile.am
diff -u pnet/engine/Makefile.am:1.82 pnet/engine/Makefile.am:1.83
--- pnet/engine/Makefile.am:1.82        Wed Mar  8 21:03:52 2006
+++ pnet/engine/Makefile.am     Sun Mar 19 11:29:11 2006
@@ -19,7 +19,9 @@
                                jitc_call.c \
                                jitc_const.c \
                                jitc_conv.c \
+                               jitc_diag.c \
                                jitc_except.c \
+                               jitc_labels.c \
                                jitc_locals.c \
                                jitc_obj.c \
                                jitc_ptr.c \
Index: pnet/engine/jitc.c
diff -u pnet/engine/jitc.c:1.25 pnet/engine/jitc.c:1.26
--- pnet/engine/jitc.c:1.25     Sun Mar 12 17:57:06 2006
+++ pnet/engine/jitc.c  Sun Mar 19 11:29:11 2006
@@ -118,6 +118,11 @@
 static ILJitType _ILJitSignature_ILEngineAlloc = 0;
 
 /*
+ * System_Array *_ILJitGetExceptionStackTrace(ILExecThread *thread)
+ */
+static ILJitType _ILJitSignature_ILJitGetExceptionStackTrace = 0;
+
+/*
  * static void *_ILRuntimeLookupInterfaceMethod(ILClassPrivate 
*objectClassPrivate,
  *                                                                             
                ILClass *interfaceClass,
  *                                                                             
                ILUInt32 index)
@@ -723,70 +728,6 @@
 }
 
 /*
- * Get the ILMethod for the call frame up n slots.
- * Returns 0 if the function at that slot is not a jitted function.
- */
-ILMethod *_ILJitGetCallingMethod(ILExecThread *thread, ILUInt32 frames)
-{
-       ILExecProcess *process = _ILExecThreadProcess(thread);
-       ILJITCoder *jitCoder;
-       ILJitFunction jitFunction = 0;
-       void *callFrame = jit_get_current_frame();
-       void *returnAddress = 0;
-       void *exceptionHandler = 0;
-
-       if(!process)
-       {
-               return 0;
-       }
-       if(!(jitCoder = _ILCoderToILJITCoder(process->coder)))
-       {
-               return 0;
-       }
-       /* Find the first callframe that has a jitFunction assigned. */
-       /* This callframe is usually the jitFunction for the internalcall. */
-       do {
-               returnAddress = jit_get_return_address(callFrame);
-               if(!(callFrame = jit_get_next_frame_address(callFrame)))
-               {
-                       /* Could not get the next frame address. */
-                       return 0;
-               }
-               if((jitFunction = jit_function_from_pc(jitCoder->context,
-                                                                               
          returnAddress,
-                                                                               
          &exceptionHandler)))
-               {
-                       break;
-               }
-
-       } while(1);
-
-       /* callFrame is the first frame with a jitFunction assigned. */
-       /* Now we have to find the return address frames down the stack */
-       /* with a jitFunction assigned. */
-       do {
-               returnAddress = jit_get_return_address(callFrame);
-               if((jitFunction = jit_function_from_pc(jitCoder->context,
-                                                                               
          returnAddress,
-                                                                               
          &exceptionHandler)))
-               {
-                       if(frames == 0)
-                       {
-                               break;
-                       }
-               }
-               frames--;
-               if(!(callFrame = jit_get_next_frame_address(callFrame)))
-               {
-                       /* Could not get the next frame address. */
-                       return 0;
-               }
-       } while(1);
-       /* And we return the ILMethod assigned to that jitFunction. */
-       return (ILMethod *)jit_function_get_meta(jitFunction, 
IL_JIT_META_METHOD);
-}
-
-/*
  * Perform a class cast, taking arrays into account.
  */
 ILInt32 ILRuntimeCanCastClass(ILExecThread *thread, ILObject *object, ILClass 
*toClass)
@@ -1309,6 +1250,14 @@
                return 0;
        }
 
+       args[0] = _IL_JIT_TYPE_VPTR;
+       returnType = _IL_JIT_TYPE_VPTR;
+       if(!(_ILJitSignature_ILJitGetExceptionStackTrace =
+               jit_type_create_signature(IL_JIT_CALLCONV_CDECL, returnType, 
args, 1, 1)))
+       {
+               return 0;
+       }
+
        return 1;
 }
 /*
@@ -1583,6 +1532,10 @@
  */
 static int _ILJitCompileInternal(jit_function_t func, ILMethod *method, void 
*nativeFunction)
 {
+#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS) && 
defined(_IL_JIT_ENABLE_DEBUG)
+       ILExecThread *_thread = ILExecThreadCurrent();
+       ILJITCoder *jitCoder = (ILJITCoder 
*)(_ILExecThreadProcess(_thread)->coder);
+#endif
        ILType *ilSignature = ILMethod_Signature(method);
        ILType *type = ILTypeGetEnumType(ILTypeGetParam(ilSignature, 0));
        ILJitType signature = jit_function_get_signature(func);
@@ -1595,43 +1548,60 @@
        char *methodName = 0;
        jit_label_t label = jit_label_undefined;
        ILJitValue thrownException = 0;
+       ILUInt32 current;
 
 #if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS) && 
defined(_IL_JIT_ENABLE_DEBUG)
        methodName = _ILJitFunctionGetMethodName(func);
-       ILMutexLock(globalTraceMutex);
-       fprintf(stdout, "CompileInternalMethod: %s\n", methodName);
-       ILMutexUnlock(globalTraceMutex);
+       if(jitCoder->flags & IL_CODER_FLAG_STATS)
+       {
+               ILMutexLock(globalTraceMutex);
+               fprintf(stdout, "CompileInternalMethod: %s\n", methodName);
+               ILMutexUnlock(globalTraceMutex);
+       }
 #endif
 
-       if(ILType_IsValueType(type))
+       /* We need to set the method member in the ILExecThread == arg[0]. */
+       if(numParams > 0)
        {
+               ILJitValue paramValue;
+               ILJitType paramType;
+               ILJitType jitParamTypes[totalParams + 1];
+               ILJitValue jitParams[totalParams + 1];
+               ILUInt32 param = 1;
+
                /* We need to create a new Signature for the native Call with */
-               /* a pointer to the return value as second arg after the 
ILExecThread. */
-               ++totalParams;
-               ILJitType jitParamTypes[totalParams];
-               ILUInt32 current;
-               
+               /* an additional argument when the return value is a value type 
*/
+               /* and pointers for structs. */
                jitParamTypes[0] = jit_type_get_param(signature, 0); 
-               jitParamTypes[1] = _IL_JIT_TYPE_VPTR;
-               for(current = 1; current < numParams; current++)
+               if(ILType_IsValueType(type))
                {
-                       jitParamTypes[current + 1] = 
jit_type_get_param(signature, current); 
+                       ++totalParams;
+                       jitParamTypes[1] = _IL_JIT_TYPE_VPTR;
+                       returnValue = jit_value_create(func, returnType);
+                       returnType = _IL_JIT_TYPE_VOID;
+                       hasStructReturn = 1;
+                       ++param;
+               }
+               for(current = 1; current < numParams; ++current)
+               {
+                       paramType = jit_type_get_param(signature, current);
+       
+                       if(jit_type_is_struct(paramType))
+                       {
+                               jitParamTypes[param] = _IL_JIT_TYPE_VPTR;
+                       }
+                       else
+                       {
+                               jitParamTypes[param] = paramType;
+                       }
+                       ++param;
                }
                signature = jit_type_create_signature(IL_JIT_CALLCONV_CDECL,
-                                                                               
          _IL_JIT_TYPE_VOID,
+                                                                               
          returnType,
                                                                                
          jitParamTypes,
                                                                                
          totalParams, 1);
-               returnValue = jit_value_create(func, returnType);
-               hasStructReturn = 1;
-       }
 
-       /* We need to set the method member in the ILExecThread == arg[0]. */
-       if(numParams > 0)
-       {
-               ILJitValue jitParams[totalParams];
-               ILUInt32 current;
-               ILUInt32 param = 1;
-               
+               param = 1;
                jitParams[0] = jit_value_get_param(func, 0);
                if(hasStructReturn)
                {
@@ -1639,12 +1609,22 @@
                        ++param;
 
                }
-               for(current = 1; current < numParams; current++)
+               for(current = 1; current < numParams; ++current)
                {
-                       if(!(jitParams[param] = jit_value_get_param(func, 
current)))
+                       if(!(paramValue = jit_value_get_param(func, current)))
                        {
                                return JIT_RESULT_OUT_OF_MEMORY;
                        }
+                       paramType = jit_value_get_type(paramValue);
+                       if(jit_type_is_struct(paramType))
+                       {
+                               jit_value_set_addressable(paramValue);
+                               jitParams[param] = jit_insn_address_of(func, 
paramValue);
+                       }
+                       else
+                       {
+                               jitParams[param] = paramValue;
+                       }       
                        ++param;
                }
                _ILJitSetMethodInThread(func, jitParams[0], method);
@@ -1660,10 +1640,12 @@
                                                                 signature,
                                                                 jitParams, 
totalParams, 0);
                }
+               jit_type_free(signature);
        }
        else
        {
-               returnValue = jit_insn_call_native(func, methodName, 
nativeFunction, signature, 0, 0, 0);
+               returnValue = jit_insn_call_native(func, methodName, 
nativeFunction,
+                                                                               
   signature, 0, 0, 0);
        }
        thrownException = jit_insn_load_relative(func, thread,
                                                                        
offsetof(ILExecThread, thrownException),
@@ -1671,7 +1653,33 @@
        jit_insn_branch_if(func, thrownException, &label);
        jit_insn_return(func, returnValue);     
        jit_insn_label(func, &label);
+       jit_insn_call_native(func, "jit_exception_clear_last",
+                                                               
jit_exception_clear_last,
+                                                               
_ILJitSignature_JitExceptionClearLast,
+                                                               0, 0, 
JIT_CALL_NOTHROW);
        jit_insn_throw(func, thrownException);
+#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS) && 
defined(_IL_JIT_ENABLE_DEBUG)
+#ifdef _IL_JIT_DUMP_FUNCTION
+       if(jitCoder->flags & IL_CODER_FLAG_STATS)
+       {
+               ILMutexLock(globalTraceMutex);
+               jit_dump_function(stdout, func, methodName);
+               ILMutexUnlock(globalTraceMutex);
+       }
+#endif
+#ifdef _IL_JIT_DISASSEMBLE_FUNCTION
+       if(jitCoder->flags & IL_CODER_FLAG_STATS)
+       {
+               if(!jit_function_compile(func))
+               {
+                       return IL_CODER_END_TOO_BIG;
+               }
+               ILMutexLock(globalTraceMutex);
+               jit_dump_function(stdout, func, methodName);
+               ILMutexUnlock(globalTraceMutex);
+       }
+#endif
+#endif
        return JIT_RESULT_OK;
 }
 
@@ -2308,7 +2316,9 @@
        return 0;
 }
 
+#include "jitc_diag.c"
 #include "jitc_locals.c"
+#include "jitc_labels.c"
 
 /*
  * Include the rest of the JIT conversion routines from other files.
Index: pnet/engine/jitc.h
diff -u pnet/engine/jitc.h:1.10 pnet/engine/jitc.h:1.11
--- pnet/engine/jitc.h:1.10     Sun Mar 12 17:57:06 2006
+++ pnet/engine/jitc.h  Sun Mar 19 11:29:11 2006
@@ -24,6 +24,7 @@
 #ifdef IL_USE_JIT
 
 #include "jit/jit.h"
+#include "lib_defs.h"
 
 /*
  * Map the native IL types to JIT types.
@@ -156,6 +157,17 @@
 ILMethod *_ILJitGetCallingMethod(ILExecThread *thread, ILUInt32 frames);
 
 /*
+ * Get the number of stack frames associated with an ILMethod on the current
+ * call stack.
+ */
+ILInt32 _ILJitDiagNumFrames(ILExecThread *thread);
+
+/*
+ * Get the current PackedStackFrame.
+ */
+System_Array *_ILJitGetExceptionStackTrace(ILExecThread *thread);
+
+/*
  * Create the class/struct representation of a clr type for libjit.
  * and store the type in classPrivate.
  * Returns the jit type on success else 0
@@ -194,6 +206,7 @@
  */
 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.10 pnet/engine/jitc_branch.c:1.11
--- pnet/engine/jitc_branch.c:1.10      Sun Mar 12 17:57:06 2006
+++ pnet/engine/jitc_branch.c   Sun Mar 19 11:29:11 2006
@@ -21,177 +21,12 @@
 #ifdef IL_JITC_CODE
 
 /*
- * Save the current jitStack status to the label.
- * This is done when the label is referenced the first time.
- */
-static int _ILJitLabelSaveStack(ILJITCoder *coder, ILJITLabel *label)
-{
-       if(((label->labelType & (_IL_JIT_LABEL_NORMAL |
-                                                        
_IL_JIT_LABEL_STARTCATCH)) != 0) &&
-               (coder->stackTop > 0))
-       {
-               int current = 0;
-               ILJitValue *stack = ILMemStackAllocItem(&(coder->stackStates),
-                                                                       
coder->stackTop * sizeof(ILJitValue));
-               if(!stack)
-               {
-                       return 0;
-               }
-               /* Now save the current stack state. */
-               for(current = 0; current < coder->stackTop; current++)
-               {
-                       ILJitValue value = coder->jitStack[current];
-
-                       if(jit_value_is_constant(value))
-                       {
-                               /* We have to handle this case different. */
-                               /* Create a local value of the type of the 
constant. */
-                               ILJitValue temp = 
jit_value_create(coder->jitFunction,
-                                                                               
                   jit_value_get_type(value));
-                               /* and store the value o the constant in the 
new temporary. */
-                               jit_insn_store(coder->jitFunction, temp, value);
-                               /* Now replace the constant with the new 
temporary. */
-                               coder->jitStack[current] = temp;
-                       }
-                       else
-                       {
-                               if(_ILJitValueIsArgOrLocal(coder, 
coder->jitStack[current]))
-                               {
-                                       coder->jitStack[current] = 
jit_insn_dup(coder->jitFunction,
-                                                                               
                        coder->jitStack[current]);
-                               }
-                       }
-                       stack[current] = coder->jitStack[current];
-               }
-               label->jitStack = stack;
-               label->stackSize = coder->stackTop;
-       }
-       return 1;
-}
-
-/*
- * Merge the current jitStack status with the one saved in the label.
- */
-static int _ILJitLabelMergeStack(ILJITCoder *coder, ILJITLabel *label)
-{
-       if(label->labelType & (_IL_JIT_LABEL_NORMAL | _IL_JIT_LABEL_STARTCATCH))
-       {
-               /* Verify that the stack sizes match. */
-               if(coder->stackTop != label->stackSize)
-               {
-                       fprintf(stdout, "Stack sizes don't match!\n");
-                       /* return 0; */
-               }
-               if(coder->stackTop > 0)
-               {
-                       int numItems = coder->stackTop > label->stackSize ?
-                                                               
label->stackSize : coder->stackTop;
-                       int current = 0;
-
-                       /* Now save the current stack state. */
-                       for(current = 0; current < numItems; current++)
-                       {
-                               ILJitValue value = coder->jitStack[current];
-
-                               if(value != label->jitStack[current])
-                               {
-                                       /* store the changed value to the saved 
stack. */
-                                       jit_insn_store(coder->jitFunction, 
label->jitStack[current],
-                                                                  value);
-                               }
-                       }
-               }
-       }
-       return 1;
-}
-
-/*
- * Restore the stack from the label to the coder.
- */
-static void _ILJitLabelRestoreStack(ILJITCoder *coder, ILJITLabel *label)
-{
-       if(label->stackSize > 0)
-       {
-               int current = 0;
-
-               /* Now restore the stack state. */
-               for(current = 0; current < label->stackSize; current++)
-               {
-                       coder->jitStack[current] = label->jitStack[current];
-               }
-       }
-       coder->stackTop = label->stackSize;
-}
-
-/*
- * Look for an existing label for the specified IL address.
- * Returns 0 if there is no label for this address.
- */
-static ILJITLabel *FindLabel(ILJITCoder *coder, ILUInt32 address)
-{
-       ILJITLabel *label = coder->labelList;
-
-       while(label != 0)
-       {
-               if(label->address == address)
-               {
-                       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))
-                       {
-                               coder->labelOutOfMemory = 1;
-                               return 0;
-                       }
-                       label->next = coder->labelList;
-                       coder->labelList = label;
-               }
-               else
-               {
-                       coder->labelOutOfMemory = 1;
-               }
-       }
-       else
-       {
-               if(!_ILJitLabelMergeStack(coder, label))
-               {
-                       /* We have a stack size mismatch!!! */
-                       coder->labelOutOfMemory = 1;
-                       return 0;
-               }
-       }
-       return label;
-}
-
-/*
  * Handle a label.
  */
 static void JITCoder_Label(ILCoder *coder, ILUInt32 offset)
 {
        ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
-       ILJITLabel *label = GetLabel(jitCoder, offset, _IL_JIT_LABEL_NORMAL);
+       ILJITLabel *label = _ILJitLabelGet(jitCoder, offset, 
_IL_JIT_LABEL_NORMAL);
 
        if(label)
        {
@@ -358,7 +193,7 @@
                case IL_OP_LEAVE_S:
                {
                        /* Unconditional branch */
-                       label = GetLabel(jitCoder, dest, _IL_JIT_LABEL_NORMAL);
+                       label = _ILJitLabelGet(jitCoder, dest, 
_IL_JIT_LABEL_NORMAL);
 
                        jit_insn_branch(jitCoder->jitFunction, &(label->label));
                }
@@ -370,7 +205,7 @@
                        /* Branch if the top-most stack item is true */
                        value1 = jitCoder->jitStack[jitCoder->stackTop - 1];
                        JITC_ADJUST(jitCoder, -1);
-                       label = GetLabel(jitCoder, dest, _IL_JIT_LABEL_NORMAL);
+                       label = _ILJitLabelGet(jitCoder, dest, 
_IL_JIT_LABEL_NORMAL);
 
                        jit_insn_branch_if(jitCoder->jitFunction, value1, 
&(label->label));
                }
@@ -382,7 +217,7 @@
                        /* Branch if the top-most stack item is false */
                        value1 = jitCoder->jitStack[jitCoder->stackTop - 1];
                        JITC_ADJUST(jitCoder, -1);
-                       label = GetLabel(jitCoder, dest, _IL_JIT_LABEL_NORMAL);
+                       label = _ILJitLabelGet(jitCoder, dest, 
_IL_JIT_LABEL_NORMAL);
 
                        jit_insn_branch_if_not(jitCoder->jitFunction, value1,
                                                                        
&(label->label));
@@ -394,7 +229,7 @@
                        value1 = jitCoder->jitStack[jitCoder->stackTop - 2];
                        value2 = jitCoder->jitStack[jitCoder->stackTop - 1];
                        JITC_ADJUST(jitCoder, -2);
-                       label = GetLabel(jitCoder, dest, _IL_JIT_LABEL_NORMAL);
+                       label = _ILJitLabelGet(jitCoder, dest, 
_IL_JIT_LABEL_NORMAL);
 
                        switch(opcode)
                        {
@@ -528,7 +363,7 @@
 static void JITCoder_SwitchEntry(ILCoder *_coder, ILUInt32 dest)
 {
        ILJITCoder *jitCoder = _ILCoderToILJITCoder(_coder);
-       ILJITLabel *label = GetLabel(jitCoder, dest, _IL_JIT_LABEL_NORMAL);
+       ILJITLabel *label = _ILJitLabelGet(jitCoder, dest, 
_IL_JIT_LABEL_NORMAL);
        
        ILJitValue constant = 
jit_value_create_nint_constant(jitCoder->jitFunction,
                                                                                
                                 jit_type_nint,
Index: pnet/engine/jitc_except.c
diff -u pnet/engine/jitc_except.c:1.4 pnet/engine/jitc_except.c:1.5
--- pnet/engine/jitc_except.c:1.4       Sun Mar 12 17:57:06 2006
+++ pnet/engine/jitc_except.c   Sun Mar 19 11:29:11 2006
@@ -21,6 +21,36 @@
 #ifdef IL_JITC_CODE
 
 /*
+ * Find the "stackTrace" field within "System.Exception" and then set.
+ */
+static void _ILJitFindAndSetStackTrace(ILJITCoder *jitCoder, ILJitValue 
exception)
+{
+       ILExecThread *_thread = ILExecThreadCurrent();
+       ILJitValue thread = jit_value_get_param(jitCoder->jitFunction,0);
+       ILJitValue trace;
+       ILField *field;
+
+       /* Find the "stackTrace" field within the "Exception" class */
+       field = ILExecThreadLookupField
+                       (_thread, "System.Exception", "stackTrace",
+                        "[vSystem.Diagnostics.PackedStackFrame;");
+       if(field)
+       {
+               /* Get the stack trace and pop the frame */
+               trace = jit_insn_call_native(jitCoder->jitFunction,
+                                                                        
"_ILJitGetExceptionStackTrace",
+                                                                        
_ILJitGetExceptionStackTrace,
+                                                                        
_ILJitSignature_ILJitGetExceptionStackTrace,
+                                                                        
&thread, 1, JIT_CALL_NOTHROW);
+
+               /* Write the stack trace into the object */
+               jit_insn_store_relative(jitCoder->jitFunction, exception,
+                                                               field->offset, 
trace);
+       }
+}
+
+
+/*
  * Set up exception handling for the current method.
  */
 static void JITCoder_SetupExceptions(ILCoder *_coder, ILException *exceptions,
@@ -60,8 +90,8 @@
                                ILMutexUnlock(globalTraceMutex);
                        }
                #endif
-                       GetLabel(jitCoder, exceptions->handlerOffset,
-                                                          
_IL_JIT_LABEL_STARTFINALLY);
+                       _ILJitLabelGet(jitCoder, exceptions->handlerOffset,
+                                                                        
_IL_JIT_LABEL_STARTFINALLY);
                }
                else if ((exceptions->flags & IL_META_EXCEPTION_FILTER) == 0)
                {
@@ -82,8 +112,8 @@
                #endif
                        jitCoder->jitStack[0] = exception;
                        jitCoder->stackTop = 1;
-                       GetLabel(jitCoder, exceptions->handlerOffset,
-                                                          
_IL_JIT_LABEL_STARTCATCH);
+                       _ILJitLabelGet(jitCoder, exceptions->handlerOffset,
+                                                                        
_IL_JIT_LABEL_STARTCATCH);
                        jitCoder->stackTop = 0;
                }
                exceptions = exceptions->next;
@@ -115,6 +145,9 @@
                jit_insn_store_relative(jitCoder->jitFunction, thread,
                                                                
offsetof(ILExecThread, thrownException), 
                                                                exception);
+               /* Set the stacktrace in the exception. */
+               _ILJitFindAndSetStackTrace(jitCoder, exception);
+
                jit_insn_throw(jitCoder->jitFunction, exception);
                JITC_ADJUST(jitCoder, -1);
        }
@@ -210,8 +243,11 @@
                
                jitCoder->isInCatcher = 1;
        }
-       /* Insert the jump target for the previous block. */
-       jit_insn_label(jitCoder->jitFunction, &(jitCoder->nextBlock));
+       else
+       {
+               /* 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;
 
@@ -223,8 +259,8 @@
        }
        else
        {
-               ILJITLabel *startLabel = FindLabel(jitCoder, start);;
-               ILJITLabel *endLabel = FindLabel(jitCoder, end);
+               ILJITLabel *startLabel = _ILJitLabelFind(jitCoder, start);;
+               ILJITLabel *endLabel = _ILJitLabelFind(jitCoder, end);
                if(startLabel && endLabel)
                {
                        
jit_insn_branch_if_pc_not_in_range(jitCoder->jitFunction,
@@ -295,8 +331,8 @@
        /* Push the exception object on the stack. */
        jitCoder->jitStack[0] = exceptionObject;
        jitCoder->stackTop = 1;
-       catchBlock = GetLabel(jitCoder, exception->handlerOffset,
-                                                                       
_IL_JIT_LABEL_STARTCATCH);
+       catchBlock = _ILJitLabelGet(jitCoder, exception->handlerOffset,
+                                                                               
  _IL_JIT_LABEL_STARTCATCH);
 
        /* Look if the object can be casted to the cought exception type. */
        args[0] = thread;
@@ -307,7 +343,7 @@
                                                                           
ILRuntimeCanCastClass,
                                                                           
_ILJitSignature_ILRuntimeCanCastClass,
                                                                           
args, 3, JIT_CALL_NOTHROW);
-       jit_insn_branch_if_not(jitCoder->jitFunction, returnValue, 
&(catchBlock->label));
+       jit_insn_branch_if_not(jitCoder->jitFunction, returnValue, &label);
        jit_insn_store_relative(jitCoder->jitFunction, thread, 
                                                        offsetof(ILExecThread, 
thrownException),
                                                        nullException);
@@ -345,7 +381,8 @@
 static void JITCoder_Finally(ILCoder *coder, ILException *exception, int dest)
 {
        ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
-       ILJITLabel *label = GetLabel(jitCoder, dest, 
_IL_JIT_LABEL_STARTFINALLY);
+       ILJITLabel *label = _ILJitLabelGet(jitCoder, dest,
+                                                                          
_IL_JIT_LABEL_STARTFINALLY);
 
 #if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS)
        if (jitCoder->flags & IL_CODER_FLAG_STATS)
Index: pnet/engine/jitc_ptr.c
diff -u pnet/engine/jitc_ptr.c:1.6 pnet/engine/jitc_ptr.c:1.7
--- pnet/engine/jitc_ptr.c:1.6  Wed Mar  8 21:09:00 2006
+++ pnet/engine/jitc_ptr.c      Sun Mar 19 11:29:11 2006
@@ -25,7 +25,7 @@
  */
 static ILJitValue GetArrayBase(ILJITCoder *coder, ILJitValue array)
 {
-       return jit_insn_add_relative(coder->jitFunction, array, sizeof(void *));
+       return jit_insn_add_relative(coder->jitFunction, array, 
sizeof(System_Array));
 }
 
 /*
Index: pnet/engine/jitc_setup.c
diff -u pnet/engine/jitc_setup.c:1.11 pnet/engine/jitc_setup.c:1.12
--- pnet/engine/jitc_setup.c:1.11       Wed Mar  8 21:03:52 2006
+++ pnet/engine/jitc_setup.c    Sun Mar 19 11:29:11 2006
@@ -27,6 +27,7 @@
                                                  ILMethod *method, 
ILMethodCode *code)
 {
        ILJITCoder *coder = ((ILJITCoder *)_coder);
+       ILJITLabel *label0;
 
        /* Record the current jitted function. */
        coder->jitFunction = (ILJitFunction)(method->userData);
@@ -70,6 +71,10 @@
        /* Reset the isInCatcher flag. */
        coder->isInCatcher = 0;
 
+       /* Set the label for the start of the function. */
+       label0 = _ILJitLabelGet(coder, 0, _IL_JIT_LABEL_NORMAL);
+       jit_insn_label(coder->jitFunction, &(label0->label));
+
        /* Set the current method in the thread. */
        _ILJitSetMethodInThread(coder->jitFunction, 
                                                        
jit_value_get_param(coder->jitFunction, 0),
@@ -162,18 +167,24 @@
 
 #if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS) && 
defined(_IL_JIT_ENABLE_DEBUG)
 #ifdef _IL_JIT_DUMP_FUNCTION
-       ILMutexLock(globalTraceMutex);
-       jit_dump_function(stdout, jitCoder->jitFunction, methodName);
-       ILMutexUnlock(globalTraceMutex);
+       if(jitCoder->flags & IL_CODER_FLAG_STATS)
+       {
+               ILMutexLock(globalTraceMutex);
+               jit_dump_function(stdout, jitCoder->jitFunction, methodName);
+               ILMutexUnlock(globalTraceMutex);
+       }
 #endif
 #ifdef _IL_JIT_DISASSEMBLE_FUNCTION
-       if(!jit_function_compile(jitCoder->jitFunction))
+       if(jitCoder->flags & IL_CODER_FLAG_STATS)
        {
-               return IL_CODER_END_TOO_BIG;
+               if(!jit_function_compile(jitCoder->jitFunction))
+               {
+                       return IL_CODER_END_TOO_BIG;
+               }
+               ILMutexLock(globalTraceMutex);
+               jit_dump_function(stdout, jitCoder->jitFunction, methodName);
+               ILMutexUnlock(globalTraceMutex);
        }
-       ILMutexLock(globalTraceMutex);
-       jit_dump_function(stdout, jitCoder->jitFunction, methodName);
-       ILMutexUnlock(globalTraceMutex);
 #endif
 #endif
        return IL_CODER_END_OK;
Index: pnet/engine/lib_diag.c
diff -u pnet/engine/lib_diag.c:1.11 pnet/engine/lib_diag.c:1.12
--- pnet/engine/lib_diag.c:1.11 Mon May 26 04:29:13 2003
+++ pnet/engine/lib_diag.c      Sun Mar 19 11:29:11 2006
@@ -269,12 +269,17 @@
 ILInt32 _IL_StackFrame_InternalGetTotalFrames(ILExecThread *thread)
 {
        ILInt32 num = 0;
+#ifdef IL_USE_CVM
        ILCallFrame *frame = _ILGetCallFrame(thread, 0);
        while(frame != 0)
        {
                ++num;
                frame = _ILGetNextCallFrame(thread, frame);
        }
+#endif
+#ifdef IL_USE_JIT
+       num = _ILJitDiagNumFrames(thread);
+#endif
        return num;
 }
 
@@ -284,6 +289,7 @@
 void _IL_StackFrame_InternalGetMethod(ILExecThread *thread,
                                                                          void 
*result, ILInt32 skipFrames)
 {
+#ifdef IL_USE_CVM
        ILCallFrame *frame = _ILGetCallFrame(thread, skipFrames);
        if(frame)
        {
@@ -293,6 +299,10 @@
        {
                *((ILMethod **)result) = 0;
        }
+#endif
+#ifdef IL_USE_JIT
+       *(ILMethod **)result = _ILJitGetCallingMethod(thread, skipFrames);
+#endif
 }
 
 /*
@@ -403,6 +413,7 @@
  */
 System_Array *_IL_StackFrame_GetExceptionStackTrace(ILExecThread *thread)
 {
+#ifdef IL_USE_CVM
 #ifdef IL_CONFIG_REFLECTION
        ILInt32 num;
        ILCallFrame *frame;
@@ -489,6 +500,10 @@
 #else
        return 0;
 #endif
+#endif
+#ifdef IL_USE_JIT
+       return _ILJitGetExceptionStackTrace(thread);
+#endif
 }
 
 #else /* !IL_CONFIG_DEBUG_LINES */




reply via email to

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