[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[dotgnu-pnet-commits] pnet ./ChangeLog engine/jitc.c engine/jitc.h en...
From: |
Klaus Treichel |
Subject: |
[dotgnu-pnet-commits] pnet ./ChangeLog engine/jitc.c engine/jitc.h en... |
Date: |
Thu, 18 May 2006 19:34:31 +0000 |
CVSROOT: /cvsroot/dotgnu-pnet
Module name: pnet
Branch:
Changes by: Klaus Treichel <address@hidden> 06/05/18 19:34:31
Modified files:
. : ChangeLog
engine : jitc.c jitc.h jitc_call.c jitc_setup.c layout.c
Makefile.am
Added files:
engine : jitc_delegate.c
Log message:
2006-05-18 Klaus Treichel <address@hidden>
* engine/Makefile.am: Add jitc_delegate.c to the jit coder sources.
* engine/layout.c: Replace the direct access of method->userdata with a
function call of ILJitFunctionFromILMethod.
* engine/jitc.h: Add the declaration of the delegate types and change
the
ILJitTypes.
* engine/jitc.c: Redo lots of the the jit function creation.
* engine/jitc_call.c: Changed calls to _ILJitCreateMethodSignature and
replace the direct access of method->userdata with a call of
ILJitFunctionFromILMethod.
* engine/jitc_setup.c: Replace the direct access of method->userdata
with a
function call of ILJitFunctionFromILMethod.
* engine/jitc_delegate.c: Added.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/ChangeLog.diff?tr1=1.3315&tr2=1.3316&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc.c.diff?tr1=1.31&tr2=1.32&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc.h.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc_call.c.diff?tr1=1.14&tr2=1.15&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc_delegate.c?rev=1.1
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc_setup.c.diff?tr1=1.14&tr2=1.15&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/layout.c.diff?tr1=1.43&tr2=1.44&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/Makefile.am.diff?tr1=1.84&tr2=1.85&r1=text&r2=text
Patches:
Index: pnet/ChangeLog
diff -u pnet/ChangeLog:1.3315 pnet/ChangeLog:1.3316
--- pnet/ChangeLog:1.3315 Mon May 1 17:30:49 2006
+++ pnet/ChangeLog Thu May 18 19:34:31 2006
@@ -1,3 +1,24 @@
+2006-05-18 Klaus Treichel <address@hidden>
+
+ * engine/Makefile.am: Add jitc_delegate.c to the jit coder sources.
+
+ * engine/layout.c: Replace the direct access of method->userdata with a
+ function call of ILJitFunctionFromILMethod.
+
+ * engine/jitc.h: Add the declaration of the delegate types and change
the
+ ILJitTypes.
+
+ * engine/jitc.c: Redo lots of the the jit function creation.
+
+ * engine/jitc_call.c: Changed calls to _ILJitCreateMethodSignature and
+ replace the direct access of method->userdata with a call of
+ ILJitFunctionFromILMethod.
+
+ * engine/jitc_setup.c: Replace the direct access of method->userdata
with a
+ function call of ILJitFunctionFromILMethod.
+
+ * engine/jitc_delegate.c: Added.
+
2006-05-01 Klaus Treichel <address@hidden>
* engine/call.c: Add support for the thread not included in the
signature.
Index: pnet/engine/Makefile.am
diff -u pnet/engine/Makefile.am:1.84 pnet/engine/Makefile.am:1.85
--- pnet/engine/Makefile.am:1.84 Mon Apr 17 17:39:44 2006
+++ pnet/engine/Makefile.am Thu May 18 19:34:31 2006
@@ -20,6 +20,7 @@
jitc_call.c \
jitc_const.c \
jitc_conv.c \
+ jitc_delegate.c \
jitc_diag.c \
jitc_except.c \
jitc_labels.c \
Index: pnet/engine/jitc.c
diff -u pnet/engine/jitc.c:1.31 pnet/engine/jitc.c:1.32
--- pnet/engine/jitc.c:1.31 Mon May 1 17:30:50 2006
+++ pnet/engine/jitc.c Thu May 18 19:34:31 2006
@@ -64,7 +64,7 @@
/* #define _IL_JIT_OPTIMIZE_NULLCHECKS 1 */
/*
- * To delay the initialization of the locals uncomment the following define.
+ * To defer the initialization of the locals uncomment the following define.
*/
/* #define _IL_JIT_OPTIMIZE_INIT_LOCALS 1 */
@@ -194,6 +194,13 @@
*/
static ILJitType _ILJitSignature_malloc = 0;
+#ifdef IL_JIT_FNPTR_ILMETHOD
+/*
+ * void *ILRuntimeMethodToVtablePointer(ILMethod *method)
+ */
+static ILJitType _ILJitSignature_ILRuntimeMethodToVtablePointer = 0;
+#endif
+
/*
* Define offsetof macro if not present.
*/
@@ -263,6 +270,17 @@
} while (0);
/*
+ * Private method information for the jit coder.
+ */
+typedef struct _tagILJitMethodInfo ILJitMethodInfo;
+struct _tagILJitMethodInfo
+{
+ ILJitFunction jitFunction; /* Implementation of the
method. */
+ ILUInt32 implementationType; /* Flag how the method is implemented.
*/
+ ILInternalInfo fnInfo; /* Information for internal
calls or pinvokes. */
+};
+
+/*
* Define the structure of a JIT coder's instance block.
*/
typedef struct _tagILJITCoder ILJITCoder;
@@ -276,6 +294,9 @@
int debugEnabled;
int flags;
+ /* Pool for the method infos. */
+ ILMemPool methodPool;
+
/* Members to manage the evaluation stack. */
ILJitValue *jitStack;
int stackSize;
@@ -379,6 +400,7 @@
#define _IL_JIT_OUT_OF_MEMORY 1
#define _IL_JIT_INVALID_CAST 2
#define _IL_JIT_INDEX_OUT_OF_RANGE 3
+#define _IL_JIT_METHOD_INVOKATION 4
/*
* Emit the code to throw a system exception.
@@ -391,9 +413,7 @@
#define _ILJitTypesInitBase(jitTypes, jitType) \
{ \
(jitTypes)->jitTypeBase = (jitType); \
- (jitTypes)->jitTypePtr = 0; \
- (jitTypes)->jitTypeRef = 0; \
- (jitTypes)->jitTypeOut = 0; \
+ (jitTypes)->jitTypeKind = 0; \
}
/*
@@ -1126,21 +1146,6 @@
*/
void ILJitTypesDestroy(ILJitTypes *jitTypes)
{
- if(jitTypes->jitTypeOut)
- {
- ILJitTypeDestroy(jitTypes->jitTypeOut);
- jitTypes->jitTypeOut = 0;
- }
- if(jitTypes->jitTypeRef)
- {
- ILJitTypeDestroy(jitTypes->jitTypeRef);
- jitTypes->jitTypeRef = 0;
- }
- if(jitTypes->jitTypePtr)
- {
- ILJitTypeDestroy(jitTypes->jitTypePtr);
- jitTypes->jitTypePtr = 0;
- }
if(jitTypes->jitTypeBase)
{
ILJitTypeDestroy(jitTypes->jitTypeBase);
@@ -1404,6 +1409,32 @@
return ptr;
}
+#ifdef IL_JIT_FNPTR_ILMETHOD
+/*
+ * Get the vtable pointer for an ILMethod.
+ */
+void *ILRuntimeMethodToVtablePointer(ILMethod *method)
+{
+ ILJitFunction jitFunction = ILJitFunctionFromILMethod(method);
+
+ if(!jitFunction)
+ {
+ /* The method's owner class needs to be layouted first. */
+ if(!_LayoutClass(ILExecThreadCurrent(), ILMethod_Owner(method)))
+ {
+ /* TODO: Throw an exception here. */
+ return 0;
+ }
+ if(!(jitFunction = ILJitFunctionFromILMethod(method)))
+ {
+ /* TODO: Throw an exception here. */
+ return 0;
+ }
+ }
+ return jit_function_to_vtable_pointer(jitFunction);
+}
+#endif
+
static void *_ILRuntimeLookupInterfaceMethod(ILClassPrivate
*objectClassPrivate,
ILClass *interfaceClass,
ILUInt32 index)
@@ -1925,6 +1956,16 @@
return 0;
}
+#ifdef IL_JIT_FNPTR_ILMETHOD
+ args[0] = _IL_JIT_TYPE_VPTR;
+ returnType = _IL_JIT_TYPE_VPTR;
+ if(!(_ILJitSignature_ILRuntimeMethodToVtablePointer =
+ jit_type_create_signature(IL_JIT_CALLCONV_CDECL, returnType,
args, 1, 1)))
+ {
+ return 0;
+ }
+#endif
+
return 1;
}
/*
@@ -1948,6 +1989,9 @@
coder->debugEnabled = 0;
coder->flags = 0;
+ /* Intialize the pool for the method infos. */
+ ILMemPoolInit(&(coder->methodPool), sizeof(ILJitMethodInfo), 100);
+
/* Initialize the stack management. */
coder->jitStack = 0;
coder->stackTop = -1;
@@ -2032,6 +2076,8 @@
}
ILMemPoolDestroy(&(coder->labelPool));
+ ILMemPoolDestroy(&(coder->methodPool));
+
ILFree(coder);
}
@@ -2066,35 +2112,11 @@
{
ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
- /* TODO: this should be enabled in the final version
- if(jitCoder->debugEnabled)
+ if(offset != 0)
{
- */
- if(offset != 0)
- {
- jit_insn_mark_offset(jitCoder->jitFunction,
(jit_int)offset);
- }
- /*
+ jit_insn_mark_offset(jitCoder->jitFunction, (jit_int)offset);
}
- */
-}
-
-/*
- * Get a block of method cache memory for use in code unrolling.
- */
-/*
-int _ILJITStartUnrollBlock(ILCoder *_coder, int align, ILCachePosn *posn)
-{
- ILJITCoder *coder = (ILJITCoder *)_coder;
- return (ILCacheStartMethod(coder->cache, posn, align, 0) != 0);
- return 0;
}
-*/
-
-#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS)
-
-
-#endif /* !IL_CONFIG_REDUCE_CODE */
#ifdef IL_CONFIG_PINVOKE
@@ -2220,55 +2242,15 @@
static int _ILJitFunctionIsInternal(ILJITCoder *coder, ILMethod *method,
ILInternalInfo *fnInfo, int isConstructor)
{
- ILMethodCode code;
+ ILJitMethodInfo *jitMethodInfo = (ILJitMethodInfo *)(method->userData);
- /* Get the method code */
- if(!ILMethodGetCode(method, &code))
+ if(jitMethodInfo)
{
- code.code = 0;
- }
- if(!(code.code))
- {
- switch(method->implementAttrs &
- (IL_META_METHODIMPL_CODE_TYPE_MASK |
- IL_META_METHODIMPL_INTERNAL_CALL |
- IL_META_METHODIMPL_JAVA))
+ if(jitMethodInfo->implementationType)
{
- case IL_META_METHODIMPL_RUNTIME:
- case IL_META_METHODIMPL_IL |
IL_META_METHODIMPL_INTERNAL_CALL:
- {
- /* Look up the internalcall function details */
- if(isConstructor)
- {
- if(!_ILFindInternalCall(coder->process,
-
method, 0, fnInfo))
- {
-
if(!_ILFindInternalCall(coder->process,
-
method, 1, fnInfo))
- {
- return 0;
- }
- if(fnInfo->func)
- {
- return 2;
- }
- }
- }
- else
- {
- if(!_ILFindInternalCall(coder->process,
-
method, 0, fnInfo))
- {
- return 0;
- }
- }
- if(fnInfo->func)
- {
- return 1;
- }
- }
- break;
+ fnInfo->func = jitMethodInfo->fnInfo.func;
}
+ return jitMethodInfo->implementationType;
}
return 0;
}
@@ -2424,12 +2406,14 @@
/*
* Generate the stub for calling an internal function.
*/
-static int _ILJitCompileInternal(ILJitFunction func, ILMethod *method, void
*nativeFunction)
+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);
+ ILJitMethodInfo *jitMethodInfo = (ILJitMethodInfo *)(method->userData);
ILJitType signature = jit_function_get_signature(func);
unsigned int numParams = jit_type_num_params(signature);
ILJitValue returnValue = 0;
@@ -2463,7 +2447,7 @@
jitParams[current - 1] = paramValue;
}
returnValue = _ILJitCallInternal(func, thread, method,
-
nativeFunction, methodName,
+
jitMethodInfo->fnInfo.func, methodName,
jitParams, numParams - 1);
#else
for(current = 0; current < numParams; ++current)
@@ -2475,7 +2459,7 @@
jitParams[current] = paramValue;
}
returnValue = _ILJitCallInternal(func, thread, method,
-
nativeFunction, methodName,
+
jitMethodInfo->fnInfo.func, methodName,
jitParams, numParams);
#endif
jit_insn_return(func, returnValue);
@@ -2506,163 +2490,80 @@
}
/*
- * On demand code generator.
+ * On demand code generator.for functions implemented in IL code.
*/
-static int _ILJitOnDemandFunc(jit_function_t func)
+static int _ILJitCompile(jit_function_t func)
{
ILExecThread *thread = ILExecThreadCurrent();
ILMethod *method = (ILMethod *)jit_function_get_meta(func,
IL_JIT_META_METHOD);
- ILMethodCode code;
if(!method)
{
return JIT_RESULT_COMPILE_ERROR;
}
- /* Get the method code */
- if(!ILMethodGetCode(method, &code))
+ if(!_ILConvertMethod(thread, method))
{
- code.code = 0;
- }
-
- /* We have to handle pinvokes too. */
- if(code.code)
- {
- if(!_ILConvertMethod(thread, method))
- {
- return JIT_RESULT_COMPILE_ERROR;
- }
- return JIT_RESULT_OK;
+ return JIT_RESULT_COMPILE_ERROR;
}
- else
- {
- /* This is a "PInvoke", "internalcall", or "runtime" method */
- ILPInvoke *pinv = ILPInvokeFind(method);
- ILInternalInfo fnInfo;
- int isConstructor = ILMethod_IsConstructor(method);;
- #ifdef IL_CONFIG_PINVOKE
- ILModule *module;
- const char *name;
- void *moduleHandle;
- #endif
-
- switch(method->implementAttrs &
- (IL_META_METHODIMPL_CODE_TYPE_MASK |
- IL_META_METHODIMPL_INTERNAL_CALL |
- IL_META_METHODIMPL_JAVA))
- {
- case IL_META_METHODIMPL_IL:
- case IL_META_METHODIMPL_OPTIL:
- {
- /* If we don't have a PInvoke record, then we
don't
- know what to map this method call to */
- if(!pinv)
- {
- return JIT_RESULT_COMPILE_ERROR;
- }
-
- #ifdef IL_CONFIG_PINVOKE
- /* Find the module for the PInvoke record */
- module = ILPInvoke_Module(pinv);
- if(!module)
- {
- return JIT_RESULT_COMPILE_ERROR;
- }
- name = ILModule_Name(module);
- if(!name || *name == '\0')
- {
- return JIT_RESULT_COMPILE_ERROR;
- }
- moduleHandle = LocateExternalModule
-
(ILExecThreadGetProcess(thread), name, pinv);
- if(!moduleHandle)
- {
- return JIT_RESULT_COMPILE_ERROR;
- }
+ return JIT_RESULT_OK;
+}
- /* Get the name of the function within the
module */
- name = ILPInvoke_Alias(pinv);
- if(!name || *name == '\0')
- {
- name = ILMethod_Name(method);
- }
+/*
+ * On demand code generator.for functions implemented in IL code.
+ */
+static int _ILJitCompilePinvoke(jit_function_t func)
+{
+ ILMethod *method = (ILMethod *)jit_function_get_meta(func,
IL_JIT_META_METHOD);
- /* Look up the method within the module */
- fnInfo.func =
ILDynLibraryGetSymbol(moduleHandle, name);
- #else /* !IL_CONFIG_PINVOKE */
- return JIT_RESULT_COMPILE_ERROR;
- #endif /* IL_CONFIG_PINVOKE */
- }
- break;
+ /* TODO */
+ return JIT_RESULT_COMPILE_ERROR;
+}
- case IL_META_METHODIMPL_RUNTIME:
- case IL_META_METHODIMPL_IL |
IL_META_METHODIMPL_INTERNAL_CALL:
- {
- /* "internalcall" and "runtime" methods must not
- have PInvoke records associated with them */
- if(pinv)
- {
- return JIT_RESULT_COMPILE_ERROR;
- }
+/*
+ * Check if the given method is abstract (should have no implementation).
+ */
+static int _ILJitMethodIsAbstract(ILMethod *method)
+{
+ ILMethodCode code;
- /* Look up the internalcall function details */
-
if(!_ILFindInternalCall(_ILExecThreadProcess(thread),
-
method, 0, &fnInfo))
- {
- if(isConstructor)
- {
-
if(!_ILFindInternalCall(_ILExecThreadProcess(thread),
-
method, 1, &fnInfo))
- {
- return
JIT_RESULT_COMPILE_ERROR;
- }
- }
- else
- {
- return JIT_RESULT_COMPILE_ERROR;
- }
- }
- else if(isConstructor)
- {
-
_ILFindInternalCall(ILExecThreadGetProcess(thread),
-
method, 1, &fnInfo);
- }
- }
- break;
+ if(!method)
+ {
+ /* This is obviously a bug and should not happen. */
+ return 0;
+ }
- default:
- {
- /* No idea how to invoke this method */
- return JIT_RESULT_COMPILE_ERROR;
- }
- /* Not reached */
- }
+ /* Get the method code */
+ if(!ILMethodGetCode(method, &code))
+ {
+ code.code = 0;
+ }
- /* Bail out if we did not find the underlying native method */
- if(!(fnInfo.func))
- {
- return JIT_RESULT_COMPILE_ERROR;
- }
+ if(code.code)
+ {
+ /* Code is present so zhe method is not abstract. */
+ return 0;
+ }
- switch(method->implementAttrs &
- (IL_META_METHODIMPL_CODE_TYPE_MASK |
- IL_META_METHODIMPL_INTERNAL_CALL |
- IL_META_METHODIMPL_JAVA))
- {
- case IL_META_METHODIMPL_RUNTIME:
- case IL_META_METHODIMPL_IL |
IL_META_METHODIMPL_INTERNAL_CALL:
- {
- return _ILJitCompileInternal(func, method,
fnInfo.func);
- }
- }
- return JIT_RESULT_COMPILE_ERROR;
+ if(method->implementAttrs &
+ (IL_META_METHODIMPL_CODE_TYPE_MASK |
+ IL_META_METHODIMPL_INTERNAL_CALL |
+ IL_META_METHODIMPL_JAVA))
+ {
+ /* An internalcall or pinvoke implementation should exist. */
+ return 0;
}
+ return 1;
}
+#include "jitc_delegate.c"
+
/*
* Create the signature type for an ILMethod.
*/
-static ILJitType _ILJitCreateMethodSignature(ILJITCoder *coder, ILMethod
*method)
+static ILJitType _ILJitCreateMethodSignature(ILJITCoder *coder,
+
ILMethod *method,
+
ILUInt32 implementationType)
{
ILType *signature = ILMethod_Signature(method);
ILType *type;
@@ -2704,14 +2605,7 @@
}
else
{
- ILType *ownerType = ILType_FromClass(info);
- ILType *synType = ILClassGetSynType(info);
- ILInternalInfo fnInfo;
- int ctorType = _ILJitFunctionIsInternal(coder, method,
&fnInfo, 1);
-
- if(!(synType && ILType_IsArray(synType)) &&
- !ILTypeIsStringClass(ownerType) &&
- !(ctorType == 2))
+ if(implementationType != 2)
{
/* we need an other arg for this */
total++;
@@ -2797,53 +2691,338 @@
}
/*
+ * Fill the MethodInfo and set the corresponding on demand compiler.
+ */
+static int _ILJitSetMethodInfo(ILJITCoder *jitCoder, ILMethod *method,
+
ILJitType jitSignature)
+{
+ ILClass *info;
+ ILClassPrivate *classPrivate;
+ ILUInt32 implementationType = 0;
+ jit_on_demand_func onDemandCompiler = 0;
+ ILInt32 setRecompilable = 0;
+ ILInternalInfo fnInfo;
+
+ if(!method)
+ {
+ return 0;
+ }
+
+ /* Get the method's owner class. */
+ info = ILMethod_Owner(method);
+ classPrivate = (ILClassPrivate *)(info->userData);
+ fnInfo.func = 0;
+
+ if(classPrivate->jitTypes.jitTypeKind != 0)
+ {
+ ILType *type = ILClassToType(info);
+
+ /* Handle the special cases. */
+ if(method == ILTypeGetDelegateMethod(type))
+ {
+ /* Flag method implemented in IL.. */
+ implementationType = 0;
+
+ /* now set the on demand compiler function */
+ onDemandCompiler = _ILJitCompileMultiCastDelegateInvoke;
+ }
+ }
+
+ if(!onDemandCompiler)
+ {
+ ILMethodCode code;
+
+ /* Get the method code */
+ if(!ILMethodGetCode(method, &code))
+ {
+ code.code = 0;
+ }
+
+ /* Check if the method is implemented in IL. */
+ if(code.code)
+ {
+ /* Flag method implemented in IL.. */
+ implementationType = 0;
+
+ /* set the function recompilable. */
+ setRecompilable = 1;
+
+ /* now set the on demand compiler function */
+ onDemandCompiler = _ILJitCompile;
+ }
+ else
+ {
+ /* This is a "PInvoke", "internalcall", or "runtime"
method */
+ ILExecThread *thread = ILExecThreadCurrent();
+ ILPInvoke *pinv = ILPInvokeFind(method);
+ int isConstructor = ILMethod_IsConstructor(method);;
+ #ifdef IL_CONFIG_PINVOKE
+ ILModule *module;
+ const char *name;
+ void *moduleHandle;
+ #endif
+
+ switch(method->implementAttrs &
+
(IL_META_METHODIMPL_CODE_TYPE_MASK |
+
IL_META_METHODIMPL_INTERNAL_CALL |
+ IL_META_METHODIMPL_JAVA))
+ {
+ case IL_META_METHODIMPL_IL:
+ case IL_META_METHODIMPL_OPTIL:
+ {
+ /* If we don't have a PInvoke record,
then we don't
+ know what to map this method call to
*/
+ if(!pinv)
+ {
+ return 0;
+ }
+
+ #ifdef IL_CONFIG_PINVOKE
+ /* Find the module for the PInvoke
record */
+ module = ILPInvoke_Module(pinv);
+ if(!module)
+ {
+ return 0;
+ }
+ name = ILModule_Name(module);
+ if(!name || *name == '\0')
+ {
+ return 0;
+ }
+ moduleHandle = LocateExternalModule
+
(ILExecThreadGetProcess(thread), name, pinv);
+ if(!moduleHandle)
+ {
+ return 0;
+ }
+
+ /* Get the name of the function within
the module */
+ name = ILPInvoke_Alias(pinv);
+ if(!name || *name == '\0')
+ {
+ name = ILMethod_Name(method);
+ }
+
+ /* Look up the method within the module
*/
+ fnInfo.func =
ILDynLibraryGetSymbol(moduleHandle, name);
+
+ /* Bail out if we did not find the
underlying native method */
+ if(!(fnInfo.func))
+ {
+ return 0;
+ }
+
+ /* Flag the method pinvoke. */
+ implementationType = 3;
+
+ /* now set the on demand compiler
function */
+ onDemandCompiler = _ILJitCompilePinvoke;
+
+ #else /* !IL_CONFIG_PINVOKE */
+ return 0;
+ #endif /* IL_CONFIG_PINVOKE */
+ }
+ break;
+
+ case IL_META_METHODIMPL_RUNTIME:
+ case IL_META_METHODIMPL_IL |
IL_META_METHODIMPL_INTERNAL_CALL:
+ {
+ /* "internalcall" and "runtime" methods
must not
+ have PInvoke records associated with
them */
+ if(pinv)
+ {
+ return 0;
+ }
+
+ /* Look up the internalcall function
details */
+ if(isConstructor)
+ {
+ if(ILClassIsValueType(info))
+ {
+
_ILFindInternalCall(_ILExecThreadProcess(thread),
+
method, 0, &fnInfo);
+ if(fnInfo.func)
+ {
+ /* Flag the
method internal. */
+
implementationType = 1;
+ }
+ }
+ else
+ {
+
if(!_ILFindInternalCall(_ILExecThreadProcess(thread),
+
method, 0, &fnInfo))
+ {
+
if(!_ILFindInternalCall(_ILExecThreadProcess(thread),
+
method, 1, &fnInfo))
+ {
+
implementationType = 0;
+ }
+ if(fnInfo.func)
+ {
+ /* Flag
the method an allocating constructor. */
+
implementationType = 2;
+ }
+ }
+ else
+ {
+ if(fnInfo.func)
+ {
+ /* Flag
the method internal. */
+
implementationType = 1;
+ }
+ else
+ {
+
if(!_ILFindInternalCall(_ILExecThreadProcess(thread),
+
method, 1, &fnInfo))
+ {
+
implementationType = 0;
+ }
+
if(fnInfo.func)
+ {
+
/* Flag the method an allocating constructor. */
+
implementationType = 2;
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+
if(!_ILFindInternalCall(_ILExecThreadProcess(thread),
+
method, 0, &fnInfo))
+ {
+ implementationType = 0;
+ }
+ else
+ {
+ if(fnInfo.func)
+ {
+ /* Flag the
method internal. */
+
implementationType = 1;
+ }
+ }
+ }
+
+ /* Bail out if the native method could
not be found. */
+ if(!(fnInfo.func))
+ {
+ return 0;
+ }
+
+ /* now set the on demand compiler. */
+ onDemandCompiler =
_ILJitCompileInternal;
+ }
+ break;
+
+ default:
+ {
+ /* No idea how to invoke this method */
+ return 0;
+ }
+ /* Not reached */
+ }
+ }
+ }
+
+ if(onDemandCompiler)
+ {
+ ILJitMethodInfo *jitMethodInfo = 0;
+ ILInt32 signatureCreated = 0;
+ ILJitFunction jitFunction = 0;
+
+ if(!jitSignature)
+ {
+ if(!(jitSignature =
_ILJitCreateMethodSignature(jitCoder, method,
+
implementationType)))
+ {
+ return 0;
+ }
+ signatureCreated = 1;
+ }
+
+ /* Now we can create the jit function itself. */
+ /* We must be able to create jit function prototypes while an
other */
+ /* function is on demand compiled. */
+ if(!(jitFunction = jit_function_create(jitCoder->context,
jitSignature)))
+ {
+ if(signatureCreated)
+ {
+ ILJitTypeDestroy(jitSignature);
+ }
+ return 0;
+ }
+
+ /* Set the ILMethod in the new functions metadata. */
+ /* Because there has nothing to be freed we can use 0 for the
free_func. */
+ if(!jit_function_set_meta(jitFunction, IL_JIT_META_METHOD,
method, 0, 0))
+ {
+ if(signatureCreated)
+ {
+ ILJitTypeDestroy(jitSignature);
+ }
+ return 0;
+ }
+
+ if(!(jitMethodInfo = ILMemPoolAlloc(&(jitCoder->methodPool),
+
ILJitMethodInfo)))
+ {
+ if(signatureCreated)
+ {
+ ILJitTypeDestroy(jitSignature);
+ }
+ return 0;
+ }
+
+ /* Copy the infos to the MethodInfo structure. */
+ jitMethodInfo->jitFunction = jitFunction;
+ jitMethodInfo->implementationType = implementationType;
+ jitMethodInfo->fnInfo.func = fnInfo.func;
+
+ /* and link the new jitFunction to the method. */
+ method->userData = (void *)jitMethodInfo;
+
+ if(setRecompilable)
+ {
+ /* set the function recompilable. */
+ jit_function_set_recompilable(jitFunction);
+ }
+ /* now set the on demand compiler function */
+ jit_function_set_on_demand_compiler(jitFunction,
onDemandCompiler);
+
+ #if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS) &&
defined(_IL_JIT_ENABLE_DEBUG)
+ _ILJitFunctionSetMethodName(jitFunction, method);
+ #endif
+
+ return 1;
+ }
+ return 0;
+}
+
+/*
* Create the jit function header for an ILMethod.
* We allways pass the ILExecThread as arg 0.
*/
int ILJitFunctionCreate(ILCoder *_coder, ILMethod *method)
{
ILJITCoder *coder = ((ILJITCoder *)_coder);
- /* The type of the jit signature for this function. */
- ILJitType jitSignature;
- /* The new created function. */
- ILJitFunction jitFunction;
/* Don't create the jit function twice. */
if(method->userData)
{
return 1;
}
- if(!(jitSignature = _ILJitCreateMethodSignature(coder, method)))
- {
- return 0;
- }
-
- /* Now we can create the jit function itself. */
- /* We must be able to create jit function prototypes while an other */
- /* function is on demand compiled. */
- if(!(jitFunction = jit_function_create(coder->context, jitSignature)))
+
+ if(_ILJitMethodIsAbstract(method))
{
- ILJitTypeDestroy(jitSignature);
- return 0;
+ /* This Method is abstract so we do nothing. */
+ return 1;
}
- /* Set the ILMethod in the new functions metadata. */
- /* Because there has nothing to be freed we can use 0 for the
free_func. */
- if(!jit_function_set_meta(jitFunction, IL_JIT_META_METHOD, method, 0,
0))
+ if(!_ILJitSetMethodInfo(coder, method, 0))
{
- ILJitTypeDestroy(jitSignature);
return 0;
}
-
- /* now set the on demand compiler function */
- jit_function_set_on_demand_compiler(jitFunction, _ILJitOnDemandFunc);
- /* and link the new jitFunction to the method. */
- method->userData = jitFunction;
-
-#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS) &&
defined(_IL_JIT_ENABLE_DEBUG)
- _ILJitFunctionSetMethodName(jitFunction, method);
-#endif
/* are we ready now ? */
return 1;
@@ -2858,8 +3037,7 @@
ILMethod *virtualAncestor)
{
ILJITCoder *jitCoder = ((ILJITCoder *)_coder);
- ILJitFunction ancestor = virtualAncestor->userData;
- ILJitFunction jitFunction;
+ ILJitMethodInfo *ancestorInfo = (ILJitMethodInfo
*)(virtualAncestor->userData);
ILJitType jitSignature;
/* Don't create the jit function twice. */
@@ -2868,7 +3046,13 @@
return 1;
}
- if(!ancestor)
+ if(_ILJitMethodIsAbstract(method))
+ {
+ /* This Method is abstract so we do nothing. */
+ return 1;
+ }
+
+ if(!ancestorInfo)
{
/* Tha ancestor has no jit function (might be abstract). */
/* So we need to do it the hard way. */
@@ -2889,32 +3073,13 @@
ILMutexUnlock(globalTraceMutex);
}
#endif
- jitSignature = jit_function_get_signature(ancestor);
+ jitSignature = jit_function_get_signature(ancestorInfo->jitFunction);
- /* Now we can create the jit function itself. */
- /* We must be able to create jit function prototypes while an other */
- /* function is on demand compiled. */
- if(!(jitFunction = jit_function_create(jitCoder->context,
jitSignature)))
+ if(!_ILJitSetMethodInfo(jitCoder, method, jitSignature))
{
return 0;
}
- /* Set the ILMethod in the new functions metadata. */
- /* Because there has nothing to be freed we can use 0 for the
free_func. */
- if(!jit_function_set_meta(jitFunction, IL_JIT_META_METHOD, method, 0,
0))
- {
- return 0;
- }
-
- /* now set the on demand compiler function */
- jit_function_set_on_demand_compiler(jitFunction, _ILJitOnDemandFunc);
-
- /* and link the new jitFunction to the method. */
- method->userData = jitFunction;
-
-#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS) &&
defined(_IL_JIT_ENABLE_DEBUG)
- _ILJitFunctionSetMethodName(jitFunction, method);
-#endif
/* are we ready now ? */
return 1;
@@ -2940,7 +3105,7 @@
{
if(!ILJitFunctionCreate(_coder, method))
{
- result = 0;
+ return 0;
}
}
}
@@ -2953,7 +3118,7 @@
*/
int ILJitCallMethod(ILExecThread *thread, ILMethod *method, void **jitArgs,
void *result)
{
- ILJitFunction jitFunction = method->userData;
+ ILJitFunction jitFunction = ILJitFunctionFromILMethod(method);
if(!jitFunction)
{
@@ -2962,7 +3127,7 @@
{
return 0;
}
- jitFunction = method->userData;
+ jitFunction = ILJitFunctionFromILMethod(method);
}
if(!jit_function_apply(jitFunction, jitArgs, result))
@@ -2980,7 +3145,12 @@
{
if(method)
{
- return (ILJitFunction)(method->userData);
+ ILJitMethodInfo *jitMethodInfo = (ILJitMethodInfo
*)(method->userData);
+
+ if(jitMethodInfo)
+ {
+ return jitMethodInfo->jitFunction;
+ }
}
return 0;
}
@@ -3020,31 +3190,40 @@
*/
int ILJitTypeCreate(ILClassPrivate *classPrivate, ILExecProcess *process)
{
- ILJitType type = 0;
+ ILJitType jitType = 0;
if(classPrivate->size >= 0)
{
+ ILType *type = ILClassToType(classPrivate->classInfo);
+
/* When it's a runtime object check if it has to be handled
special. */
if(process->context->systemImage ==
classPrivate->classInfo->programItem.image)
{
- type =
_ILJitTypeSpecials(classPrivate->classInfo->className);
+ jitType =
_ILJitTypeSpecials(classPrivate->classInfo->className);
}
- if(!type)
+ if(!jitType)
{
- if(!(type = jit_type_create_struct(0, 0, 0)))
+ if(!(jitType = jit_type_create_struct(0, 0, 0)))
{
return 0;
}
- jit_type_set_size_and_alignment(type,
+ jit_type_set_size_and_alignment(jitType,
classPrivate->size,
classPrivate->alignment);
}
- classPrivate->jitTypes.jitTypeBase = type;
- if(!(classPrivate->jitTypes.jitTypePtr =
jit_type_create_pointer(type, 1)))
+ classPrivate->jitTypes.jitTypeBase = jitType;
+ /* Check if it's one of the classes thet need special handling.
*/
+ if(ILTypeIsDelegateSubClass(type))
{
- jit_type_free(type);
- classPrivate->jitTypes.jitTypeBase = 0;
- return 0;
+ if(ILTypeIsDelegate(type))
+ {
+ /* This is a subclass of
System.MulticastDelegate. */
+ classPrivate->jitTypes.jitTypeKind =
IL_JIT_TYPEKIND_MULTICASTDELEGATE;
+ }
+ else
+ {
+ classPrivate->jitTypes.jitTypeKind =
IL_JIT_TYPEKIND_DELEGATE;
+ }
}
}
else
Index: pnet/engine/jitc.h
diff -u pnet/engine/jitc.h:1.12 pnet/engine/jitc.h:1.13
--- pnet/engine/jitc.h:1.12 Mon May 1 17:30:50 2006
+++ pnet/engine/jitc.h Thu May 18 19:34:31 2006
@@ -103,20 +103,22 @@
struct _tagILJitTypes
{
ILJitType jitTypeBase; /* the base type (class or struct) */
- ILJitType jitTypePtr; /* the pointer type pointing to
the base type. */
- ILJitType jitTypeRef; /* the type to pass the base
type as a byref arg. */
- ILJitType jitTypeOut; /* the type to pass the base
type as an out arg. */
+ ILUInt32 jitTypeKind; /* special class. */
};
/*
+ * Definition of the class which need special handling by the jit coder.
+ */
+#define IL_JIT_TYPEKIND_DELEGATE 0x00000001
+#define IL_JIT_TYPEKIND_MULTICASTDELEGATE 0x00000002
+
+/*
* Initialize a ILJitTypes structure
*/
#define _ILJitTypesInit(jitTypes) \
{ \
(jitTypes)->jitTypeBase = 0; \
- (jitTypes)->jitTypePtr = 0; \
- (jitTypes)->jitTypeRef = 0; \
- (jitTypes)->jitTypeOut = 0; \
+ (jitTypes)->jitTypeKind = 0; \
}
/*
Index: pnet/engine/jitc_call.c
diff -u pnet/engine/jitc_call.c:1.14 pnet/engine/jitc_call.c:1.15
--- pnet/engine/jitc_call.c:1.14 Mon May 1 17:30:50 2006
+++ pnet/engine/jitc_call.c Thu May 18 19:34:31 2006
@@ -702,7 +702,6 @@
ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
ILJitValue ftnPtr = jitCoder->jitStack[jitCoder->stackTop - 1];
-
#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS)
if (jitCoder->flags & IL_CODER_FLAG_STATS)
{
@@ -712,6 +711,16 @@
ILMutexUnlock(globalTraceMutex);
}
#endif
+
+#ifdef IL_JIT_FNPTR_ILMETHOD
+ /* We need to convert the method pointer to the vtable pointer first. */
+ ftnPtr = jit_insn_call_native(jitCoder->jitFunction,
+
"ILRuntimeMethodToVtablePointer",
+
ILRuntimeMethodToVtablePointer,
+
_ILJitSignature_ILRuntimeMethodToVtablePointer,
+ &ftnPtr, 1,
0);
+#endif
+
/* Pop the function pointer from the stack. */
JITC_ADJUST(jitCoder, -1);
}
@@ -904,7 +913,7 @@
if(!func)
{
- signature = _ILJitCreateMethodSignature(jitCoder, methodInfo);
+ signature = _ILJitCreateMethodSignature(jitCoder, methodInfo,
0);
}
else
{
@@ -980,7 +989,7 @@
{
ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
int argCount = info->numBaseArgs + info->numVarArgs;
- ILJitFunction func = methodInfo->userData;
+ ILJitFunction func = ILJitFunctionFromILMethod(methodInfo);
ILJitType signature;
ILJitValue jitParams[argCount + 1];
ILJitValue returnValue;
@@ -989,7 +998,7 @@
if(!func)
{
- signature = _ILJitCreateMethodSignature(jitCoder, methodInfo);
+ signature = _ILJitCreateMethodSignature(jitCoder, methodInfo,
0);
}
else
{
Index: pnet/engine/jitc_setup.c
diff -u pnet/engine/jitc_setup.c:1.14 pnet/engine/jitc_setup.c:1.15
--- pnet/engine/jitc_setup.c:1.14 Mon May 1 17:30:50 2006
+++ pnet/engine/jitc_setup.c Thu May 18 19:34:31 2006
@@ -30,7 +30,7 @@
ILJITLabel *label0;
/* Record the current jitted function. */
- coder->jitFunction = (ILJitFunction)(method->userData);
+ coder->jitFunction = ILJitFunctionFromILMethod(method);
/* Record the current method. */
coder->currentMethod = method;
Index: pnet/engine/layout.c
diff -u pnet/engine/layout.c:1.43 pnet/engine/layout.c:1.44
--- pnet/engine/layout.c:1.43 Sat Mar 4 14:36:08 2006
+++ pnet/engine/layout.c Thu May 18 19:34:31 2006
@@ -1065,7 +1065,7 @@
{
vtable[method->index] = method;
#ifdef IL_USE_JIT
- jitVtable[method->index] =
jit_function_to_vtable_pointer(method->userData);
+ jitVtable[method->index] =
jit_function_to_vtable_pointer(ILJitFunctionFromILMethod(method));
#endif
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [dotgnu-pnet-commits] pnet ./ChangeLog engine/jitc.c engine/jitc.h en...,
Klaus Treichel <=