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/call.c engine/jitc.c en...


From: Klaus Treichel
Subject: [dotgnu-pnet-commits] pnet ./ChangeLog engine/call.c engine/jitc.c en...
Date: Mon, 01 May 2006 17:30:50 +0000

CVSROOT:        /cvsroot/dotgnu-pnet
Module name:    pnet
Branch:         
Changes by:     Klaus Treichel <address@hidden> 06/05/01 17:30:50

Modified files:
        .              : ChangeLog 
        engine         : call.c jitc.c jitc.h jitc_alloc.c jitc_arith.c 
                         jitc_call.c jitc_except.c jitc_locals.c 
                         jitc_obj.c jitc_ptr.c jitc_setup.c lib_defs.h 

Log message:
        2006-05-01  Klaus Treichel  <address@hidden>
        
        * engine/call.c: Add support for the thread not included in the 
signature.
        
        * engine/jitc.c, engine/jitc.h, engine/jitc_alloc.c, 
engine/jitc_arith.c,
        engine/jitc_call.c, engine/jitc_except.c, engine/jitc_locals.c,
        engine/jitc_obj.c, engine/jitc_ptr.c, engine/jitc_setup.c: Add support 
for
        the thread not included in the signature. Remove as many thread 
accesses as
        possible. Add more exception support. Fix Bugs and improve performance.
        
        * engine/lib_defs.h: Add declaration of the ECMA specific part of the
        System.Exception class.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/ChangeLog.diff?tr1=1.3314&tr2=1.3315&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/call.c.diff?tr1=1.41&tr2=1.42&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc.c.diff?tr1=1.30&tr2=1.31&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc.h.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc_alloc.c.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc_arith.c.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc_call.c.diff?tr1=1.13&tr2=1.14&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc_except.c.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc_locals.c.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc_obj.c.diff?tr1=1.16&tr2=1.17&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc_ptr.c.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc_setup.c.diff?tr1=1.13&tr2=1.14&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/lib_defs.h.diff?tr1=1.27&tr2=1.28&r1=text&r2=text

Patches:
Index: pnet/ChangeLog
diff -u pnet/ChangeLog:1.3314 pnet/ChangeLog:1.3315
--- pnet/ChangeLog:1.3314       Mon Apr 17 17:39:44 2006
+++ pnet/ChangeLog      Mon May  1 17:30:49 2006
@@ -1,3 +1,16 @@
+2006-05-01  Klaus Treichel  <address@hidden>
+
+       * engine/call.c: Add support for the thread not included in the 
signature.
+
+       * engine/jitc.c, engine/jitc.h, engine/jitc_alloc.c, 
engine/jitc_arith.c,
+       engine/jitc_call.c, engine/jitc_except.c, engine/jitc_locals.c,
+       engine/jitc_obj.c, engine/jitc_ptr.c, engine/jitc_setup.c: Add support 
for
+       the thread not included in the signature. Remove as many thread 
accesses as
+       possible. Add more exception support. Fix Bugs and improve performance.
+
+       * engine/lib_defs.h: Add declaration of the ECMA specific part of the
+       System.Exception class.
+
 2006-04-17  Klaus Treichel  <address@hidden>
 
        * engine/Makefile.am: Add jitc_alloc.c to jitc.o sources.
Index: pnet/engine/call.c
diff -u pnet/engine/call.c:1.41 pnet/engine/call.c:1.42
--- pnet/engine/call.c:1.41     Sun Apr  2 13:06:12 2006
+++ pnet/engine/call.c  Mon May  1 17:30:50 2006
@@ -954,10 +954,16 @@
 {
        ILType *signature = ILMethod_Signature(method);
        ILUInt32 numParams = ILTypeNumParams(signature);
+#ifdef IL_JIT_THREAD_IN_SIGNATURE
        /* We need an additional parameter for the ILExecThread. */
        ILUInt32 totalParams = numParams + 1;
        /* current arg in the parameter Array. */
        ILUInt32 current = 1;
+#else
+       ILUInt32 totalParams = numParams;
+       /* current arg in the parameter Array. */
+       ILUInt32 current = 0;
+#endif
        /* Some infos that we'll need later. */
        ILClass *info = ILMethod_Owner(method);
        /* Flag if this is an array or string constructor. */
@@ -997,8 +1003,10 @@
        /* We take the biggest possible arg type here so we don't need to 
compute it. */
        ILNativeFloat jitArgsBuffer[numParams];
 
+#ifdef IL_JIT_THREAD_IN_SIGNATURE
        /* Store the ILExecThread instance in arg[0]. */
        jitArgs[0] = &thread;
+#endif
 
        if(ILType_HasThis(signature))
        {
@@ -1014,7 +1022,11 @@
                                {
                                        return 1;
                                }
+                       #ifdef IL_JIT_THREAD_IN_SIGNATURE
                                jitArgs[1] = &_this;
+                       #else
+                               jitArgs[0] = &_this;
+                       #endif
                                current++;
                        }
                }
@@ -1032,7 +1044,11 @@
                if(isCtor && !isArrayOrString && result)
                {
                        /* Return the this pointer. */
+               #ifdef IL_JIT_THREAD_IN_SIGNATURE
                        *(void **)result = *(void **)(jitArgs[1]);
+               #else
+                       *(void **)result = *(void **)(jitArgs[0]);
+               #endif
                }
                return 0;
        }
Index: pnet/engine/jitc.c
diff -u pnet/engine/jitc.c:1.30 pnet/engine/jitc.c:1.31
--- pnet/engine/jitc.c:1.30     Mon Apr 17 17:39:44 2006
+++ pnet/engine/jitc.c  Mon May  1 17:30:50 2006
@@ -112,10 +112,27 @@
 static ILJitType _ILJitTypedRef = 0;
 
 /*
+ * Allocate memory for an object that contains object references.
+ */
+static ILObject *_ILJitAlloc(ILClass *classInfo, ILUInt32 size);
+
+/*
+ * Allocate memory for an object that does not contain any object references.
+ */
+static ILObject *_ILJitAllocAtomic(ILClass *classInfo, ILUInt32 size);
+
+/*
  * Definition of signatures of internal functions used by jitted code.
  * They have to be kept in sync wirh the corresponding engine funcions.
  */
 
+#ifndef IL_JIT_THREAD_IN_SIGNATURE
+/*
+ * ILExecThread *ILExecThreadCurrent()
+ */
+static ILJitType _ILJitSignature_ILExecThreadCurrent = 0;
+#endif
+
 /*
  * ILObject *_ILJitAlloc(ILClass *classInfo, ILUInt32 size)
  */
@@ -127,6 +144,22 @@
 static ILJitType _ILJitSignature_ILJitGetExceptionStackTrace = 0;
 
 /*
+ * void ILRuntimeExceptionThrow(ILObject *exception)
+ */
+static ILJitType _ILJitSignature_ILRuntimeExceptionThrow = 0;
+
+/*
+ * void ILRuntimeExceptionThrowClass(ILClass *classInfo)
+ */
+static ILJitType _ILJitSignature_ILRuntimeExceptionThrowClass = 0;
+
+/*
+ * void ILRuntimeExceptionThrowOutOfMemory()
+ */
+static ILJitType _ILJitSignature_ILRuntimeExceptionThrowOutOfMemory = 0;
+
+
+/*
  * static void *_ILRuntimeLookupInterfaceMethod(ILClassPrivate 
*objectClassPrivate,
  *                                                                             
                ILClass *interfaceClass,
  *                                                                             
                ILUInt32 index)
@@ -134,7 +167,7 @@
 static ILJitType _ILJitSignature_ILRuntimeLookupInterfaceMethod = 0;
 
 /*
- * ILInt32 ILRuntimeCanCastClass(ILExecThread *thread, ILObject *object, 
ILClass *toClass)
+ * ILInt32 ILRuntimeCanCastClass(ILMethod *method, ILObject *object, ILClass 
*toClass)
  *
  */
 static ILJitType _ILJitSignature_ILRuntimeCanCastClass = 0;
@@ -151,11 +184,6 @@
 static ILJitType _ILJitSignature_ILRuntimeGetThreadStatic = 0;
 
 /*
- * void jit_exception_builtin(int exception_type)
- */
-static ILJitType _ILJitSignature_JitExceptionBuiltin = 0;
-
-/*
  * void jit_exception_clear_last()
  */
 static ILJitType _ILJitSignature_JitExceptionClearLast = 0;
@@ -280,6 +308,11 @@
        int                             isInCatcher;
        jit_label_t     nextBlock;
        jit_label_t     rethrowBlock;
+
+#ifndef IL_JIT_THREAD_IN_SIGNATURE
+       /* cache for the current thread. */
+       ILJitValue              thread;
+#endif
 };
 
 /*
@@ -300,6 +333,58 @@
  */
 static ILJitValue _ILJitAllocObjectGen(ILJITCoder *jitCoder, ILClass 
*classInfo);
 
+#ifdef IL_JIT_THREAD_IN_SIGNATURE
+#define _ILJitCoderGetThread(coder)            
jit_value_get_param((coder)->jitFunction, 0)
+#define _ILJitFunctionGetThread(func)  jit_value_get_param((func), 0)
+#else
+static ILJitValue _ILJitFunctionGetThread(ILJitFunction func)
+{
+       return jit_insn_call_native(func, "ILExecThreadCurrent",
+                                                                               
ILExecThreadCurrent,
+                                                                               
_ILJitSignature_ILExecThreadCurrent,
+                                                                               
0, 0, JIT_CALL_NOTHROW);
+}
+
+static ILJitValue _ILJitCoderGetThread(ILJITCoder *jitCoder)
+{
+       if(!(jitCoder->thread))
+       {
+               ILJitValue thread;
+
+               if(!(jitCoder->isInCatcher))
+               {
+                       jit_label_t startLabel = jit_label_undefined;
+                       jit_label_t endLabel = jit_label_undefined;
+                       
+                       jit_insn_label(jitCoder->jitFunction, &startLabel);
+                       thread = _ILJitFunctionGetThread(jitCoder->jitFunction);
+                       jit_insn_label(jitCoder->jitFunction, &endLabel);
+                       jit_insn_move_blocks_to_start(jitCoder->jitFunction, 
startLabel,
+                                                                               
                                                 endLabel);
+               }
+               else
+               {
+                       thread = _ILJitFunctionGetThread(jitCoder->jitFunction);
+               }
+               jitCoder->thread = thread;
+       }
+       return jitCoder->thread;
+}
+#endif
+
+/*
+ * Declaration of the engine internal exceptions.
+ */
+#define _IL_JIT_OK                                     0
+#define _IL_JIT_OUT_OF_MEMORY          1
+#define _IL_JIT_INVALID_CAST           2
+#define _IL_JIT_INDEX_OUT_OF_RANGE     3
+
+/*
+ * Emit the code to throw a system exception.
+ */
+static void _ILJitThrowSystem(ILJITCoder *jitCoder, ILUInt32 exception);
+
 /*
  * Initialize a ILJitTypes base structure 
  */
@@ -951,21 +1036,6 @@
        }
 }
 
-/*
- * Emit the code to throw a libjit internal exception.
- */
-static void _ILJitThrowInternal(ILJitFunction func, int exception)
-{
-       ILJitValue value = jit_value_create_nint_constant(func,
-                                                                               
                          _IL_JIT_TYPE_INT32,
-                                                                               
                          (jit_nint)exception);
-
-       jit_insn_call_native(func, "jit_exception_builtin", 
jit_exception_builtin,
-                                                
_ILJitSignature_JitExceptionBuiltin, &value, 1,
-                                                JIT_CALL_NORETURN);
-}
-
-
 #if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS) && 
defined(_IL_JIT_ENABLE_DEBUG)
 /*
  * Get a complete methodname.
@@ -1177,11 +1247,71 @@
 }
 
 /*
+ * Throw the given exception.
+ */
+void ILRuntimeExceptionThrow(ILObject *object)
+{
+       ILExecThread *thread = ILExecThreadCurrent();
+       System_Exception *exception = (System_Exception *)object;
+
+       if(thread)
+       {
+               thread->thrownException = object;
+               if(exception)
+               {
+                       exception->stackTrace = 
_ILJitGetExceptionStackTrace(thread);
+               }
+       }
+       if(exception)
+       {
+               jit_exception_throw(exception);
+       }
+}
+
+/*
+ * Throw an exception of the given type.
+ * The caller has to make sure that the exception class is allready layouted.
+ */
+void ILRuntimeExceptionThrowClass(ILClass *classInfo)
+{
+       ILExecThread *thread = ILExecThreadCurrent();
+       System_Exception *exception =
+               (System_Exception *)_ILJitAlloc(classInfo,
+                                                       ((ILClassPrivate 
*)(classInfo->userData))->size);
+
+       /* We don't have to check exception for 0 because _ILJitAlloc would 
have */
+       /* thrown an OutOfMenory exception then. */
+       if(thread)
+       {
+               thread->thrownException = (ILObject *)exception;
+               exception->stackTrace = _ILJitGetExceptionStackTrace(thread);
+       }
+       jit_exception_throw(exception);
+}
+
+/*
+ * Throw an OutOfMemoryException.
+ */
+void ILRuntimeExceptionThrowOutOfMemory()
+{
+       ILExecThread *thread = ILExecThreadCurrent();
+       void *exception = 0;
+
+       if(thread)
+       {
+               thread->thrownException = thread->process->outOfMemoryObject;
+               jit_exception_throw(exception);
+               return;
+       }
+       jit_exception_builtin(JIT_RESULT_OUT_OF_MEMORY);
+}
+
+/*
  * Perform a class cast, taking arrays into account.
  */
-ILInt32 ILRuntimeCanCastClass(ILExecThread *thread, ILObject *object, ILClass 
*toClass)
+ILInt32 ILRuntimeCanCastClass(ILMethod *method, ILObject *object, ILClass 
*toClass)
 {
-       ILImage *image = ILProgramItem_Image(thread->method);
+       ILImage *image = ILProgramItem_Image(method);
        ILClass *fromClass = GetObjectClass(object);
        ILType *fromType = ILClassGetSynType(fromClass);
        ILType *toType = ILClassGetSynType(toClass);
@@ -1319,6 +1449,57 @@
        return 0;
 }
 
+#ifdef IL_JIT_FNPTR_ILMETHOD
+/*
+ * This is the same function as above but returns the ILMethod instead of the
+ * vtable pointer of the interface method.
+ */
+static void *_ILRuntimeLookupInterfaceILMethod(ILClassPrivate 
*objectClassPrivate,
+                                                                               
           ILClass *interfaceClass,
+                                                                               
           ILUInt32 index)
+{
+       ILImplPrivate *implements;
+       ILClassPrivate *searchClass = objectClassPrivate;
+       ILClass *parent;
+
+       /* Locate the interface table within the class hierarchy for the object 
*/
+       while(searchClass != 0)
+       {
+               implements = searchClass->implements;
+               while(implements != 0)
+               {
+                       if(implements->interface == interfaceClass)
+                       {
+                               /* We've found the interface, so look in the 
interface
+                                  table to find the vtable slot, which is then 
used to
+                                  look in the class's vtable for the actual 
method */
+                               index = 
(ILUInt32)((ILImplPrivate_Table(implements))[index]);
+                               if(index != (ILUInt32)(ILUInt16)0xFFFF)
+                               {
+                                       return 
objectClassPrivate->vtable[index];
+                               }
+                               else
+                               {
+                                       /* The interface slot is abstract.  
This shouldn't
+                                          happen in practice, but let's be 
paranoid anyway */
+                                       return 0;
+                               }
+                       }
+                       implements = implements->next;
+               }
+               parent = ILClassGetParent(searchClass->classInfo);
+               if(!parent)
+               {
+                       break;
+               }
+               searchClass = (ILClassPrivate *)(parent->userData);
+       }
+
+       /* The interface implementation was not found */
+       return 0;
+}
+#endif
+
 /*
  * Get the pointer to base type from the JitTypes.
  * The pointer type is created on demand if not allready present.
@@ -1476,11 +1657,17 @@
                        if(cctor != coder->currentMethod)
                        {
                                /* Output a call to the static constructor */
-                               jit_value_t thread = 
jit_value_get_param(coder->jitFunction, 0);
+                       #ifdef IL_JIT_THREAD_IN_SIGNATURE
+                               jit_value_t thread = 
_ILJitCoderGetThread(coder);
 
                                jit_insn_call(coder->jitFunction, "cctor",
                                                                
ILJitFunctionFromILMethod(cctor), 0,
                                                                &thread, 1, 0);
+                       #else
+                               jit_insn_call(coder->jitFunction, "cctor",
+                                                               
ILJitFunctionFromILMethod(cctor), 0,
+                                                               0, 0, 0);
+                       #endif
                        }
                }
                else
@@ -1572,7 +1759,7 @@
  */
 static void _ILJitThrowCurrentException(ILJITCoder *coder)
 {
-       ILJitValue thread = jit_value_get_param(coder->jitFunction,0);
+       ILJitValue thread = _ILJitCoderGetThread(coder);
        ILJitValue thrownException = jit_insn_load_relative(coder->jitFunction,
                                                                        thread,
                                                                        
offsetof(ILExecThread, thrownException), 
@@ -1635,6 +1822,15 @@
        _ILJitTypesInitBase(&_ILJitType_TYPEDREF, _ILJitTypedRef);
 
        /* Initialize the native method signatures. */
+#ifndef IL_JIT_THREAD_IN_SIGNATURE
+       returnType = _IL_JIT_TYPE_VPTR;
+       if(!(_ILJitSignature_ILExecThreadCurrent = 
+               jit_type_create_signature(IL_JIT_CALLCONV_CDECL, returnType, 0, 
0, 1)))
+       {
+               return 0;
+       }
+#endif
+
        args[0] = _IL_JIT_TYPE_VPTR;
        args[1] = _IL_JIT_TYPE_UINT32;
        returnType = _IL_JIT_TYPE_VPTR;
@@ -1664,6 +1860,29 @@
        }
 
        args[0] = _IL_JIT_TYPE_VPTR;
+       returnType = _IL_JIT_TYPE_VOID;
+       if(!(_ILJitSignature_ILRuntimeExceptionThrow =
+               jit_type_create_signature(IL_JIT_CALLCONV_CDECL, returnType, 
args, 1, 1)))
+       {
+               return 0;
+       }
+
+       args[0] = _IL_JIT_TYPE_VPTR;
+       returnType = _IL_JIT_TYPE_VOID;
+       if(!(_ILJitSignature_ILRuntimeExceptionThrowClass =
+               jit_type_create_signature(IL_JIT_CALLCONV_CDECL, returnType, 
args, 1, 1)))
+       {
+               return 0;
+       }
+
+       returnType = _IL_JIT_TYPE_VOID;
+       if(!(_ILJitSignature_ILRuntimeExceptionThrowOutOfMemory =
+               jit_type_create_signature(IL_JIT_CALLCONV_CDECL, returnType, 0, 
0, 1)))
+       {
+               return 0;
+       }
+
+       args[0] = _IL_JIT_TYPE_VPTR;
        args[1] = _IL_JIT_TYPE_UINT32;
        args[2] = _IL_JIT_TYPE_UINT32;
        returnType = _IL_JIT_TYPE_VPTR;
@@ -1683,14 +1902,6 @@
                return 0;
        }
 
-       args[0] = _IL_JIT_TYPE_INT32;
-       returnType = _IL_JIT_TYPE_VOID;
-       if(!(_ILJitSignature_JitExceptionBuiltin =
-               jit_type_create_signature(IL_JIT_CALLCONV_CDECL, returnType, 
args, 1, 1)))
-       {
-               return 0;
-       }
-
        returnType = _IL_JIT_TYPE_VOID;
        if(!(_ILJitSignature_JitExceptionClearLast =
                jit_type_create_signature(IL_JIT_CALLCONV_CDECL, returnType, 0, 
0, 1)))
@@ -1761,6 +1972,10 @@
        coder->numSwitch = 0;
        coder->maxSwitch = 0;
 
+#ifndef IL_JIT_THREAD_IN_SIGNATURE
+       coder->thread = 0;
+#endif
+
        /* Ready to go */
        return &(coder->coder);
 }
@@ -1851,10 +2066,17 @@
 {
        ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
 
-       if(offset != 0)
+       /* TODO: this should be enabled in the final version
+       if(jitCoder->debugEnabled)
        {
-               jit_insn_mark_offset(jitCoder->jitFunction, (jit_int)offset);
+       */
+               if(offset != 0)
+               {
+                       jit_insn_mark_offset(jitCoder->jitFunction, 
(jit_int)offset);
+               }
+       /*
        }
+       */
 }
 
 /*
@@ -2054,15 +2276,18 @@
 /*
  * Generate the code to call an internal function.
  */
-static ILJitValue _ILJitCallInternal(ILJitFunction func, ILMethod *method,
-                                                         void *nativeFunction, 
const char *methodName,
-                                                          ILJitValue *args, 
ILUInt32 numArgs)
+static ILJitValue _ILJitCallInternal(ILJitFunction func,
+                                                                        
ILJitValue thread,
+                                                                        
ILMethod *method,
+                                                                        void 
*nativeFunction,
+                                                                        const 
char *methodName,
+                                                                        
ILJitValue *args,
+                                                                        
ILUInt32 numArgs)
 {
        ILType *ilSignature = ILMethod_Signature(method);
        ILType *type = ILTypeGetEnumType(ILTypeGetParam(ilSignature, 0));
        /* Get the function to call. */
        ILJitFunction jitFunction = ILJitFunctionFromILMethod(method);
-       ILJitValue thread = jit_value_get_param(func, 0);
        jit_label_t label = jit_label_undefined;
        ILJitType signature = 0;
        ILJitType callSignature = 0;
@@ -2092,17 +2317,24 @@
                return 0;
        }
        numParams = jit_type_num_params(signature);
+#ifdef IL_JIT_THREAD_IN_SIGNATURE
        totalParams = numParams;
+#else
+       totalParams = numParams + 1;
+#endif
        returnType = jit_type_get_return(signature);;
 
+#ifdef IL_JIT_THREAD_IN_SIGNATURE
        if(numParams != (numArgs + 1))
+#else
+       if(numParams != numArgs)
+#endif
        {
                printf("Number of args doesn't match: signature: %i - numArgs: 
%i\n", numParams, numArgs);
        }
 
-       /* We need to set the method member in the ILExecThread == arg[0]. */
-       if(numParams > 0)
        {
+               /* We need to set the method member in the ILExecThread == 
arg[0]. */
                ILJitType paramType;
                ILJitType jitParamTypes[totalParams + 1];
                ILJitValue jitParams[totalParams + 1];
@@ -2111,8 +2343,11 @@
                /* We need to create a new Signature for the native Call with */
                /* an additional argument when the return value is a value type 
*/
                /* and pointers for structs. */
-               jitParamTypes[0] = jit_type_get_param(signature, 0); 
-               jitParams[0] = jit_value_get_param(func, 0);
+               /* Set the current thread as arg[0]. */
+               jitParamTypes[0] = _IL_JIT_TYPE_VPTR;
+               jitParams[0] = thread;
+
+               /* Check if the return type is a value type. */
                if(ILType_IsValueType(type))
                {
                        ++totalParams;
@@ -2123,19 +2358,32 @@
                        hasStructReturn = 1;
                        ++param;
                }
+
+       #ifdef IL_JIT_THREAD_IN_SIGNATURE
                for(current = 1; current < numParams; ++current)
+       #else
+               for(current = 0; current < numParams; ++current)
+       #endif
                {
                        paramType = jit_type_get_param(signature, current);
-       
+
                        if(jit_type_is_struct(paramType))
                        {
                                jitParamTypes[param] = _IL_JIT_TYPE_VPTR;
+                       #ifdef IL_JIT_THREAD_IN_SIGNATURE
                                jitParams[param] = jit_insn_address_of(func, 
args[current - 1]);
+                       #else
+                               jitParams[param] = jit_insn_address_of(func, 
args[current]);
+                       #endif
                        }
                        else
                        {
                                jitParamTypes[param] = paramType;
+                       #ifdef IL_JIT_THREAD_IN_SIGNATURE
                                jitParams[param] = args[current - 1];
+                       #else
+                               jitParams[param] = args[current];
+                       #endif
                        }
                        ++param;
                }
@@ -2144,26 +2392,21 @@
                                                                                
                  jitParamTypes,
                                                                                
                  totalParams, 1);
 
-               _ILJitSetMethodInThread(func, jitParams[0], method);
+               _ILJitSetMethodInThread(func, thread, method);
                if(!hasStructReturn)
                {
                        returnValue = jit_insn_call_native(func, methodName, 
nativeFunction,
                                                                                
           callSignature,
-                                                                               
           jitParams, numParams, 0);
+                                                                               
           jitParams, totalParams, 0);
                }
                else
                {
                        jit_insn_call_native(func, methodName, nativeFunction,
-                                                                callSignature,
-                                                                jitParams, 
totalParams, 0);
+                                                                callSignature,
+                                                                jitParams, 
totalParams, 0);
                }
                jit_type_free(callSignature);
        }
-       else
-       {
-               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);
@@ -2190,8 +2433,15 @@
        ILJitType signature = jit_function_get_signature(func);
        unsigned int numParams = jit_type_num_params(signature);
        ILJitValue returnValue = 0;
+       ILJitValue thread = _ILJitFunctionGetThread(func);
        char *methodName = 0;
+       ILJitValue paramValue;
        ILUInt32 current;
+#ifdef IL_JIT_THREAD_IN_SIGNATURE
+       ILJitValue jitParams[numParams - 1];
+#else
+       ILJitValue jitParams[numParams];
+#endif
 
 #if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS) && 
defined(_IL_JIT_ENABLE_DEBUG)
        methodName = _ILJitFunctionGetMethodName(func);
@@ -2203,29 +2453,31 @@
        }
 #endif
 
-       if(numParams > 0)
+#ifdef IL_JIT_THREAD_IN_SIGNATURE
+       for(current = 1; current < numParams; ++current)
        {
-               ILJitValue paramValue;
-               ILJitValue jitParams[numParams - 1];
-
-               for(current = 1; current < numParams; ++current)
+               if(!(paramValue = jit_value_get_param(func, current)))
                {
-                       if(!(paramValue = jit_value_get_param(func, current)))
-                       {
-                               return JIT_RESULT_OUT_OF_MEMORY;
-                       }
-                       jitParams[current - 1] = paramValue;
+                       return JIT_RESULT_OUT_OF_MEMORY;
                }
-
-               returnValue = _ILJitCallInternal(func, method,
-                                                                               
 nativeFunction, methodName,
-                                                                               
 jitParams, numParams - 1);
+               jitParams[current - 1] = paramValue;
        }
-       else
+       returnValue = _ILJitCallInternal(func, thread, method,
+                                                                        
nativeFunction, methodName,
+                                                                        
jitParams, numParams - 1);
+#else
+       for(current = 0; current < numParams; ++current)
        {
-               returnValue = jit_insn_call_native(func, methodName, 
nativeFunction,
-                                                                               
   signature, 0, 0, 0);
+               if(!(paramValue = jit_value_get_param(func, current)))
+               {
+                       return JIT_RESULT_OUT_OF_MEMORY;
+               }
+               jitParams[current] = paramValue;
        }
+       returnValue = _ILJitCallInternal(func, thread, method,
+                                                                        
nativeFunction, methodName,
+                                                                        
jitParams, numParams);
+#endif
        jit_insn_return(func, returnValue);     
 
 #if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS) && 
defined(_IL_JIT_ENABLE_DEBUG)
@@ -2419,14 +2671,18 @@
        /* Argument 0 is the type of the return value. */
        ILUInt32 num = ILTypeNumParams(signature);
        /* total number of args */
+#ifdef IL_JIT_THREAD_IN_SIGNATURE
        /* because we pass the ILExecThread as first arg we have to add one */
        ILUInt32 total = num + 1;
-       ILUInt32 current;
        /* We set jitArgc to 1 because we allways pass the current ILExecThread 
*/
        /* in jitArgs[0]. */
        ILUInt32 jitArgc = 1;
-       /* We use the C calling convention by default for jitted functions. */
-       jit_abi_t jitAbi = jit_abi_cdecl;
+#else
+       ILUInt32 total = num;
+       ILUInt32 jitArgc = 0;
+#endif
+       ILUInt32 current;
+       jit_abi_t jitAbi = IL_JIT_CALLCONV_DEFAULT;
        /* JitType to hold the return type */
        ILJitType jitReturnType;
        /* calling convention for this function. */
@@ -2484,8 +2740,10 @@
                return 0;
        }
 
+#ifdef IL_JIT_THREAD_IN_SIGNATURE
        /* arg 0 is allways the ILExecThread */
        jitArgs[0] = _IL_JIT_TYPE_VPTR;
+#endif
 
        if(ILType_HasThis(signature))
        {
@@ -2498,7 +2756,11 @@
                                return 0;
                        }
                        /* at this time the type must be layouted or at least 
partially layouted */
+               #ifdef IL_JIT_THREAD_IN_SIGNATURE
                        if(!(jitArgs[1] = _ILJitGetThisType(type, 
coder->process)))
+               #else
+                       if(!(jitArgs[0] = _ILJitGetThisType(type, 
coder->process)))
+               #endif
                        {
                                return 0;
                        }
@@ -2522,7 +2784,7 @@
        if((ILType_CallConv(signature) & IL_META_CALLCONV_MASK) ==
                        IL_META_CALLCONV_VARARG)
        {
-               jitAbi = jit_abi_vararg;
+               jitAbi = IL_JIT_CALLCONV_VARARG;
        }
 #endif
 
Index: pnet/engine/jitc.h
diff -u pnet/engine/jitc.h:1.11 pnet/engine/jitc.h:1.12
--- pnet/engine/jitc.h:1.11     Sun Mar 19 11:29:11 2006
+++ pnet/engine/jitc.h  Mon May  1 17:30:50 2006
@@ -59,10 +59,14 @@
 #define IL_JIT_META_METHODNAME 1001
 
 /*
- * Defaut calling convention for libjit.
+ * Use the ILMethod * as function pointer.
  */
-#define IL_JIT_CALLCONV_DEFAULT                jit_abi_cdecl
+#define IL_JIT_FNPTR_ILMETHOD 1
 
+/*
+ * Include the current thread in the method's signature.
+ */
+#define IL_JIT_THREAD_IN_SIGNATURE 1
 
 /*
  * Calling conventions for libjit.
@@ -73,12 +77,17 @@
 #define IL_JIT_CALLCONV_FASTCALL       jit_abi_fastcall
 
 /*
+ * Defaut calling convention for libjit.
+ */
+#define IL_JIT_CALLCONV_DEFAULT                IL_JIT_CALLCONV_CDECL
+
+/*
  * Representation of a type representation for libjit.
  */
 typedef jit_type_t             ILJitType;
 
 /*
- * Representation of a method representation for libjit.
+ * Definition of a method representation for libjit.
  */
 typedef jit_function_t ILJitFunction;
 
Index: pnet/engine/jitc_alloc.c
diff -u pnet/engine/jitc_alloc.c:1.1 pnet/engine/jitc_alloc.c:1.2
--- pnet/engine/jitc_alloc.c:1.1        Mon Apr 17 17:39:44 2006
+++ pnet/engine/jitc_alloc.c    Mon May  1 17:30:50 2006
@@ -19,8 +19,7 @@
  */
 
 /*
- * Allocate memory for an object that contains object references and has a
- * finalizer.
+ * Allocate memory for an object that contains object references.
  */
 static ILObject *_ILJitAlloc(ILClass *classInfo, ILUInt32 size)
 {
@@ -34,10 +33,7 @@
        if(!ptr)
        {
                /* Throw an "OutOfMemoryException" */
-               ILExecThread *thread = ILExecThreadCurrent();
-
-               thread->thrownException = thread->process->outOfMemoryObject;
-               jit_exception_throw(thread->thrownException);
+               ILRuntimeExceptionThrowOutOfMemory();
        }
 
        obj = GetObjectFromGcBase(ptr);
@@ -58,8 +54,7 @@
 }
 
 /*
- * Allocate memory for an object that does not contain any object references
- *  and has a finalizer.
+ * Allocate memory for an object that does not contain any object references.
  */
 static ILObject *_ILJitAllocAtomic(ILClass *classInfo, ILUInt32 size)
 {
@@ -73,10 +68,7 @@
        if(!ptr)
        {
                /* Throw an "OutOfMemoryException" */
-               ILExecThread *thread = ILExecThreadCurrent();
-
-               thread->thrownException = thread->process->outOfMemoryObject;
-               jit_exception_throw(thread->thrownException);
+               ILRuntimeExceptionThrowOutOfMemory();
        }
 
        obj = GetObjectFromGcBase(ptr);
Index: pnet/engine/jitc_arith.c
diff -u pnet/engine/jitc_arith.c:1.3 pnet/engine/jitc_arith.c:1.4
--- pnet/engine/jitc_arith.c:1.3        Mon Feb 27 16:27:00 2006
+++ pnet/engine/jitc_arith.c    Mon May  1 17:30:50 2006
@@ -148,7 +148,8 @@
                }
        }
 
-       jitCoder->jitStack[jitCoder->stackTop - 2] = result;
+       jitCoder->jitStack[jitCoder->stackTop - 2] =
+               _ILJitValueConvertToStackType(jitCoder->jitFunction, result);
        JITC_ADJUST(jitCoder, -1);
 }
 
@@ -159,41 +160,35 @@
                                                           ILEngineType type1, 
ILEngineType type2)
 {
        ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
+       ILJitValue value1 = jitCoder->jitStack[jitCoder->stackTop - 2];
+       ILJitValue value2 = jitCoder->jitStack[jitCoder->stackTop - 1];
+       ILJitValue result = 0;
 
        switch(opcode)
        {
                case IL_OP_ADD:
                {
-                       jitCoder->jitStack[jitCoder->stackTop - 2] = 
jit_insn_add(jitCoder->jitFunction, 
-                                                                       
jitCoder->jitStack[jitCoder->stackTop - 2],
-                                                                       
jitCoder->jitStack[jitCoder->stackTop - 1]);
-                       JITC_ADJUST(jitCoder, -1);
+                       result = jit_insn_add(jitCoder->jitFunction, value1, 
value2);
                }
                case IL_OP_ADD_OVF_UN:
                {
-                       jitCoder->jitStack[jitCoder->stackTop - 2] = 
jit_insn_add_ovf(jitCoder->jitFunction, 
-                                                                       
jitCoder->jitStack[jitCoder->stackTop - 2],
-                                                                       
jitCoder->jitStack[jitCoder->stackTop - 1]);
-                       JITC_ADJUST(jitCoder, -1);
+                       result = jit_insn_add_ovf(jitCoder->jitFunction, 
value1, value2);
                }
                break;
 
                case IL_OP_SUB:
                {
-                       jitCoder->jitStack[jitCoder->stackTop - 2] = 
jit_insn_sub(jitCoder->jitFunction, 
-                                                                       
jitCoder->jitStack[jitCoder->stackTop - 2],
-                                                                       
jitCoder->jitStack[jitCoder->stackTop - 1]);
-                       JITC_ADJUST(jitCoder, -1);
+                       result = jit_insn_sub(jitCoder->jitFunction, value1, 
value2);
                }
                case IL_OP_SUB_OVF_UN:
                {
-                       jitCoder->jitStack[jitCoder->stackTop - 2] = 
jit_insn_sub_ovf(jitCoder->jitFunction, 
-                                                                       
jitCoder->jitStack[jitCoder->stackTop - 2],
-                                                                       
jitCoder->jitStack[jitCoder->stackTop - 1]);
-                       JITC_ADJUST(jitCoder, -1);
+                       result = jit_insn_sub_ovf(jitCoder->jitFunction, 
value1, value2);
                }
                break;
        }
+       JITC_ADJUST(jitCoder, -1);
+       jitCoder->jitStack[jitCoder->stackTop - 1] = 
+                       _ILJitValueConvertToStackType(jitCoder->jitFunction, 
result);
 }
 
 /*
@@ -203,37 +198,37 @@
                                                   ILEngineType type1, 
ILEngineType type2)
 {
        ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
+       ILJitValue value1 = jitCoder->jitStack[jitCoder->stackTop - 2];
+       ILJitValue value2 = jitCoder->jitStack[jitCoder->stackTop - 1];
+       ILJitValue result = 0;
 
        /* Determine how to perform the operation */
        switch(opcode)
        {
                case IL_OP_SHL:
                {
-                       jitCoder->jitStack[jitCoder->stackTop - 2] = 
jit_insn_shl(jitCoder->jitFunction, 
-                                                                       
jitCoder->jitStack[jitCoder->stackTop - 2],
-                                                                       
jitCoder->jitStack[jitCoder->stackTop - 1]);
-                       JITC_ADJUST(jitCoder, -1);
+                       AdjustSign(jitCoder->jitFunction, &value1, 0, 0);
+                       result = jit_insn_shl(jitCoder->jitFunction, value1, 
value2);
                }
                break;
 
                case IL_OP_SHR:
                {
-                       jitCoder->jitStack[jitCoder->stackTop - 2] = 
jit_insn_shr(jitCoder->jitFunction, 
-                                                                       
jitCoder->jitStack[jitCoder->stackTop - 2],
-                                                                       
jitCoder->jitStack[jitCoder->stackTop - 1]);
-                       JITC_ADJUST(jitCoder, -1);
+                       AdjustSign(jitCoder->jitFunction, &value1, 0, 0);
+                       result= jit_insn_shr(jitCoder->jitFunction, value1, 
value2);
                }
                break;
 
                case IL_OP_SHR_UN:
                {
-                       jitCoder->jitStack[jitCoder->stackTop - 2] = 
jit_insn_shr(jitCoder->jitFunction,
-                                                                       
jitCoder->jitStack[jitCoder->stackTop - 2],
-                                                                       
jitCoder->jitStack[jitCoder->stackTop - 1]);            
-                       JITC_ADJUST(jitCoder, -1);
+                       AdjustSign(jitCoder->jitFunction, &value1, 1, 0);
+                       result = jit_insn_shr(jitCoder->jitFunction, value1, 
value2);
                }
                break;
        }
+       JITC_ADJUST(jitCoder, -1);
+       jitCoder->jitStack[jitCoder->stackTop - 1] = 
+                       _ILJitValueConvertToStackType(jitCoder->jitFunction, 
result);
 }
 
 /*
@@ -242,31 +237,32 @@
 static void JITCoder_Unary(ILCoder *coder, int opcode, ILEngineType type)
 {
        ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
+       ILJitValue value = jitCoder->jitStack[jitCoder->stackTop - 1];
+       ILJitValue result = 0;
 
        switch(opcode)
        {
                case IL_OP_NEG:
                {
-                       jitCoder->jitStack[jitCoder->stackTop - 1] = 
jit_insn_neg(jitCoder->jitFunction, 
-                                                                       
jitCoder->jitStack[jitCoder->stackTop - 1]);
+                       result = jit_insn_neg(jitCoder->jitFunction, value);
                }
                break;
 
                case IL_OP_NOT:
                {
-                       jitCoder->jitStack[jitCoder->stackTop - 1] = 
jit_insn_not(jitCoder->jitFunction, 
-                                                                       
jitCoder->jitStack[jitCoder->stackTop - 1]);
+                       result = jit_insn_not(jitCoder->jitFunction, value);
                }
                break;
 
                case IL_OP_CKFINITE:
                {
                        /* Check the stack Top-most F value to see if it is 
finite */
-                       jitCoder->jitStack[jitCoder->stackTop - 1] = 
jit_insn_is_finite(jitCoder->jitFunction,
-                                                                       
jitCoder->jitStack[jitCoder->stackTop - 1]);
+                       result = jit_insn_is_finite(jitCoder->jitFunction, 
value);
                }
                break;
        }
+       jitCoder->jitStack[jitCoder->stackTop - 1] = 
+                       _ILJitValueConvertToStackType(jitCoder->jitFunction, 
result);
 }
 
 #endif /* IL_JITC_CODE */
Index: pnet/engine/jitc_call.c
diff -u pnet/engine/jitc_call.c:1.13 pnet/engine/jitc_call.c:1.14
--- pnet/engine/jitc_call.c:1.13        Mon Apr 17 17:39:44 2006
+++ pnet/engine/jitc_call.c     Mon May  1 17:30:50 2006
@@ -44,7 +44,7 @@
 /*
  * Get the vtable pointer for an interface function from an object.
  */
-static ILJitValue _ILJitGetInterfaceFunction(ILJitFunction func,
+static ILJitValue _ILJitGetInterfaceFunction(ILJITCoder *jitCoder,
                                                                                
         ILJitValue object,
                                                                                
         ILClass *interface,
                                                                                
         int index)
@@ -54,28 +54,28 @@
        ILJitValue methodIndex;
        ILJitValue args[3];
 
-       jit_insn_check_null(func, object);
-       classPrivate = _ILJitGetObjectClassPrivate(func, object);
-       interfaceClass = jit_value_create_nint_constant(func,
+       _ILJitCheckNull(jitCoder, object);
+       classPrivate = _ILJitGetObjectClassPrivate(jitCoder->jitFunction, 
object);
+       interfaceClass = jit_value_create_nint_constant(jitCoder->jitFunction,
                                                                                
                        _IL_JIT_TYPE_VPTR,
                                                                                
                        (jit_nint)interface);
-       methodIndex = jit_value_create_nint_constant(func,
+       methodIndex = jit_value_create_nint_constant(jitCoder->jitFunction,
                                                                                
                 _IL_JIT_TYPE_UINT32,
                                                                                
                 (jit_nint)index);
        args[0] = classPrivate;
        args[1] = interfaceClass;
        args[2] = methodIndex;
-       return jit_insn_call_native(func,
+       return jit_insn_call_native(jitCoder->jitFunction,
                                                                
"_ILRuntimeLookupInterfaceMethod",
                                                                
_ILRuntimeLookupInterfaceMethod,
                                                                
_ILJitSignature_ILRuntimeLookupInterfaceMethod,
-                                                               args, 3, 
JIT_CALL_NOTHROW);
+                                                               args, 3, 0);
 }
 
 /*
  * Get the vtable pointer for a virtual function from an object.
  */
-static ILJitValue _ILJitGetVirtualFunction(ILJitFunction func,
+static ILJitValue _ILJitGetVirtualFunction(ILJITCoder *jitCoder,
                                                                                
   ILJitValue object,
                                                                                
   int index)
 {
@@ -83,15 +83,16 @@
        ILJitValue vtable;
        ILJitValue vtableIndex;
 
-       jit_insn_check_null(func, object);
-       classPrivate = _ILJitGetObjectClassPrivate(func, object);
-       vtable = jit_insn_load_relative(func, classPrivate, 
+       _ILJitCheckNull(jitCoder, object);
+       classPrivate = _ILJitGetObjectClassPrivate(jitCoder->jitFunction, 
object);
+       vtable = jit_insn_load_relative(jitCoder->jitFunction, classPrivate, 
                                                                        
offsetof(ILClassPrivate, jitVtable), 
                                                                        
_IL_JIT_TYPE_VPTR);
-       vtableIndex = jit_value_create_nint_constant(func,
+       vtableIndex = jit_value_create_nint_constant(jitCoder->jitFunction,
                                                                                
                 _IL_JIT_TYPE_INT32,
                                                                                
                 (jit_nint)index);
-       return jit_insn_load_elem(func, vtable, vtableIndex, _IL_JIT_TYPE_VPTR);
+       return jit_insn_load_elem(jitCoder->jitFunction,
+                                                         vtable, vtableIndex, 
_IL_JIT_TYPE_VPTR);
 }
 
 /*
@@ -120,7 +121,7 @@
        ILMethod *ctor;
        ILUInt32 typeSize;
        ILJitFunction jitCtor;
-       ILJitValue thread = jit_value_get_param(jitCoder->jitFunction, 0);
+       ILJitValue thread = _ILJitCoderGetThread(jitCoder);
        ILJitValue arrayLength = 
jit_value_create_nint_constant(jitCoder->jitFunction,
                                                                                
                                        _IL_JIT_TYPE_UINT32,
                                                                                
                                        (jit_nint)numArgs);
@@ -492,27 +493,6 @@
        JITC_ADJUST(jitCoder, 1);
 }
 
-static int _ILJitIsStringClass(ILClass *info)
-{
-       ILImage *systemImage;
-       if(!strcmp(info->className->name, "String") &&
-           info->className->namespace &&
-           !strcmp(info->className->namespace, "System"))
-       {
-               /* Check that it is within the system image, to prevent
-                  applications from fooling us into believeing that their
-                  own class is the system's string class */
-               
-               info = ILClassResolve(info);
-               systemImage = info->programItem.image->context->systemImage;
-               if(!systemImage || systemImage == info->programItem.image)
-               {
-                       return 1;
-               }
-       }       
-       return 0;
-}
-
 static void JITCoder_UpConvertArg(ILCoder *coder, ILEngineStackItem *args,
                                                          ILUInt32 numArgs, 
ILUInt32 param,
                                                          ILType *paramType)
@@ -646,9 +626,12 @@
        /* Check if the function is implemented in the engine. */
        if(_ILJitFunctionIsInternal(jitCoder, methodInfo, &fnInfo, 0))
        {
+               ILJitValue thread = _ILJitCoderGetThread(jitCoder);
+
                /* Call the engine function directly with the supplied args. */
                JITC_ADJUST(jitCoder, -argCount);
-               returnValue = _ILJitCallInternal(jitCoder->jitFunction, 
methodInfo,
+               returnValue = _ILJitCallInternal(jitCoder->jitFunction, thread,
+                                                                               
 methodInfo,
                                                                                
 fnInfo.func, methodName,
                                                                                
 &(jitCoder->jitStack[jitCoder->stackTop]),
                                                                                
 argCount);
@@ -662,17 +645,28 @@
                return;
        }
 
+#ifdef IL_JIT_THREAD_IN_SIGNATURE
        /* Set the ILExecThread argument. */
-       jitParams[0] = jit_value_get_param(jitCoder->jitFunction, 0);
+       jitParams[0] = _ILJitCoderGetThread(jitCoder);
 
        _ILJitFillArguments(jitCoder, &(jitParams[1]), info);
+#else
+       _ILJitFillArguments(jitCoder, &(jitParams[0]), info);
+#endif
+
        /* TODO: create call signature for vararg calls. */     
                
        if(info->tailCall == 1)
        {
+       #ifdef IL_JIT_THREAD_IN_SIGNATURE
                returnValue = jit_insn_call(jitCoder->jitFunction, methodName,
                                                                        
jitFunction, 0,
                                                                        
jitParams, argCount + 1, JIT_CALL_TAIL);
+       #else
+               returnValue = jit_insn_call(jitCoder->jitFunction, methodName,
+                                                                       
jitFunction, 0,
+                                                                       
jitParams, argCount, JIT_CALL_TAIL);
+       #endif
                if(returnItem->engineType != ILEngineType_Invalid)
                {
                        jitCoder->jitStack[jitCoder->stackTop] =
@@ -683,9 +677,15 @@
        }
        else
        {               
+       #ifdef IL_JIT_THREAD_IN_SIGNATURE
                returnValue = jit_insn_call(jitCoder->jitFunction, methodName,
                                                                        
jitFunction, 0,
                                                                        
jitParams, argCount + 1, 0);
+       #else
+               returnValue = jit_insn_call(jitCoder->jitFunction, methodName,
+                                                                       
jitFunction, 0,
+                                                                       
jitParams, argCount, 0);
+       #endif
                if(returnItem && returnItem->engineType != ILEngineType_Invalid)
                {
                        jitCoder->jitStack[jitCoder->stackTop] =
@@ -694,15 +694,26 @@
                        JITC_ADJUST(jitCoder, 1);
                }
        }
-       /* Restore the current method in the thread on return. */
-       _ILJitSetMethodInThread(jitCoder->jitFunction, 
-                                                       
jit_value_get_param(jitCoder->jitFunction, 0),
-                                                       
jitCoder->currentMethod);
 }
 
 static void JITCoder_CallIndirect(ILCoder *coder, ILCoderMethodInfo *info,
                                                                  
ILEngineStackItem *returnItem)
 {
+       ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
+       ILJitValue ftnPtr = jitCoder->jitStack[jitCoder->stackTop - 1];
+
+
+#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS)
+       if (jitCoder->flags & IL_CODER_FLAG_STATS)
+       {
+               ILMutexLock(globalTraceMutex);
+               fprintf(stdout,
+                       "CallIndirect\n");
+               ILMutexUnlock(globalTraceMutex);
+       }
+#endif
+       /* Pop the function pointer from the stack. */
+       JITC_ADJUST(jitCoder, -1);
 }
 
 static void JITCoder_CallCtor(ILCoder *coder, ILCoderMethodInfo *info,
@@ -769,6 +780,8 @@
        /* Check if the function is implemented in the engine. */
        if((internalType = _ILJitFunctionIsInternal(jitCoder, methodInfo, 
&fnInfo, 1)))
        {
+               ILJitValue thread = _ILJitCoderGetThread(jitCoder);
+
                /* Call the engine function directly with the supplied args. */
                if(internalType == 2)
                {
@@ -778,7 +791,8 @@
                                ++argCount;
                        }
                        JITC_ADJUST(jitCoder, -argCount);
-                       returnValue = _ILJitCallInternal(jitCoder->jitFunction, 
methodInfo,
+                       returnValue = _ILJitCallInternal(jitCoder->jitFunction, 
thread,
+                                                                               
         methodInfo,
                                                                                
         fnInfo.func, methodName,
                                                                                
         &(jitCoder->jitStack[jitCoder->stackTop]),
                                                                                
         argCount);
@@ -792,7 +806,8 @@
                        _ILJitNewObj(jitCoder, ILMethod_Owner(methodInfo), 
&jitParams[0]); 
                        _ILJitFillArguments(jitCoder, &(jitParams[1]), info);
 
-                       returnValue = _ILJitCallInternal(jitCoder->jitFunction, 
methodInfo,
+                       returnValue = _ILJitCallInternal(jitCoder->jitFunction, 
thread,
+                                                                               
         methodInfo,
                                                                                
         fnInfo.func, methodName,
                                                                                
         jitParams, argCount + 1);
                        jitCoder->jitStack[jitCoder->stackTop] =
@@ -803,19 +818,28 @@
                return;
        }
 
+#ifdef IL_JIT_THREAD_IN_SIGNATURE
        /* Output a call to the constructor */
-       jitParams[0] = jit_value_get_param(jitCoder->jitFunction, 0); // we add 
the current function thread as the first param
-               
+       jitParams[0] = _ILJitCoderGetThread(jitCoder); // we add the current 
function thread as the first param
+#endif
        if((synType && ILType_IsArray(synType)) || ILTypeIsStringClass(type))
        {
+       #ifdef IL_JIT_THREAD_IN_SIGNATURE
                _ILJitFillArguments(jitCoder, &(jitParams[1]), info);
                // call the constructor with jitParams as input
                returnValue = jit_insn_call(jitCoder->jitFunction, 0, 
jitFunction, 0,
                                                                        
jitParams, argCount + 1, 0);
+       #else
+               _ILJitFillArguments(jitCoder, &(jitParams[0]), info);
+               // call the constructor with jitParams as input
+               returnValue = jit_insn_call(jitCoder->jitFunction, 0, 
jitFunction, 0,
+                                                                       
jitParams, argCount, 0);
+       #endif
                jitCoder->jitStack[jitCoder->stackTop] = returnValue;
        }
        else
        {
+       #ifdef IL_JIT_THREAD_IN_SIGNATURE
                /* create a newobj and add it to the jitParams[1]. */
                _ILJitNewObj(jitCoder, ILMethod_Owner(methodInfo), 
&jitParams[1]);
                _ILJitFillArguments(jitCoder, &(jitParams[2]), info);
@@ -824,14 +848,22 @@
                returnValue = jit_insn_call(jitCoder->jitFunction, methodName,
                                                                        
jitFunction, 0,
                                                                        
jitParams, argCount + 2, 0);
+
                jitCoder->jitStack[jitCoder->stackTop] = jitParams[1];
+       #else
+               /* create a newobj and add it to the jitParams[0]. */
+               _ILJitNewObj(jitCoder, ILMethod_Owner(methodInfo), 
&jitParams[0]);
+               _ILJitFillArguments(jitCoder, &(jitParams[1]), info);
+
+               // call the constructor with jitParams as input
+               returnValue = jit_insn_call(jitCoder->jitFunction, methodName,
+                                                                       
jitFunction, 0,
+                                                                       
jitParams, argCount + 1, 0);
+
+               jitCoder->jitStack[jitCoder->stackTop] = jitParams[0];
+       #endif
        }       
        JITC_ADJUST(jitCoder, 1);
-
-       /* Restore the current method in the thread on return. */
-       _ILJitSetMethodInThread(jitCoder->jitFunction, 
-                                                       
jit_value_get_param(jitCoder->jitFunction, 0),
-                                                       
jitCoder->currentMethod);
 }
 
 static void JITCoder_CallVirtual(ILCoder *coder, ILCoderMethodInfo *info,
@@ -890,26 +922,49 @@
                ILMutexUnlock(globalTraceMutex);
        }
 #endif
-       jitParams[0] = jit_value_get_param(jitCoder->jitFunction, 0);
+#ifdef IL_JIT_THREAD_IN_SIGNATURE
+       jitParams[0] = _ILJitCoderGetThread(jitCoder);
        _ILJitFillArguments(jitCoder, &(jitParams[1]), info);
        /* TODO: handle varargs here and create a call signature. */
 
-       jitFunction = _ILJitGetVirtualFunction(jitCoder->jitFunction,
+       jitFunction = _ILJitGetVirtualFunction(jitCoder,
                                                                                
   jitParams[1],
                                                                                
   methodInfo->index);
+#else
+       _ILJitFillArguments(jitCoder, &(jitParams[0]), info);
+       /* TODO: handle varargs here and create a call signature. */
+
+       jitFunction = _ILJitGetVirtualFunction(jitCoder,
+                                                                               
   jitParams[0],
+                                                                               
   methodInfo->index);
+#endif
        if(info->tailCall == 1)
        {
+       #ifdef IL_JIT_THREAD_IN_SIGNATURE
                returnValue = 
jit_insn_call_indirect_vtable(jitCoder->jitFunction,
                                                                                
                        jitFunction, signature,
                                                                                
                        jitParams, argCount + 1,
                                                                                
                        JIT_CALL_TAIL);
+       #else
+               returnValue = 
jit_insn_call_indirect_vtable(jitCoder->jitFunction,
+                                                                               
                        jitFunction, signature,
+                                                                               
                        jitParams, argCount,
+                                                                               
                        JIT_CALL_TAIL);
+       #endif
        }
        else
        {
+       #ifdef IL_JIT_THREAD_IN_SIGNATURE
                returnValue = 
jit_insn_call_indirect_vtable(jitCoder->jitFunction,
                                                                                
                        jitFunction, signature,
                                                                                
                        jitParams, argCount + 1,
                                                                                
                        0);
+       #else
+               returnValue = 
jit_insn_call_indirect_vtable(jitCoder->jitFunction,
+                                                                               
                        jitFunction, signature,
+                                                                               
                        jitParams, argCount,
+                                                                               
                        0);
+       #endif
        }
        if(returnItem->engineType != ILEngineType_Invalid)
        {
@@ -917,10 +972,6 @@
                        _ILJitValueConvertToStackType(jitCoder->jitFunction, 
returnValue);
                JITC_ADJUST(jitCoder, 1);
        }
-       /* Restore the current method in the thread on return. */
-       _ILJitSetMethodInThread(jitCoder->jitFunction, 
-                                                       
jit_value_get_param(jitCoder->jitFunction, 0),
-                                                       
jitCoder->currentMethod);
 }
 
 static void JITCoder_CallInterface(ILCoder *coder, ILCoderMethodInfo *info,
@@ -968,31 +1019,55 @@
        }
 #endif
 #endif
-       jitParams[0] = jit_value_get_param(jitCoder->jitFunction, 0);
+#ifdef IL_JIT_THREAD_IN_SIGNATURE
+       jitParams[0] = _ILJitCoderGetThread(jitCoder);
        _ILJitFillArguments(jitCoder, &(jitParams[1]), info);
        /* TODO: handle varargs here and create a call signature. */
 
-       jitFunction = _ILJitGetInterfaceFunction(jitCoder->jitFunction,
+       jitFunction = _ILJitGetInterfaceFunction(jitCoder,
                                                                                
         jitParams[1],
                                                                                
         methodInfo->member.owner,
                                                                                
         methodInfo->index);
+#else
+       _ILJitFillArguments(jitCoder, &(jitParams[0]), info);
+       /* TODO: handle varargs here and create a call signature. */
+
+       jitFunction = _ILJitGetInterfaceFunction(jitCoder,
+                                                                               
         jitParams[0],
+                                                                               
         methodInfo->member.owner,
+                                                                               
         methodInfo->index);
+#endif
        jit_insn_branch_if(jitCoder->jitFunction, jitFunction, &label);
        /* TODO: raise a MissingMethodException here. */
 
        jit_insn_label(jitCoder->jitFunction, &label);
        if(info->tailCall == 1)
        {
+       #ifdef IL_JIT_THREAD_IN_SIGNATURE
                returnValue = 
jit_insn_call_indirect_vtable(jitCoder->jitFunction,
                                                                                
                        jitFunction, signature,
                                                                                
                        jitParams, argCount + 1,
                                                                                
                        JIT_CALL_TAIL);
+       #else
+               returnValue = 
jit_insn_call_indirect_vtable(jitCoder->jitFunction,
+                                                                               
                        jitFunction, signature,
+                                                                               
                        jitParams, argCount,
+                                                                               
                        JIT_CALL_TAIL);
+       #endif
        }
        else
        {
+       #ifdef IL_JIT_THREAD_IN_SIGNATURE
                returnValue = 
jit_insn_call_indirect_vtable(jitCoder->jitFunction,
                                                                                
                        jitFunction, signature,
                                                                                
                        jitParams, argCount + 1,
                                                                                
                        0);
+       #else
+               returnValue = 
jit_insn_call_indirect_vtable(jitCoder->jitFunction,
+                                                                               
                        jitFunction, signature,
+                                                                               
                        jitParams, argCount,
+                                                                               
                        0);
+       #endif
        }
        if(returnItem->engineType != ILEngineType_Invalid)
        {
@@ -1000,10 +1075,6 @@
                        _ILJitValueConvertToStackType(jitCoder->jitFunction, 
returnValue);
                JITC_ADJUST(jitCoder, 1);
        }
-       /* Restore the current method in the thread on return. */
-       _ILJitSetMethodInThread(jitCoder->jitFunction, 
-                                                       
jit_value_get_param(jitCoder->jitFunction, 0),
-                                                       
jitCoder->currentMethod);
 }
 
 static int JITCoder_CallInlineable(ILCoder *coder, int inlineType,
@@ -1047,8 +1118,14 @@
 {
        ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
        ILJitFunction jitFunction = ILJitFunctionFromILMethod(methodInfo);
+#ifndef IL_JIT_FNPTR_ILMETHOD
        void *function; /* vtable pointer for the function. */
-       ILJitValue functionPtr; /* jt value containing the vtable pointer. */
+       ILJitValue functionPtr; /* jit value containing the vtable pointer. */
+#else
+       ILJitValue functionPtr = 
jit_value_create_nint_constant(jitCoder->jitFunction,
+                                                                               
                                        _IL_JIT_TYPE_VPTR,
+                                                                               
                                        (jit_nint)methodInfo);
+#endif
 
 #if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS)
        if (jitCoder->flags & IL_CODER_FLAG_STATS)
@@ -1070,12 +1147,13 @@
                }
                jitFunction = ILJitFunctionFromILMethod(methodInfo);
        }
+#ifndef IL_JIT_FNPTR_ILMETHOD
        /* Get the vtable pointer for the function. */
        function = jit_function_to_vtable_pointer(jitFunction);
        functionPtr = jit_value_create_nint_constant(jitCoder->jitFunction,
                                                                                
                 _IL_JIT_TYPE_VPTR,
                                                                                
                (jit_nint)function);
-
+#endif
        /* Push the function pointer on the stack. */
        jitCoder->jitStack[jitCoder->stackTop] = functionPtr;
        JITC_ADJUST(jitCoder, 1);
@@ -1086,6 +1164,11 @@
        ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
        ILJitValue object = jitCoder->jitStack[jitCoder->stackTop - 1];
        ILJitValue jitFunction;
+#ifdef IL_JIT_FNPTR_ILMETHOD
+       ILJitValue classPrivate;
+       ILJitValue vtable;
+       ILJitValue vtableIndex;
+#endif
 
 #if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS)
        if (jitCoder->flags & IL_CODER_FLAG_STATS)
@@ -1100,9 +1183,22 @@
        }
 #endif
 
-       jitFunction = _ILJitGetVirtualFunction(jitCoder->jitFunction,
+#ifdef IL_JIT_FNPTR_ILMETHOD
+       _ILJitCheckNull(jitCoder, object);
+       classPrivate = _ILJitGetObjectClassPrivate(jitCoder->jitFunction, 
object);
+       vtable = jit_insn_load_relative(jitCoder->jitFunction, classPrivate, 
+                                                                       
offsetof(ILClassPrivate, vtable), 
+                                                                       
_IL_JIT_TYPE_VPTR);
+       vtableIndex = jit_value_create_nint_constant(jitCoder->jitFunction,
+                                                                               
                 _IL_JIT_TYPE_INT32,
+                                                                               
                 (jit_nint)methodInfo->index);
+       jitFunction = jit_insn_load_elem(jitCoder->jitFunction,
+                                                                        
vtable, vtableIndex, _IL_JIT_TYPE_VPTR);
+#else
+       jitFunction = _ILJitGetVirtualFunction(jitCoder,
                                                                                
   object,
                                                                                
   methodInfo->index);
+#endif
        /* Push the function pointer on the stack. */
        jitCoder->jitStack[jitCoder->stackTop - 1] = jitFunction;
 }
@@ -1112,6 +1208,9 @@
        ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
        ILJitValue object = jitCoder->jitStack[jitCoder->stackTop - 1];
        ILJitValue jitFunction;
+#ifdef IL_JIT_FNPTR_ILMETHOD
+       ILJitValue args[3];
+#endif
 
 #if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS)
        if (jitCoder->flags & IL_CODER_FLAG_STATS)
@@ -1126,10 +1225,28 @@
        }
 #endif
 
-       jitFunction = _ILJitGetInterfaceFunction(jitCoder->jitFunction,
+#ifdef IL_JIT_FNPTR_ILMETHOD
+       _ILJitCheckNull(jitCoder, object);
+       args[0] = _ILJitGetObjectClassPrivate(jitCoder->jitFunction, object);
+       args[1] = jit_value_create_nint_constant(jitCoder->jitFunction,
+                                                                               
         _IL_JIT_TYPE_VPTR,
+                                                                               
         (jit_nint)methodInfo->member.owner);
+       args[2] = jit_value_create_nint_constant(jitCoder->jitFunction,
+                                                                               
         _IL_JIT_TYPE_UINT32,
+                                                                               
         (jit_nint)methodInfo->index);
+
+       jitFunction = jit_insn_call_native(jitCoder->jitFunction,
+                                                                          
"_ILRuntimeLookupInterfaceILMethod",
+                                                                          
_ILRuntimeLookupInterfaceILMethod,
+                                                                          
_ILJitSignature_ILRuntimeLookupInterfaceMethod,
+                                                                          
args, 3, 0);
+
+#else
+       jitFunction = _ILJitGetInterfaceFunction(jitCoder,
                                                                                
         object,
                                                                                
         methodInfo->member.owner,
                                                                                
         methodInfo->index);
+#endif
        /* Push the function pointer on the stack. */
        jitCoder->jitStack[jitCoder->stackTop - 1] = jitFunction;
 }
Index: pnet/engine/jitc_except.c
diff -u pnet/engine/jitc_except.c:1.5 pnet/engine/jitc_except.c:1.6
--- pnet/engine/jitc_except.c:1.5       Sun Mar 19 11:29:11 2006
+++ pnet/engine/jitc_except.c   Mon May  1 17:30:50 2006
@@ -26,7 +26,7 @@
 static void _ILJitFindAndSetStackTrace(ILJITCoder *jitCoder, ILJitValue 
exception)
 {
        ILExecThread *_thread = ILExecThreadCurrent();
-       ILJitValue thread = jit_value_get_param(jitCoder->jitFunction,0);
+       ILJitValue thread = _ILJitCoderGetThread(jitCoder);
        ILJitValue trace;
        ILField *field;
 
@@ -49,6 +49,61 @@
        }
 }
 
+/*
+ * Emit the code to throw a system exception.
+ */
+static void _ILJitThrowSystem(ILJITCoder *jitCoder, ILUInt32 exception)
+{
+       static const char * const exceptionClasses[] = {
+               "Ok",
+               "System.OutOfMemoryException",
+               "System.InvalidCastException",
+               "System.IndexOutOfRangeException"
+       };
+       #define numExceptions   (sizeof(exceptionClasses) / sizeof(const char 
*))
+       ILExecThread *_thread = ILExecThreadCurrent();
+
+       if(exception == _IL_JIT_OUT_OF_MEMORY)
+       {
+               jit_insn_call_native(jitCoder->jitFunction,
+                                                        
"ILRuntimeExceptionThrowOutOfMemory",
+                                                        
ILRuntimeExceptionThrowOutOfMemory,
+                                                        
_ILJitSignature_ILRuntimeExceptionThrowOutOfMemory,
+                                                        0, 0, 
JIT_CALL_NORETURN);
+       }
+       if(exception > 0)
+       {
+               ILClass *classInfo = ILExecThreadLookupClass(_thread,
+                                                                               
                         exceptionClasses[exception]);
+               ILJitValue info;
+               if(!classInfo)
+               {
+               #ifndef REDUCED_STDIO
+                       /* Huh?  The required class doesn't exist.  This 
shouldn't happen */
+                       fprintf(stderr, "Fatal error: %s is missing from the 
system library\n",
+                                       exceptionClasses[exception]);
+                       return;
+               #endif
+               }
+               classInfo = ILClassResolve(classInfo);
+               if(!(classInfo->userData) || 
+                       (((ILClassPrivate *)(classInfo->userData))->inLayout))
+               {
+                       if(!_LayoutClass(_thread, classInfo))
+                       {
+                               return;
+                       }
+               }
+               info = jit_value_create_nint_constant(jitCoder->jitFunction,
+                                                                               
          _IL_JIT_TYPE_VPTR,
+                                                                               
          (jit_nint)classInfo);
+               jit_insn_call_native(jitCoder->jitFunction,
+                                                        
"ILRuntimeExceptionThrowClass",
+                                                        
ILRuntimeExceptionThrowClass,
+                                                        
_ILJitSignature_ILRuntimeExceptionThrowClass,
+                                                        &info, 1, 
JIT_CALL_NORETURN);
+       }
+}
 
 /*
  * Set up exception handling for the current method.
@@ -126,7 +181,6 @@
 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)
@@ -142,13 +196,11 @@
 
        if(!(jitCoder->isInCatcher))
        {
-               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);
+               jit_insn_call_native(jitCoder->jitFunction,
+                                                        
"ILRuntimeExceptionThrow",
+                                                        
ILRuntimeExceptionThrow,
+                                                        
_ILJitSignature_ILRuntimeExceptionThrow,
+                                                        &exception, 1, 
JIT_CALL_NORETURN);
                JITC_ADJUST(jitCoder, -1);
        }
 }
@@ -235,10 +287,9 @@
        }
 #endif
 
-       if(!jitCoder->isInCatcher)
+       if(!(jitCoder->isInCatcher))
        {
                /* Tell libjit that we are in the catcher. */
-               
                jit_insn_start_catcher(jitCoder->jitFunction);
                
                jitCoder->isInCatcher = 1;
@@ -297,10 +348,13 @@
                                                   ILClass *classInfo, int 
hasRethrow)
 {
        ILJITCoder *jitCoder = _ILCoderToILJITCoder(_coder);
-       ILJitValue thread = jit_value_get_param(jitCoder->jitFunction, 0);
+       ILJitValue thread = _ILJitCoderGetThread(jitCoder);
        ILJitValue classTo = 
jit_value_create_nint_constant(jitCoder->jitFunction,
                                                                                
                                _IL_JIT_TYPE_VPTR,
                                                                                
                                (jit_nint)classInfo);
+       ILJitValue method = 
jit_value_create_nint_constant(jitCoder->jitFunction,
+                                                                               
                           _IL_JIT_TYPE_VPTR,
+                                                                               
                           (jit_nint)jitCoder->currentMethod);
        ILJitValue nullException = 
jit_value_create_nint_constant(jitCoder->jitFunction,
                                                                                
                                          _IL_JIT_TYPE_VPTR,
                                                                                
                                      (jit_nint)0);
@@ -335,7 +389,7 @@
                                                                                
  _IL_JIT_LABEL_STARTCATCH);
 
        /* Look if the object can be casted to the cought exception type. */
-       args[0] = thread;
+       args[0] = method;
        args[1] = exceptionObject;
        args[2] = classTo;
        returnValue = jit_insn_call_native(jitCoder->jitFunction,
@@ -402,6 +456,15 @@
  */
 static void *JITCoder_PCToHandler(ILCoder *_coder, void *pc, int beyond)
 {
+       ILJITCoder *jitCoder = _ILCoderToILJITCoder(_coder);
+       void *handler;
+
+       ILJitFunction jitFunction = jit_function_from_pc(jitCoder->context, pc,
+                                                                               
                         &handler);
+       if(jitFunction)
+       {
+               return handler;
+       }
        return 0;
 }
 
@@ -410,6 +473,15 @@
  */
 static ILMethod *JITCoder_PCToMethod(ILCoder *_coder, void *pc, int beyond)
 {
+       ILJITCoder *jitCoder = _ILCoderToILJITCoder(_coder);
+       ILJitFunction jitFunction = jit_function_from_pc(jitCoder->context, pc,
+                                                                               
                         (void **)0);
+
+       if(jitFunction)
+       {
+               return (ILMethod *)jit_function_get_meta(jitFunction,
+                                                                               
                 IL_JIT_META_METHOD);
+       }
        return 0;
 }
 
Index: pnet/engine/jitc_locals.c
diff -u pnet/engine/jitc_locals.c:1.2 pnet/engine/jitc_locals.c:1.3
--- pnet/engine/jitc_locals.c:1.2       Mon Apr 17 17:39:44 2006
+++ pnet/engine/jitc_locals.c   Mon May  1 17:30:50 2006
@@ -273,6 +273,7 @@
                ILJitLocalSlot *param = 0;
                ILUInt32 numParams = jit_type_num_params(signature);
 
+#ifdef IL_JIT_THREAD_IN_SIGNATURE
                /* We don't include the ILExecThread in the params. */
                if(numParams > 1)
                {
@@ -290,6 +291,24 @@
                        }
                        coder->jitParams.numSlots = numParams - 1;
                }
+#else
+               if(numParams > 0)
+               {
+                       ILInt32 current = 0;
+
+                       /* Allocate the locals for the parameters */
+                       _ILJitLocalsAlloc(coder->jitParams, numParams);
+
+                       for(current = 0; current < numParams; ++current)
+                       {
+                               param = &_ILJitParamGet(coder, current);
+
+                               param->value = 
jit_value_get_param(coder->jitFunction, current);
+                               param->flags = 0;
+                       }
+                       coder->jitParams.numSlots = numParams;
+               }
+#endif
                else
                {
                        coder->jitParams.numSlots = 0;
@@ -333,7 +352,10 @@
 
        if((slot->flags & _IL_JIT_VALUE_INITIALIZED) == 0)
        {
-               _ILJitLocalInit(coder, slot);
+               if(!_ILJitLocalInit(coder, slot))
+               {
+                       return 0;
+               }
        }
        return slot->value;
 }
@@ -350,7 +372,10 @@
        _ILJitValueFindAndDup(coder, slot->value);
 #endif
 
-       jit_insn_store(coder->jitFunction, slot->value, value);
+       jit_insn_store(coder->jitFunction, slot->value, 
+                                  
_ILJitValueConvertImplicit(coder->jitFunction,
+                                                                               
          value,
+                                                                               
          jit_value_get_type(slot->value)));
 
        slot->flags |= _IL_JIT_VALUE_INITIALIZED;
        slot->flags &= ~_IL_JIT_VALUE_NULLCHECKED;
@@ -378,7 +403,10 @@
        _ILJitValueFindAndDup(coder, slot->value);
 #endif
 
-       jit_insn_store(coder->jitFunction, slot->value, value);
+       jit_insn_store(coder->jitFunction, slot->value,
+                                  
_ILJitValueConvertImplicit(coder->jitFunction,
+                                                                               
          value,
+                                                                               
          jit_value_get_type(slot->value)));
 
        slot->flags &= ~_IL_JIT_VALUE_NULLCHECKED;
 }
Index: pnet/engine/jitc_obj.c
diff -u pnet/engine/jitc_obj.c:1.16 pnet/engine/jitc_obj.c:1.17
--- pnet/engine/jitc_obj.c:1.16 Mon Apr 17 17:57:14 2006
+++ pnet/engine/jitc_obj.c      Mon May  1 17:30:50 2006
@@ -69,7 +69,7 @@
        ILJitValue slot;
        jit_label_t label = jit_label_undefined;
 
-       args[0] = jit_value_get_param(jitCoder->jitFunction, 0);
+       args[0] = _ILJitCoderGetThread(jitCoder);
        args[1] = jit_value_create_nint_constant(jitCoder->jitFunction,
                                                                                
         _IL_JIT_TYPE_UINT32,
                                                                                
         (jit_nint)field->offset);
@@ -109,8 +109,8 @@
 
        temp = jit_insn_eq(jitCoder->jitFunction, type, info);
        jit_insn_branch_if(jitCoder->jitFunction, temp, &label1);
-       /* TODO: Throw System.InvalidCastException */
-
+       /* Throw an InvalidCastException */
+       _ILJitThrowSystem(jitCoder, _IL_JIT_INVALID_CAST);
        jit_insn_label(jitCoder->jitFunction, &label1);
        valuePtr = jit_insn_load_relative(jitCoder->jitFunction, ptr,
                                                                          
offsetof(ILTypedRef, value),
@@ -211,7 +211,9 @@
        }
        else
        {
-               args[0] = jit_value_get_param(jitCoder->jitFunction, 0);
+               args[0] = jit_value_create_nint_constant(jitCoder->jitFunction,
+                                                                               
                 _IL_JIT_TYPE_VPTR,
+                                                                               
                 (jit_nint)jitCoder->currentMethod);
                args[1] = object;
                args[2] = classTo;
                returnValue = jit_insn_call_native(jitCoder->jitFunction,
@@ -223,7 +225,8 @@
        if(throwException)
        {
                jit_insn_branch_if(jitCoder->jitFunction, returnValue, &label);
-               /* TODO: Throw an InvalidCastException here. */
+               /* Throw an InvalidCastException. */
+               _ILJitThrowSystem(jitCoder, _IL_JIT_INVALID_CAST);
 
        }
        else
@@ -708,7 +711,7 @@
        ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
     ILUInt32 size = _ILSizeOfTypeLocked(jitCoder->process, type);
        ILJitValue constSize = 
jit_value_create_nint_constant(jitCoder->jitFunction,
-                                                                               
                                  _IL_JIT_TYPE_UINT32,
+                                                                               
                                  _IL_JIT_TYPE_INT32,
                                                                                
                                  (jit_nint)size);
        jitCoder->jitStack[jitCoder->stackTop] = constSize;
        JITC_ADJUST(jitCoder, 1);
Index: pnet/engine/jitc_ptr.c
diff -u pnet/engine/jitc_ptr.c:1.9 pnet/engine/jitc_ptr.c:1.10
--- pnet/engine/jitc_ptr.c:1.9  Mon Apr 17 17:39:44 2006
+++ pnet/engine/jitc_ptr.c      Mon May  1 17:30:50 2006
@@ -55,8 +55,8 @@
 
        temp = jit_insn_lt(coder->jitFunction, index, length);
        jit_insn_branch_if(coder->jitFunction, temp, &label);
-       /* throw the System.IndexOutOfRange exception. */
-       _ILJitThrowInternal(coder->jitFunction, JIT_RESULT_OUT_OF_BOUNDS);
+       /* Throw a System.IndexOutOfRange exception. */
+       _ILJitThrowSystem(coder, _IL_JIT_INDEX_OUT_OF_RANGE);
        jit_insn_label(coder->jitFunction, &label);
 }
 
@@ -483,10 +483,10 @@
                address = jitCoder->jitStack[jitCoder->stackTop - 1];
                _ILJitCheckNull(jitCoder, address);
                jitCoder->jitStack[jitCoder->stackTop - 1] =
-               _ILJitValueConvertToStackType(jitCoder->jitFunction,
-                                                                         
jit_insn_load_relative(jitCoder->jitFunction,
-                                                                               
                                         address, (jit_nint)0,
-                                                                               
                                         jitType));
+                       _ILJitValueConvertToStackType(jitCoder->jitFunction,
+                                                                               
  jit_insn_load_relative(jitCoder->jitFunction,
+                                                                               
                                                 address, (jit_nint)0,
+                                                                               
                                                 jitType));
        }
        else
        {
@@ -566,19 +566,28 @@
        }
        if(_ILJitFunctionIsInternal(jitCoder, ctor, &fnInfo, 1))
        {
+               ILJitValue thread = _ILJitCoderGetThread(jitCoder);
+
                JITC_ADJUST(jitCoder, -1);
-               returnValue = _ILJitCallInternal(jitCoder->jitFunction, ctor,
+               returnValue = _ILJitCallInternal(jitCoder->jitFunction, thread, 
ctor,
                                                                                
 fnInfo.func, 0, &length, 1);
        }
        else
        {
-               args[0] = jit_value_get_param(jitCoder->jitFunction, 0);
+       #ifdef IL_JIT_THREAD_IN_SIGNATURE
+               args[0] = _ILJitCoderGetThread(jitCoder);
                args[1] = length;
                JITC_ADJUST(jitCoder, -1);
-               _ILJitSetMethodInThread(jitCoder->jitFunction, args[0], ctor);
                /* Output code to call the array type's constructor */
                returnValue = jit_insn_call(jitCoder->jitFunction, 0, 
jitFunction,
                                                                        0, 
args, 2, 0);
+       #else
+               args[0] = length;
+               JITC_ADJUST(jitCoder, -1);
+               /* Output code to call the array type's constructor */
+               returnValue = jit_insn_call(jitCoder->jitFunction, 0, 
jitFunction,
+                                                                       0, 
args, 1, 0);
+       #endif
        }
        jit_insn_branch_if(jitCoder->jitFunction, returnValue, &label);
        _ILJitThrowCurrentException(jitCoder);
Index: pnet/engine/jitc_setup.c
diff -u pnet/engine/jitc_setup.c:1.13 pnet/engine/jitc_setup.c:1.14
--- pnet/engine/jitc_setup.c:1.13       Mon Apr 17 17:39:44 2006
+++ pnet/engine/jitc_setup.c    Mon May  1 17:30:50 2006
@@ -63,6 +63,11 @@
        coder->localsInitialized = 0;
 #endif
 
+#ifndef IL_JIT_THREAD_IN_SIGNATURE
+       /* Reset the cached thread. */
+       coder->thread = 0;
+#endif
+
        /* Ensure that the evaluation stack can hold at least the methods 
maxStack */
        /* items. */
        /* We need two additional slots for the ValueCtorArgs. */
@@ -78,11 +83,6 @@
        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),
-                                                       method);
-
        if(ILMethod_IsStaticConstructor(method))
        {
                /* We have to take care that the method is executed only once. 
*/
Index: pnet/engine/lib_defs.h
diff -u pnet/engine/lib_defs.h:1.27 pnet/engine/lib_defs.h:1.28
--- pnet/engine/lib_defs.h:1.27 Tue Aug 24 05:48:05 2004
+++ pnet/engine/lib_defs.h      Mon May  1 17:30:50 2006
@@ -345,6 +345,18 @@
 } PackedStackFrame;
 
 /*
+ * Structure of the ECMA part of the "System.Exception" class.
+ */
+typedef struct _tagSystemException System_Exception;
+struct _tagSystemException
+{
+       System_String      *message;
+       System_Exception   *innerException;
+       System_Array       *stackTrace;
+
+};
+
+/*
  * Prototype all of the "internalcall" methods in the engine.
  */
 #include "int_proto.h"




reply via email to

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