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/engine.c engine/engine.h ...


From: Klaus Treichel
Subject: [dotgnu-pnet-commits] pnet ChangeLog engine/engine.c engine/engine.h ...
Date: Tue, 12 Aug 2008 18:19:53 +0000

CVSROOT:        /cvsroot/dotgnu-pnet
Module name:    pnet
Changes by:     Klaus Treichel <ktreichel>      08/08/12 18:19:52

Modified files:
        .              : ChangeLog 
        engine         : engine.c engine.h int_proto.h int_table.c 
                         lib_appdomain.c process.c 

Log message:
        Add more AppDomain support and fix some issues.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pnet/ChangeLog?cvsroot=dotgnu-pnet&r1=1.3555&r2=1.3556
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/engine.c?cvsroot=dotgnu-pnet&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/engine.h?cvsroot=dotgnu-pnet&r1=1.125&r2=1.126
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/int_proto.h?cvsroot=dotgnu-pnet&r1=1.105&r2=1.106
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/int_table.c?cvsroot=dotgnu-pnet&r1=1.109&r2=1.110
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/lib_appdomain.c?cvsroot=dotgnu-pnet&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/process.c?cvsroot=dotgnu-pnet&r1=1.77&r2=1.78

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ChangeLog,v
retrieving revision 1.3555
retrieving revision 1.3556
diff -u -b -r1.3555 -r1.3556
--- ChangeLog   10 Aug 2008 16:16:12 -0000      1.3555
+++ ChangeLog   12 Aug 2008 18:19:50 -0000      1.3556
@@ -1,3 +1,32 @@
+2008-08-12  Klaus Treichel  <address@hidden>
+
+       * engine/engine.c (ILExecDeinit): Unregister the current thread for
+       managed execution before unloading the processes.
+       (ILExecEngineCreate): Initialize the new lastId member.
+       (ILExecEngineDestroy): Don't destroy the processes but let the gc
+       do it except it's built without multiple appdomain support.
+
+       * engine/engine.h: Add member lastId to the ILExecEngine. Add member id
+       to the ILExecProcess.
+
+       * engine/int_table.c, engine/int_proto.h: Regenerated.
+
+       * engine/lib_appdomain.c: Replace ILNativeInt appdomain by
+       ILObject *appDomain in all function prototypes.
+       (_IL_AppDomain_GetIdInternal): Added to implement the AppDomain.Id
+       property.
+
+       * engine/process.c (ILExecProcessJoinEngine): Fill the new id property.
+       (_ILExecProcessCreateInternal): Allocate the process block including the
+       ILObjectHeader even if that's not used by now.
+       (_ILExecProcessDestroyInternal): Set the destroyed member references to 
0.
+       (_ILExecProcessUnloadFunc): Added thread func to run the unloading from 
a
+       different thread.
+       (ILExecProcessUnload): Implement unloading the process from a different
+       thread if the current thread is in the process to be unloaded.
+       (ILExecProcessDestroy): Handle the additional object header when
+       deallocating the process block.
+
 2008-08-10  Klaus Treichel  <address@hidden>
 
        * engine/engine.c (ILExecDeInit): Reset the console mode to normal here

Index: engine/engine.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/engine.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- engine/engine.c     10 Aug 2008 16:16:13 -0000      1.5
+++ engine/engine.c     12 Aug 2008 18:19:51 -0000      1.6
@@ -1,7 +1,7 @@
 /*
  * engine.c - Manage multiple application domains in the runtime engine.
  *
- * Copyright (C) 2001  Southern Storm Software, Pty Ltd.
+ * Copyright (C) 2001, 2008  Southern Storm Software, Pty Ltd.
  *
  * Contributions by Klaus Treichel (address@hidden)
  *
@@ -68,6 +68,9 @@
 
 void ILExecDeinit()
 {      
+       /* unregister the current threas for managed execution */
+       ILThreadUnregisterForManagedExecution(ILThreadSelf());
+
        if (globalEngine)
        {
                ILExecEngineDestroy(globalEngine);
@@ -112,6 +115,7 @@
        engine->processLock = 0;
        engine->defaultProcess = 0;
 #ifdef IL_CONFIG_APPDOMAINS
+       engine->lastId = 0;
        engine->firstProcess = 0;
 #endif
 #ifdef IL_USE_CVM
@@ -136,13 +140,14 @@
  */
 void ILExecEngineDestroy(ILExecEngine *engine)
 {
+       ILExecProcess *defaultProcess;
+
 #ifdef IL_CONFIG_APPDOMAINS
        ILExecProcess *process; 
        int count;
-       ILQueueEntry *unloadQueue, *destroyQueue;
+       ILQueueEntry *unloadQueue;
        
        unloadQueue = ILQueueCreate();
-       destroyQueue = ILQueueCreate();
 
        /* Lock the engine process list*/
        ILMutexLock(engine->processLock);
@@ -162,7 +167,6 @@
                                ILQueueAdd(&unloadQueue, process);
 
                        }
-                       ILQueueAdd(&destroyQueue, process);
                        count++;
                }
                /* Move onto the next process */
@@ -172,10 +176,9 @@
        /* Unlock the engine process list */
        ILMutexUnlock(engine->processLock);
 
-       if ((!unloadQueue || !destroyQueue) && count != 0)
+       if (!unloadQueue && count != 0)
        {
-               /* Probably ran out of memory trying to build the unload and 
destroy
-                       queue */
+               /* Probably ran out of memory trying to build the unload queue 
*/
                return;
        }
 
@@ -186,20 +189,21 @@
                ILExecProcessUnload(process);
        }
 
-       /* now destroy the processes */
-       while (destroyQueue)
-       {
-               process = (ILExecProcess *)ILQueueRemove(&destroyQueue);
-               ILExecProcessDestroy(process);
-       }
 #endif
  
        /* now unload and destroy the default process */
-       if(engine->defaultProcess)
+       defaultProcess = engine->defaultProcess;
+       if(defaultProcess)
+       {
+               ILExecProcessUnload(defaultProcess);
+       }
+
+#ifndef IL_CONFIG_APPDOMAINS
+       if(defaultProcess)
        {
-               ILExecProcessUnload(engine->defaultProcess);
                ILExecProcessDestroy(engine->defaultProcess);
        }
+#endif
 
        if (engine->processLock)
        {

Index: engine/engine.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/engine.h,v
retrieving revision 1.125
retrieving revision 1.126
diff -u -b -r1.125 -r1.126
--- engine/engine.h     10 Aug 2008 16:16:13 -0000      1.125
+++ engine/engine.h     12 Aug 2008 18:19:51 -0000      1.126
@@ -1,7 +1,7 @@
 /*
  * engine.h - Core definitions for the runtime engine.
  *
- * Copyright (C) 2001  Southern Storm Software, Pty Ltd.
+ * Copyright (C) 2001, 2008  Southern Storm Software, Pty Ltd.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -148,6 +148,9 @@
 #ifdef IL_CONFIG_APPDOMAINS
        /* linked list of application domains */
        ILExecProcess  *firstProcess;
+
+       /* Id for the latest application domain that joined the engine */
+       ILInt32                 lastId;
 #endif
 };
 
@@ -334,6 +337,8 @@
 #endif
 
 #ifdef IL_CONFIG_APPDOMAINS
+       /* Id of the application domain */
+       ILInt32                 id;
 
        /* sibling app domains */
        ILExecProcess   *prevProcess;

Index: engine/int_proto.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/int_proto.h,v
retrieving revision 1.105
retrieving revision 1.106
diff -u -b -r1.105 -r1.106
--- engine/int_proto.h  10 Aug 2008 16:16:13 -0000      1.105
+++ engine/int_proto.h  12 Aug 2008 18:19:51 -0000      1.106
@@ -34,24 +34,25 @@
 extern ILObject * _IL_Enum_EnumValueOr(ILExecThread * _thread, ILObject * 
value1, ILObject * value2);
 extern ILObject * _IL_Enum_EnumLongToObject(ILExecThread * _thread, ILObject * 
enumType, ILInt64 value);
 
-extern void _IL_AppDomain_AppendPrivatePathsInternal(ILExecThread * _thread, 
ILNativeInt appDomain, System_Array * paths);
-extern void _IL_AppDomain_ClearPrivatePathInternal(ILExecThread * _thread, 
ILNativeInt appDomain);
-extern void _IL_AppDomain_ClearShadowCopyPathInternal(ILExecThread * _thread, 
ILNativeInt appDomain);
-extern void _IL_AppDomain_CreateAppDomain(ILExecThread * _thread, ILNativeInt 
* appDomain);
-extern void _IL_AppDomain_CurrentAppDomain(ILExecThread * _thread, ILNativeInt 
* appDomain);
-extern ILString * _IL_AppDomain_GetBaseDirectoryInternal(ILExecThread * 
_thread, ILNativeInt appDomain);
-extern ILString * _IL_AppDomain_GetFriendlyNameInternal(ILExecThread * 
_thread, ILNativeInt appDomain);
-extern ILString * _IL_AppDomain_GetRelativeSearchPathInternal(ILExecThread * 
_thread, ILNativeInt appDomain);
-extern ILBool _IL_AppDomain_GetShadowCopyFilesInternal(ILExecThread * _thread, 
ILNativeInt appDomain);
-extern ILBool _IL_AppDomain_IsDefaultAppDomainInternal(ILExecThread * _thread, 
ILNativeInt appDomain);
-extern void _IL_AppDomain_SetBaseDirectoryInternal(ILExecThread * _thread, 
ILNativeInt appDomain, ILString * baseDirectory);
-extern void _IL_AppDomain_SetFriendlyNameInternal(ILExecThread * _thread, 
ILNativeInt appDomain, ILString * friendlyName);
-extern void _IL_AppDomain_SetRelativeSearchPathInternal(ILExecThread * 
_thread, ILNativeInt appDomain, ILString * appRelativePath);
-extern void _IL_AppDomain_SetShadowCopyFilesInternal(ILExecThread * _thread, 
ILNativeInt appDomain, ILBool shadowCopyFiles);
-extern void _IL_AppDomain_SetShadowCopyPathInternal(ILExecThread * _thread, 
ILNativeInt appDomain, System_Array * paths);
-extern void _IL_AppDomain_UnloadAppDomain(ILExecThread * _thread, ILNativeInt 
appDomain);
-extern System_Array * _IL_AppDomain_GetAssembliesInternal(ILExecThread * 
_thread, ILNativeInt appDomain);
-extern ILBool _IL_AppDomain_IsFinalizingForUnloadInternal(ILExecThread * 
_thread, ILNativeInt appDomain);
+extern void _IL_AppDomain_AppendPrivatePathsInternal(ILExecThread * _thread, 
ILObject * appDomain, System_Array * paths);
+extern void _IL_AppDomain_ClearPrivatePathInternal(ILExecThread * _thread, 
ILObject * appDomain);
+extern void _IL_AppDomain_ClearShadowCopyPathInternal(ILExecThread * _thread, 
ILObject * appDomain);
+extern void _IL_AppDomain_CreateAppDomain(ILExecThread * _thread, ILObject * * 
appDomain);
+extern void _IL_AppDomain_CurrentAppDomain(ILExecThread * _thread, ILObject * 
* appDomain);
+extern ILString * _IL_AppDomain_GetBaseDirectoryInternal(ILExecThread * 
_thread, ILObject * appDomain);
+extern ILInt32 _IL_AppDomain_GetIdInternal(ILExecThread * _thread, ILObject * 
appDomain);
+extern ILString * _IL_AppDomain_GetFriendlyNameInternal(ILExecThread * 
_thread, ILObject * appDomain);
+extern ILString * _IL_AppDomain_GetRelativeSearchPathInternal(ILExecThread * 
_thread, ILObject * appDomain);
+extern ILBool _IL_AppDomain_GetShadowCopyFilesInternal(ILExecThread * _thread, 
ILObject * appDomain);
+extern ILBool _IL_AppDomain_IsDefaultAppDomainInternal(ILExecThread * _thread, 
ILObject * appDomain);
+extern void _IL_AppDomain_SetBaseDirectoryInternal(ILExecThread * _thread, 
ILObject * appDomain, ILString * baseDirectory);
+extern void _IL_AppDomain_SetFriendlyNameInternal(ILExecThread * _thread, 
ILObject * appDomain, ILString * friendlyName);
+extern void _IL_AppDomain_SetRelativeSearchPathInternal(ILExecThread * 
_thread, ILObject * appDomain, ILString * appRelativePath);
+extern void _IL_AppDomain_SetShadowCopyFilesInternal(ILExecThread * _thread, 
ILObject * appDomain, ILBool shadowCopyFiles);
+extern void _IL_AppDomain_SetShadowCopyPathInternal(ILExecThread * _thread, 
ILObject * appDomain, System_Array * paths);
+extern void _IL_AppDomain_UnloadAppDomain(ILExecThread * _thread, ILObject * 
appDomain);
+extern System_Array * _IL_AppDomain_GetAssembliesInternal(ILExecThread * 
_thread, ILObject * appDomain);
+extern ILBool _IL_AppDomain_IsFinalizingForUnloadInternal(ILExecThread * 
_thread, ILObject * appDomain);
 
 extern ILObject * _IL_Delegate_CreateBlankDelegate(ILExecThread * _thread, 
ILObject * type, ILObject * method);
 
@@ -173,8 +174,8 @@
 extern ILUInt8 _IL_Buffer_GetElement(ILExecThread * _thread, ILObject * array, 
ILInt32 index);
 extern void _IL_Buffer_SetElement(ILExecThread * _thread, ILObject * array, 
ILInt32 index, ILUInt8 value);
 
-extern void _IL_AppDomainSetup_GetPrivateBinPaths(ILExecThread * _thread, 
ILNativeInt appDomain, System_Array * * paths);
-extern void _IL_AppDomainSetup_SetPrivateBinPaths(ILExecThread * _thread, 
ILNativeInt appDomain, System_Array * paths);
+extern void _IL_AppDomainSetup_GetPrivateBinPaths(ILExecThread * _thread, 
ILObject * appDomain, System_Array * * paths);
+extern void _IL_AppDomainSetup_SetPrivateBinPaths(ILExecThread * _thread, 
ILObject * appDomain, System_Array * paths);
 
 extern ILObject * _IL_MethodBase_GetMethodFromHandle(ILExecThread * _thread, 
void * handle);
 extern ILObject * _IL_MethodBase_GetCurrentMethod(ILExecThread * _thread);

Index: engine/int_table.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/int_table.c,v
retrieving revision 1.109
retrieving revision 1.110
diff -u -b -r1.109 -r1.110
--- engine/int_table.c  10 Aug 2008 16:16:13 -0000      1.109
+++ engine/int_table.c  12 Aug 2008 18:19:52 -0000      1.110
@@ -231,45 +231,27 @@
 
 #if !defined(HAVE_LIBFFI)
 
-static void marshal_vpjp(void (*fn)(), void *rvalue, void **avalue)
-{
-       (*(void (*)(void *, ILNativeUInt, void *))fn)(*((void * *)(avalue[0])), 
*((ILNativeUInt *)(avalue[1])), *((void * *)(avalue[2])));
-}
-
-#endif
-
-#if !defined(HAVE_LIBFFI)
-
-static void marshal_vpj(void (*fn)(), void *rvalue, void **avalue)
-{
-       (*(void (*)(void *, ILNativeUInt))fn)(*((void * *)(avalue[0])), 
*((ILNativeUInt *)(avalue[1])));
-}
-
-#endif
-
-#if !defined(HAVE_LIBFFI)
-
-static void marshal_ppj(void (*fn)(), void *rvalue, void **avalue)
+static void marshal_vppp(void (*fn)(), void *rvalue, void **avalue)
 {
-       *((void * *)rvalue) = (*(void * (*)(void *, ILNativeUInt))fn)(*((void * 
*)(avalue[0])), *((ILNativeUInt *)(avalue[1])));
+       (*(void (*)(void *, void *, void *))fn)(*((void * *)(avalue[0])), 
*((void * *)(avalue[1])), *((void * *)(avalue[2])));
 }
 
 #endif
 
 #if !defined(HAVE_LIBFFI)
 
-static void marshal_bpj(void (*fn)(), void *rvalue, void **avalue)
+static void marshal_bpp(void (*fn)(), void *rvalue, void **avalue)
 {
-       *((ILNativeInt *)rvalue) = (*(ILInt8 (*)(void *, 
ILNativeUInt))fn)(*((void * *)(avalue[0])), *((ILNativeUInt *)(avalue[1])));
+       *((ILNativeInt *)rvalue) = (*(ILInt8 (*)(void *, void *))fn)(*((void * 
*)(avalue[0])), *((void * *)(avalue[1])));
 }
 
 #endif
 
 #if !defined(HAVE_LIBFFI)
 
-static void marshal_vpjb(void (*fn)(), void *rvalue, void **avalue)
+static void marshal_vppb(void (*fn)(), void *rvalue, void **avalue)
 {
-       (*(void (*)(void *, ILNativeUInt, ILInt8))fn)(*((void * *)(avalue[0])), 
*((ILNativeUInt *)(avalue[1])), *((ILInt8 *)(avalue[2])));
+       (*(void (*)(void *, void *, ILInt8))fn)(*((void * *)(avalue[0])), 
*((void * *)(avalue[1])), *((ILInt8 *)(avalue[2])));
 }
 
 #endif
@@ -277,24 +259,25 @@
 #ifndef _IL_AppDomain_suppressed
 
 IL_METHOD_BEGIN(AppDomain_Methods)
-       IL_METHOD("AppendPrivatePathsInternal", "(j[oSystem.String;)V", 
_IL_AppDomain_AppendPrivatePathsInternal, marshal_vpjp)
-       IL_METHOD("ClearPrivatePathInternal", "(j)V", 
_IL_AppDomain_ClearPrivatePathInternal, marshal_vpj)
-       IL_METHOD("ClearShadowCopyPathInternal", "(j)V", 
_IL_AppDomain_ClearShadowCopyPathInternal, marshal_vpj)
-       IL_METHOD("CreateAppDomain", "(&j)V", _IL_AppDomain_CreateAppDomain, 
marshal_vpp)
-       IL_METHOD("CurrentAppDomain", "(&j)V", _IL_AppDomain_CurrentAppDomain, 
marshal_vpp)
-       IL_METHOD("GetBaseDirectoryInternal", "(j)oSystem.String;", 
_IL_AppDomain_GetBaseDirectoryInternal, marshal_ppj)
-       IL_METHOD("GetFriendlyNameInternal", "(j)oSystem.String;", 
_IL_AppDomain_GetFriendlyNameInternal, marshal_ppj)
-       IL_METHOD("GetRelativeSearchPathInternal", "(j)oSystem.String;", 
_IL_AppDomain_GetRelativeSearchPathInternal, marshal_ppj)
-       IL_METHOD("GetShadowCopyFilesInternal", "(j)Z", 
_IL_AppDomain_GetShadowCopyFilesInternal, marshal_bpj)
-       IL_METHOD("IsDefaultAppDomainInternal", "(j)Z", 
_IL_AppDomain_IsDefaultAppDomainInternal, marshal_bpj)
-       IL_METHOD("SetBaseDirectoryInternal", "(joSystem.String;)V", 
_IL_AppDomain_SetBaseDirectoryInternal, marshal_vpjp)
-       IL_METHOD("SetFriendlyNameInternal", "(joSystem.String;)V", 
_IL_AppDomain_SetFriendlyNameInternal, marshal_vpjp)
-       IL_METHOD("SetRelativeSearchPathInternal", "(joSystem.String;)V", 
_IL_AppDomain_SetRelativeSearchPathInternal, marshal_vpjp)
-       IL_METHOD("SetShadowCopyFilesInternal", "(jZ)V", 
_IL_AppDomain_SetShadowCopyFilesInternal, marshal_vpjb)
-       IL_METHOD("SetShadowCopyPathInternal", "(j[oSystem.String;)V", 
_IL_AppDomain_SetShadowCopyPathInternal, marshal_vpjp)
-       IL_METHOD("UnloadAppDomain", "(j)V", _IL_AppDomain_UnloadAppDomain, 
marshal_vpj)
-       IL_METHOD("GetAssembliesInternal", "(j)[oSystem.Reflection.Assembly;", 
_IL_AppDomain_GetAssembliesInternal, marshal_ppj)
-       IL_METHOD("IsFinalizingForUnloadInternal", "(j)Z", 
_IL_AppDomain_IsFinalizingForUnloadInternal, marshal_bpj)
+       IL_METHOD("AppendPrivatePathsInternal", 
"(oSystem.Object;[oSystem.String;)V", _IL_AppDomain_AppendPrivatePathsInternal, 
marshal_vppp)
+       IL_METHOD("ClearPrivatePathInternal", "(oSystem.Object;)V", 
_IL_AppDomain_ClearPrivatePathInternal, marshal_vpp)
+       IL_METHOD("ClearShadowCopyPathInternal", "(oSystem.Object;)V", 
_IL_AppDomain_ClearShadowCopyPathInternal, marshal_vpp)
+       IL_METHOD("CreateAppDomain", "(&oSystem.Object;)V", 
_IL_AppDomain_CreateAppDomain, marshal_vpp)
+       IL_METHOD("CurrentAppDomain", "(&oSystem.Object;)V", 
_IL_AppDomain_CurrentAppDomain, marshal_vpp)
+       IL_METHOD("GetBaseDirectoryInternal", 
"(oSystem.Object;)oSystem.String;", _IL_AppDomain_GetBaseDirectoryInternal, 
marshal_ppp)
+       IL_METHOD("GetIdInternal", "(oSystem.Object;)i", 
_IL_AppDomain_GetIdInternal, marshal_ipp)
+       IL_METHOD("GetFriendlyNameInternal", 
"(oSystem.Object;)oSystem.String;", _IL_AppDomain_GetFriendlyNameInternal, 
marshal_ppp)
+       IL_METHOD("GetRelativeSearchPathInternal", 
"(oSystem.Object;)oSystem.String;", 
_IL_AppDomain_GetRelativeSearchPathInternal, marshal_ppp)
+       IL_METHOD("GetShadowCopyFilesInternal", "(oSystem.Object;)Z", 
_IL_AppDomain_GetShadowCopyFilesInternal, marshal_bpp)
+       IL_METHOD("IsDefaultAppDomainInternal", "(oSystem.Object;)Z", 
_IL_AppDomain_IsDefaultAppDomainInternal, marshal_bpp)
+       IL_METHOD("SetBaseDirectoryInternal", 
"(oSystem.Object;oSystem.String;)V", _IL_AppDomain_SetBaseDirectoryInternal, 
marshal_vppp)
+       IL_METHOD("SetFriendlyNameInternal", 
"(oSystem.Object;oSystem.String;)V", _IL_AppDomain_SetFriendlyNameInternal, 
marshal_vppp)
+       IL_METHOD("SetRelativeSearchPathInternal", 
"(oSystem.Object;oSystem.String;)V", 
_IL_AppDomain_SetRelativeSearchPathInternal, marshal_vppp)
+       IL_METHOD("SetShadowCopyFilesInternal", "(oSystem.Object;Z)V", 
_IL_AppDomain_SetShadowCopyFilesInternal, marshal_vppb)
+       IL_METHOD("SetShadowCopyPathInternal", 
"(oSystem.Object;[oSystem.String;)V", _IL_AppDomain_SetShadowCopyPathInternal, 
marshal_vppp)
+       IL_METHOD("UnloadAppDomain", "(oSystem.Object;)V", 
_IL_AppDomain_UnloadAppDomain, marshal_vpp)
+       IL_METHOD("GetAssembliesInternal", 
"(oSystem.Object;)[oSystem.Reflection.Assembly;", 
_IL_AppDomain_GetAssembliesInternal, marshal_ppp)
+       IL_METHOD("IsFinalizingForUnloadInternal", "(oSystem.Object;)Z", 
_IL_AppDomain_IsFinalizingForUnloadInternal, marshal_bpp)
 IL_METHOD_END
 
 #endif
@@ -582,15 +565,6 @@
 
 #if !defined(HAVE_LIBFFI)
 
-static void marshal_vppp(void (*fn)(), void *rvalue, void **avalue)
-{
-       (*(void (*)(void *, void *, void *))fn)(*((void * *)(avalue[0])), 
*((void * *)(avalue[1])), *((void * *)(avalue[2])));
-}
-
-#endif
-
-#if !defined(HAVE_LIBFFI)
-
 static void marshal_vppf(void (*fn)(), void *rvalue, void **avalue)
 {
        (*(void (*)(void *, void *, ILFloat))fn)(*((void * *)(avalue[0])), 
*((void * *)(avalue[1])), *((ILFloat *)(avalue[2])));
@@ -893,8 +867,8 @@
 #ifndef _IL_AppDomainSetup_suppressed
 
 IL_METHOD_BEGIN(AppDomainSetup_Methods)
-       IL_METHOD("GetPrivateBinPaths", "(j&[oSystem.String;)V", 
_IL_AppDomainSetup_GetPrivateBinPaths, marshal_vpjp)
-       IL_METHOD("SetPrivateBinPaths", "(j[oSystem.String;)V", 
_IL_AppDomainSetup_SetPrivateBinPaths, marshal_vpjp)
+       IL_METHOD("GetPrivateBinPaths", "(oSystem.Object;&[oSystem.String;)V", 
_IL_AppDomainSetup_GetPrivateBinPaths, marshal_vppp)
+       IL_METHOD("SetPrivateBinPaths", "(oSystem.Object;[oSystem.String;)V", 
_IL_AppDomainSetup_SetPrivateBinPaths, marshal_vppp)
 IL_METHOD_END
 
 #endif
@@ -944,6 +918,15 @@
 
 #endif
 
+#if !defined(HAVE_LIBFFI)
+
+static void marshal_ppj(void (*fn)(), void *rvalue, void **avalue)
+{
+       *((void * *)rvalue) = (*(void * (*)(void *, ILNativeUInt))fn)(*((void * 
*)(avalue[0])), *((ILNativeUInt *)(avalue[1])));
+}
+
+#endif
+
 #ifndef _IL_ClrProperty_suppressed
 
 IL_METHOD_BEGIN(ClrProperty_Methods)
@@ -961,15 +944,6 @@
 
 #endif
 
-#if !defined(HAVE_LIBFFI)
-
-static void marshal_bpp(void (*fn)(), void *rvalue, void **avalue)
-{
-       *((ILNativeInt *)rvalue) = (*(ILInt8 (*)(void *, void *))fn)(*((void * 
*)(avalue[0])), *((void * *)(avalue[1])));
-}
-
-#endif
-
 #ifndef _IL_Module_suppressed
 
 IL_METHOD_BEGIN(Module_Methods)
@@ -1004,6 +978,15 @@
 
 #if !defined(HAVE_LIBFFI)
 
+static void marshal_bpj(void (*fn)(), void *rvalue, void **avalue)
+{
+       *((ILNativeInt *)rvalue) = (*(ILInt8 (*)(void *, 
ILNativeUInt))fn)(*((void * *)(avalue[0])), *((ILNativeUInt *)(avalue[1])));
+}
+
+#endif
+
+#if !defined(HAVE_LIBFFI)
+
 static void marshal_bpjib(void (*fn)(), void *rvalue, void **avalue)
 {
        *((ILNativeInt *)rvalue) = (*(ILInt8 (*)(void *, ILNativeUInt, ILInt32, 
ILInt8))fn)(*((void * *)(avalue[0])), *((ILNativeUInt *)(avalue[1])), 
*((ILInt32 *)(avalue[2])), *((ILInt8 *)(avalue[3])));
@@ -1480,6 +1463,15 @@
 
 #endif
 
+#if !defined(HAVE_LIBFFI)
+
+static void marshal_vpjp(void (*fn)(), void *rvalue, void **avalue)
+{
+       (*(void (*)(void *, ILNativeUInt, void *))fn)(*((void * *)(avalue[0])), 
*((ILNativeUInt *)(avalue[1])), *((void * *)(avalue[2])));
+}
+
+#endif
+
 #ifndef _IL_FieldBuilder_suppressed
 
 IL_METHOD_BEGIN(FieldBuilder_Methods)
@@ -1833,6 +1825,15 @@
 
 #if !defined(HAVE_LIBFFI)
 
+static void marshal_vpj(void (*fn)(), void *rvalue, void **avalue)
+{
+       (*(void (*)(void *, ILNativeUInt))fn)(*((void * *)(avalue[0])), 
*((ILNativeUInt *)(avalue[1])));
+}
+
+#endif
+
+#if !defined(HAVE_LIBFFI)
+
 static void marshal_bppib(void (*fn)(), void *rvalue, void **avalue)
 {
        *((ILNativeInt *)rvalue) = (*(ILInt8 (*)(void *, void *, ILInt32, 
ILInt8))fn)(*((void * *)(avalue[0])), *((void * *)(avalue[1])), *((ILInt32 
*)(avalue[2])), *((ILInt8 *)(avalue[3])));
@@ -1943,15 +1944,6 @@
 
 #if !defined(HAVE_LIBFFI)
 
-static void marshal_vppb(void (*fn)(), void *rvalue, void **avalue)
-{
-       (*(void (*)(void *, void *, ILInt8))fn)(*((void * *)(avalue[0])), 
*((void * *)(avalue[1])), *((ILInt8 *)(avalue[2])));
-}
-
-#endif
-
-#if !defined(HAVE_LIBFFI)
-
 static void marshal_bppi(void (*fn)(), void *rvalue, void **avalue)
 {
        *((ILNativeInt *)rvalue) = (*(ILInt8 (*)(void *, void *, 
ILInt32))fn)(*((void * *)(avalue[0])), *((void * *)(avalue[1])), *((ILInt32 
*)(avalue[2])));

Index: engine/lib_appdomain.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/lib_appdomain.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- engine/lib_appdomain.c      10 Aug 2008 16:16:14 -0000      1.1
+++ engine/lib_appdomain.c      12 Aug 2008 18:19:52 -0000      1.2
@@ -1,7 +1,7 @@
 /*
  * lib_appdomain.c - Internalcall methods for the "System.AppDomain" class.
  *
- * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
+ * Copyright (C) 2003, 2008  Southern Storm Software, Pty Ltd.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -82,9 +82,9 @@
 }
 
 /*
- * private static void AppendPrivatePathInternal(IntPtr appDomain, String[] 
splitPaths);
+ * private static void AppendPrivatePathInternal(Object appDomain, String[] 
splitPaths);
  */
-void _IL_AppDomain_AppendPrivatePathsInternal(ILExecThread *thread, 
ILNativeInt appDomain, System_Array *splitPaths)
+void _IL_AppDomain_AppendPrivatePathsInternal(ILExecThread *thread, ILObject 
*appDomain, System_Array *splitPaths)
 {
        if(!IsAppDomainUnloaded(thread, (ILExecProcess *)appDomain))
        {
@@ -133,9 +133,9 @@
 }
 
 /*
- * private static void CreateAppDomain(ref IntPtr appDomain);
+ * private static void CreateAppDomain(ref Object appDomain);
  */
-void _IL_AppDomain_CreateAppDomain(ILExecThread *thread, ILNativeInt 
*appDomain)
+void _IL_AppDomain_CreateAppDomain(ILExecThread *thread, ILObject **appDomain)
 {
 #ifdef IL_CONFIG_APPDOMAINS
        ILExecProcess *process = ILExecProcessCreate(0, 0);
@@ -159,7 +159,7 @@
                {
                         _ILExecProcessLoadStandard(process, corlibImage);
                        /* return the new process */
-                       *appDomain = (ILNativeInt)((void *)process);
+                       *appDomain = (ILObject *)process;
                }
        }
        else
@@ -173,9 +173,9 @@
 }
 
 /*
- * private static void ClearPrivatePathInternal(IntPtr appDomain);
+ * private static void ClearPrivatePathInternal(Object appDomain);
  */
-void _IL_AppDomain_ClearPrivatePathInternal(ILExecThread *thread, ILNativeInt 
appDomain)
+void _IL_AppDomain_ClearPrivatePathInternal(ILExecThread *thread, ILObject 
*appDomain)
 {
        if(!IsAppDomainUnloaded(thread, (ILExecProcess *)appDomain))
        {
@@ -188,9 +188,9 @@
 }
 
 /*
- * private static void ClearShadowCopyPathInternal(IntPtr appDomain);
+ * private static void ClearShadowCopyPathInternal(Object appDomain);
  */
-void _IL_AppDomain_ClearShadowCopyPathInternal(ILExecThread *thread, 
ILNativeInt appDomain)
+void _IL_AppDomain_ClearShadowCopyPathInternal(ILExecThread *thread, ILObject 
*appDomain)
 {
        if(!IsAppDomainUnloaded(thread, (ILExecProcess *)appDomain))
        {
@@ -203,18 +203,18 @@
 }
 
 /*
- * private static void CurrentAppDomain(ref IntPtr appDomain);
+ * private static void CurrentAppDomain(ref Object appDomain);
  */
-void _IL_AppDomain_CurrentAppDomain(ILExecThread *thread, ILNativeInt 
*appDomain)
+void _IL_AppDomain_CurrentAppDomain(ILExecThread *thread, ILObject **appDomain)
 {
-       *appDomain = (ILNativeInt)((void *)thread->process);
+       *appDomain = (ILObject *)(thread->process);
 }
 
 /*
- * private static Assembly[] GetAssembliesInternal(IntPtr appDomain);
+ * private static Assembly[] GetAssembliesInternal(Object appDomain);
  */
 System_Array *_IL_AppDomain_GetAssembliesInternal(ILExecThread *thread,
-                                                                               
                        ILNativeInt appDomain)
+                                                                               
                  ILObject *appDomain)
 {
        if(!IsAppDomainUnloaded(thread, (ILExecProcess *)appDomain))
        {
@@ -288,9 +288,21 @@
 }
 
 /*
- * private static bool IsDefaultAppDomainInternal(IntPtr appDomain);
+ * private static int GetIdInternal(Object appDomain);
+ */
+ILInt32 _IL_AppDomain_GetIdInternal(ILExecThread *thread, ILObject *appDomain)
+{
+#ifdef IL_CONFIG_APPDOMAINS
+       return ((ILExecProcess *)appDomain)->id;
+#else
+       return 1;
+#endif
+}
+
+/*
+ * private static bool IsDefaultAppDomainInternal(Object appDomain);
  */
-ILBool _IL_AppDomain_IsDefaultAppDomainInternal(ILExecThread *thread, 
ILNativeInt appDomain)
+ILBool _IL_AppDomain_IsDefaultAppDomainInternal(ILExecThread *thread, ILObject 
*appDomain)
 {
 #ifdef IL_CONFIG_APPDOMAINS
        ILExecEngine *engine = ILExecEngineInstance();
@@ -310,9 +322,9 @@
 }
 
 /*
- * private static bool IsFinalizingForUnloadInternal(IntPtr appDomain);
+ * private static bool IsFinalizingForUnloadInternal(Object appDomain);
  */
-ILBool _IL_AppDomain_IsFinalizingForUnloadInternal(ILExecThread *thread, 
ILNativeInt appDomain)
+ILBool _IL_AppDomain_IsFinalizingForUnloadInternal(ILExecThread *thread, 
ILObject *appDomain)
 {
        if(((ILExecProcess *)appDomain)->state == 
_IL_PROCESS_STATE_RUNNING_FINALIZERS)
        {
@@ -325,9 +337,9 @@
 }
 
 /*
- * private static String GetBaseDirectoryInternal(IntPtr appDomain);
+ * private static String GetBaseDirectoryInternal(Object appDomain);
  */
-ILString *_IL_AppDomain_GetBaseDirectoryInternal(ILExecThread *thread, 
ILNativeInt appDomain)
+ILString *_IL_AppDomain_GetBaseDirectoryInternal(ILExecThread *thread, 
ILObject *appDomain)
 {
        if(!IsAppDomainUnloaded(thread, (ILExecProcess *)appDomain))
        {
@@ -357,9 +369,9 @@
 }
 
 /*
- * private static void SetBaseDirectoryInternal(IntPtr appDomain, String 
baseDirectory);
+ * private static void SetBaseDirectoryInternal(Object appDomain, String 
baseDirectory);
  */
-void _IL_AppDomain_SetBaseDirectoryInternal(ILExecThread *thread, ILNativeInt 
appDomain, ILString *baseDirectory)
+void _IL_AppDomain_SetBaseDirectoryInternal(ILExecThread *thread, ILObject 
*appDomain, ILString *baseDirectory)
 {
        if(!IsAppDomainUnloaded(thread, (ILExecProcess *)appDomain))
        {
@@ -389,9 +401,9 @@
 
 
 /*
- * private static String GetFriendlyNameInternal(IntPtr appDomain);
+ * private static String GetFriendlyNameInternal(Object appDomain);
  */
-ILString *_IL_AppDomain_GetFriendlyNameInternal(ILExecThread *thread, 
ILNativeInt appDomain)
+ILString *_IL_AppDomain_GetFriendlyNameInternal(ILExecThread *thread, ILObject 
*appDomain)
 {
        if(!IsAppDomainUnloaded(thread, (ILExecProcess *)appDomain))
        {
@@ -421,9 +433,9 @@
 }
 
 /*
- * private static void SetFriendlyNameInternal(IntPtr appDomain, String 
friendlyName);
+ * private static void SetFriendlyNameInternal(Object appDomain, String 
friendlyName);
  */
-void _IL_AppDomain_SetFriendlyNameInternal(ILExecThread *thread, ILNativeInt 
appDomain, ILString *friendlyName)
+void _IL_AppDomain_SetFriendlyNameInternal(ILExecThread *thread, ILObject 
*appDomain, ILString *friendlyName)
 {
        if(!IsAppDomainUnloaded(thread, (ILExecProcess *)appDomain))
        {
@@ -452,9 +464,9 @@
 }
 
 /*
- * private static String GetRelativeSearchPathInternal(IntPtr appDomain);
+ * private static String GetRelativeSearchPathInternal(Object appDomain);
  */
-ILString *_IL_AppDomain_GetRelativeSearchPathInternal(ILExecThread *thread, 
ILNativeInt appDomain)
+ILString *_IL_AppDomain_GetRelativeSearchPathInternal(ILExecThread *thread, 
ILObject *appDomain)
 {
        if(!IsAppDomainUnloaded(thread, (ILExecProcess *)appDomain))
        {
@@ -484,9 +496,11 @@
 }
 
 /*
- * private static void SetRelativeSearchPathInternal(IntPtr appDomain, String 
appRelativePath);
+ * private static void SetRelativeSearchPathInternal(Object appDomain, String 
appRelativePath);
  */
-void _IL_AppDomain_SetRelativeSearchPathInternal(ILExecThread *thread, 
ILNativeInt appDomain, ILString *appRelativePath)
+void _IL_AppDomain_SetRelativeSearchPathInternal(ILExecThread *thread,
+                                                                               
                 ILObject *appDomain,
+                                                                               
                 ILString *appRelativePath)
 {
        if(!IsAppDomainUnloaded(thread, (ILExecProcess *)appDomain))
        {
@@ -515,9 +529,9 @@
 }
 
 /*
- * private static bool GetShadowCopyFilesInternal(IntPtr appDomain);
+ * private static bool GetShadowCopyFilesInternal(Object appDomain);
  */
-ILBool _IL_AppDomain_GetShadowCopyFilesInternal(ILExecThread *thread, 
ILNativeInt appDomain)
+ILBool _IL_AppDomain_GetShadowCopyFilesInternal(ILExecThread *thread, ILObject 
*appDomain)
 {
        if(!IsAppDomainUnloaded(thread, (ILExecProcess *)appDomain))
        {
@@ -530,9 +544,11 @@
 }
 
 /*
- * private static void SetShadowCopyFilesInternal(IntPtr appDomain, ILBool 
shadowCopyFiles);
+ * private static void SetShadowCopyFilesInternal(Object appDomain, ILBool 
shadowCopyFiles);
  */
-void _IL_AppDomain_SetShadowCopyFilesInternal(ILExecThread *thread, 
ILNativeInt appDomain, ILBool shadowCopyFiles)
+void _IL_AppDomain_SetShadowCopyFilesInternal(ILExecThread *thread,
+                                                                               
          ILObject *appDomain,
+                                                                               
          ILBool shadowCopyFiles)
 {
        if(!IsAppDomainUnloaded(thread, (ILExecProcess *)appDomain))
        {
@@ -545,9 +561,11 @@
 }
 
 /*
- * private static void SetShadowCopyPathInternal(IntPtr appDomain, String[] 
splitPaths);
+ * private static void SetShadowCopyPathInternal(Object appDomain, String[] 
splitPaths);
  */
-void _IL_AppDomain_SetShadowCopyPathInternal(ILExecThread *thread, ILNativeInt 
appDomain, System_Array *splitPaths)
+void _IL_AppDomain_SetShadowCopyPathInternal(ILExecThread *thread,
+                                                                               
         ILObject *appDomain,
+                                                                               
         System_Array *splitPaths)
 {
        if(!IsAppDomainUnloaded(thread, (ILExecProcess *)appDomain))
        {
@@ -604,7 +622,7 @@
  *                                                                             
Assembly parent);
  */
 ILObject *_IL_AppDomain_LoadFromName(ILExecThread *thread,
-                                                                       
ILNativeInt appDomain,
+                                                                       
ILObject *appDomain,
                                                                        
ILString *name,
                                                                        ILInt32 
*error,
                                                                        
ILObject *parent)
@@ -664,7 +682,7 @@
  *                                                                             
 Assembly parent);
  */
 ILObject *_IL_AppDomain_LoadFromFile(ILExecThread *thread,
-                                                                       
ILNativeInt appDomain,
+                                                                       
ILObject *appDomain,
                                                                        
ILString *name,
                                                                        ILInt32 
*error,
                                                                        
ILObject *parent)
@@ -734,7 +752,7 @@
  *                                                                             
  Assembly parent);
  */
 ILObject *_IL_AppDomain_LoadFromBytes(ILExecThread *thread,
-                                                                        
ILNativeInt appDomain,
+                                                                        
ILObject *appDomain,
                                                                         
System_Array *bytes,
                                                                         
ILInt32 *error,
                                                                         
ILObject *parent)
@@ -787,9 +805,9 @@
 }
 
 /*
- * private static void UnloadAppDomain(IntPtr appDomain);
+ * private static void UnloadAppDomain(Object appDomain);
  */
-void _IL_AppDomain_UnloadAppDomain(ILExecThread *thread, ILNativeInt appDomain)
+void _IL_AppDomain_UnloadAppDomain(ILExecThread *thread, ILObject *appDomain)
 {
        if(!IsAppDomainUnloaded(thread, (ILExecProcess *)appDomain))
        {
@@ -825,9 +843,11 @@
 }
 
 /*
- * private static void GetPrivateBinPaths(IntPtr appDomain, ref String[] 
splitPaths);
+ * private static void GetPrivateBinPaths(Object appDomain, ref String[] 
splitPaths);
  */
-void _IL_AppDomainSetup_GetPrivateBinPaths(ILExecThread *thread, ILNativeInt 
appDomain, System_Array **splitPaths)
+void _IL_AppDomainSetup_GetPrivateBinPaths(ILExecThread *thread,
+                                                                               
   ILObject *appDomain,
+                                                                               
   System_Array **splitPaths)
 {
        if(!IsAppDomainUnloaded(thread, (ILExecProcess *)appDomain))
        {
@@ -874,9 +894,11 @@
 }
 
 /*
- * private static void SetPrivateBinPaths(IntPtr appDomain, String[] 
splitPaths);
+ * private static void SetPrivateBinPaths(Object appDomain, String[] 
splitPaths);
  */
-void _IL_AppDomainSetup_SetPrivateBinPaths(ILExecThread *thread, ILNativeInt 
appDomain, System_Array *splitPaths)
+void _IL_AppDomainSetup_SetPrivateBinPaths(ILExecThread *thread,
+                                                                               
   ILObject *appDomain,
+                                                                               
   System_Array *splitPaths)
 {
        if(!IsAppDomainUnloaded(thread, (ILExecProcess *)appDomain))
        {

Index: engine/process.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/process.c,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -b -r1.77 -r1.78
--- engine/process.c    10 Aug 2008 16:16:14 -0000      1.77
+++ engine/process.c    12 Aug 2008 18:19:52 -0000      1.78
@@ -1,7 +1,7 @@
 /*
  * process.c - Manage processes within the runtime engine.
  *
- * Copyright (C) 2001  Southern Storm Software, Pty Ltd.
+ * Copyright (C) 2001, 2008  Southern Storm Software, Pty Ltd.
  *
  * Contributions by Thong Nguyen (address@hidden)
  *
@@ -62,6 +62,7 @@
        }
 
 #ifdef IL_CONFIG_APPDOMAINS
+       process->id = ++(engine->lastId);
        process->nextProcess = engine->firstProcess;
        process->prevProcess = 0;
        if(engine->firstProcess)
@@ -147,6 +148,14 @@
        ILQueueEntry *joinQueue;
        int count = 0;
 
+#ifdef PROCESS_DEBUG
+#ifndef REDUCED_STDIO
+       fprintf(stderr, "Start unloading process : %p\n", (void *)process);     
+#else
+       printf("Start unloading process : %p\n", (void *)process);      
+#endif
+#endif
+
        joinQueue = ILQueueCreate();
 
        /* Lock down the process */
@@ -242,9 +251,9 @@
 {
 #ifdef PROCESS_DEBUG
 #ifndef REDUCED_STDIO
-       fprintf(stderr, "DestroyProcess : %p\n", (void *)process);      
+       fprintf(stderr, "Start destroying process : %p\n", (void *)process);    
 #else
-       printf("DestroyProcess : %p\n", (void *)process);       
+       printf("Start destroying process : %p\n", (void *)process);     
 #endif
 #endif
        /* Mark the process as dead in the finalization context. */
@@ -266,6 +275,7 @@
        if(process->debugger)
        {
                ILDebuggerDestroy(process->debugger);
+               process->debugger = 0;
        }
 #endif
 
@@ -273,12 +283,14 @@
        if (process->coder)
        {
                ILCoderDestroy(process->coder);
+               process->coder = 0;
        }
 
        /* Destroy the metadata lock */
        if(process->metadataLock)
        {
                ILRWLockDestroy(process->metadataLock);
+               process->metadataLock = 0;
        }
 
        /* Destroy the image loading context */
@@ -286,6 +298,7 @@
        {
                /* and destroy the context */
                ILContextDestroy(process->context);
+               process->context = 0;
        }
 
        if (process->internHash)
@@ -293,6 +306,7 @@
                /* Destroy the main part of the intern'ed hash table.
                The rest will be cleaned up by the garbage collector */
                ILGCFreePersistent(process->internHash);
+               process->internHash = 0;
        }
 
        if (process->reflectionHash)
@@ -300,6 +314,7 @@
                /* Destroy the main part of the reflection hash table.
                The rest will be cleaned up by the garbage collector */
                ILGCFreePersistent(process->reflectionHash);
+               process->reflectionHash = 0;
        }
 
 #ifdef IL_CONFIG_PINVOKE
@@ -317,6 +332,7 @@
                        ILFree(loaded);
                        loaded = nextLoaded;
                }
+               process->loadedModules = 0;
        }
 #endif
 
@@ -341,6 +357,7 @@
                        ILFree(watch);
                        watch = nextWatch;
                }
+               process->debugWatchList = 0;
        }
 #endif
 
@@ -348,6 +365,7 @@
        {
                /* Destroy the random seed pool */
                ILMutexDestroy(process->randomLock);
+               process->randomLock = 0;
        }
 
        if (process->randomPool)
@@ -361,6 +379,7 @@
        {
                /* Destroy the object lock */
                ILMutexDestroy(process->lock);
+               process->lock = 0;
        }
 
        /* free the friendly name if available */
@@ -377,31 +396,40 @@
  */
 static void _ILExecProcessFinalizer(void *block, void *data)
 {
-       ILExecProcess *process = (ILExecProcess *)block;
+       ILExecProcess *process = (ILExecProcess *)GetObjectFromGcBase(block);
 
        _ILExecProcessDestroyInternal(process, 1);
 }
 #endif
 
 /*
+ * Thread func for unloading a process from a new thread.
+ */
+static void _ILExecProcessUnloadFunc(void *process)
+{
+       _ILExecProcessUnloadInternal((ILExecProcess *)process);
+}
+
+/*
  * Create the ILExecProcess without creating the coder.
  * Initializing the coder to use is up to the caller.
  */
 static ILExecProcess *_ILExecProcessCreateInternal(void)
 {
+       void *processBase;
        ILExecProcess *process;
 
        /* Create the process record */
 #ifdef IL_CONFIG_APPDOMAINS
-       if((process = (ILExecProcess *)ILGCAlloc
-                                               (sizeof(ILExecProcess))) == 0)
+       if((processBase = ILGCAlloc
 #else
-       if((process = (ILExecProcess *)ILGCAllocPersistent
-                                               (sizeof(ILExecProcess))) == 0)
+       if((processBase = ILGCAllocPersistent
 #endif
+                                               (sizeof(ILExecProcess) + 
IL_OBJECT_HEADER_SIZE)) == 0)
        {
                return 0;
        }
+       process = (ILExecProcess *)GetObjectFromGcBase(processBase);
        /* Initialize the fields */
        process->lock = 0;
        process->state = _IL_PROCESS_STATE_CREATED;
@@ -494,7 +522,7 @@
        }
 
 #ifdef IL_CONFIG_APPDOMAINS
-       ILGCRegisterFinalizer(process, _ILExecProcessFinalizer, 0);
+       ILGCRegisterFinalizer(GetObjectGcBase(process), 
_ILExecProcessFinalizer, 0);
 #endif
 
        /* Return the process record to the caller */
@@ -621,7 +649,7 @@
  */
 void ILExecProcessUnload(ILExecProcess *process)
 {
-       ILExecThread *thread = ILExecThreadCurrent();
+       ILExecThread *execThread = ILExecThreadCurrent();
 
        if(!process)
        {
@@ -634,34 +662,24 @@
                return;
        }
 
-       if(!thread)
-       {
-               /* Unload was called from an unmanaged thread */
-               ILThread *self = ILThreadSelf();
-
-               thread = ILThreadRegisterForManagedExecution(0, self);
-
-               if(thread)
+       if(!execThread || execThread->process != process)
                {
+               /* Unload was called from an unmanaged thread or
+                  a managed thread in a different domain */
                        _ILExecProcessUnloadInternal(process);
-                       ILThreadUnregisterForManagedExecution(self);
-               }
                return;
        }
 
-       if(thread->process != process)
-       {
-               /* We can invoke the unload directly */
-               _ILExecProcessUnloadInternal(process);
-       }
-       else
-       {
                /* We have to run the unload from different thread */
                if(ILHasThreads())
                {
-                       /* TODO */
+               ILThread *thread;
 
+               if(!(thread = ILThreadCreate(_ILExecProcessUnloadFunc, 
process)))
+               {
+                       return;
                }
+               ILThreadStart(thread);
        }
 }
 
@@ -752,7 +770,7 @@
 
 #ifndef IL_CONFIG_APPDOMAINS
        /* Free the process block itself */
-       ILGCFreePersistent(process);
+       ILGCFreePersistent(GetObjectGcBase(process));
 #endif
 }
 




reply via email to

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