[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[dotgnu-pnet-commits] pnet ChangeLog engine/cvmc.c engine/debugger.c ...
From: |
Klaus Treichel |
Subject: |
[dotgnu-pnet-commits] pnet ChangeLog engine/cvmc.c engine/debugger.c ... |
Date: |
Wed, 06 Aug 2008 13:31:48 +0000 |
CVSROOT: /cvsroot/dotgnu-pnet
Module name: pnet
Changes by: Klaus Treichel <ktreichel> 08/08/06 13:31:48
Modified files:
. : ChangeLog
engine : cvmc.c debugger.c engine.c engine.h ilrun.c
ilverify.c lib_diag.c lib_thread.c process.c
thread.c
include : il_engine.h
Log message:
Do some code cleanup. Include cvm specific stuff only if built with cvm
interpreter.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pnet/ChangeLog?cvsroot=dotgnu-pnet&r1=1.3553&r2=1.3554
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/cvmc.c?cvsroot=dotgnu-pnet&r1=1.59&r2=1.60
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/debugger.c?cvsroot=dotgnu-pnet&r1=1.31&r2=1.32
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/engine.c?cvsroot=dotgnu-pnet&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/engine.h?cvsroot=dotgnu-pnet&r1=1.123&r2=1.124
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/ilrun.c?cvsroot=dotgnu-pnet&r1=1.61&r2=1.62
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/ilverify.c?cvsroot=dotgnu-pnet&r1=1.31&r2=1.32
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/lib_diag.c?cvsroot=dotgnu-pnet&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/lib_thread.c?cvsroot=dotgnu-pnet&r1=1.38&r2=1.39
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/process.c?cvsroot=dotgnu-pnet&r1=1.75&r2=1.76
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/thread.c?cvsroot=dotgnu-pnet&r1=1.46&r2=1.47
http://cvs.savannah.gnu.org/viewcvs/pnet/include/il_engine.h?cvsroot=dotgnu-pnet&r1=1.51&r2=1.52
Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ChangeLog,v
retrieving revision 1.3553
retrieving revision 1.3554
diff -u -b -r1.3553 -r1.3554
--- ChangeLog 4 Aug 2008 10:42:05 -0000 1.3553
+++ ChangeLog 6 Aug 2008 13:31:47 -0000 1.3554
@@ -1,3 +1,56 @@
+2008-08-06 Klaus Treichel <address@hidden>
+
+ * engine/cvmc.c (_ILCVMUnrollInitStack): Use the current thread for
+ initializing the unrooler stack instead of the mainthread of the
+ process. The thread must be initialitzed for managed execution and
+ running in the process.
+
+ * engine/debugger.c (GetId, SetId): Use ILNativeUInt instead of ILUInt32
+ for the ids for working correctly on 64bit systems.
+ (ShowProfiling): Use ILNativeInt instead of ILInt32 for time and count
to
+ fix compiler warnings on 64bit systems.
+ (ShowSourceFiles, DebugHook): Add additional casts to fix compiler
+ warnings on 64bit systems.
+
+ * engine/engine.c (ILExecInit, ILExecDeinit): Create the global engine
+ without appdomain support too. Use the default stackSize only if built
+ with cvm.
+ (ILExecEngineCreate): Initialize the process list only if built with
+ appdomain support.
+ (ILExecEngineDestroy): Destroy the processes in the list only if built
+ with appdomain support.
+
+ * engine/engine.h: Include cvm specific members in ILExecThread,
+ ILExecProcess and ILExecEngine only if built with cvm now.
+ Change prototypes of ILExecEngineInstance and ILExecEngineCreate.
+ Move the declaration of ILExecEngine from include/il_engine.h to here.
+
+ *engine/ilrun.c, engine/il_verify.c (main): Use the general calls to
+ ILExecInit and ILExecProcessCreate again.
+
+ * engine/lib_diag.c(_ILBreak, _IL_Debugger_Break): compile code only if
+ built with debugger support.
+
+ * engine/lib_thread.c(_IL_Thread_ResetAbort): Handle cvm specific stuff
+ only if built with cvm.
+
+ * engine/process.c (ILExecProcessJoinEngine,
+ ILExecProcessDetachFromEngine): Remove the IL_INLINE from the methods.
+ Compile the methods with and without appdomain support. Add some sanity
+ checks and don't add the default process to the list of attached
+ processes. Handle the list of attached processes to the engine only if
+ built with appdomain support.
+ (ILExecProcessGetMain): Return the managed thread of the current thread
+ instead of the process' main thread because this is what would have
+ happened with the old implementation anyways.
+
+ * engine/thread.c: Compile in cvm specific stuff only if built with cvm.
+
+ * include/il_engine.h (ILExecInit, ILExecProcessCreate): Use the same
+ prototypes independent of appdomain support.
+ (ILExecProcessGetMain): Add some comments and mark it obsolete.
+ Move the declaration of ILExecEngine to engine/engine.h
+
2008-08-04 Klaus Treichel <address@hidden>
* engine/lib_object.c (_ILGetClrType): Optimize function so that the
Index: engine/cvmc.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/cvmc.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -b -r1.59 -r1.60
--- engine/cvmc.c 27 Nov 2007 11:35:05 -0000 1.59
+++ engine/cvmc.c 6 Aug 2008 13:31:47 -0000 1.60
@@ -385,8 +385,16 @@
{
#if defined(IL_CVM_DIRECT_UNROLLED) && defined(IL_NO_REGISTERS_USED)
ILCVMCoder *coder;
+ ILExecThread *thread;
coder = _ILCoderToILCVMCoder(process->coder);
+ thread = ILExecThreadCurrent();
+
+ /* This function must be called from a managed thread in the process */
+ if(!thread || thread->process != process)
+ {
+ return 0;
+ }
/* Find some room in the cache */
coder->start = ILCacheStartMethod(coder->cache, &(coder->codePosn), 1,
0);
@@ -402,8 +410,8 @@
ILCacheEndMethod(&coder->codePosn);
/* Execute register initialization code */
- process->mainThread->pc = coder->start;
- _ILCVMInterpreter(process->mainThread);
+ thread->pc = coder->start;
+ _ILCVMInterpreter(thread);
return 1;
#else
Index: engine/debugger.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/debugger.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- engine/debugger.c 30 Dec 2007 00:09:43 -0000 1.31
+++ engine/debugger.c 6 Aug 2008 13:31:47 -0000 1.32
@@ -688,7 +688,7 @@
*/
static int GetId(ILDebugger *debugger, const void *ptr, int type)
{
- int id = (int) GetUserData(debugger, ptr, type);
+ ILNativeInt id = (ILNativeInt) GetUserData(debugger, ptr, type);
if(id == 0)
{
id = --(debugger->minId);
@@ -1350,8 +1350,8 @@
void SetId(ILDebugger *debugger, FILE *stream)
{
char *arg = 0;
- int oldId;
- int newId;
+ ILNativeInt oldId;
+ ILNativeInt newId;
int size;
ILUserDataEntry *entry;
int found = 0;
@@ -2300,8 +2300,8 @@
{
int size;
ILUserDataEntry *entry;
- ILUInt32 time;
- ILUInt32 count;
+ ILNativeUInt time;
+ ILNativeUInt count;
int memberId;
fputs("<Profiling>\n", stream);
@@ -2313,14 +2313,14 @@
/* Case with entry->ptr==0 is valid and must be skipped */
if(entry->type == IL_USER_DATA_METHOD_TIME && entry->ptr != 0)
{
- time = (ILUInt32) entry->data;
- count = (ILUInt32) GetUserData(debugger, entry->ptr,
+ time = (ILNativeUInt) entry->data;
+ count = (ILNativeUInt) GetUserData(debugger, entry->ptr,
IL_USER_DATA_METHOD_CALL_COUNT);
memberId = GetId(debugger, entry->ptr,
IL_USER_DATA_MEMBER_ID);
fprintf(stream,
" <ProfilingEntry
MemberId=\"%d\" CallCount=\"%d\" "
- "Time=\"%d\"", memberId, count,
time);
+ "Time=\"%d\"", memberId,
(ILUInt32)count, (ILUInt32)time);
if(memberId >= 0)
{
@@ -2536,7 +2536,7 @@
SetUserData(debugger, (void *)
sourceFile,
IL_USER_DATA_SOURCE_FILE_IMAGE_ID,
-
(void *) imageId);
+
(void *)(ILNativeInt) imageId);
}
}
}
@@ -3339,7 +3339,7 @@
ILCurrTime time;
ILInt64 delta;
ILInt64 total;
- ILUInt32 count;
+ ILNativeUInt count;
/* Get debugger attached to thread's process */
debugger = _ILExecThreadProcess(thread)->debugger;
@@ -3386,18 +3386,18 @@
(time.secs -
info->profilerLastStopTime.secs);
/* Add time delta to previous hit */
- total = (ILUInt32) GetUserData(debugger,
+ total = (ILNativeUInt) GetUserData(debugger,
(void *) info->profilerLastMethod,
IL_USER_DATA_METHOD_TIME);
total += delta;
SetUserData(debugger, (void *) info->profilerLastMethod,
IL_USER_DATA_METHOD_TIME,
-
(void *)(ILUInt32)total);
+ (void *)(ILNativeUInt)total);
/* Increase method call count */
if(offset == 0)
{
- count = (ILUInt32) GetUserData(debugger, (void *)
method,
+ count = (ILNativeUInt) GetUserData(debugger, (void *)
method,
IL_USER_DATA_METHOD_CALL_COUNT);
count++;
SetUserData(debugger, (void *) method,
Index: engine/engine.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/engine.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- engine/engine.c 9 Dec 2007 21:17:20 -0000 1.3
+++ engine/engine.c 6 Aug 2008 13:31:47 -0000 1.4
@@ -30,20 +30,12 @@
extern "C" {
#endif
-#ifdef IL_CONFIG_APPDOMAINS
/* global engine object */
-ILExecEngine *globalEngine;
-#endif
+ILExecEngine *globalEngine = 0;
-#ifdef IL_CONFIG_APPDOMAINS
-int ILExecInit(unsigned long maxSize, unsigned long stackSize)
-#else
int ILExecInit(unsigned long maxSize)
-#endif
{
-#ifdef IL_CONFIG_APPDOMAINS
globalEngine = 0;
-#endif
/* Initialize the thread routines */
ILThreadInit();
@@ -65,25 +57,21 @@
/* Initialize the global garbage collector */
ILGCInit(maxSize);
-#ifdef IL_CONFIG_APPDOMAINS
- globalEngine = ILExecEngineCreate(stackSize);
+ globalEngine = ILExecEngineCreate();
if (!globalEngine)
{
return IL_EXEC_INIT_OUTOFMEMORY;
}
-#endif
return IL_EXEC_INIT_OK;
}
void ILExecDeinit()
{
-#ifdef IL_CONFIG_APPDOMAINS
if (globalEngine)
{
ILExecEngineDestroy(globalEngine);
}
-#endif
/* Deinitialize the global garbage collector */
ILGCDeinit();
@@ -97,8 +85,6 @@
#endif
}
-
-#ifdef IL_CONFIG_APPDOMAINS
/* global accessor function to get the global engine object */
ILExecEngine *ILExecEngineInstance()
{
@@ -109,7 +95,7 @@
* Create a new execution engine.
* Returns the ILExecEngine or 0 if the function fails.
*/
-ILExecEngine *ILExecEngineCreate(unsigned long stackSize)
+ILExecEngine *ILExecEngineCreate(void)
{
ILExecEngine *engine;
@@ -121,12 +107,14 @@
}
/* Initialize the fields */
engine->processLock = 0;
- engine->firstProcess = 0;
engine->defaultProcess = 0;
- engine->stackSize = ((stackSize < IL_CONFIG_STACK_SIZE)
- ? IL_CONFIG_STACK_SIZE
: stackSize);
+#ifdef IL_CONFIG_APPDOMAINS
+ engine->firstProcess = 0;
+#endif
+#ifdef IL_USE_CVM
+ engine->stackSize = IL_CONFIG_STACK_SIZE;
engine->frameStackSize = IL_CONFIG_FRAME_STACK_SIZE;
-
+#endif
/* Initialize the process lock */
engine->processLock = ILMutexCreate();
@@ -145,8 +133,9 @@
*/
void ILExecEngineDestroy(ILExecEngine *engine)
{
- int count;
ILExecProcess *process;
+#ifdef IL_CONFIG_APPDOMAINS
+ int count;
ILQueueEntry *unloadQueue, *destroyQueue;
unloadQueue = ILQueueCreate();
@@ -200,6 +189,7 @@
process = (ILExecProcess *)ILQueueRemove(&destroyQueue);
ILExecProcessDestroy(process);
}
+#endif
/* now unload and destroy the default process */
if(engine->defaultProcess)
@@ -217,7 +207,7 @@
/* Free the engine block itself */
ILGCFreePersistent(engine);
}
-#endif
+
#ifdef __cplusplus
};
#endif
Index: engine/engine.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/engine.h,v
retrieving revision 1.123
retrieving revision 1.124
diff -u -b -r1.123 -r1.124
--- engine/engine.h 3 Aug 2008 21:49:12 -0000 1.123
+++ engine/engine.h 6 Aug 2008 13:31:48 -0000 1.124
@@ -125,25 +125,29 @@
};
-#ifdef IL_CONFIG_APPDOMAINS
/*
* structure that keeps track of the created processes
*/
+typedef struct __tagILExecEngine ILExecEngine;
struct __tagILExecEngine
{
+ /* default appdomain */
+ ILExecProcess *defaultProcess;
+
+ /* lock to serialize access to application domains */
+ ILMutex *processLock;
+
+#ifdef IL_USE_CVM
/* Default stack size for new threads */
ILUInt32 stackSize;
ILUInt32 frameStackSize;
+#endif
- /* lock to serialize access to application domains */
- ILMutex *processLock;
+#ifdef IL_CONFIG_APPDOMAINS
/* linked list of application domains */
ILExecProcess *firstProcess;
-
- /* default appdomain */
- ILExecProcess *defaultProcess;
-};
#endif
+};
/*
* Structure of a breakpoint watch registration.
@@ -209,6 +213,9 @@
/* Lock to serialize access to this object */
ILMutex *lock;
+ /* The engine this process is attached to */
+ ILExecEngine *engine;
+
/* List of threads that are active within this process */
ILExecThread *firstThread;
@@ -218,12 +225,6 @@
/* The finalizer thread for the process */
ILExecThread *finalizerThread;
-#ifndef IL_CONFIG_APPDOMAINS
- /* Default stack size for new threads */
- ILUInt32 stackSize;
- ILUInt32 frameStackSize;
-#endif
-
/* Context that holds all images that have been loaded by this process
*/
ILContext *context;
@@ -290,6 +291,19 @@
/* The custom internal call table which is runtime settable */
ILEngineInternalClassList* internalClassTable;
+ /* Cryptographic seed material */
+ ILMutex *randomLock;
+ int randomBytesDelivered;
+ ILInt64 randomLastTime;
+ unsigned char randomPool[20];
+ int randomCount;
+
+ /* Size of the global thread-static allocation */
+ ILUInt32 numThreadStaticSlots;
+
+ /* Image loading flags */
+ int loadFlags;
+
#ifdef IL_CONFIG_DEBUG_LINES
/* Breakpoint debug information */
@@ -307,18 +321,11 @@
#endif
- /* Cryptographic seed material */
- ILMutex *randomLock;
- int randomBytesDelivered;
- ILInt64 randomLastTime;
- unsigned char randomPool[20];
- int randomCount;
-
- /* Size of the global thread-static allocation */
- ILUInt32 numThreadStaticSlots;
-
- /* Image loading flags */
- int loadFlags;
+#ifdef IL_USE_CVM
+ /* Default stack size for new threads */
+ ILUInt32 stackSize;
+ ILUInt32 frameStackSize;
+#endif
#ifdef IL_USE_IMTS
@@ -333,8 +340,6 @@
ILExecProcess *prevProcess;
ILExecProcess *nextProcess;
- ILExecEngine *engine;
-
#endif /* IL_CONFIG_APPDOMAINS */
};
@@ -398,21 +403,26 @@
/* Support thread object */
ILThread *supportThread;
- /* Extent of the execution stack */
- CVMWord *stackBase;
- CVMWord *stackLimit;
+ /* Current method being executed */
+ ILMethod *method;
- /* Current thread state */
- unsigned char *pc; /* Current program
position */
- CVMWord *exceptHeight; /* Height of the frame for
exceptions */
- CVMWord *frame; /* Base of the local
variable frame */
- CVMWord *stackTop; /* Current stack top */
- ILMethod *method; /* Current method being
executed */
- ILUInt32 offset; /* Current IL offset */
+ /* Thread-static values for this thread */
+ void **threadStaticSlots;
+ ILUInt32 threadStaticSlotsUsed;
+
+ /* Flagged if the thread is running managed code */
+ int runningManagedCode;
+
+ /* The last exception that was thrown (as seen from the CVM)
+ This always stores the last exception thrown and is never reset */
+ ILObject *currentException;
/* Last exception that was thrown */
ILObject *thrownException;
+ /* The ThreadAbortException instance of the thread is being aborted */
+ ILObject *threadAbortException;
+
/* Flag that indicates whether a thread is aborting */
volatile int aborting;
@@ -433,37 +443,40 @@
/* Number of monitors in the free monitor list */
int freeMonitorCount;
+#ifdef IL_USE_CVM
+ /* Extent of the execution stack */
+ CVMWord *stackBase;
+ CVMWord *stackLimit;
+
+ /* Current thread state */
+ unsigned char *pc; /* Current program
position */
+ CVMWord *exceptHeight; /* Height of the frame for
exceptions */
+ CVMWord *frame; /* Base of the local
variable frame */
+ CVMWord *stackTop; /* Current stack top */
+ ILUInt32 offset; /* Current IL offset */
+
+ /* The PC where the ThreadAbortException should be rethrown */
+ unsigned char *abortHandlerEndPC;
+
+ /* The frame where the ThreadAbortException was first noticed */
+ ILUInt32 abortHandlerFrame;
+
/* Stack of call frames in use */
ILCallFrame *frameStack;
ILUInt32 numFrames;
ILUInt32 maxFrames;
+#endif
#ifdef IL_DEBUGGER
/* Stack for watching local variables and function params */
ILLocalWatch *watchStack;
ILUInt32 numWatches;
ILUInt32 maxWatches;
+#ifdef IL_USE_JIT
+ void *frame; /* Base of the local
variable frame */
+ ILUInt32 offset; /* Current IL offset */
+#endif
#endif
-
- /* Thread-static values for this thread */
- void **threadStaticSlots;
- ILUInt32 threadStaticSlotsUsed;
-
- /* Flagged if the thread is running managed code */
- int runningManagedCode;
-
- /* The last exception that was thrown (as seen from the CVM)
- This always stores the last exception thrown and is never reset */
- ILObject *currentException;
-
- /* The ThreadAbortException instance of the thread is being aborted */
- ILObject *threadAbortException;
-
- /* The PC where the ThreadAbortException should be rethrown */
- unsigned char *abortHandlerEndPC;
-
- /* The frame where the ThreadAbortException was first noticed */
- ILUInt32 abortHandlerFrame;
#if defined(ENHANCED_PROFILER)
int profilingEnabled;
@@ -565,9 +578,8 @@
#endif
};
-#ifdef IL_CONFIG_APPDOMAINS
/* global accessor function to get the global engine object */
-ILExecEngine *ILExecEngineInstance();
+ILExecEngine *ILExecEngineInstance(void);
/*
* Destroy the engine.
@@ -578,8 +590,9 @@
* Create a new execution engine.
* Returns the ILExecEngine or 0 if the function fails.
*/
-ILExecEngine *ILExecEngineCreate(unsigned long stackSize);
+ILExecEngine *ILExecEngineCreate(void);
+#ifdef IL_CONFIG_APPDOMAINS
/*
* Let the thread return from an other ILExecProcess and restore the saved
* state.
Index: engine/ilrun.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/ilrun.c,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -b -r1.61 -r1.62
--- engine/ilrun.c 3 Aug 2008 21:49:13 -0000 1.61
+++ engine/ilrun.c 6 Aug 2008 13:31:48 -0000 1.62
@@ -390,11 +390,7 @@
}
/* Initialize the engine and set the maximum heap size */
-#ifdef IL_CONFIG_APPDOMAINS
- if (ILExecInit(heapSize, stackSize) != IL_EXEC_INIT_OK)
-#else
if (ILExecInit(heapSize) != IL_EXEC_INIT_OK)
-#endif
{
#ifndef REDUCED_STDIO
fprintf(stderr, "%s: could not initialize engine\n", progname);
@@ -404,11 +400,7 @@
}
/* Create a process to load the program into */
-#ifdef IL_CONFIG_APPDOMAINS
- process = ILExecProcessCreate(methodCachePageSize);
-#else
process = ILExecProcessCreate(stackSize, methodCachePageSize);
-#endif
if(!process)
{
#ifndef REDUCED_STDIO
Index: engine/ilverify.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/ilverify.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- engine/ilverify.c 31 May 2007 15:19:05 -0000 1.31
+++ engine/ilverify.c 6 Aug 2008 13:31:48 -0000 1.32
@@ -98,18 +98,10 @@
}
/* Initialize the engine, to ensure that the garbage collector is OK */
-#ifdef IL_CONFIG_APPDOMAINS
- ILExecInit(0, 0);
-#else
ILExecInit(0);
-#endif
/* Create the default appdomain for the image loading. */
-#ifdef IL_CONFIG_APPDOMAINS
- if(!(process = ILExecProcessCreate(0)))
-#else
if(!(process = ILExecProcessCreate(0, 0)))
-#endif
{
fprintf(stderr, "%s: out of memory\n", progname);
return 1;
Index: engine/lib_diag.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/lib_diag.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- engine/lib_diag.c 17 Dec 2006 10:31:32 -0000 1.16
+++ engine/lib_diag.c 6 Aug 2008 13:31:48 -0000 1.17
@@ -158,6 +158,7 @@
void _ILBreak(ILExecThread *thread, int type)
{
+#ifdef IL_CONFIG_DEBUGGER
int action;
#ifdef IL_USE_CVM
unsigned char *start;
@@ -194,6 +195,7 @@
exit(7);
}
}
+#endif /* IL_CONFIG_DEBUGGER */
}
/*
@@ -213,6 +215,7 @@
*/
void _IL_Debugger_Break(ILExecThread *thread)
{
+#ifdef IL_CONFIG_DEBUGGER
ILInt32 offset;
int action;
@@ -230,6 +233,7 @@
exit(7);
}
}
+#endif /* IL_CONFIG_DEBUGGER */
}
/*
Index: engine/lib_thread.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/lib_thread.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -b -r1.38 -r1.39
--- engine/lib_thread.c 12 Oct 2007 15:07:09 -0000 1.38
+++ engine/lib_thread.c 6 Aug 2008 13:31:48 -0000 1.39
@@ -457,8 +457,10 @@
ILThreadAtomicEnd();
thread->aborting = 0;
+#ifdef IL_USE_CVM
thread->abortHandlerEndPC = 0;
thread->abortHandlerFrame = 0;
+#endif
thread->threadAbortException = 0;
}
}
Index: engine/process.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/process.c,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -b -r1.75 -r1.76
--- engine/process.c 3 Aug 2008 21:49:13 -0000 1.75
+++ engine/process.c 6 Aug 2008 13:31:48 -0000 1.76
@@ -29,7 +29,6 @@
extern "C" {
#endif
-#ifdef IL_CONFIG_APPDOMAINS
/*
* Add an application domain to the list of application domains.
* param: process = application domain to join to the linked list
@@ -37,12 +36,27 @@
* engine = ILExecEngine to join.
* Returns: void
*/
-static IL_INLINE void ILExecProcessJoinEngine(ILExecProcess *process,
+static void ILExecProcessJoinEngine(ILExecProcess *process,
ILExecEngine *engine)
{
+ if(!process || !engine)
+ {
+ return;
+ }
+
ILMutexLock(engine->processLock);
process->engine = engine;
+
+ /* The first ILExecProcess attached will be the default process */
+ if (!engine->defaultProcess)
+ {
+ engine->defaultProcess = process;
+ ILMutexUnlock(engine->processLock);
+ return;
+ }
+
+#ifdef IL_CONFIG_APPDOMAINS
process->nextProcess = engine->firstProcess;
process->prevProcess = 0;
if(engine->firstProcess)
@@ -50,11 +64,8 @@
engine->firstProcess->prevProcess = process;
}
engine->firstProcess = process;
+#endif
- if (!engine->defaultProcess)
- {
- engine->defaultProcess = process;
- }
ILMutexUnlock(engine->processLock);
}
@@ -64,12 +75,33 @@
* (must be not null)
* Returns: void
*/
-static IL_INLINE void ILExecProcessDetachFromEngine(ILExecProcess *process)
+static void ILExecProcessDetachFromEngine(ILExecProcess *process)
{
ILExecEngine *engine = process->engine;
+ if(!process)
+ {
+ return;
+ }
+
+ engine = process->engine;
+
+ if(!engine)
+ {
+ return;
+ }
+
ILMutexLock(engine->processLock);
+ if(engine->defaultProcess == process)
+ {
+ engine->defaultProcess = 0;
+ process->engine = 0,
+ ILMutexUnlock(engine->processLock);
+ return;
+ }
+
+#ifdef IL_CONFIG_APPDOMAINS
/* Detach the application domain from its process */
if(process->nextProcess)
{
@@ -83,27 +115,38 @@
{
engine->firstProcess = process->nextProcess;
}
-
- if (engine->defaultProcess == process)
- {
- engine->defaultProcess = 0;
- }
ILMutexUnlock(engine->processLock);
/* reset the links */
process->engine = 0,
process->prevProcess = 0;
process->nextProcess = 0;
-}
+#else /* !IL_CONFIG_APPDOMAINS */
+ /* We should never get here but to be sure release the lock. */
+ ILMutexUnlock(engine->processLock);
#endif
+}
-#ifdef IL_CONFIG_APPDOMAINS
-ILExecProcess *ILExecProcessCreate(unsigned long cachePageSize)
-#else
ILExecProcess *ILExecProcessCreate(unsigned long stackSize, unsigned long
cachePageSize)
-#endif
{
ILExecProcess *process;
+ ILExecEngine *engine;
+
+ engine = ILExecEngineInstance();
+
+ /* The engine must be initialized prior to creating any processes */
+ if(!engine)
+ {
+ return 0;
+ }
+
+#ifndef IL_CONFIG_APPDOMAINS
+ /* Multiple processes are not supported */
+ if(engine->defaultProcess)
+ {
+ return 0;
+ }
+#endif
/* Create the process record */
if((process = (ILExecProcess *)ILGCAllocPersistent
@@ -114,6 +157,7 @@
/* Initialize the fields */
process->lock = 0;
process->state = _IL_PROCESS_STATE_CREATED;
+ process->engine = 0;
process->firstThread = 0;
process->mainThread = 0;
process->finalizerThread = 0;
@@ -137,29 +181,27 @@
process->internalClassTable = 0;
process->friendlyName = 0;
process->firstClassPrivate = 0;
+ process->randomBytesDelivered = 1024;
+ process->randomLastTime = 0;
+ process->randomCount = 0;
+ process->numThreadStaticSlots = 0;
+ process->loadFlags = IL_LOADFLAG_FORCE_32BIT;
#ifdef IL_CONFIG_DEBUG_LINES
process->debugHookFunc = 0;
process->debugHookData = 0;
process->debugWatchList = 0;
process->debugWatchAll = 0;
#endif
- process->randomBytesDelivered = 1024;
- process->randomLastTime = 0;
- process->randomCount = 0;
- process->numThreadStaticSlots = 0;
- process->loadFlags = IL_LOADFLAG_FORCE_32BIT;
#ifdef IL_USE_IMTS
process->imtBase = 1;
#endif
-#ifdef IL_CONFIG_APPDOMAINS
- process->engine = 0;
- ILExecProcessJoinEngine(process, ILExecEngineInstance());
-#else
+#ifdef IL_USE_CVM
process->stackSize = ((stackSize < IL_CONFIG_STACK_SIZE)
? IL_CONFIG_STACK_SIZE
: stackSize);
process->frameStackSize = IL_CONFIG_FRAME_STACK_SIZE;
#endif
+
/* Initialize the image loading context */
if((process->context = ILContextCreate()) == 0)
{
@@ -246,6 +288,9 @@
return 0;
}
+ /* Attach the process to the engine */
+ ILExecProcessJoinEngine(process, ILExecEngineInstance());
+
/* Return the process record to the caller */
return process;
}
@@ -318,13 +363,10 @@
{
if (mainIsFinalizer)
{
+#ifdef IL_USE_CVM
/* If the main thread is the finalizer thread then
we have to zero the memory of the CVM stack so that
stray pointers are erased */
-#ifdef IL_CONFIG_APPDOMAINS
- ILMemZero(process->mainThread->stackBase,
process->engine->stackSize);
- ILMemZero(process->mainThread->frameStack,
process->engine->frameStackSize);
-#else
ILMemZero(process->mainThread->stackBase,
process->stackSize);
ILMemZero(process->mainThread->frameStack,
process->frameStackSize);
#endif
@@ -554,19 +596,16 @@
_ILExecMonitorProcessDestroy(process);
- if (process->lock)
+ if (process->engine)
{
- /* Destroy the object lock */
- ILMutexDestroy(process->lock);
+ ILExecProcessDetachFromEngine(process);
}
-#ifdef IL_CONFIG_APPDOMAINS
-
- if (process->engine)
+ if (process->lock)
{
- ILExecProcessDetachFromEngine(process);
+ /* Destroy the object lock */
+ ILMutexDestroy(process->lock);
}
-#endif
/* free the friendly name if available */
if(process->friendlyName != 0)
@@ -596,7 +635,13 @@
ILExecThread *ILExecProcessGetMain(ILExecProcess *process)
{
- return process->mainThread;
+ ILExecThread *thread = ILExecThreadCurrent();
+
+ if(!thread)
+ {
+ thread = ILThreadRegisterForManagedExecution(process,
ILThreadSelf());
+ }
+ return thread;
}
/*
Index: engine/thread.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/thread.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -b -r1.46 -r1.47
--- engine/thread.c 10 Mar 2007 21:54:57 -0000 1.46
+++ engine/thread.c 6 Aug 2008 13:31:48 -0000 1.47
@@ -315,10 +315,11 @@
ILThreadAtomicEnd();
thread->aborting = 1;
- thread->abortHandlerEndPC = 0;
thread->threadAbortException = 0;
+#ifdef IL_USE_CVM
+ thread->abortHandlerEndPC = 0;
thread->abortHandlerFrame = 0;
-
+#endif
ILExecThreadSetException(thread, exception);
return 0;
@@ -602,30 +603,35 @@
return 0;
}
+ /* Initialize the thread state */
+ thread->supportThread = 0;
+ thread->clrThread = 0;
+ thread->aborting = 0;
+ thread->freeMonitor = 0;
+ thread->freeMonitorCount = 0;
+ thread->isFinalizerThread = 0;
+ thread->method = 0;
+ thread->thrownException = 0;
+ thread->threadStaticSlots = 0;
+ thread->threadStaticSlotsUsed = 0;
+ thread->currentException = 0;
+ thread->managedSafePointFlags = 0;
+ thread->runningManagedCode = 0;
+ thread->threadAbortException = 0;
+
+#ifdef IL_USE_CVM
/* Allocate space for the thread-specific value stack */
if((thread->stackBase = (CVMWord *)ILGCAllocPersistent
-#ifdef IL_CONFIG_APPDOMAINS
- (sizeof(CVMWord) *
process->engine->stackSize)) == 0)
-#else
(sizeof(CVMWord) * process->stackSize))
== 0)
-#endif
{
ILGCFreePersistent(thread);
return 0;
}
-#ifdef IL_CONFIG_APPDOMAINS
- thread->stackLimit = thread->stackBase + process->engine->stackSize;
-#else
thread->stackLimit = thread->stackBase + process->stackSize;
-#endif
/* Allocate space for the initial frame stack */
if((thread->frameStack = (ILCallFrame *)ILGCAllocPersistent
-#ifdef IL_CONFIG_APPDOMAINS
- (sizeof(ILCallFrame) *
process->engine->frameStackSize))
-#else
(sizeof(ILCallFrame) *
process->frameStackSize))
-#endif
== 0)
{
ILGCFreePersistent(thread->stackBase);
@@ -634,32 +640,13 @@
}
thread->numFrames = 0;
-#ifdef IL_CONFIG_APPDOMAINS
- thread->maxFrames = process->engine->frameStackSize;
-#else
thread->maxFrames = process->frameStackSize;
-#endif
-
- /* Initialize the thread state */
- thread->supportThread = 0;
- thread->clrThread = 0;
- thread->aborting = 0;
- thread->freeMonitor = 0;
- thread->freeMonitorCount = 0;
thread->pc = 0;
- thread->isFinalizerThread = 0;
- thread->frame = thread->stackBase;
- thread->stackTop = thread->stackBase;
- thread->method = 0;
- thread->thrownException = 0;
- thread->threadStaticSlots = 0;
- thread->threadStaticSlotsUsed = 0;
- thread->currentException = 0;
- thread->managedSafePointFlags = 0;
- thread->runningManagedCode = 0;
thread->abortHandlerEndPC = 0;
- thread->threadAbortException = 0;
thread->abortHandlerFrame = 0;
+ thread->frame = thread->stackBase;
+ thread->stackTop = thread->stackBase;
+#endif /* IL_USE_CVM */
#ifdef IL_DEBUGGER
thread->numWatches = 0;
@@ -671,8 +658,10 @@
if (!ignoreProcessState
&& process->state & (_IL_PROCESS_STATE_UNLOADED |
_IL_PROCESS_STATE_UNLOADING))
{
+#ifdef IL_USE_CVM
ILGCFreePersistent(thread->stackBase);
ILGCFreePersistent(thread->frameStack);
+#endif
ILGCFreePersistent(thread);
ILMutexUnlock(process->lock);
@@ -718,11 +707,13 @@
_ILThreadClearExecContext(thread->supportThread);
}
+#ifdef IL_USE_CVM
/* Destroy the operand stack */
ILGCFreePersistent(thread->stackBase);
/* Destroy the call frame stack */
ILGCFreePersistent(thread->frameStack);
+#endif
#ifdef IL_DEBUGGER
/* Destroy the watch stack */
@@ -747,6 +738,7 @@
ILCallFrame *_ILGetCallFrame(ILExecThread *thread, ILInt32 n)
{
+#ifdef IL_USE_CVM
ILCallFrame *frame;
ILUInt32 posn;
if(n < 0)
@@ -764,11 +756,13 @@
}
--n;
}
+#endif
return 0;
}
ILCallFrame *_ILGetNextCallFrame(ILExecThread *thread, ILCallFrame *frame)
{
+#ifdef IL_USE_CVM
ILUInt32 posn;
posn = frame - thread->frameStack;
if(posn > 0)
@@ -780,6 +774,9 @@
{
return 0;
}
+#else
+ return 0;
+#endif
}
#ifdef IL_DEBUGGER
Index: include/il_engine.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/include/il_engine.h,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -b -r1.51 -r1.52
--- include/il_engine.h 3 Aug 2008 21:49:13 -0000 1.51
+++ include/il_engine.h 6 Aug 2008 13:31:48 -0000 1.52
@@ -28,13 +28,6 @@
extern "C" {
#endif
-#ifdef IL_CONFIG_APPDOMAINS
-/*
- * structure that keeps track of the created processes
- */
-typedef struct __tagILExecEngine ILExecEngine;
-#endif
-
/*
* Structure used by the EE for storing monitors.
*/
@@ -192,11 +185,7 @@
*
* Returns 0 if the engine was successfully initialized.
*/
-#ifdef IL_CONFIG_APPDOMAINS
-int ILExecInit(unsigned long maxSize, unsigned long frameStackSize);
-#else
int ILExecInit(unsigned long maxSize);
-#endif
/*
* Deinitialize the engine.
@@ -216,11 +205,7 @@
/*
* Create a new process, including the "main" thread.
*/
-#ifdef IL_CONFIG_APPDOMAINS
-ILExecProcess *ILExecProcessCreate(unsigned long cachePageSize);
-#else
ILExecProcess *ILExecProcessCreate(unsigned long frameStackSize, unsigned long
cachePageSize);
-#endif
/*
* Destroy a process and all threads associated with it.
@@ -282,6 +267,13 @@
/*
* Get the "main" thread for a process.
+ * This function is obsolete.
+ * It worked only correctly if called from the thread that created the
+ * ILExecProcess with calling ILExecProcessCreate.
+ * Failing to do so resulted the same ILExecThread being used by multiple
+ * threads and causing trouble as soon as both of them started executing
+ * managed code.
+ * Simply use ILExecThreadCurrent() instead.
*/
ILExecThread *ILExecProcessGetMain(ILExecProcess *process);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [dotgnu-pnet-commits] pnet ChangeLog engine/cvmc.c engine/debugger.c ...,
Klaus Treichel <=