[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_setup.c
From: |
Klaus Treichel |
Subject: |
[dotgnu-pnet-commits] pnet ./ChangeLog engine/jitc.c engine/jitc_setup.c |
Date: |
Sat, 24 Dec 2005 11:34:57 +0000 |
CVSROOT: /cvsroot/dotgnu-pnet
Module name: pnet
Branch:
Changes by: Klaus Treichel <address@hidden> 05/12/24 11:34:57
Modified files:
. : ChangeLog
engine : jitc.c jitc_setup.c
Log message:
Add some more work on the jit coder.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/ChangeLog.diff?tr1=1.3256&tr2=1.3257&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc.c.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc_setup.c.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
Patches:
Index: pnet/ChangeLog
diff -u pnet/ChangeLog:1.3256 pnet/ChangeLog:1.3257
--- pnet/ChangeLog:1.3256 Fri Dec 23 15:44:35 2005
+++ pnet/ChangeLog Sat Dec 24 11:34:56 2005
@@ -1,3 +1,7 @@
+2005-12-24 Klaus Treichel <address@hidden>
+
+ * engine/jitc.c, engine/jitc_setup.c: Add some more work on the jit
coder.
+
2005-12-23 Marc Haisenko <address@hidden>
* engine/cvm_call.c: Don't count method calls if enhanced profiler is
Index: pnet/engine/jitc.c
diff -u pnet/engine/jitc.c:1.2 pnet/engine/jitc.c:1.3
--- pnet/engine/jitc.c:1.2 Thu Dec 22 18:23:44 2005
+++ pnet/engine/jitc.c Sat Dec 24 11:34:57 2005
@@ -66,9 +66,19 @@
ILMethod *currentMethod;
int debugEnabled;
+
+ /* Members to manage the evaluation stack. */
jit_value_t *jitStack;
int stackSize;
int stackTop;
+
+ /* Members to manage the local variables. */
+ jit_value_t *jitLocals;
+ int numLocals;
+ int maxLocals;
+
+ /* The current jitted function. */
+ ILJitFunction jitFunction;
};
/*
@@ -95,13 +105,13 @@
if(n > (coder)->stackSize) \
{ \
ILJitValue *newStack = \
- (ILJitValue
*)ILRealloc((coder)->stack, \
+ (ILJitValue
*)ILRealloc((coder)->jitStack, \
n * sizeof(ILJitValue)); \
if(!newStack) \
{ \
return 0; \
} \
- (coder)->stack = newStack; \
+ (coder)->jitStack = newStack; \
(coder)->stackSize = n; \
} \
} while (0)
@@ -250,6 +260,7 @@
/*
* Get the jit type representing the this pointer for the given ILType.
+ * Returns 0 whne the type could not be found or out of memory.
*/
static ILJitType _ILJitGetThisType(ILType *type, ILExecProcess *process)
{
@@ -264,6 +275,7 @@
/*
* Get the jit type representing the argument type for the given ILType.
+ * Returns 0 whne the type could not be found or out of memory.
* TODO: Handle ref and out args.
*/
static ILJitType _ILJitGetArgType(ILType *type, ILExecProcess *process)
@@ -285,6 +297,28 @@
}
/*
+ * Get the jit type representing the local type for the given ILType.
+ * Returns 0 whne the type could not be found or out of memory.
+ */
+static ILJitType _ILJitGetLocalsType(ILType *type, ILExecProcess *process)
+{
+ ILJitTypes *types = _ILJitGetTypes(type, process);
+
+ if(!types)
+ {
+ return 0;
+ }
+ if(ILType_IsClass(type))
+ {
+ return _ILJitGetPointerTypeFromJitTypes(types);
+ }
+ else
+ {
+ return types->jitTypeBase;
+ }
+}
+
+/*
* Get the jit type representing the return value for the given ILType.
*/
static ILJitType _ILJitGetReturnType(ILType *type, ILExecProcess *process)
@@ -369,6 +403,14 @@
coder->jitStack = 0;
coder->stackTop = -1;
coder->stackSize = 0;
+ /* Initialize the locals management. */
+ coder->jitLocals = 0;
+ coder->numLocals = 0;
+ coder->maxLocals = 0;
+
+ /* Init the current jitted function. */
+ coder->jitFunction = 0;
+
/* Ready to go */
return &(coder->coder);
}
@@ -413,6 +455,11 @@
ILFree(coder->jitStack);
coder->jitStack = 0;
}
+ if(coder->jitLocals)
+ {
+ ILFree(coder->jitLocals);
+ coder->jitLocals = 0;
+ }
if(coder->context)
{
jit_context_destroy(coder->context);
Index: pnet/engine/jitc_setup.c
diff -u pnet/engine/jitc_setup.c:1.1 pnet/engine/jitc_setup.c:1.2
--- pnet/engine/jitc_setup.c:1.1 Mon Dec 19 18:00:35 2005
+++ pnet/engine/jitc_setup.c Sat Dec 24 11:34:57 2005
@@ -21,11 +21,99 @@
#ifdef IL_JITC_CODE
/*
+ * Allocate enough space for "n" locals.
+ */
+#define ALLOC_LOCALS(n) \
+ do { \
+ ILUInt32 temp = (ILUInt32)(((n) + 7) & ~7); \
+ if(temp > coder->maxLocals) \
+ { \
+ jit_value_t *newLocals = \
+ (jit_value_t
*)ILRealloc(coder->jitLocals, \
+
temp * sizeof(jit_value_t)); \
+ if(!newLocals) \
+ { \
+ return 0; \
+ } \
+ coder->jitLocals = newLocals; \
+ coder->maxLocals = temp; \
+ } \
+ } while (0)
+
+
+/*
+ * Create the jit vars for the declared local variables.
+ * Returns zero if out of memory.
+ */
+static int _JITCreateLocals(ILJITCoder *coder, ILStandAloneSig *localVarSig)
+{
+ ILType *signature;
+ ILType *type;
+ ILJitType jitType;
+ ILUInt32 num;
+ ILUInt32 current;
+
+ if(localVarSig)
+ {
+ /* Determine the number of locals to allocate */
+ signature = ILStandAloneSigGetType(localVarSig);
+ num = ILTypeNumLocals(signature);
+
+ /* Allocate the "jitLocals" array for the variables */
+ ALLOC_LOCALS(num);
+
+ /* Set the offsets for each of the local variables */
+ for(current = 0; current < num; ++current)
+ {
+ type = ILTypeGetLocal(signature, current);
+ if(!(jitType = _ILJitGetLocalsType(type,
coder->process)))
+ {
+ return 0;
+ }
+ if(!(coder->jitLocals[current] =
jit_value_create(coder->jitFunction, jitType)))
+ {
+ return 0;
+ }
+ }
+ /* Record the number of used locals in the coder. */
+ coder->numLocals = num;
+ }
+ else
+ {
+ /* Set the number of used locals to 0. */
+ coder->numLocals = 0;
+ }
+
+ return 1;
+}
+
+/*
* Set up a JIT coder instance to process a specific method.
*/
static int JITCoder_Setup(ILCoder *_coder, unsigned char **start,
ILMethod *method,
ILMethodCode *code)
{
+ ILJITCoder *coder = ((ILJITCoder *)_coder);
+
+ /* Record the current jitted function. */
+ coder->jitFunction = (ILJitFunction)(method->userData);
+
+ /* Create the local variables. */
+ if(!_JITCreateLocals(coder, code->localVarSig))
+ {
+ return 0;
+ }
+
+ /* Ensure that the evaluation stack can hold at least the methods
maxStack */
+ /* items. */
+ if(code->maxStack > 0)
+ {
+ ALLOC_STACK(coder, code->maxStack);
+ }
+
+ /* And reset the stack top. */
+ coder->stackTop = 0;
+
return 1;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [dotgnu-pnet-commits] pnet ./ChangeLog engine/jitc.c engine/jitc_setup.c,
Klaus Treichel <=