[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[dotgnu-pnet-commits] pnet ChangeLog engine/cctormgr.c engine/cctormg...
From: |
Klaus Treichel |
Subject: |
[dotgnu-pnet-commits] pnet ChangeLog engine/cctormgr.c engine/cctormg... |
Date: |
Sun, 21 Jan 2007 17:53:29 +0000 |
CVSROOT: /cvsroot/dotgnu-pnet
Module name: pnet
Changes by: Klaus Treichel <ktreichel> 07/01/21 17:53:29
Modified files:
. : ChangeLog
engine : cctormgr.c cctormgr.h cvmc.c cvmc_call.c
cvmc_setup.c jitc.c jitc_call.c jitc_except.c
jitc_obj.c jitc_setup.c
Log message:
2007-01-21 Klaus Treichel <address@hidden>
* engine/cctormgr.c, engine/cctormgr.h: Add the
SetCurrentMethod function.
Use this information to optimize the queuing of classes to be
initialized.
* engine/cvmc.c, engine/cvmc_call.c, engine/cvmc_setup.c,
engine/jitc.c,
engine/jitc_call.c, engine/jitc_except.c, engine/jitc_setup.c:
Set the
current method in the cctormanager. Move the cctor invokation
from the
call of the method to the invokation of the method.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pnet/ChangeLog?cvsroot=dotgnu-pnet&r1=1.3405&r2=1.3406
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/cctormgr.c?cvsroot=dotgnu-pnet&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/cctormgr.h?cvsroot=dotgnu-pnet&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/cvmc.c?cvsroot=dotgnu-pnet&r1=1.50&r2=1.51
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/cvmc_call.c?cvsroot=dotgnu-pnet&r1=1.35&r2=1.36
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/cvmc_setup.c?cvsroot=dotgnu-pnet&r1=1.44&r2=1.45
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/jitc.c?cvsroot=dotgnu-pnet&r1=1.65&r2=1.66
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/jitc_call.c?cvsroot=dotgnu-pnet&r1=1.35&r2=1.36
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/jitc_except.c?cvsroot=dotgnu-pnet&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/jitc_obj.c?cvsroot=dotgnu-pnet&r1=1.26&r2=1.27
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/jitc_setup.c?cvsroot=dotgnu-pnet&r1=1.23&r2=1.24
Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ChangeLog,v
retrieving revision 1.3405
retrieving revision 1.3406
diff -u -b -r1.3405 -r1.3406
--- ChangeLog 21 Jan 2007 11:46:38 -0000 1.3405
+++ ChangeLog 21 Jan 2007 17:53:29 -0000 1.3406
@@ -1,5 +1,13 @@
2007-01-21 Klaus Treichel <address@hidden>
+ * engine/cctormgr.c, engine/cctormgr.h: Add the SetCurrentMethod
function.
+ Use this information to optimize the queuing of classes to be
initialized.
+
+ * engine/cvmc.c, engine/cvmc_call.c, engine/cvmc_setup.c, engine/jitc.c,
+ engine/jitc_call.c, engine/jitc_except.c, engine/jitc_setup.c: Set the
+ current method in the cctormanager. Move the cctor invokation from the
+ call of the method to the invokation of the method.
+
* engine/jitc_array.c: Fix a deadlock if the object array for varargs or
async delegate invokation is created and the class for the object array
doesn't exist yet.
Index: engine/cctormgr.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/cctormgr.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- engine/cctormgr.c 16 Jan 2007 06:46:08 -0000 1.1
+++ engine/cctormgr.c 21 Jan 2007 17:53:29 -0000 1.2
@@ -84,6 +84,7 @@
classInfo->attributes |= IL_META_TYPEDEF_CCTOR_RUNNING;
if(ILExecThreadCall(thread, cctor, 0))
{
+ classInfo->attributes &=
~IL_META_TYPEDEF_CCTOR_RUNNING;
return 0;
}
}
@@ -245,6 +246,7 @@
cctorMgr->thread = (ILThread *)0;;
cctorMgr->currentMethod = (ILMethod *)0;
cctorMgr->isStaticConstructor = 0;
+ cctorMgr->isConstructor = 0;
cctorMgr->lastClass = (ILClassEntry *)0;
@@ -276,6 +278,76 @@
}
/*
+ * Set the current method to be compiled.
+ * This checks if the class initializer of the class owning the method has
+ * to be executed prior to executing the method.
+ */
+void ILCCtorMgr_SetCurrentMethod(ILCCtorMgr *cctorMgr,
+ ILMethod
*method)
+{
+ if(cctorMgr)
+ {
+ if(method)
+ {
+ ILClass *methodOwner = ILMethod_Owner(method);
+
+ /* Setup the information for the current method. */
+ cctorMgr->currentMethod = method;
+ if(ILMethod_IsConstructor(method))
+ {
+ cctorMgr->isConstructor = 1;
+ cctorMgr->isStaticConstructor = 0;
+ }
+ else
+ {
+ cctorMgr->isConstructor = 0;
+ if(ILMethod_IsStaticConstructor(method))
+ {
+ cctorMgr->isStaticConstructor = 1;
+ }
+ else
+ {
+ cctorMgr->isStaticConstructor = 0;
+ }
+ }
+
+ if((methodOwner->attributes &
IL_META_TYPEDEF_CCTOR_ONCE) != 0)
+ {
+ /* We already know that the static constructor
has been called, */
+ return;
+ }
+
+ /* Now check if the class initializer of the method's
owner */
+ /* needs to be executed first and queue the class */
+ /* if neccessairy. */
+ if((methodOwner->attributes &
IL_META_TYPEDEF_BEFORE_FIELD_INIT) == 0)
+ {
+ if(ILMethod_IsStatic(method))
+ {
+ /* We have to call the cctor before
calling any static method */
+ /* of this type */
+ _ILCCtorMgr_QueueClass(cctorMgr,
methodOwner);
+ return;
+ }
+ if(cctorMgr->isConstructor)
+ {
+ /* We have to call the cctor before
calling a */
+ /* constructor of this type. */
+ _ILCCtorMgr_QueueClass(cctorMgr,
methodOwner);
+ return;
+ }
+ }
+ }
+ else
+ {
+ cctorMgr->currentMethod = (ILMethod *)0;
+ cctorMgr->isStaticConstructor = 0;
+ cctorMgr->isConstructor = 0;
+ }
+ }
+}
+
+/*
* Call this method before any non virtual method call is done.
* It checks if the static constructor for the method owner has to be invoked
* before the call is done.
@@ -293,17 +365,21 @@
if((methodOwner->attributes & IL_META_TYPEDEF_BEFORE_FIELD_INIT) == 0)
{
- if(ILMethod_IsStatic(method))
- {
/* We have to call the cctor before calling any static
method */
- /* of this type */
- return _ILCCtorMgr_QueueClass(cctorMgr, methodOwner);
+ /* or constructor of this type. */
+ if(ILMethod_IsStatic(method) || ILMethod_IsConstructor(method))
+ {
+ if(cctorMgr->isStaticConstructor)
+ {
+ ILClass *cctorOwner =
ILMethod_Owner(cctorMgr->currentMethod);
- }
- if(ILMethod_IsConstructor(method))
+ if(cctorOwner == methodOwner)
{
- /* We have to call the cctor before calling a
constructor of */
- /* this type. */
+ /* We are in the static constructor of
the class owning */
+ /* the method. So we don't need to call
the cctor again. */
+ return 1;
+ }
+ }
return _ILCCtorMgr_QueueClass(cctorMgr, methodOwner);
}
}
@@ -330,6 +406,17 @@
{
/* We have to call the cctor before accessing any static field
*/
/* of this type */
+ if(cctorMgr->isStaticConstructor)
+ {
+ ILClass *methodOwner =
ILMethod_Owner(cctorMgr->currentMethod);
+
+ if(methodOwner == fieldOwner)
+ {
+ /* We are in the static constructor of the
class owning */
+ /* the field. So we don't need to call the
cctor again. */
+ return 1;
+ }
+ }
return _ILCCtorMgr_QueueClass(cctorMgr, fieldOwner);
}
return 1;
Index: engine/cctormgr.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/cctormgr.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- engine/cctormgr.h 16 Jan 2007 06:46:08 -0000 1.1
+++ engine/cctormgr.h 21 Jan 2007 17:53:29 -0000 1.2
@@ -49,7 +49,9 @@
/* The currently compiled method. */
ILMethod *currentMethod;
/* Flag if the current method is a cctor. */
- ILInt32 isStaticConstructor;
+ int isStaticConstructor : 1;
+ /* Flag if the current method is a ctor. */
+ int isConstructor : 1;
/* Pool for the class entries. */
ILMemPool classPool;
@@ -64,6 +66,31 @@
void ILCCtorMgr_Destroy(ILCCtorMgr *cctorMgr);
/*
+ * Set the current method to be compiled.
+ * This checks if the class initializer of the class owning the method has
+ * to be executed prior to executing the method.
+ */
+void ILCCtorMgr_SetCurrentMethod(ILCCtorMgr *cctorMgr,
+ ILMethod
*method);
+
+/*
+ * Get the current method to be compiled.
+ */
+#define ILCCtorMgr_GetCurrentMethod(cctorMgr) (cctorMgr)->currentMethod
+
+/*
+ * Check if the current method is a static constructor.
+ */
+#define ILCCtorMgr_CurrentMethodIsStaticConstructor(cctorMgr) \
+ ((cctorMgr)->isStaticConstructor != 0)
+
+/*
+ * Check if the current method is a constructor.
+ */
+#define ILCCtorMgr_CurrentMethodIsConstructor(cctorMgr) \
+ ((cctorMgr)->isConstructor != 0)
+
+/*
* Call this method before any non virtual method call is done.
* It checks if the static constructor for the method owner has to be invoked
* before the call is done.
Index: engine/cvmc.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/cvmc.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -b -r1.50 -r1.51
--- engine/cvmc.c 16 Jan 2007 06:46:08 -0000 1.50
+++ engine/cvmc.c 21 Jan 2007 17:53:29 -0000 1.51
@@ -82,7 +82,6 @@
ILCVMLabel *labelList;
int labelOutOfMemory;
unsigned char *switchStart;
- ILMethod *currentMethod;
int debugEnabled;
#ifdef IL_DEBUGGER
/* Flag if current method can be debugged */
@@ -185,7 +184,6 @@
coder->labelList = 0;
coder->labelOutOfMemory = 0;
coder->switchStart = 0;
- coder->currentMethod = 0;
coder->debugEnabled = 0;
coder->flags = 0;
coder->nativeArgPosn = 0;
Index: engine/cvmc_call.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/cvmc_call.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- engine/cvmc_call.c 19 Jan 2007 18:42:11 -0000 1.35
+++ engine/cvmc_call.c 21 Jan 2007 17:53:29 -0000 1.36
@@ -97,8 +97,6 @@
ILEngineStackItem *returnItem,
ILMethod
*methodInfo)
{
- /* Queue the cctor to run. */
- ILCCtorMgr_OnCallMethod(&(((ILCVMCoder *)coder)->cctorMgr), methodInfo);
if(info->tailCall)
{
CVMP_OUT_PTR(COP_PREFIX_TAIL_CALL, methodInfo);
@@ -128,8 +126,6 @@
static void CVMCoder_CallCtor(ILCoder *coder, ILCoderMethodInfo *info,
ILMethod *methodInfo)
{
- /* Queue the cctor to run. */
- ILCCtorMgr_OnCallMethod(&(((ILCVMCoder *)coder)->cctorMgr), methodInfo);
CVM_OUT_PTR(COP_CALL_CTOR, methodInfo);
AdjustForCall(coder, info, 0);
CVM_ADJUST(1);
@@ -502,6 +498,9 @@
static void CVMCoder_LoadFuncAddr(ILCoder *coder, ILMethod *methodInfo)
{
/* Queue the cctor to run. */
+ /* TODO: leave this one because the methodpointer might be used to
start */
+ /* a new thread. This makes sure that the class of the thread start */
+ /* function is initialized. */
ILCCtorMgr_OnCallMethod(&(((ILCVMCoder *)coder)->cctorMgr), methodInfo);
CVMP_OUT_PTR(COP_PREFIX_LDFTN, methodInfo);
CVM_ADJUST(1);
Index: engine/cvmc_setup.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/cvmc_setup.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -b -r1.44 -r1.45
--- engine/cvmc_setup.c 16 Jan 2007 06:46:08 -0000 1.44
+++ engine/cvmc_setup.c 21 Jan 2007 17:53:29 -0000 1.45
@@ -1278,6 +1278,9 @@
coder->markBreakpoints = (debugger &&
ILDebuggerIsAssemblyWatched(debugger, method));
#endif
+ /* Set the current method in the coder and queue a cctor if needed. */
+ ILCCtorMgr_SetCurrentMethod(&(coder->cctorMgr), method);
+
/* Generate the entry point code */
return CVMEntryGen(&ctx, coder, method, signature,
ILMethod_IsConstructor(method), 1,
start, 1);
@@ -1368,6 +1371,9 @@
return 0;
}
+ /* Set the current method in the coder and queue a cctor if needed. */
+ ILCCtorMgr_SetCurrentMethod(&(coder->cctorMgr), method);
+
/* Output the body of the method */
CVMEntryPushLeadIn(&ctx, coder, signature, useRawCalls, isInternal, 0);
CVMEntryPushNativeArgs(&ctx, coder, method, signature,
Index: engine/jitc.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/jitc.c,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -b -r1.65 -r1.66
--- engine/jitc.c 16 Jan 2007 06:55:57 -0000 1.65
+++ engine/jitc.c 21 Jan 2007 17:53:29 -0000 1.66
@@ -79,13 +79,18 @@
#define IL_JIT_ENABLE_CCTORMGR
/*
- * Reenable finalizers, unlock the metadata lock and run finalizers.
+ * Acquire and release the metadata lock, while suppressing finalizers
* Must be kept in sync with convert.c
*/
-#define METADATA_UNLOCK(thread) \
+#define METADATA_WRLOCK(process) \
+ do { \
+ IL_METADATA_WRLOCK(process); \
+ ILGCDisableFinalizers(0); \
+ } while (0)
+#define METADATA_UNLOCK(process) \
do { \
ILGCEnableFinalizers(); \
-
IL_METADATA_UNLOCK(_ILExecThreadProcess(thread)); \
+ IL_METADATA_UNLOCK(process); \
ILGCInvokeFinalizers(0); \
} while (0)
@@ -410,7 +415,9 @@
ILExecProcess *process;
jit_context_t context;
+#ifndef IL_JIT_ENABLE_CCTORMGR
ILMethod *currentMethod;
+#endif /* !IL_JIT_ENABLE_CCTORMGR */
int debugEnabled;
int flags;
@@ -2737,7 +2744,11 @@
{
/* Mark breakpoint that reports current ILMethod and IL offset
*/
jit_insn_mark_breakpoint(jitCoder->jitFunction,
+ #ifdef IL_JIT_ENABLE_CCTORMGR
+ (jit_nint)
ILCCtorMgr_GetCurrentMethod(&(jitCoder->cctorMgr)),
+ #else /* !IL_JIT_ENABLE_CCTORMGR */
(jit_nint)
jitCoder->currentMethod,
+ #endif /* !IL_JIT_ENABLE_CCTORMGR */
(jit_nint)
offset);
}
#endif
@@ -2755,7 +2766,7 @@
#else /* !IL_JIT_ENABLE_CCTORMGR */
ILExecThread *thread = ILExecThreadCurrent();
- METADATA_UNLOCK(thread);
+ METADATA_UNLOCK(_ILExecThreadProcess(thread));
return 1;
#endif /* !IL_JIT_ENABLE_CCTORMGR */
}
@@ -3073,11 +3084,11 @@
*/
static int _ILJitCompileInternal(ILJitFunction func)
{
-#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS) &&
defined(_IL_JIT_ENABLE_DEBUG)
- ILExecThread *_thread = ILExecThreadCurrent();
- ILJITCoder *jitCoder = (ILJITCoder
*)(_ILExecThreadProcess(_thread)->coder);
-#endif
ILMethod *method = (ILMethod *)jit_function_get_meta(func,
IL_JIT_META_METHOD);
+#if (!defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS) &&
defined(_IL_JIT_ENABLE_DEBUG)) || defined(IL_JIT_ENABLE_CCTORMGR)
+ ILClassPrivate *classPrivate = (ILClassPrivate
*)(ILMethod_Owner(method)->userData);
+ ILJITCoder *jitCoder = (ILJITCoder *)(classPrivate->process->coder);
+#endif
ILJitMethodInfo *jitMethodInfo = (ILJitMethodInfo *)(method->userData);
ILJitType signature = jit_function_get_signature(func);
unsigned int numParams = jit_type_num_params(signature);
@@ -3102,6 +3113,12 @@
}
#endif
+#ifdef IL_JIT_ENABLE_CCTORMGR
+ METADATA_WRLOCK(jitCoder->process);
+ jitCoder->jitFunction = func;
+ ILCCtorMgr_SetCurrentMethod(&(jitCoder->cctorMgr), method);
+#endif /* IL_JIT_ENABLE_CCTORMGR */
+
#ifdef IL_JIT_THREAD_IN_SIGNATURE
for(current = 1; current < numParams; ++current)
{
Index: engine/jitc_call.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/jitc_call.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- engine/jitc_call.c 19 Jan 2007 18:42:11 -0000 1.35
+++ engine/jitc_call.c 21 Jan 2007 17:53:29 -0000 1.36
@@ -480,10 +480,7 @@
ILMutexUnlock(globalTraceMutex);
}
#endif
-#ifdef IL_JIT_ENABLE_CCTORMGR
- /* Queue the cctor to run. */
- ILCCtorMgr_OnCallMethod(&(jitCoder->cctorMgr), methodInfo);
-#else /* !IL_JIT_ENABLE_CCTORMGR */
+#ifndef IL_JIT_ENABLE_CCTORMGR
/* Output a call to the static constructor */
_ILJitCallStaticConstructor(jitCoder, ILMethod_Owner(methodInfo), 0);
#endif /* !IL_JIT_ENABLE_CCTORMGR */
@@ -827,10 +824,7 @@
type = ILType_FromClass(classInfo);
synType = ILClassGetSynType(classInfo);
-#ifdef IL_JIT_ENABLE_CCTORMGR
- /* Queue the cctor to run. */
- ILCCtorMgr_OnCallMethod(&(jitCoder->cctorMgr), methodInfo);
-#else /* !IL_JIT_ENABLE_CCTORMGR */
+#ifndef IL_JIT_ENABLE_CCTORMGR
/* Output a call to the static constructor */
_ILJitCallStaticConstructor(jitCoder, ILMethod_Owner(methodInfo), 1);
#endif /* !IL_JIT_ENABLE_CCTORMGR */
Index: engine/jitc_except.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/jitc_except.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- engine/jitc_except.c 16 Jan 2007 06:46:08 -0000 1.14
+++ engine/jitc_except.c 21 Jan 2007 17:53:29 -0000 1.15
@@ -530,7 +530,11 @@
(jit_nint)classInfo);
ILJitValue method =
jit_value_create_nint_constant(jitCoder->jitFunction,
_IL_JIT_TYPE_VPTR,
+#ifdef IL_JIT_ENABLE_CCTORMGR
+
(jit_nint)ILCCtorMgr_GetCurrentMethod(&(jitCoder->cctorMgr)));
+#else /* !IL_JIT_ENABLE_CCTORMGR */
(jit_nint)jitCoder->currentMethod);
+#endif /* !IL_JIT_ENABLE_CCTORMGR */
ILJitValue nullException =
jit_value_create_nint_constant(jitCoder->jitFunction,
_IL_JIT_TYPE_VPTR,
(jit_nint)0);
Index: engine/jitc_obj.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/jitc_obj.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- engine/jitc_obj.c 16 Jan 2007 06:46:08 -0000 1.26
+++ engine/jitc_obj.c 21 Jan 2007 17:53:29 -0000 1.27
@@ -301,7 +301,11 @@
{
args[0] = jit_value_create_nint_constant(jitCoder->jitFunction,
_IL_JIT_TYPE_VPTR,
+#ifdef IL_JIT_ENABLE_CCTORMGR
+
(jit_nint)ILCCtorMgr_GetCurrentMethod(&(jitCoder->cctorMgr)));
+#else /* !IL_JIT_ENABLE_CCTORMGR */
(jit_nint)jitCoder->currentMethod);
+#endif /* !IL_JIT_ENABLE_CCTORMGR */
args[1] = _ILJitStackItemValue(object);
args[2] = classTo;
returnValue = jit_insn_call_native(jitCoder->jitFunction,
Index: engine/jitc_setup.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/jitc_setup.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- engine/jitc_setup.c 16 Jan 2007 12:00:58 -0000 1.23
+++ engine/jitc_setup.c 21 Jan 2007 17:53:29 -0000 1.24
@@ -45,7 +45,11 @@
/* Record the current jitted function. */
coder->jitFunction = ILJitFunctionFromILMethod(method);
/* Record the current method. */
+#ifdef IL_JIT_ENABLE_CCTORMGR
+ ILCCtorMgr_SetCurrentMethod(&(coder->cctorMgr), method);
+#else /* !IL_JIT_ENABLE_CCTORMGR */
coder->currentMethod = method;
+#endif /* !IL_JIT_ENABLE_CCTORMGR */
#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS)
if (coder->flags & IL_CODER_FLAG_STATS)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [dotgnu-pnet-commits] pnet ChangeLog engine/cctormgr.c engine/cctormg...,
Klaus Treichel <=