[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_allo...
From: |
Klaus Treichel |
Subject: |
[dotgnu-pnet-commits] pnet ./ChangeLog engine/jitc.c engine/jitc_allo... |
Date: |
Sat, 03 Jun 2006 11:00:40 +0000 |
CVSROOT: /sources/dotgnu-pnet
Module name: pnet
Branch:
Changes by: Klaus Treichel <address@hidden> 06/06/03 11:00:40
Modified files:
. : ChangeLog
engine : jitc.c jitc_alloc.c jitc_call.c jitc_delegate.c
jitc_obj.c
Log message:
Add the first async support for delegates.
The double and valuetype tests still fail.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/ChangeLog.diff?tr1=1.3319&tr2=1.3320&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc.c.diff?tr1=1.34&tr2=1.35&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc_alloc.c.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc_call.c.diff?tr1=1.16&tr2=1.17&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc_delegate.c.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc_obj.c.diff?tr1=1.17&tr2=1.18&r1=text&r2=text
Patches:
Index: pnet/ChangeLog
diff -u pnet/ChangeLog:1.3319 pnet/ChangeLog:1.3320
--- pnet/ChangeLog:1.3319 Sun May 28 10:50:16 2006
+++ pnet/ChangeLog Sat Jun 3 11:00:40 2006
@@ -1,3 +1,19 @@
+2006-06-03 Klaus Treichel <address@hidden>
+
+ * engine/jitc.c: Use the on demand compilers for DelegateBeginInvoke and
+ DelegateEndInvoke for the corresponding delegate methods. Use the
+ ILJitFunction instead of the ILJITCoder in calls to the alloc functions.
+
+ * engine/jitc_alloc.c: Use the ILJitFunction instead of the ILJITCoder
+ in calls to the alloc functions. Call AllocAtomic again because the
error
+ seemed to be caused by multiple executions of the cctors.
+
+ * engine/jitc_delegate.c: Add the support for the Begin- and EndInvoke
+ methods.
+
+ * engine/jitc_call.c, engine/jitc_bj.c: Pass the jit function instead of
+ the coder to the alloc functions.
+
2006-05-28 Aleksey Demakov <address@hidden>
* engine/jitc_setup.c (JITCoder_Setup): move static ctor once check
Index: pnet/engine/jitc.c
diff -u pnet/engine/jitc.c:1.34 pnet/engine/jitc.c:1.35
--- pnet/engine/jitc.c:1.34 Sat May 27 12:10:50 2006
+++ pnet/engine/jitc.c Sat Jun 3 11:00:40 2006
@@ -370,14 +370,14 @@
* Generate the code to allocate the memory for an object.
* Returns the ILJitValue with the pointer to the new object.
*/
-static ILJitValue _ILJitAllocGen(ILJITCoder *jitCoder, ILClass *classInfo,
+static ILJitValue _ILJitAllocGen(ILJitFunction jitFunction, ILClass *classInfo,
ILUInt32 size);
/*
* Generate the code to allocate the memory for an object.
* Returns the ILJitValue with the pointer to the new object.
*/
-static ILJitValue _ILJitAllocObjectGen(ILJITCoder *jitCoder, ILClass
*classInfo);
+static ILJitValue _ILJitAllocObjectGen(ILJitFunction jitFunction, ILClass
*classInfo);
#ifdef IL_JIT_THREAD_IN_SIGNATURE
#define _ILJitCoderGetThread(coder)
jit_value_get_param((coder)->jitFunction, 0)
@@ -2818,6 +2818,22 @@
/* now set the on demand compiler function */
onDemandCompiler = _ILJitCompileMultiCastDelegateInvoke;
}
+ else if (method == (ILMethod
*)ILTypeGetDelegateBeginInvokeMethod(type))
+ {
+ /* Flag method implemented in IL.. */
+ implementationType = _IL_JIT_IMPL_DEFAULT;
+
+ /* now set the on demand compiler function */
+ onDemandCompiler = _ILJitCompileDelegateBeginInvoke;
+ }
+ else if (method == (ILMethod
*)ILTypeGetDelegateEndInvokeMethod(type))
+ {
+ /* Flag method implemented in IL.. */
+ implementationType = _IL_JIT_IMPL_DEFAULT;
+
+ /* now set the on demand compiler function */
+ onDemandCompiler = _ILJitCompileDelegateEndInvoke;
+ }
}
if(!onDemandCompiler)
Index: pnet/engine/jitc_alloc.c
diff -u pnet/engine/jitc_alloc.c:1.3 pnet/engine/jitc_alloc.c:1.4
--- pnet/engine/jitc_alloc.c:1.3 Sat May 27 12:10:51 2006
+++ pnet/engine/jitc_alloc.c Sat Jun 3 11:00:40 2006
@@ -63,11 +63,7 @@
ILObject *obj;
/* Allocate memory from the heap */
- /* TODO: There seem to be classes in the runtime where managed pointers
*/
- /* are not correctly recognized (are IntPtrs in the class definition).
*/
- /* This is why i'm using ILGCAlloc here. */
- /* ptr = ILGCAllocAtomic(size + IL_OBJECT_HEADER_SIZE); */
- ptr = ILGCAlloc(size + IL_OBJECT_HEADER_SIZE);
+ ptr = ILGCAllocAtomic(size + IL_OBJECT_HEADER_SIZE);
if(!ptr)
{
@@ -96,7 +92,7 @@
* Generate the code to allocate the memory for an object with the given size.
* Returns the ILJitValue with the pointer to the new object.
*/
-static ILJitValue _ILJitAllocGen(ILJITCoder *jitCoder, ILClass *classInfo,
+static ILJitValue _ILJitAllocGen(ILJitFunction jitFunction, ILClass *classInfo,
ILUInt32 size)
{
ILJitValue newObj;
@@ -112,22 +108,22 @@
}
/* We call the alloc functions. */
/* They thow an out of memory exception so we don't need to care. */
- args[0] = jit_value_create_nint_constant(jitCoder->jitFunction,
+ args[0] = jit_value_create_nint_constant(jitFunction,
_IL_JIT_TYPE_VPTR,
(jit_nint)classInfo);
- args[1] = jit_value_create_nint_constant(jitCoder->jitFunction,
+ args[1] = jit_value_create_nint_constant(jitFunction,
_IL_JIT_TYPE_UINT32, size);
if(((ILClassPrivate *)(classInfo->userData))->managedInstance)
{
- newObj = jit_insn_call_native(jitCoder->jitFunction,
"_ILJitAlloc",
+ newObj = jit_insn_call_native(jitFunction, "_ILJitAlloc",
_ILJitAlloc,
_ILJitSignature_ILJitAlloc,
args,
2, 0);
}
else
{
- newObj = jit_insn_call_native(jitCoder->jitFunction,
+ newObj = jit_insn_call_native(jitFunction,
"_ILJitAllocAtomic",
_ILJitAllocAtomic,
_ILJitSignature_ILJitAlloc,
@@ -140,7 +136,7 @@
* Generate the code to allocate the memory for an object.
* Returns the ILJitValue with the pointer to the new object.
*/
-static ILJitValue _ILJitAllocObjectGen(ILJITCoder *jitCoder, ILClass
*classInfo)
+static ILJitValue _ILJitAllocObjectGen(ILJitFunction jitFunction, ILClass
*classInfo)
{
/* Make sure the class has been layouted. */
if(!(classInfo->userData) ||
@@ -151,7 +147,7 @@
return (ILJitValue)0;
}
}
- return _ILJitAllocGen(jitCoder, classInfo,
+ return _ILJitAllocGen(jitFunction, classInfo,
((ILClassPrivate
*)(classInfo->userData))->size);
}
Index: pnet/engine/jitc_call.c
diff -u pnet/engine/jitc_call.c:1.16 pnet/engine/jitc_call.c:1.17
--- pnet/engine/jitc_call.c:1.16 Thu May 25 09:29:00 2006
+++ pnet/engine/jitc_call.c Sat Jun 3 11:00:40 2006
@@ -100,7 +100,7 @@
*/
static void _ILJitNewObj(ILJITCoder *coder, ILClass *info, ILJitValue *newArg)
{
- *newArg = _ILJitAllocObjectGen(coder, info);
+ *newArg = _ILJitAllocObjectGen(coder->jitFunction, info);
}
/*
@@ -465,7 +465,7 @@
boxObjectSize =
jit_value_create_nint_constant(jitCoder->jitFunction,
_IL_JIT_TYPE_UINT32, typeSize);
- boxObject = _ILJitAllocGen(jitCoder, info, typeSize);
+ boxObject = _ILJitAllocGen(jitCoder->jitFunction, info,
typeSize);
if(boxValue)
{
jit_insn_store_relative(jitCoder->jitFunction,
boxObject, 0,
Index: pnet/engine/jitc_delegate.c
diff -u pnet/engine/jitc_delegate.c:1.2 pnet/engine/jitc_delegate.c:1.3
--- pnet/engine/jitc_delegate.c:1.2 Thu May 25 09:29:00 2006
+++ pnet/engine/jitc_delegate.c Sat Jun 3 11:00:40 2006
@@ -19,6 +19,324 @@
*/
/*
+ * Create an Object array with the given size.
+ */
+static ILJitValue _ILJitObjectArrayCreate(ILJitFunction jitFunction,
+
ILExecThread *_thread,
+
ILJitValue thread,
+
ILUInt32 numElements)
+{
+ ILMethod *ctor;
+ ILJitFunction jitCtor;
+ ILJitValue array;
+ ILJitValue arrayLength = jit_value_create_nint_constant(jitFunction,
+
_IL_JIT_TYPE_UINT32,
+
(jit_nint)numElements);
+ ILJitValue args[2];
+
+ /* Find the constructor for the array. */
+ ctor = ILExecThreadLookupMethod(_thread, "[oSystem.Object;", ".ctor",
+
"(Ti)V");
+ if(!ctor)
+ {
+ return 0;
+ }
+
+ jitCtor = ILJitFunctionFromILMethod(ctor);
+ if(!jitCtor)
+ {
+ /* We have to layout the class first. */
+ if(!_LayoutClass(_thread, ILMethod_Owner(ctor)))
+ {
+ return 0;
+ }
+ jitCtor = ILJitFunctionFromILMethod(ctor);
+ }
+ args[0] = thread;
+ args[1] = arrayLength;
+ array = jit_insn_call(jitFunction, 0, jitCtor,
+ 0, args, 2, 0);
+
+ return array;
+}
+
+/*
+ * Pack the delegate invoke arguments into an "Object[]" array and return the
+ * new array.
+ */
+static ILJitValue _ILJitPackDelegateArgs(ILJitFunction jitFunction,
+
ILExecThread *_thread,
+
ILType *invokeSignature,
+
ILJitValue *invokeArgs,
+
ILUInt32 firstArg,
+
ILUInt32 numArgs)
+{
+ ILUInt32 param;
+ ILType *paramType;
+ ILType *enumType;
+ ILClass *info;
+ ILUInt32 typeSize;
+ ILJitValue thread = _ILJitFunctionGetThread(jitFunction);
+ ILJitValue arrayBaseOffset = jit_value_create_nint_constant(jitFunction,
+
_IL_JIT_TYPE_UINT32,
+
(jit_nint)(sizeof(System_Array)));
+ ILJitValue ptrSize = jit_value_create_nint_constant(jitFunction,
+
_IL_JIT_TYPE_UINT32,
+
(jit_nint)(sizeof(void *)));
+ ILJitValue array;
+ ILJitValue arrayBase;
+ ILJitValue boxObject;
+ ILJitValue boxValue;
+ ILJitValue boxObjectSize;
+ ILJitValue ptr;
+
+ /* Allocate an array to hold all of the arguments */
+ array = _ILJitObjectArrayCreate(jitFunction, _thread, thread, numArgs);
+ if(!array)
+ {
+ return 0;
+ }
+
+ arrayBase = jit_insn_add(jitFunction, array, arrayBaseOffset);
+
+ /* Convert the arguments into objects in the array */
+ for(param = 0; param < numArgs; ++param)
+ {
+ paramType = ILTypeGetParam(invokeSignature, firstArg + param);
+ boxValue = 0;
+ ptr = 0;
+
+ if (ILType_IsComplex(paramType)
+ && ILType_Kind(paramType) == IL_TYPE_COMPLEX_BYREF)
+ {
+ paramType = ILType_Ref(paramType);
+
+ enumType = ILTypeGetEnumType(paramType);
+
+ if(ILType_IsPrimitive(enumType))
+ {
+ ILJitType jitType =
_ILJitGetReturnType(enumType,
+
_ILExecThreadProcess(_thread));
+
+ if(!jitType)
+ {
+ return 0;
+ }
+
+ boxValue = jit_insn_load_relative(jitFunction,
+
invokeArgs[param],
+
0, jitType);
+ }
+ else if(ILType_IsValueType(paramType))
+ {
+ ptr = invokeArgs[param];
+ }
+ else if(ILTypeIsReference(paramType))
+ {
+ /* Ref to an object reference type: pass the
object reference */
+ boxValue = jit_insn_load_relative(jitFunction,
+
invokeArgs[param],
+
0, _IL_JIT_TYPE_VPTR);
+ jit_insn_store_relative(jitFunction, arrayBase,
0, boxValue);
+ boxValue = 0;
+ }
+ else
+ {
+ /* Assume that everything else is a pointer,
and wrap
+ it up within a "System.IntPtr" object */
+ boxValue = jit_insn_load_relative(jitFunction,
+
invokeArgs[param],
+
0, _IL_JIT_TYPE_VPTR);
+ paramType = ILType_Int;
+ }
+ }
+ else
+ {
+ enumType = ILTypeGetEnumType(paramType);
+ if(ILType_IsPrimitive(enumType))
+ {
+ ILJitType jitType =
_ILJitGetReturnType(enumType,
+
_ILExecThreadProcess(_thread));
+
+ if(!jitType)
+ {
+ return 0;
+ }
+
+ boxValue =
_ILJitValueConvertImplicit(jitFunction,
+
invokeArgs[param],
+
jitType);
+ }
+ else if(ILType_IsValueType(paramType))
+ {
+ ptr = jit_insn_address_of(jitFunction,
+
invokeArgs[param]);
+ }
+ else if(ILTypeIsReference(paramType))
+ {
+ /* Object reference type: pass it directly */
+ jit_insn_store_relative(jitFunction, arrayBase,
0,
+
invokeArgs[param]);
+ }
+ else
+ {
+ /* Assume that everything else is a pointer,
and wrap
+ it up within a "System.IntPtr" object */
+ boxValue =
_ILJitValueConvertImplicit(jitFunction,
+
invokeArgs[param],
+
_IL_JIT_TYPE_VPTR);
+ paramType = ILType_Int;
+ }
+ }
+ if(boxValue || ptr)
+ {
+ /* We have to box the argument. */
+ info = ILClassFromType
+
(ILContextNextImage(_thread->process->context, 0),
+ 0, paramType, 0);
+ info = ILClassResolve(info);
+ typeSize = ILSizeOfType(_thread, paramType);
+ boxObjectSize =
jit_value_create_nint_constant(jitFunction,
+
_IL_JIT_TYPE_UINT32,
+
typeSize);
+
+ boxObject = _ILJitAllocGen(jitFunction, info, typeSize);
+ if(boxValue)
+ {
+ jit_insn_store_relative(jitFunction, boxObject,
0, boxValue);
+ }
+ else
+ {
+ jit_insn_memcpy(jitFunction, boxObject, ptr,
boxObjectSize);
+ }
+ jit_insn_store_relative(jitFunction, arrayBase, 0,
boxObject);
+
+ }
+ arrayBase = jit_insn_add(jitFunction, arrayBase, ptrSize);
+ }
+
+ return array;
+}
+
+/*
+ * Unpack the delegate out arguments from the "Object[]" array to the given
+ * locations.
+ */
+static int _ILJitUnpackDelegateArgs(ILJitFunction jitFunction,
+
ILExecThread *_thread,
+ ILType
*endInvokeSignature,
+
ILJitValue *endInvokeArgs,
+
ILJitValue array,
+
ILUInt32 firstArg,
+
ILUInt32 numArgs)
+{
+ ILJitValue arrayBaseOffset = jit_value_create_nint_constant(jitFunction,
+
_IL_JIT_TYPE_UINT32,
+
(jit_nint)(sizeof(System_Array)));
+ ILJitValue arrayBase = jit_insn_add(jitFunction, array,
arrayBaseOffset);
+ ILInt32 i;
+
+ for (i = 0; i < numArgs; i++)
+ {
+ ILType *paramType;
+
+ paramType = ILTypeGetParam(endInvokeSignature, firstArg + i);
+ paramType = ILType_Ref(paramType);
+ paramType = ILTypeGetEnumType(paramType);
+
+ if(ILType_IsPrimitive(paramType))
+ {
+ ILJitType jitType = _ILJitGetReturnType(paramType,
_ILExecThreadProcess(_thread));
+ ILJitValue srcPtr;
+ ILJitValue value;
+
+ if(!jitType)
+ {
+ return 0;
+ }
+
+ srcPtr = jit_insn_load_relative(jitFunction,
+
arrayBase,
+
i * sizeof(void *),
+
_IL_JIT_TYPE_VPTR);
+ value = jit_insn_load_relative(jitFunction, srcPtr, 0,
jitType);
+ jit_insn_store_relative(jitFunction, endInvokeArgs[i],
0, value);
+ }
+ else if(ILType_IsValueType(paramType))
+ {
+ ILJitType jitType = _ILJitGetReturnType(paramType,
_ILExecThreadProcess(_thread));
+
+ ILUInt32 typeSize = ILSizeOfType(_thread, paramType);
+ ILJitValue boxObjectSize =
jit_value_create_nint_constant(jitFunction,
+
_IL_JIT_TYPE_UINT32,
+
typeSize);
+ ILJitValue srcPtr = jit_insn_load_relative(jitFunction,
+
arrayBase,
+
i * sizeof(void *),
+
_IL_JIT_TYPE_VPTR);
+
+ if(!jitType)
+ {
+ return 0;
+ }
+
+ jit_insn_memcpy(jitFunction, endInvokeArgs[i], srcPtr,
boxObjectSize);
+ }
+ else if (ILType_IsClass(paramType))
+ {
+ /* If the param is a class reference then set the new
class reference */
+ ILJitValue value;
+
+ value = jit_insn_load_relative(jitFunction,
+
arrayBase,
+
i * sizeof(void *),
+
_IL_JIT_TYPE_VPTR);
+ jit_insn_store_relative(jitFunction, endInvokeArgs[i],
0, value);
+ }
+ else
+ {
+ /* Don't know how to return this type of out param */
+ }
+ }
+ return 1;
+}
+
+/*
+ * Unbox the object returned by EndInvoke and generate the return statement.
+ */
+static int _ILJitDelegateUnboxReturn(ILJitFunction func,
+
ILExecThread *_thread,
+ ILType
*endInvokeSignature,
+
ILJitValue returnObject)
+{
+ ILType *returnType = ILTypeGetParam(endInvokeSignature, 0); /* 0 ==
return type */
+
+
+ returnType = ILTypeGetEnumType(returnType);
+
+ if(ILType_IsPrimitive(returnType) || ILType_IsValueType(returnType))
+ {
+ ILJitType jitType = _ILJitGetReturnType(returnType,
+
_ILExecThreadProcess(_thread));
+ if(!jitType)
+ {
+ return 0;
+ }
+ jit_insn_return_ptr(func, returnObject, jitType);
+ }
+ else if (ILType_IsClass(returnType))
+ {
+ jit_insn_return(func, returnObject);
+ }
+ else
+ {
+ /* don't know how to return this type. */
+ return 0;
+ }
+ return 1;
+}
+
+/*
* Emit the code to call a delegate.
* args contains only the arguments passed to the method (excluding the this
pointer).
*/
@@ -135,7 +453,324 @@
*/
static int _ILJitCompileDelegateInvoke(ILJitFunction func)
{
+#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS) &&
defined(_IL_JIT_ENABLE_DEBUG)
+ ILMethod *method = (ILMethod *)jit_function_get_meta(func,
IL_JIT_META_METHOD);
+ ILClass *info = ILMethod_Owner(method);
+ ILClassPrivate *classPrivate = (ILClassPrivate *)info->userData;
+ ILJITCoder *jitCoder = (ILJITCoder *)(classPrivate->process->coder);
+ char *methodName = _ILJitFunctionGetMethodName(func);
+#endif
+#ifdef IL_JIT_THREAD_IN_SIGNATURE
+ ILJitValue thread = _ILJitFunctionGetThread(func);
+#endif
+#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS) &&
defined(_IL_JIT_ENABLE_DEBUG)
+ if(jitCoder->flags & IL_CODER_FLAG_STATS)
+ {
+ ILMutexLock(globalTraceMutex);
+ fprintf(stdout, "CompileDelegateInvoke: %s\n", methodName);
+ ILMutexUnlock(globalTraceMutex);
+ }
+#endif
+
+ /* TODO: Add the code generation here. */
+
+#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS) &&
defined(_IL_JIT_ENABLE_DEBUG)
+#ifdef _IL_JIT_DUMP_FUNCTION
+ if(jitCoder->flags & IL_CODER_FLAG_STATS)
+ {
+ ILMutexLock(globalTraceMutex);
+ jit_dump_function(stdout, func, methodName);
+ ILMutexUnlock(globalTraceMutex);
+ }
+#endif
+#ifdef _IL_JIT_DISASSEMBLE_FUNCTION
+ if(jitCoder->flags & IL_CODER_FLAG_STATS)
+ {
+ if(!jit_function_compile(func))
+ {
+ return JIT_RESULT_COMPILE_ERROR;
+ }
+ ILMutexLock(globalTraceMutex);
+ jit_dump_function(stdout, func, methodName);
+ ILMutexUnlock(globalTraceMutex);
+ }
+#endif
+#endif
+ return JIT_RESULT_OK;
+}
+
+/*
+ * Build the BeginInvoke method for a delegate.
+ * The arguments to this function are:
+ * arg 0 = thread
+ * arg 1 = this pointer to the delegate
+ * arg 2 ... n = arguments for the delegate function
+ * arg n+1 = System.AsyncCallback
+ * arg n+2 = IAsyncResult
+ */
+static int _ILJitCompileDelegateBeginInvoke(ILJitFunction func)
+{
+ ILExecThread *_thread = ILExecThreadCurrent();
+ ILMethod *beginInvokeMethod = (ILMethod *)jit_function_get_meta(func,
IL_JIT_META_METHOD);
+ ILType *beginInvokeSignature = ILMethod_Signature(beginInvokeMethod);
+ ILJitType jitSignature = jit_function_get_signature(func);
+ unsigned int numBeginInvokeParams = jit_type_num_params(jitSignature);
+ ILMethod *asyncResultCtor = ILExecThreadLookupMethod(_thread,
+
"System.Runtime.Remoting.Messaging.AsyncResult",
+ ".ctor",
+
"(ToSystem.Delegate;[oSystem.Object;oSystem.AsyncCallback;oSystem.Object;)V");
+ ILClass *asyncResultInfo = 0;
+ ILJitFunction jitAsyncResultCtor = 0;
+
+#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS) &&
defined(_IL_JIT_ENABLE_DEBUG)
+ ILClass *info = ILMethod_Owner(beginInvokeMethod);
+ ILClassPrivate *classPrivate = (ILClassPrivate *)info->userData;
+ ILJITCoder *jitCoder = (ILJITCoder *)(classPrivate->process->coder);
+ char *methodName = _ILJitFunctionGetMethodName(func);
+#endif
+#ifdef IL_JIT_THREAD_IN_SIGNATURE
+ ILJitValue ctorArgs[6];
+#else
+ ILJitValue ctorArgs[5];
+#endif
+ ILJitValue args[numBeginInvokeParams];
+ ILUInt32 current;
+
+#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS) &&
defined(_IL_JIT_ENABLE_DEBUG)
+ if(jitCoder->flags & IL_CODER_FLAG_STATS)
+ {
+ ILMutexLock(globalTraceMutex);
+ fprintf(stdout, "CompileDelegateBeginInvoke: %s\n", methodName);
+ ILMutexUnlock(globalTraceMutex);
+ }
+#endif
+
+ /* Check if the ctor for AsyncResult class was found. */
+ if(!asyncResultCtor)
+ {
+ return JIT_RESULT_COMPILE_ERROR;
+ }
+ asyncResultInfo = ILMethod_Owner(asyncResultCtor);
+
+ jitAsyncResultCtor = ILJitFunctionFromILMethod(asyncResultCtor);
+ /* Make sure the class is allready layouted. */
+ if(!jitAsyncResultCtor)
+ {
+ /* We have to layout the class first. */
+ if(!_LayoutClass(_thread, asyncResultInfo))
+ {
+ return JIT_RESULT_COMPILE_ERROR;
+ }
+ jitAsyncResultCtor = ILJitFunctionFromILMethod(asyncResultCtor);
+ }
+
+ /* get the arguments passed to this function. */
+ for(current = 0; current < numBeginInvokeParams; ++current)
+ {
+ args[current] = jit_value_get_param(func, current);
+ }
+
+#ifdef IL_JIT_THREAD_IN_SIGNATURE
+ ctorArgs[0] = _ILJitFunctionGetThread(func);
+ if(!(ctorArgs[1] = _ILJitAllocObjectGen(func, asyncResultInfo)))
+ {
+ return JIT_RESULT_COMPILE_ERROR;
+ }
+ ctorArgs[2] = args[1]; /* _this */
+ if(!(ctorArgs[3] = _ILJitPackDelegateArgs(func, _thread,
+
beginInvokeSignature,
+
&(args[2]),
+
1, numBeginInvokeParams - 4)))
+ {
+ return JIT_RESULT_COMPILE_ERROR;
+ }
+ ctorArgs[4] = args[numBeginInvokeParams - 2];
+ ctorArgs[5] = args[numBeginInvokeParams - 1];
+
+ /* Call the ctor for the AsyncResult. */
+ jit_insn_call(func, 0, jitAsyncResultCtor, 0, ctorArgs, 6, 0);
+
+ jit_insn_return(func, ctorArgs[1]);
+#else
+ if(!(ctorArgs[0] = _ILJitAllocObjectGen(func, asyncResultInfo)))
+ {
+ return JIT_RESULT_COMPILE_ERROR;
+ }
+ ctorArgs[1] = args[1]; /* _this */
+ if(!(ctorArgs[2] = _ILJitPackDelegateArgs(func, _thread,
+
beginInvokeSignature,
+
&(args[1]),
+
1, numBeginInvokeParams - 3)))
+ {
+ return JIT_RESULT_COMPILE_ERROR;
+ }
+ ctorArgs[3] = args[numBeginInvokeParams - 2];
+ ctorArgs[4] = args[numBeginInvokeParams - 1];
+
+ /* Call the ctor for the AsyncResult. */
+ jit_insn_call(func, 0, jitAsyncResultCtor, 0, ctorArgs, 5, 0);
+
+ jit_insn_return(func, ctorArgs[0]);
+#endif
+
+#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS) &&
defined(_IL_JIT_ENABLE_DEBUG)
+#ifdef _IL_JIT_DUMP_FUNCTION
+ if(jitCoder->flags & IL_CODER_FLAG_STATS)
+ {
+ ILMutexLock(globalTraceMutex);
+ jit_dump_function(stdout, func, methodName);
+ ILMutexUnlock(globalTraceMutex);
+ }
+#endif
+#ifdef _IL_JIT_DISASSEMBLE_FUNCTION
+ if(jitCoder->flags & IL_CODER_FLAG_STATS)
+ {
+ if(!jit_function_compile(func))
+ {
+ return JIT_RESULT_COMPILE_ERROR;
+ }
+ ILMutexLock(globalTraceMutex);
+ jit_dump_function(stdout, func, methodName);
+ ILMutexUnlock(globalTraceMutex);
+ }
+#endif
+#endif
+ return JIT_RESULT_OK;
+}
+
+/*
+ * Build the EndInvoke method for a delegate.
+ * The arguments to this function are:
+ * arg 0 = thread
+ * arg 1 = this pointer to the delegate
+ * arg 2 ... n = by ref arguments for the delegate function
+ * arg n+1 = IAsyncResult
+ */
+static int _ILJitCompileDelegateEndInvoke(ILJitFunction func)
+{
+ ILExecThread *_thread = ILExecThreadCurrent();
+ ILMethod *endInvokeMethod = (ILMethod *)jit_function_get_meta(func,
IL_JIT_META_METHOD);
+ ILType *endInvokeSignature = ILMethod_Signature(endInvokeMethod);
+ ILJitType jitSignature = jit_function_get_signature(func);
+ unsigned int numEndInvokeParams = jit_type_num_params(jitSignature);
+ ILMethod *asyncEndInvokeMethodInfo = ILExecThreadLookupMethod(_thread,
+
"System.Runtime.Remoting.Messaging.AsyncResult",
+
"EndInvoke",
+
"(T[oSystem.Object;)oSystem.Object;");
+ ILJitValue array; /* Array to hold the out params. */
+ ILJitValue returnObject; /* returnvalue of the call to
IAsyncResult.EndInvoke. */
+ ILJitFunction jitEndInvoke;
+
+#ifdef IL_JIT_THREAD_IN_SIGNATURE
+ ILJitValue thread = _ILJitFunctionGetThread(func);
+ ILUInt32 numOutParams = numEndInvokeParams - 3;
+ ILJitValue endInvokeArgs[3];
+#else
+ ILUInt32 numOutParams = numEndInvokeParams - 2;
+ ILJitValue endInvokeArgs[2];
+#endif
+ ILJitValue args[numEndInvokeParams];
+ ILUInt32 current;
+
+#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS) &&
defined(_IL_JIT_ENABLE_DEBUG)
+ ILClass *info = ILMethod_Owner(endInvokeMethod);
+ ILClassPrivate *classPrivate = (ILClassPrivate *)info->userData;
+ ILJITCoder *jitCoder = (ILJITCoder *)(classPrivate->process->coder);
+ char *methodName = _ILJitFunctionGetMethodName(func);
+#endif
+
+#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS) &&
defined(_IL_JIT_ENABLE_DEBUG)
+ if(jitCoder->flags & IL_CODER_FLAG_STATS)
+ {
+ ILMutexLock(globalTraceMutex);
+ fprintf(stdout, "CompileDelegateEndInvoke: %s\n", methodName);
+ ILMutexUnlock(globalTraceMutex);
+ }
+#endif
+
+ /* Check if the EndInvoke Method for AsyncResult class was found. */
+ if(!asyncEndInvokeMethodInfo)
+ {
+ return JIT_RESULT_COMPILE_ERROR;
+ }
+
+ jitEndInvoke = ILJitFunctionFromILMethod(asyncEndInvokeMethodInfo);
+ if(!jitEndInvoke)
+ {
+ /* We have to layout the class first. */
+ if(!_LayoutClass(_thread,
ILMethod_Owner(asyncEndInvokeMethodInfo)))
+ {
+ return JIT_RESULT_COMPILE_ERROR;
+ }
+ jitEndInvoke =
ILJitFunctionFromILMethod(asyncEndInvokeMethodInfo);
+ }
+
+ /* get the arguments passed to this function. */
+ for(current = 0; current < numEndInvokeParams; ++current)
+ {
+ args[current] = jit_value_get_param(func, current);
+ }
+
+ /* Allocate an array to hold the out arguments */
+ array = _ILJitObjectArrayCreate(func, _thread, thread, numOutParams);
+ if(!array)
+ {
+ return JIT_RESULT_COMPILE_ERROR;
+ }
+
+#ifdef IL_JIT_THREAD_IN_SIGNATURE
+ endInvokeArgs[0] = thread;
+ endInvokeArgs[1] = args[numEndInvokeParams - 1];
+ endInvokeArgs[2] = array;
+ returnObject = jit_insn_call(func, 0, jitEndInvoke,
+ 0, endInvokeArgs, 3, 0);
+ if(!(_ILJitUnpackDelegateArgs(func, _thread, endInvokeSignature,
+ &(args[2]),
array, 1, numOutParams)))
+ {
+ return JIT_RESULT_COMPILE_ERROR;
+ }
+#else
+ endInvokeArgs[0] = args[numEndInvokeParams - 1];
+ endInvokeArgs[1] = array;
+ returnObject = jit_insn_call(func, 0, jitEndInvoke,
+ 0, endInvokeArgs, 2, 0);
+ if(!(_ILJitUnpackDelegateArgs(func, _thread, endInvokeSignature,
+ &(args[1]),
array, 1, numOutParams)))
+ {
+ return JIT_RESULT_COMPILE_ERROR;
+ }
+#endif
+
+ if(!_ILJitDelegateUnboxReturn(func, _thread, endInvokeSignature,
+
returnObject))
+ {
+ return JIT_RESULT_COMPILE_ERROR;
+ }
+
+#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS) &&
defined(_IL_JIT_ENABLE_DEBUG)
+#ifdef _IL_JIT_DUMP_FUNCTION
+ if(jitCoder->flags & IL_CODER_FLAG_STATS)
+ {
+ ILMutexLock(globalTraceMutex);
+ jit_dump_function(stdout, func, methodName);
+ ILMutexUnlock(globalTraceMutex);
+ }
+#endif
+#ifdef _IL_JIT_DISASSEMBLE_FUNCTION
+ if(jitCoder->flags & IL_CODER_FLAG_STATS)
+ {
+ if(!jit_function_compile(func))
+ {
+ return JIT_RESULT_COMPILE_ERROR;
+ }
+ ILMutexLock(globalTraceMutex);
+ jit_dump_function(stdout, func, methodName);
+ ILMutexUnlock(globalTraceMutex);
+ }
+#endif
+#endif
+ return JIT_RESULT_OK;
}
/*
@@ -230,3 +865,4 @@
#endif
return JIT_RESULT_OK;
}
+
Index: pnet/engine/jitc_obj.c
diff -u pnet/engine/jitc_obj.c:1.17 pnet/engine/jitc_obj.c:1.18
--- pnet/engine/jitc_obj.c:1.17 Mon May 1 17:30:50 2006
+++ pnet/engine/jitc_obj.c Sat Jun 3 11:00:40 2006
@@ -609,7 +609,7 @@
#endif
/* Allocate the object. */
- newObj = _ILJitAllocObjectGen(jitCoder, boxClass);
+ newObj = _ILJitAllocObjectGen(jitCoder->jitFunction, boxClass);
if(jit_value_get_type(value) != jitType)
{
@@ -631,7 +631,8 @@
ILJitValue newObj;
/* Allocate memory */
- newObj = _ILJitAllocGen(jitCoder, boxClass, jit_type_get_size(jitType));
+ newObj = _ILJitAllocGen(jitCoder->jitFunction,
+ boxClass,
jit_type_get_size(jitType));
/* If the smallerType is smaller then the initiale type then convert to
it. */
if(jit_value_get_type(value) != jitType)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [dotgnu-pnet-commits] pnet ./ChangeLog engine/jitc.c engine/jitc_allo...,
Klaus Treichel <=