[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[dotgnu-pnet-commits] pnet ./ChangeLog engine/call.c engine/convert.c...
From: |
Klaus Treichel |
Subject: |
[dotgnu-pnet-commits] pnet ./ChangeLog engine/call.c engine/convert.c... |
Date: |
Thu, 29 Dec 2005 15:56:52 +0000 |
CVSROOT: /cvsroot/dotgnu-pnet
Module name: pnet
Branch:
Changes by: Klaus Treichel <address@hidden> 05/12/29 15:56:52
Modified files:
. : ChangeLog
engine : call.c convert.c jitc.c jitc.h jitc_const.c
jitc_setup.c jitc_stack.c
Added files:
engine : jitc_gen.h
Log message:
Add more work on the jit coder.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/ChangeLog.diff?tr1=1.3259&tr2=1.3260&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/call.c.diff?tr1=1.34&tr2=1.35&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/convert.c.diff?tr1=1.24&tr2=1.25&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc.c.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc.h.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc_gen.h?rev=1.1
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc_const.c.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc_setup.c.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc_stack.c.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
Patches:
Index: pnet/ChangeLog
diff -u pnet/ChangeLog:1.3259 pnet/ChangeLog:1.3260
--- pnet/ChangeLog:1.3259 Wed Dec 28 18:55:07 2005
+++ pnet/ChangeLog Thu Dec 29 15:56:52 2005
@@ -1,3 +1,25 @@
+2005-12-29 Klaus Treichel <address@hidden>
+
+ * engine/convert.c: Add a version of ConvertMethod for use with the jit
+ coder.
+
+ * engine/call.c: Add the ILExecThread as param 1 to the call of
+ ILJitCallMethod.
+
+ * engine/jitc.c: Add layouting of a class when necessary when a native
call
+ from the engine is done.
+
+ * engine/jitc.h: Add the ILExecTread as parameter 1 in ILJitCallMethod.
+
+ * engine/jitc_const.c: Fill in the code generation.
+
+ * engine/jitc_setup.c: Return IL_CODER_END_OK in JITCoder_Finish
instead of
+ 1.
+
+ * engine/jitc_stack.c: Implement pop and dup.
+
+ * engine/jitc_gen.h: Added code generation helper macros.
+
2005-12-28 Klaus Treichel <address@hidden>
* engine/call.c: Fix that the constructors of array and string classes
Index: pnet/engine/call.c
diff -u pnet/engine/call.c:1.34 pnet/engine/call.c:1.35
--- pnet/engine/call.c:1.34 Wed Dec 28 18:55:07 2005
+++ pnet/engine/call.c Thu Dec 29 15:56:52 2005
@@ -108,11 +108,6 @@
ILUInt32 param, numParams;
ILType *paramType;
- /* TODO */
- /* What i'm doing here right now might be not portable at all. */
- /* We might need to create a local buffer for the args and get the */
- /* parameter pointers from this buffer. */
-
/* Copy the incoming "va_list" value */
ILMemCpy(&va, userData, sizeof(VA_LIST));
@@ -1005,7 +1000,7 @@
}
/* Now we can call the jitted function. */
- return ILJitCallMethod(method, jitArgs, result);
+ return ILJitCallMethod(thread, method, jitArgs, result);
}
#else
int _ILCallMethod(ILExecThread *thread, ILMethod *method,
Index: pnet/engine/convert.c
diff -u pnet/engine/convert.c:1.24 pnet/engine/convert.c:1.25
--- pnet/engine/convert.c:1.24 Tue Aug 23 10:45:52 2005
+++ pnet/engine/convert.c Thu Dec 29 15:56:52 2005
@@ -36,6 +36,78 @@
#define IL_CONVERT_TYPE_INIT 5
#define IL_CONVERT_DLL_NOT_FOUND 6
+#ifdef IL_USE_JIT
+/*
+ * Wee keep these macros for now until all references to _ILUnrollMethod
+ * are removed when the jit coder is used.
+ */
+#define METADATA_WRLOCK(thread) \
+ do { \
+
IL_METADATA_WRLOCK(_ILExecThreadProcess(thread)); \
+ ILGCDisableFinalizers(0); \
+ } while (0)
+#define METADATA_UNLOCK(thread) \
+ do { \
+ ILGCEnableFinalizers(); \
+
IL_METADATA_UNLOCK(_ILExecThreadProcess(thread)); \
+ ILGCInvokeFinalizers(0); \
+ } while (0)
+
+
+/*
+ * Inner version of "_ILConvertMethod", which detects the type of
+ * exception to throw, but does not throw it.
+ * This method is invoked only during on demand compilation of a jitted IL
method
+ * and is secured through libjit.
+ */
+static unsigned char *ConvertMethod(ILExecThread *thread, ILMethod *method,
+ int
*errorCode, const char **errorInfo)
+{
+ ILMethodCode code;
+ ILCoder *coder = thread->process->coder;
+ unsigned char *start;
+
+#ifndef IL_CONFIG_VARARGS
+ /* Vararg methods are not supported */
+ if((ILMethod_CallConv(method) & IL_META_CALLCONV_MASK) ==
+ IL_META_CALLCONV_VARARG)
+ {
+ *errorCode = IL_CONVERT_NOT_IMPLEMENTED;
+ return 0;
+ }
+#endif
+
+ /* Get the method code */
+ if(!ILMethodGetCode(method, &code))
+ {
+ code.code = 0;
+ }
+
+ /* The conversion is different depending upon whether the
+ method is written in IL or not */
+ if(code.code)
+ {
+ /* Use the bytecode verifier and coder to convert the method */
+ if(!_ILVerify(coder, &start, method, &code,
+
ILImageIsSecure(ILProgramItem_Image(method)), thread))
+ {
+ *errorCode = IL_CONVERT_VERIFY_FAILED;
+ return 0;
+ }
+ }
+ else
+ {
+ /* All other cases should be handled in the jit coder. */
+
+ *errorCode = IL_CONVERT_OUT_OF_MEMORY;
+ return 0;
+ }
+
+ /* The method is converted now */
+ *errorCode = IL_CONVERT_OK;
+ return 1;
+}
+#else
#ifdef IL_CONFIG_PINVOKE
/*
@@ -419,6 +491,7 @@
*errorCode = IL_CONVERT_OK;
return start;
}
+#endif
unsigned char *_ILConvertMethod(ILExecThread *thread, ILMethod *method)
{
Index: pnet/engine/jitc.c
diff -u pnet/engine/jitc.c:1.5 pnet/engine/jitc.c:1.6
--- pnet/engine/jitc.c:1.5 Wed Dec 28 18:55:07 2005
+++ pnet/engine/jitc.c Thu Dec 29 15:56:52 2005
@@ -30,7 +30,7 @@
#include "il_dumpasm.h"
#endif
#include "lib_defs.h"
-#include "jitc.h"
+#include "jitc_gen.h"
#ifdef __cplusplus
extern "C" {
@@ -88,6 +88,7 @@
ILMethod *currentMethod;
int debugEnabled;
+ int flags;
/* Members to manage the evaluation stack. */
jit_value_t *jitStack;
@@ -138,6 +139,30 @@
} \
} while (0)
+/*
+ * Acquire and release the metadata lock during layouting a class.
+ */
+#define METADATA_WRLOCK(thread) \
+ do { \
+
IL_METADATA_WRLOCK(_ILExecThreadProcess(thread)); \
+ } while (0)
+#define METADATA_UNLOCK(thread) \
+ do { \
+
IL_METADATA_UNLOCK(_ILExecThreadProcess(thread)); \
+ } while (0)
+
+/*
+ * Perform a class layout.
+ */
+static int _LayoutClass(ILExecThread *thread, ILClass *info)
+{
+ int result = 0;
+
+ METADATA_WRLOCK(thread);
+ result = _ILLayoutClass(_ILExecThreadProcess(thread), info);
+ METADATA_UNLOCK(thread);
+ return result;
+}
/*
* Destroy every ILJitType in a ILJitTypes structure
@@ -448,6 +473,7 @@
return 0;
}
coder->debugEnabled = 0;
+ coder->flags = 0;
/* Initialize the stack management. */
coder->jitStack = 0;
coder->stackTop = -1;
@@ -1002,14 +1028,18 @@
* Call the jit function for a ILMethod.
* Returns 1 if an exception occured.
*/
-int ILJitCallMethod(ILMethod *method, void **jitArgs, void *result)
+int ILJitCallMethod(ILExecThread *thread, ILMethod *method, void **jitArgs,
void *result)
{
ILJitFunction jitFunction = method->userData;
if(!jitFunction)
{
- /* We may have to layout the class. */
- return 1;
+ /* We have to layout the class. */
+ if(!_LayoutClass(thread, ILMethod_Owner(method)))
+ {
+ return 1;
+ }
+ jitFunction = method->userData;
}
if(!jit_function_apply(jitFunction, jitArgs, result))
Index: pnet/engine/jitc.h
diff -u pnet/engine/jitc.h:1.3 pnet/engine/jitc.h:1.4
--- pnet/engine/jitc.h:1.3 Tue Dec 27 20:07:24 2005
+++ pnet/engine/jitc.h Thu Dec 29 15:56:52 2005
@@ -130,7 +130,8 @@
* Call the jit function for an ILMethod.
* Returns 1 if an exception occured.
*/
-int ILJitCallMethod(ILMethod *method, void**jitArgs, void *result);
+int ILJitCallMethod(ILExecThread *thread, ILMethod *method,
+ void**jitArgs, void *result);
/*
* Create the class/struct representation of a clr type for libjit.
Index: pnet/engine/jitc_const.c
diff -u pnet/engine/jitc_const.c:1.1 pnet/engine/jitc_const.c:1.2
--- pnet/engine/jitc_const.c:1.1 Mon Dec 19 18:00:35 2005
+++ pnet/engine/jitc_const.c Thu Dec 29 15:56:52 2005
@@ -25,6 +25,81 @@
*/
static void JITCoder_Constant(ILCoder *coder, int opcode, unsigned char *arg)
{
+ ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
+
+ if(opcode == IL_OP_LDNULL)
+ {
+ jitCoder->jitStack[jitCoder->stackTop] =
+ jit_value_create_nint_constant(jitCoder->jitFunction,
+
jit_type_void_ptr,
+
(jit_nint)0);
+ JITC_ADJUST(jitCoder, 1);
+ }
+ else if(opcode >= IL_OP_LDC_I4_M1 && opcode <= IL_OP_LDC_I4_8)
+ {
+ ILInt32 temp = opcode - IL_OP_LDC_I4_M1 - 1;
+
+ jitCoder->jitStack[jitCoder->stackTop] =
+ jit_value_create_nint_constant(jitCoder->jitFunction,
+
_IL_JIT_TYPE_INT32,
+
(jit_nint)temp);
+ JITC_ADJUST(jitCoder, 1);
+ }
+ else if(opcode == IL_OP_LDC_I4_S)
+ {
+ ILInt8 temp;
+
+ JITC_GET_INT8(arg, temp);
+ jitCoder->jitStack[jitCoder->stackTop] =
+ jit_value_create_nint_constant(jitCoder->jitFunction,
+
_IL_JIT_TYPE_INT32,
+
(jit_nint)temp);
+ JITC_ADJUST(jitCoder, 1);
+ }
+ else if(opcode == IL_OP_LDC_I4)
+ {
+ ILInt32 temp;
+
+ JITC_GET_INT32(arg, temp);
+ jitCoder->jitStack[jitCoder->stackTop] =
+ jit_value_create_nint_constant(jitCoder->jitFunction,
+
_IL_JIT_TYPE_INT32,
+
(jit_nint)temp);
+ JITC_ADJUST(jitCoder, 1);
+ }
+ else if(opcode == IL_OP_LDC_R4)
+ {
+ ILFloat temp;
+
+ JITC_GET_FLOAT32(arg, temp);
+ jitCoder->jitStack[jitCoder->stackTop] =
+ jit_value_create_nfloat_constant(jitCoder->jitFunction,
+
_IL_JIT_TYPE_NFLOAT,
+
(jit_nfloat)temp);
+ JITC_ADJUST(jitCoder, 1);
+ }
+ else if(opcode == IL_OP_LDC_I8)
+ {
+ ILInt64 temp;
+
+ JITC_GET_INT64(arg, temp);
+ jitCoder->jitStack[jitCoder->stackTop] =
+ jit_value_create_long_constant(jitCoder->jitFunction,
+
_IL_JIT_TYPE_INT64,
+
(jit_long)temp);
+ JITC_ADJUST(jitCoder, 1);
+ }
+ else if(opcode == IL_OP_LDC_R8)
+ {
+ ILDouble temp;
+
+ JITC_GET_FLOAT64(arg, temp);
+ jitCoder->jitStack[jitCoder->stackTop] =
+ jit_value_create_nfloat_constant(jitCoder->jitFunction,
+
_IL_JIT_TYPE_NFLOAT,
+
(jit_nfloat)temp);
+ JITC_ADJUST(jitCoder, 1);
+ }
}
/*
@@ -32,6 +107,21 @@
*/
static void JITCoder_StringConstant(ILCoder *coder, ILToken token, void
*object)
{
+ ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
+
+ if(object)
+ {
+ /* Push the object pointer directly, to save time at runtime */
+ jitCoder->jitStack[jitCoder->stackTop] =
+ jit_value_create_nint_constant(jitCoder->jitFunction,
+
jit_type_void_ptr,
+
(jit_nint)object);
+ JITC_ADJUST(jitCoder, 1);
+ }
+ else
+ {
+ /* TODO */
+ }
}
#endif /* IL_JITC_CODE */
Index: pnet/engine/jitc_setup.c
diff -u pnet/engine/jitc_setup.c:1.2 pnet/engine/jitc_setup.c:1.3
--- pnet/engine/jitc_setup.c:1.2 Sat Dec 24 11:34:57 2005
+++ pnet/engine/jitc_setup.c Thu Dec 29 15:56:52 2005
@@ -152,7 +152,7 @@
*/
static int JITCoder_Finish(ILCoder *_coder)
{
- return 1;
+ return IL_CODER_END_OK;
}
/*
@@ -160,12 +160,12 @@
*/
static void JITCoder_SetFlags(ILCoder *_coder,int flags)
{
-
+ (_ILCoderToILJITCoder(_coder))->flags = flags;
}
static int JITCoder_GetFlags(ILCoder *_coder)
{
- return 0;
+ return (_ILCoderToILJITCoder(_coder))->flags;
}
/*
Index: pnet/engine/jitc_stack.c
diff -u pnet/engine/jitc_stack.c:1.1 pnet/engine/jitc_stack.c:1.2
--- pnet/engine/jitc_stack.c:1.1 Mon Dec 19 18:00:35 2005
+++ pnet/engine/jitc_stack.c Thu Dec 29 15:56:52 2005
@@ -23,9 +23,10 @@
/*
* Refresh the coder's notion of the stack contents.
*/
-static void JITCoder_StackRefresh(ILCoder *_coder, ILEngineStackItem *stack,
+static void JITCoder_StackRefresh(ILCoder *coder, ILEngineStackItem *stack,
ILUInt32
stackSize)
{
+ ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
}
/*
@@ -33,6 +34,11 @@
*/
static void JITCoder_Dup(ILCoder *coder, ILEngineType engineType, ILType *type)
{
+ ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
+
+ jitCoder->jitStack[jitCoder->stackTop] =
+ jitCoder->jitStack[jitCoder->stackTop - 1];
+ JITC_ADJUST(jitCoder, 1);
}
/*
@@ -40,6 +46,9 @@
*/
static void JITCoder_Pop(ILCoder *coder, ILEngineType engineType, ILType *type)
{
+ ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
+
+ JITC_ADJUST(jitCoder, -1);
}
#endif /* IL_JITC_CODE */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [dotgnu-pnet-commits] pnet ./ChangeLog engine/call.c engine/convert.c...,
Klaus Treichel <=