[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[dotgnu-pnet-commits] pnet ChangeLog engine/engine.c engine/int_proto...
From: |
Klaus Treichel |
Subject: |
[dotgnu-pnet-commits] pnet ChangeLog engine/engine.c engine/int_proto... |
Date: |
Sun, 17 Aug 2008 16:45:39 +0000 |
CVSROOT: /cvsroot/dotgnu-pnet
Module name: pnet
Changes by: Klaus Treichel <ktreichel> 08/08/17 16:45:39
Modified files:
. : ChangeLog
engine : engine.c int_proto.h int_table.c lib_gc.c
process.c
include : il_gc.h
support : def_gc.c hb_gc.c
Log message:
Add new Framework 2.0 internal call and do some GC optimizations.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pnet/ChangeLog?cvsroot=dotgnu-pnet&r1=1.3559&r2=1.3560
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/engine.c?cvsroot=dotgnu-pnet&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/int_proto.h?cvsroot=dotgnu-pnet&r1=1.106&r2=1.107
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/int_table.c?cvsroot=dotgnu-pnet&r1=1.110&r2=1.111
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/lib_gc.c?cvsroot=dotgnu-pnet&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/process.c?cvsroot=dotgnu-pnet&r1=1.78&r2=1.79
http://cvs.savannah.gnu.org/viewcvs/pnet/include/il_gc.h?cvsroot=dotgnu-pnet&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/pnet/support/def_gc.c?cvsroot=dotgnu-pnet&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/pnet/support/hb_gc.c?cvsroot=dotgnu-pnet&r1=1.30&r2=1.31
Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ChangeLog,v
retrieving revision 1.3559
retrieving revision 1.3560
diff -u -b -r1.3559 -r1.3560
--- ChangeLog 15 Aug 2008 20:52:35 -0000 1.3559
+++ ChangeLog 17 Aug 2008 16:45:38 -0000 1.3560
@@ -1,3 +1,44 @@
+2008-08-17 Klaus Treichel <address@hidden>
+
+ * engine/engine.c (ILExecEngineDestroy): Clear some of the thread's
stack
+ and do a final collection after unloading all processes.
+
+ * engine/int_table.c, engine/int_proto.h: Regenerated.
+
+ * engine/lib_gc.c: Append Internal to the names of the internalcalls.
+ (_IL_GC_CollectionCountInternal): Added
+
+ * engine/process.c (_ILExecProcessUnloadInternal): Move clearing the
+ thread's stack just before the collection is done.
+ Use the new function ILGCFullCollection instead of ILGCCollect.
+ (ILExecProcessDestroy): Change check of returnvalue from
+ ILGCDisableFinalizers to == 0 to be consistent with the other functions.
+
+ * include/il_gc.h (ILGCFullCollection, ILGCCollectionCount): Add
+ prototypes for the new functions.
+
+ * support/def_gc.c (ILGCCollect): Increment the internal fake collection
+ counter.
+ (ILGCFullCollection): Added.
+ (ILGCCollectionCount): likewise
+ (ILGCInvokeFinalizers, ILGCDisableFinalizers): Add returning 1.
+
+ * support/hb_gc.c: Add the static value _FinalizingCount and the
+ declaration of GC_bytes_found.
+ Replace the %d in GC_TRACE with %p for printing the thread.
+ (_FinalizerThreadFunc): Increment _FinalizingCount before executing the
+ finalizers and clear the thread's stack after all finalizers are
executed.
+ (ILGCInit): Set GC_no_dls to 1 to prevent scanning of data segments of
+ loaded shared libraries.
+ (ILGCDeinit): Call ILGCFullCollection instead of GCCollect for the final
+ collection.
+ (ILGCFullCollection): Add function to perform collections as long as
+ anything is done (finalizers executed or memory reclaimed).
+ (ILGCCollectionCount): Added to return the total number of collections
+ executed.
+ (ILGCInvokeFinalizers, ILGCDisableFinalizers): Swap the returnvalues to
+ be consistent with the rest of the code.
+
2008-08-15 Klaus Treichel <address@hidden>
* cscc/csharp/cs_lookup.c (CheckForSealedImplementation): Add function
to
Index: engine/engine.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/engine.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- engine/engine.c 12 Aug 2008 18:19:51 -0000 1.6
+++ engine/engine.c 17 Aug 2008 16:45:38 -0000 1.7
@@ -198,6 +198,12 @@
ILExecProcessUnload(defaultProcess);
}
+ /* Clear some of the current thread's stack */
+ ILThreadClearStack(4000);
+
+ /* Do a final full collection */
+ ILGCFullCollection(1000);
+
#ifndef IL_CONFIG_APPDOMAINS
if(defaultProcess)
{
Index: engine/int_proto.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/int_proto.h,v
retrieving revision 1.106
retrieving revision 1.107
diff -u -b -r1.106 -r1.107
--- engine/int_proto.h 12 Aug 2008 18:19:51 -0000 1.106
+++ engine/int_proto.h 17 Aug 2008 16:45:38 -0000 1.107
@@ -116,12 +116,12 @@
extern ILFloat _IL_Decimal_ToSingle(ILExecThread * _thread, ILDecimal * value);
extern ILDouble _IL_Decimal_ToDouble(ILExecThread * _thread, ILDecimal *
value);
-extern void _IL_GC_KeepAlive(ILExecThread * _thread, ILObject * obj);
-extern void _IL_GC_ReRegisterForFinalize(ILExecThread * _thread, ILObject *
obj);
-extern void _IL_GC_SuppressFinalize(ILExecThread * _thread, ILObject * obj);
-extern void _IL_GC_WaitForPendingFinalizers(ILExecThread * _thread);
-extern void _IL_GC_Collect(ILExecThread * _thread);
-extern ILInt64 _IL_GC_GetTotalMemory(ILExecThread * _thread, ILBool
forceFullCollection);
+extern void _IL_GC_CollectInternal(ILExecThread * _thread, ILInt32
collectionMode);
+extern ILInt32 _IL_GC_CollectionCountInternal(ILExecThread * _thread);
+extern ILInt64 _IL_GC_GetTotalMemoryInternal(ILExecThread * _thread, ILBool
forceFullCollection);
+extern void _IL_GC_ReRegisterForFinalizeInternal(ILExecThread * _thread,
ILObject * obj);
+extern void _IL_GC_SuppressFinalizeInternal(ILExecThread * _thread, ILObject *
obj);
+extern void _IL_GC_WaitForPendingFinalizersInternal(ILExecThread * _thread);
extern ILObject * _IL_Type_GetTypeFromHandle(ILExecThread * _thread, void *
handle);
extern void _IL_Type_GetTypeHandle(ILExecThread * _thread, void * _result,
ILObject * obj);
Index: engine/int_table.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/int_table.c,v
retrieving revision 1.110
retrieving revision 1.111
diff -u -b -r1.110 -r1.111
--- engine/int_table.c 12 Aug 2008 18:19:52 -0000 1.110
+++ engine/int_table.c 17 Aug 2008 16:45:38 -0000 1.111
@@ -622,9 +622,18 @@
#if !defined(HAVE_LIBFFI)
-static void marshal_vp(void (*fn)(), void *rvalue, void **avalue)
+static void marshal_vpi(void (*fn)(), void *rvalue, void **avalue)
{
- (*(void (*)(void *))fn)(*((void * *)(avalue[0])));
+ (*(void (*)(void *, ILInt32))fn)(*((void * *)(avalue[0])), *((ILInt32
*)(avalue[1])));
+}
+
+#endif
+
+#if !defined(HAVE_LIBFFI)
+
+static void marshal_ip(void (*fn)(), void *rvalue, void **avalue)
+{
+ *((ILNativeInt *)rvalue) = (*(ILInt32 (*)(void *))fn)(*((void *
*)(avalue[0])));
}
#endif
@@ -638,15 +647,24 @@
#endif
+#if !defined(HAVE_LIBFFI)
+
+static void marshal_vp(void (*fn)(), void *rvalue, void **avalue)
+{
+ (*(void (*)(void *))fn)(*((void * *)(avalue[0])));
+}
+
+#endif
+
#ifndef _IL_GC_suppressed
IL_METHOD_BEGIN(GC_Methods)
- IL_METHOD("KeepAlive", "(oSystem.Object;)V", _IL_GC_KeepAlive,
marshal_vpp)
- IL_METHOD("ReRegisterForFinalize", "(oSystem.Object;)V",
_IL_GC_ReRegisterForFinalize, marshal_vpp)
- IL_METHOD("SuppressFinalize", "(oSystem.Object;)V",
_IL_GC_SuppressFinalize, marshal_vpp)
- IL_METHOD("WaitForPendingFinalizers", "()V",
_IL_GC_WaitForPendingFinalizers, marshal_vp)
- IL_METHOD("Collect", "()V", _IL_GC_Collect, marshal_vp)
- IL_METHOD("GetTotalMemory", "(Z)l", _IL_GC_GetTotalMemory, marshal_lpb)
+ IL_METHOD("CollectInternal", "(i)V", _IL_GC_CollectInternal,
marshal_vpi)
+ IL_METHOD("CollectionCountInternal", "()i",
_IL_GC_CollectionCountInternal, marshal_ip)
+ IL_METHOD("GetTotalMemoryInternal", "(Z)l",
_IL_GC_GetTotalMemoryInternal, marshal_lpb)
+ IL_METHOD("ReRegisterForFinalizeInternal", "(oSystem.Object;)V",
_IL_GC_ReRegisterForFinalizeInternal, marshal_vpp)
+ IL_METHOD("SuppressFinalizeInternal", "(oSystem.Object;)V",
_IL_GC_SuppressFinalizeInternal, marshal_vpp)
+ IL_METHOD("WaitForPendingFinalizersInternal", "()V",
_IL_GC_WaitForPendingFinalizersInternal, marshal_vp)
IL_METHOD_END
#endif
@@ -1664,15 +1682,6 @@
#endif
-#if !defined(HAVE_LIBFFI)
-
-static void marshal_ip(void (*fn)(), void *rvalue, void **avalue)
-{
- *((ILNativeInt *)rvalue) = (*(ILInt32 (*)(void *))fn)(*((void *
*)(avalue[0])));
-}
-
-#endif
-
#ifndef _IL_StackFrame_suppressed
IL_METHOD_BEGIN(StackFrame_Methods)
@@ -1953,15 +1962,6 @@
#if !defined(HAVE_LIBFFI)
-static void marshal_vpi(void (*fn)(), void *rvalue, void **avalue)
-{
- (*(void (*)(void *, ILInt32))fn)(*((void * *)(avalue[0])), *((ILInt32
*)(avalue[1])));
-}
-
-#endif
-
-#if !defined(HAVE_LIBFFI)
-
static void marshal_Bpp(void (*fn)(), void *rvalue, void **avalue)
{
*((ILNativeUInt *)rvalue) = (*(ILUInt8 (*)(void *, void *))fn)(*((void
* *)(avalue[0])), *((void * *)(avalue[1])));
Index: engine/lib_gc.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/lib_gc.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- engine/lib_gc.c 16 Sep 2006 20:24:05 -0000 1.12
+++ engine/lib_gc.c 17 Aug 2008 16:45:39 -0000 1.13
@@ -27,20 +27,9 @@
#endif
/*
- * public static void KeepAlive(Object obj);
+ * public static void ReRegisterForFinalizeInternal(Object obj);
*/
-void _IL_GC_KeepAlive(ILExecThread *_thread, ILObject *obj)
-{
- /* This internalcall exists purely to ensure that the object
- stays alive until this method is called, by keeping it
- somewhere on the current thread's stack. In other words,
- once this method is called, we have nothing to do */
-}
-
-/*
- * public static void ReRegisterForFinalize(Object obj);
- */
-void _IL_GC_ReRegisterForFinalize(ILExecThread *_thread, ILObject *obj)
+void _IL_GC_ReRegisterForFinalizeInternal(ILExecThread *_thread, ILObject *obj)
{
if(obj)
{
@@ -59,9 +48,9 @@
}
/*
- * public static void SuppressFinalize(Object obj);
+ * public static void SuppressFinalizeInternal(Object obj);
*/
-void _IL_GC_SuppressFinalize(ILExecThread *_thread, ILObject *obj)
+void _IL_GC_SuppressFinalizeInternal(ILExecThread *_thread, ILObject *obj)
{
if(obj)
{
@@ -75,25 +64,33 @@
}
/*
- * public static void WaitForPendingFinalizers();
+ * public static void WaitForPendingFinalizersInternal();
*/
-void _IL_GC_WaitForPendingFinalizers(ILExecThread *_thread)
+void _IL_GC_WaitForPendingFinalizersInternal(ILExecThread *_thread)
{
_ILExecThreadHandleWaitResult(_thread, ILGCInvokeFinalizers(-1));
}
/*
- * public static void Collect();
+ * public static void CollectInternal(int collectionMode);
*/
-void _IL_GC_Collect(ILExecThread *_thread)
+void _IL_GC_CollectInternal(ILExecThread *_thread, ILInt32 collectionMode)
{
ILGCCollect();
}
/*
- * public static long GetTotalMemory();
+ * public static int CollectionCountInternal();
+ */
+ILInt32 _IL_GC_CollectionCountInternal(ILExecThread *_thread)
+{
+ return ILGCCollectionCount();
+}
+
+/*
+ * public static long GetTotalMemoryInternal(bool forceFullCollection);
*/
-ILInt64 _IL_GC_GetTotalMemory(ILExecThread *_thread,
+ILInt64 _IL_GC_GetTotalMemoryInternal(ILExecThread *_thread,
ILBool
forceFullCollection)
{
if(forceFullCollection)
Index: engine/process.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/process.c,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -b -r1.78 -r1.79
--- engine/process.c 12 Aug 2008 18:19:52 -0000 1.78
+++ engine/process.c 17 Aug 2008 16:45:39 -0000 1.79
@@ -175,10 +175,6 @@
/* From this point on, no threads can be created inside or enter the
AppDomain */
- /* Clear 4K of stack space in case it contains some stray pointers
- that may still be picked up by not so accurate collectors */
- ILThreadClearStack(4096);
-
/* Walk all the threads, collecting CLR thread pointers since they are
GC
managed and stable */
@@ -226,11 +222,13 @@
process->state = _IL_PROCESS_STATE_RUNNING_FINALIZERS;
+ /* Clear 4K of stack space in case it contains some stray pointers
+ that may still be picked up by not so accurate collectors */
+ ILThreadClearStack(4096);
+
/* Invoke the finalizers -- hopefully finalizes all objects left in the
process being destroyed. Objects left lingering are orphans */
- ILGCCollect();
-
- ILGCInvokeFinalizers(30000);
+ ILGCFullCollection(1000);
if (process->engine)
{
@@ -743,7 +741,7 @@
/* Disable finalizers to ensure no finalizers are running until we
reenable them */
- if (ILGCDisableFinalizers(10000) != 0)
+ if (ILGCDisableFinalizers(10000) == 0)
{
/* Finalizers are taking too long. Abandon unloading of this
process */
return;
Index: include/il_gc.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/include/il_gc.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- include/il_gc.h 29 Jul 2008 17:35:12 -0000 1.10
+++ include/il_gc.h 17 Aug 2008 16:45:39 -0000 1.11
@@ -85,12 +85,28 @@
void ILGCCollect(void);
/*
+ * Perform full garbage collection.
+ * The difference to ILGCCollect is that collections will be done until
+ * either the timeout expired or the last collection caused no finalizers
+ * to be executed.
+ * Returns 1 if the collection completed successfully or 0 if timeout expired.
+ */
+int ILGCFullCollection(int timeout);
+
+/*
+ * Get the number of collections done so far.
+ */
+int ILGCCollectionCount(void);
+
+/*
* Invoke the pending finalizers and wait for them to complete.
+ * Returns 1 if finalizers have completed or 0 if timeout expired.
*/
int ILGCInvokeFinalizers(int timeout);
/*
* Temporarily disable finalizers that are called during allocation.
+ * Returns 1 if finalizers have been disabled or 0 if timeout expired.
*/
int ILGCDisableFinalizers(int timeout);
Index: support/def_gc.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/support/def_gc.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- support/def_gc.c 29 Jul 2008 17:35:13 -0000 1.10
+++ support/def_gc.c 17 Aug 2008 16:45:39 -0000 1.11
@@ -54,6 +54,7 @@
static void *heapMemory = 0;
static unsigned long heapSize = 0;
static unsigned long heapPosn = 0;
+static int collectionCount = 0;
/*
* Initialize the thread locking objects needed to control
@@ -185,17 +186,33 @@
void ILGCCollect(void)
{
- /* Nothing to do here */
+ /* We don't care about threads here because it's a fake value anyways.
*/
+ collectionCount++;
+}
+
+int ILGCFullCollection(int timeout)
+{
+ /* We don't care about threads here because it's a fake value anyways.
*/
+ collectionCount++;
+
+ return 1;
+}
+
+int ILGCCollectionCount(void)
+{
+ return collectionCount;
}
int ILGCInvokeFinalizers(int timeout)
{
/* Nothing to do here because we don't do finalization */
+ return 1;
}
int ILGCDisableFinalizers(int timeout)
{
/* Nothing to do here because we don't do finalization */
+ return 1;
}
void ILGCEnableFinalizers(void)
Index: support/hb_gc.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/support/hb_gc.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -b -r1.30 -r1.31
--- support/hb_gc.c 10 Aug 2008 16:16:14 -0000 1.30
+++ support/hb_gc.c 17 Aug 2008 16:45:39 -0000 1.31
@@ -66,6 +66,11 @@
static volatile int _FinalizersRunning = 0;
/*
+ * Number that is incremented each time finalizers are invoked.
+ */
+static volatile int _FinalizingCount = 0;
+
+/*
* The finalizer thread.
*/
static ILThread * volatile _FinalizerThread = 0;
@@ -100,17 +105,23 @@
#endif
/*
+ * This is a internal global variable with the number of reclaimed bytes
+ * after a garbage collection.
+ */
+extern signed_word GC_bytes_found;
+
+/*
* Main entry point for the finalizer thread.
*/
static void _FinalizerThreadFunc(void *data)
{
- GC_TRACE("GC:_FinalizerThread: Finalizer thread started [thread:%d]\n",
(int)ILThreadSelf());
+ GC_TRACE("GC:_FinalizerThread: Finalizer thread started [thread:%p]\n",
ILThreadSelf());
for (;;)
{
ILWaitOne(_FinalizerSignal, -1);
- GC_TRACE("GC:_FinalizerThread: Signal [thread:%d]\n",
(int)ILThreadSelf());
+ GC_TRACE("GC:_FinalizerThread: Signal [thread:%p]\n",
ILThreadSelf());
/* This *must* to be set before checking for
!_FinalizersDisabled to prevent
a race with ILGCDisableFinalizers */
@@ -121,11 +132,13 @@
if (GC_should_invoke_finalizers() && !_FinalizersDisabled)
{
- GC_TRACE("GC:_FinalizerThread: Finalizers running
[thread:%d]\n", (int)ILThreadSelf());
+ GC_TRACE("GC:_FinalizerThread: Finalizers running
[thread:%p]\n", ILThreadSelf());
+
+ ++_FinalizingCount;
GC_invoke_finalizers();
- GC_TRACE("GC:_FinalizerThread: Finalizers finished
[thread:%d]\n", (int)ILThreadSelf());
+ GC_TRACE("GC:_FinalizerThread: Finalizers finished
[thread:%p]\n", ILThreadSelf());
}
_FinalizersRunning = 0;
@@ -136,7 +149,7 @@
{
/* Exit finalizer thread after having invoked
finalizers one last time */
- GC_TRACE("GC:_FinalizerThread: Finalizer thread
finished [thread:%d]\n", (int)ILThreadSelf());
+ GC_TRACE("GC:_FinalizerThread: Finalizer thread
finished [thread:%p]\n", ILThreadSelf());
ILWaitEventReset(_FinalizerSignal);
/* Wake all waiting threads */
@@ -145,7 +158,9 @@
return;
}
- GC_TRACE("GC:_FinalizerThread: Response [thread:%d]\n",
(int)ILThreadSelf());
+ GC_TRACE("GC:_FinalizerThread: Response [thread:%p]\n",
ILThreadSelf());
+
+ ILThreadClearStack(4000);
ILWaitEventReset(_FinalizerSignal);
@@ -190,6 +205,8 @@
_FinalizersRunning = 1;
_FinalizersRunningSynchronously = 1;
+ ++_FinalizingCount;
+
GC_invoke_finalizers();
_FinalizersRunning = 0;
@@ -247,8 +264,8 @@
/* Couldn't create the finalizer thread */
GC_TRACE("PrivateGCInvokeFinalizers: Couldn't "
\
- "start finalizer thread
[thread: %d]\n",
- (int)ILThreadSelf());
+ "start finalizer thread
[thread: %p]\n",
+ ILThreadSelf());
_ILMutexUnlock(&_FinalizerLock);
@@ -264,11 +281,11 @@
/* Signal the finalizer thread */
GC_TRACE("PrivateGCInvokeFinalizers: Invoking finalizers " \
- "and waiting [thread: %d]\n", (int)ILThreadSelf());
+ "and waiting [thread: %p]\n", ILThreadSelf());
result = ILSignalAndWait(_FinalizerSignal, _FinalizerResponse, timeout);
- GC_TRACE("PrivateGCInvokeFinalizers: Finalizers finished[thread:
%d]\n", (int)ILThreadSelf());
+ GC_TRACE("PrivateGCInvokeFinalizers: Finalizers finished[thread:
%p]\n", ILThreadSelf());
return result;
}
@@ -293,6 +310,7 @@
GC_set_max_heap_size((size_t)maxSize);
/* Set up the finalization system the way we want it */
+ GC_no_dls = 1;
GC_finalize_on_demand = 1;
GC_java_finalization = 1;
GC_finalizer_notifier = GCNotifyFinalize;
@@ -321,27 +339,28 @@
{
_FinalizerStopFlag = 1;
- GC_TRACE("ILGCDeinit: Performing final GC [thread:%d]\n",
(int)ILThreadSelf());
+ GC_TRACE("ILGCDeinit: Performing final GC [thread:%p]\n",
ILThreadSelf());
/* Do a final GC */
- ILGCCollect();
+ ILGCFullCollection(1000);
+
/* Cleanup the finalizer thread */
if (_FinalizerThread && _FinalizerThreadStarted)
{
- GC_TRACE("ILGCDeinit: Peforming last finalizer run
[thread:%d]\n", (int)ILThreadSelf());
+ GC_TRACE("ILGCDeinit: Peforming last finalizer run
[thread:%p]\n", ILThreadSelf());
ILWaitEventSet(_FinalizerSignal);
- GC_TRACE("ILGCDeinit: Waiting for finalizer thread to end
[thread:%d]\n", (int)ILThreadSelf());
+ GC_TRACE("ILGCDeinit: Waiting for finalizer thread to end
[thread:%p]\n", ILThreadSelf());
/* Wait for the finalizer thread */
if (ILThreadJoin(_FinalizerThread, 15000))
{
- GC_TRACE("ILGCDeinit: Finalizer thread finished
[thread:%d]\n", (int)ILThreadSelf());
+ GC_TRACE("ILGCDeinit: Finalizer thread finished
[thread:%p]\n", ILThreadSelf());
}
else
{
- GC_TRACE("ILGCDeinit: Finalizer thread not responding
[thread:%d]\n", (int)ILThreadSelf());
+ GC_TRACE("ILGCDeinit: Finalizer thread not responding
[thread:%p]\n", ILThreadSelf());
}
/* Destroy the finalizer thread */
@@ -409,13 +428,135 @@
GC_gcollect();
}
+int ILGCFullCollection(int timeout)
+{
+ int lastFinalizingCount;
+ int hasThreads;
+
+ hasThreads = ILHasThreads();
+
+ if (timeout < 0)
+ {
+ ILInt32 bytesCollected;
+
+ /* No timeout */
+ if (_FinalizersRunning && hasThreads)
+ {
+ /* Wait for the finalizers to finish */
+ if(PrivateGCNotifyFinalize(timeout, 1))
+ {
+ /* timeout expired */
+ /* Then do at least one collection */
+ GC_gcollect();
+
+ return 0;
+ }
+ }
+
+ ILThreadClearStack(4000);
+
+ do
+ {
+ lastFinalizingCount = _FinalizingCount;
+
+ GC_TRACE("Last finalizingCount = %i\n",
lastFinalizingCount);
+
+ GC_gcollect();
+ bytesCollected = GC_bytes_found;
+
+ GC_TRACE("GC: bytes collected = %i\n", bytesCollected);
+
+ if(!PrivateGCNotifyFinalize(-1, 0))
+ {
+ /* something went wrong or finalizers are
disabled */
+
+ return 0;
+ }
+ } while ((lastFinalizingCount < _FinalizingCount) ||
+ (bytesCollected != 0));
+ }
+ else
+ {
+ /* With timeout */
+ ILCurrTime startTime;
+ ILUInt64 startMs;
+ int remainingTimeout;
+ ILInt32 bytesCollected;
+
+ if(!ILGetSinceRebootTime(&startTime))
+ {
+ return 0;
+ }
+ startMs = (startTime.secs * 1000) +
+ (ILUInt64)(startTime.nsecs / 1000000);
+ remainingTimeout = timeout;
+
+ if (_FinalizersRunning && hasThreads)
+ {
+ /* Wait for the finalizers to finish */
+ if(PrivateGCNotifyFinalize(timeout, 1))
+ {
+ /* timeout expired */
+ /* Then do at least one collection */
+ GC_gcollect();
+
+ return 0;
+ }
+ }
+
+ ILThreadClearStack(4000);
+
+ do
+ {
+ ILCurrTime currTime;
+ ILUInt64 currMs;
+
+ lastFinalizingCount = _FinalizingCount;
+
+ GC_TRACE("Last finalizingCount = %i\n",
lastFinalizingCount);
+
+ GC_gcollect();
+ bytesCollected = GC_bytes_found;
+
+ GC_TRACE("GC: bytes collected = %i\n", bytesCollected);
+
+ if(!ILGetSinceRebootTime(&currTime))
+ {
+ return 0;
+ }
+ currMs = (currTime.secs * 1000) +
+ (ILUInt64)(currTime.nsecs / 1000000);
+ remainingTimeout = timeout - (int)(currMs - startMs);
+
+ if(remainingTimeout <= 0)
+ {
+ return 0;
+ }
+ if(PrivateGCNotifyFinalize(remainingTimeout, 1))
+ {
+ /* timeout expired */
+ return 0;
+ }
+
+ } while ((lastFinalizingCount < _FinalizingCount) ||
+ (bytesCollected != 0));
+ }
+
+ return 1;
+}
+
+int ILGCCollectionCount(void)
+{
+ return GC_gc_no;
+}
+
int ILGCInvokeFinalizers(int timeout)
{
- int retval = 0;
+ int retval = 1;
if (GC_should_invoke_finalizers())
{
- retval = PrivateGCNotifyFinalize(timeout, 0);
+ retval = (PrivateGCNotifyFinalize(timeout, 0) ? 0 : 1);
}
return retval;
@@ -429,7 +570,7 @@
{
_ILMutexUnlock(&_FinalizerLock);
- return 0;
+ return 1;
}
_FinalizersDisabled = 1;
@@ -439,10 +580,10 @@
if (_FinalizersRunning && ILHasThreads())
{
/* Invoke and wait so we can guarantee no finalizers will run
after this method ends */
- return PrivateGCNotifyFinalize(timeout, 1);
+ return (PrivateGCNotifyFinalize(timeout, 1) ? 0 : 1);
}
- return 0;
+ return 1;
}
void ILGCEnableFinalizers(void)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [dotgnu-pnet-commits] pnet ChangeLog engine/engine.c engine/int_proto...,
Klaus Treichel <=