[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_bran...
From: |
Klaus Treichel |
Subject: |
[dotgnu-pnet-commits] pnet ./ChangeLog engine/jitc.c engine/jitc_bran... |
Date: |
Sat, 28 Jan 2006 15:07:10 +0000 |
CVSROOT: /cvsroot/dotgnu-pnet
Module name: pnet
Branch:
Changes by: Klaus Treichel <address@hidden> 06/01/28 15:07:10
Modified files:
. : ChangeLog
engine : jitc.c jitc_branch.c jitc_call.c jitc_const.c
jitc_except.c jitc_obj.c jitc_setup.c
lib_type.c
Log message:
2006-01-28 Klaus Treichel <address@hidden>
* engine/jitc.c: Add the functions _ILJitGetSizeOfClass for the ctors
and
_ILJitGetTypeFromClass for the ValueCtorArgs. Add definitions for the
two
label types (normal and startfinally). Add labelType to ILJitLabel and
isInCatcher in ILJITCoder. Change the type resolution so that
_IL_JIT_TYPE_VPTR is returned for object references and pointers to
avoid
recursive class layouting because this messed up the vtables. (We might
need
a better solution because it could still happen.) Add some debug code
that
is printed when ilrun is started with -Z.
* engine/jitc_branch.c Add support for the different label types. With
_IL_JIT_LABEL_FINALLY a finally subroutine is started instead of
inserting
a label. Add some debug code that is printed when ilrun is started with
-Z.
* engine/jitc_call.c: Pass the object size instead of 0 to
_ILEngineAlloc
and set the call type to JIT_CALL_NOTHROW. Implement the ValueCtorArgs.
Set the number of parameters to argCount + 1 in vtable- and interface
calls.
Reset the method in the current ILExecThread on return from a function.
Make sure that the returned value is pushed on the stack as a stack
type.
Add some debug code that is printed when ilrun is started with -Z.
* engine/jitc_const.c: Change the constant load to match the cvmc coder.
* engine/jitc_except.c: Add some debug code that is printed when ilrun
is
started with -Z. Add creation of the finally labels in setup exceptions.
Add the returning from a finally clause. Add some exception support for
debugging.
* engine/jitc_obj.c: Set parameter isCtor to 1 in the calls to
_ILJitCallStaticConstructor on access of a static field.
* engine/jitc_setup.c: Add two stack items to handle the ValueCtorArgs
items and initialize the isInCatcher flag in JITCoder_Setup.
* engine/lib_type.c: Handles are passed on the stack instead of a
pointer
to the handle when jitting.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/ChangeLog.diff?tr1=1.3280&tr2=1.3281&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc.c.diff?tr1=1.14&tr2=1.15&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc_branch.c.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc_call.c.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc_const.c.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc_except.c.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc_obj.c.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc_setup.c.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/lib_type.c.diff?tr1=1.51&tr2=1.52&r1=text&r2=text
Patches:
Index: pnet/ChangeLog
diff -u pnet/ChangeLog:1.3280 pnet/ChangeLog:1.3281
--- pnet/ChangeLog:1.3280 Wed Jan 18 20:48:01 2006
+++ pnet/ChangeLog Sat Jan 28 15:07:09 2006
@@ -1,3 +1,41 @@
+2006-01-28 Klaus Treichel <address@hidden>
+
+ * engine/jitc.c: Add the functions _ILJitGetSizeOfClass for the ctors
and
+ _ILJitGetTypeFromClass for the ValueCtorArgs. Add definitions for the
two
+ label types (normal and startfinally). Add labelType to ILJitLabel and
+ isInCatcher in ILJITCoder. Change the type resolution so that
+ _IL_JIT_TYPE_VPTR is returned for object references and pointers to
avoid
+ recursive class layouting because this messed up the vtables. (We might
need
+ a better solution because it could still happen.) Add some debug code
that
+ is printed when ilrun is started with -Z.
+
+ * engine/jitc_branch.c Add support for the different label types. With
+ _IL_JIT_LABEL_FINALLY a finally subroutine is started instead of
inserting
+ a label. Add some debug code that is printed when ilrun is started with
-Z.
+
+ * engine/jitc_call.c: Pass the object size instead of 0 to
_ILEngineAlloc
+ and set the call type to JIT_CALL_NOTHROW. Implement the ValueCtorArgs.
+ Set the number of parameters to argCount + 1 in vtable- and interface
calls.
+ Reset the method in the current ILExecThread on return from a function.
+ Make sure that the returned value is pushed on the stack as a stack
type.
+ Add some debug code that is printed when ilrun is started with -Z.
+
+ * engine/jitc_const.c: Change the constant load to match the cvmc coder.
+
+ * engine/jitc_except.c: Add some debug code that is printed when ilrun
is
+ started with -Z. Add creation of the finally labels in setup exceptions.
+ Add the returning from a finally clause. Add some exception support for
+ debugging.
+
+ * engine/jitc_obj.c: Set parameter isCtor to 1 in the calls to
+ _ILJitCallStaticConstructor on access of a static field.
+
+ * engine/jitc_setup.c: Add two stack items to handle the ValueCtorArgs
+ items and initialize the isInCatcher flag in JITCoder_Setup.
+
+ * engine/lib_type.c: Handles are passed on the stack instead of a
pointer
+ to the handle when jitting.
+
2006-01-18 Klaus Treichel <address@hidden>
* engine/jitc_call.c, engine/jitc_obj.c, engine/jitc_setup.c,
Index: pnet/engine/jitc.c
diff -u pnet/engine/jitc.c:1.14 pnet/engine/jitc.c:1.15
--- pnet/engine/jitc.c:1.14 Sun Jan 15 17:42:12 2006
+++ pnet/engine/jitc.c Sat Jan 28 15:07:09 2006
@@ -106,6 +106,12 @@
#endif
/*
+ * declaration of the different label types.
+ */
+#define _IL_JIT_LABEL_NORMAL 0
+#define _IL_JIT_LABEL_STARTFINALLY 1
+
+/*
* Define the structure of a JIT label.
*/
typedef struct _tagILJITLabel ILJITLabel;
@@ -114,7 +120,7 @@
ILUInt32 address; /* Address in the IL code */
jit_label_t label; /* the libjit label */
ILJITLabel *next; /* Next label block */
-
+ int labelType; /* type of the label. */
};
/*
@@ -152,6 +158,9 @@
/* The current jitted function. */
ILJitFunction jitFunction;
+
+ /* Flag if the catcher is started. */
+ int isInCatcher;
};
/*
@@ -488,14 +497,7 @@
*/
static ILJitType _ILJitGetPointerTypeFromJitTypes(ILJitTypes *types)
{
- if(!types->jitTypePtr)
- {
- if(!(types->jitTypePtr =
jit_type_create_pointer(types->jitTypeBase, 1)))
- {
- return 0;
- }
- }
- return types->jitTypePtr;
+ return _IL_JIT_TYPE_VPTR;
}
/*
@@ -504,13 +506,7 @@
*/
static ILJitType _ILJitGetThisType(ILType *type, ILExecProcess *process)
{
- ILJitTypes *types = _ILJitGetTypes(type, process);
-
- if(!types)
- {
- return 0;
- }
- return _ILJitGetPointerTypeFromJitTypes(types);
+ return _IL_JIT_TYPE_VPTR;
}
/*
@@ -520,18 +516,18 @@
*/
static ILJitType _ILJitGetArgType(ILType *type, ILExecProcess *process)
{
- ILJitTypes *types = _ILJitGetTypes(type, process);
-
- if(!types)
- {
- return 0;
- }
if(ILType_IsClass(type))
{
- return _ILJitGetPointerTypeFromJitTypes(types);
+ return _IL_JIT_TYPE_VPTR;
}
else
{
+ ILJitTypes *types = _ILJitGetTypes(type, process);
+
+ if(!types)
+ {
+ return 0;
+ }
return types->jitTypeBase;
}
}
@@ -542,18 +538,18 @@
*/
static ILJitType _ILJitGetLocalsType(ILType *type, ILExecProcess *process)
{
- ILJitTypes *types = _ILJitGetTypes(type, process);
-
- if(!types)
- {
- return 0;
- }
if(ILType_IsClass(type))
{
- return _ILJitGetPointerTypeFromJitTypes(types);
+ return _IL_JIT_TYPE_VPTR;
}
else
{
+ ILJitTypes *types = _ILJitGetTypes(type, process);
+
+ if(!types)
+ {
+ return 0;
+ }
return types->jitTypeBase;
}
}
@@ -563,23 +559,61 @@
*/
static ILJitType _ILJitGetReturnType(ILType *type, ILExecProcess *process)
{
- ILJitTypes *types = _ILJitGetTypes(type, process);
-
- if(!types)
- {
- return 0;
- }
if(ILType_IsClass(type))
{
- return _ILJitGetPointerTypeFromJitTypes(types);
+ return _IL_JIT_TYPE_VPTR;
}
else
{
+ ILJitTypes *types = _ILJitGetTypes(type, process);
+
+ if(!types)
+ {
+ return 0;
+ }
return types->jitTypeBase;
}
}
/*
+ * Get the jit typee from an ILClass.
+ */
+static ILJitType _ILJitGetTypeFromClass(ILClass *info)
+{
+ ILClassPrivate *classPrivate = (ILClassPrivate *)info->userData;
+
+ if(!classPrivate)
+ {
+ /* We need to layout the class first. */
+ if(!_LayoutClass(ILExecThreadCurrent(), info))
+ {
+ return 0;
+ }
+ classPrivate = (ILClassPrivate *)info->userData;
+ }
+ return(classPrivate->jitTypes.jitTypeBase);
+}
+
+/*
+ * Get the size of an object.
+ */
+static ILUInt32 _ILJitGetSizeOfClass(ILClass *info)
+{
+ ILClassPrivate *classPrivate = (ILClassPrivate *)info->userData;
+
+ if(!classPrivate)
+ {
+ /* We need to layout the class first. */
+ if(!_LayoutClass(ILExecThreadCurrent(), info))
+ {
+ return 0;
+ }
+ classPrivate = (ILClassPrivate *)info->userData;
+ }
+ return((ILUInt32)jit_type_get_size(classPrivate->jitTypes.jitTypeBase));
+}
+
+/*
* Call the static constructor for a class if necessary.
*/
static void _ILJitCallStaticConstructor(ILJITCoder *coder, ILClass *classInfo,
@@ -1391,6 +1425,20 @@
return ILJitFunctionCreate(_coder, method);
}
+#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS)
+ if (jitCoder->flags & IL_CODER_FLAG_STATS)
+ {
+ ILMutexLock(globalTraceMutex);
+ fprintf(stdout,
+ "CreateMethodFromAncestor: Ancestor: %s.%s at Slot %i
New: %s.%s\n",
+ ILClass_Name(ILMethod_Owner(virtualAncestor)),
+ ILMethod_Name(virtualAncestor),
+ virtualAncestor->index,
+ ILClass_Name(ILMethod_Owner(method)),
+ ILMethod_Name(method));
+ ILMutexUnlock(globalTraceMutex);
+ }
+#endif
jitSignature = jit_function_get_signature(ancestor);
/* Now we can create the jit function itself. */
Index: pnet/engine/jitc_branch.c
diff -u pnet/engine/jitc_branch.c:1.5 pnet/engine/jitc_branch.c:1.6
--- pnet/engine/jitc_branch.c:1.5 Sat Jan 7 12:23:42 2006
+++ pnet/engine/jitc_branch.c Sat Jan 28 15:07:10 2006
@@ -24,7 +24,7 @@
* Look for a label for a specific IL address. Create
* a new label if necessary.
*/
-static ILJITLabel *GetLabel(ILJITCoder *coder, ILUInt32 address)
+static ILJITLabel *GetLabel(ILJITCoder *coder, ILUInt32 address, int labelType)
{
ILJITLabel *label;
label = coder->labelList;
@@ -42,6 +42,7 @@
label->address = address;
label->label = jit_label_undefined;
label->next = coder->labelList;
+ label->labelType = labelType;
coder->labelList = label;
}
else
@@ -57,11 +58,38 @@
static void JITCoder_Label(ILCoder *coder, ILUInt32 offset)
{
ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
- ILJITLabel *label = GetLabel(jitCoder, offset);
+ ILJITLabel *label = GetLabel(jitCoder, offset, _IL_JIT_LABEL_NORMAL);
if(label)
{
- jit_insn_label(jitCoder->jitFunction, &(label->label));
+ if(label->labelType == _IL_JIT_LABEL_STARTFINALLY)
+ {
+ #if !defined(IL_CONFIG_REDUCE_CODE) &&
!defined(IL_WITHOUT_TOOLS)
+ if (jitCoder->flags & IL_CODER_FLAG_STATS)
+ {
+ ILMutexLock(globalTraceMutex);
+ fprintf(stdout,
+ "StartFinally: %i\n",
+ offset);
+ ILMutexUnlock(globalTraceMutex);
+ }
+ #endif
+ jit_insn_start_finally(jitCoder->jitFunction,
&(label->label));
+ }
+ else
+ {
+ #if !defined(IL_CONFIG_REDUCE_CODE) &&
!defined(IL_WITHOUT_TOOLS)
+ if (jitCoder->flags & IL_CODER_FLAG_STATS)
+ {
+ ILMutexLock(globalTraceMutex);
+ fprintf(stdout,
+ "Label: %i\n",
+ offset);
+ ILMutexUnlock(globalTraceMutex);
+ }
+ #endif
+ jit_insn_label(jitCoder->jitFunction, &(label->label));
+ }
}
}
@@ -317,9 +345,19 @@
ILEngineType type1,
ILEngineType type2)
{
ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
- ILJITLabel *label = GetLabel(jitCoder, dest);
+ ILJITLabel *label = GetLabel(jitCoder, dest, _IL_JIT_LABEL_NORMAL);
ILJitValue temp;
+#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS)
+ if (jitCoder->flags & IL_CODER_FLAG_STATS)
+ {
+ ILMutexLock(globalTraceMutex);
+ fprintf(stdout,
+ "Branch: %i\n",
+ dest);
+ ILMutexUnlock(globalTraceMutex);
+ }
+#endif
/* Determine what form of branch to use */
switch(opcode)
{
@@ -495,7 +533,7 @@
static void JITCoder_SwitchEntry(ILCoder *_coder, ILUInt32 dest)
{
ILJITCoder *jitCoder = _ILCoderToILJITCoder(_coder);
- ILJITLabel *label = GetLabel(jitCoder, dest);
+ ILJITLabel *label = GetLabel(jitCoder, dest, _IL_JIT_LABEL_NORMAL);
jit_value_t constant =
jit_value_create_nint_constant(jitCoder->jitFunction,
jit_type_nint,
Index: pnet/engine/jitc_call.c
diff -u pnet/engine/jitc_call.c:1.6 pnet/engine/jitc_call.c:1.7
--- pnet/engine/jitc_call.c:1.6 Wed Jan 18 20:48:01 2006
+++ pnet/engine/jitc_call.c Sat Jan 28 15:07:10 2006
@@ -42,6 +42,7 @@
*/
static void _ILJitNewObj(ILJITCoder *coder, ILClass *info, ILJitValue *newArg)
{
+ ILUInt32 objSize = _ILJitGetSizeOfClass(info);
ILJitValue newObj;
ILJitValue args[3];
jit_label_t label1 = jit_label_undefined;
@@ -50,9 +51,10 @@
args[1] = jit_value_create_nint_constant(coder->jitFunction,
jit_type_void_ptr, (jit_nint)info);
args[2] = jit_value_create_nint_constant(coder->jitFunction,
-
jit_type_int, 0);
+
jit_type_int, objSize);
newObj = jit_insn_call_native(coder->jitFunction, 0, _ILEngineAlloc,
-
_ILJitSignature_ILEngineAlloc, args, 3, 0);
+
_ILJitSignature_ILEngineAlloc, args, 3,
+
JIT_CALL_NOTHROW);
jit_insn_branch_if(coder->jitFunction, newObj, &label1);
_ILJitThrowCurrentException(coder);
jit_insn_label(coder->jitFunction, &label1);
@@ -102,6 +104,35 @@
static void JITCoder_ValueCtorArgs(ILCoder *coder, ILClass *classInfo,
ILEngineStackItem *args, ILUInt32 numArgs)
{
+ ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
+ ILInt32 argPos = jitCoder->stackTop - numArgs;
+ ILInt32 current = 0;
+ ILJitType valueType = _ILJitGetTypeFromClass(classInfo);
+ ILJitValue value = jit_value_create(jitCoder->jitFunction, valueType);
+
+#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS)
+ if (jitCoder->flags & IL_CODER_FLAG_STATS)
+ {
+ ILMutexLock(globalTraceMutex);
+ fprintf(stdout,
+ "ValueCtorArgs: %s %i\n",
+ ILClass_Name(classInfo),
+ numArgs);
+ ILMutexUnlock(globalTraceMutex);
+ }
+#endif
+
+ jitCoder->stackTop += 2;
+ /* Move the constructor args up two slots on the stack. */
+ for(current = 0; current < numArgs; current++)
+ {
+ jitCoder->jitStack[jitCoder->stackTop - current - 1] =
+ jitCoder->jitStack[jitCoder->stackTop - current - 3];
+ }
+ jitCoder->jitStack[argPos] = value;
+ jitCoder->jitStack[argPos + 1] =
jit_insn_address_of(jitCoder->jitFunction,
+
value);
+
}
static void JITCoder_CheckCallNull(ILCoder *coder, ILCoderMethodInfo *info)
@@ -126,9 +157,37 @@
"CallMethod: %s.%s\n",
ILClass_Name(ILMethod_Owner(methodInfo)),
ILMethod_Name(methodInfo));
+ ILMutexUnlock(globalTraceMutex);
+ }
+#endif
+
+ if(!jitFunction)
+ {
+ /* We need to layout the class first. */
+ if(!_LayoutClass(ILExecThreadCurrent(),
ILMethod_Owner(methodInfo)))
+ {
+ return;
+ }
+ jitFunction = ILJitFunctionFromILMethod(methodInfo);
+ }
+
+#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS)
+ if (jitCoder->flags & IL_CODER_FLAG_STATS)
+ {
+ ILJitType signature = jit_function_get_signature(jitFunction);
+
+ ILMutexLock(globalTraceMutex);
+ fprintf(stdout,
+ "CallInfos: StackTop: %i, ArgCount: %i, Signature
argCount: %i\n",
+ jitCoder->stackTop,
+ argCount,
+ jit_type_num_params(signature));
ILMutexUnlock(globalTraceMutex);
}
#endif
+ /* Output a call to the static constructor */
+ _ILJitCallStaticConstructor(jitCoder, ILMethod_Owner(methodInfo), 0);
+
/* Set the ILExecThread argument. */
jitParams[0] = jit_value_get_param(jitCoder->jitFunction, 0);
@@ -139,17 +198,30 @@
{
returnValue = jit_insn_call(jitCoder->jitFunction, 0,
jitFunction, 0,
jitParams, argCount + 1, JIT_CALL_TAIL);
+ if(returnItem->engineType != ILEngineType_Invalid)
+ {
+ jitCoder->jitStack[jitCoder->stackTop] =
+
_ILJitValueConvertToStackType(jitCoder->jitFunction,
+
returnValue);
+ JITC_ADJUST(jitCoder, 1);
+ }
}
else
{
returnValue = jit_insn_call(jitCoder->jitFunction, 0,
jitFunction, 0,
jitParams, argCount + 1, 0);
- if(returnItem->engineType != ILEngineType_Invalid)
+ if(returnItem && returnItem->engineType != ILEngineType_Invalid)
{
- jitCoder->jitStack[jitCoder->stackTop] = returnValue;
+ jitCoder->jitStack[jitCoder->stackTop] =
+
_ILJitValueConvertToStackType(jitCoder->jitFunction,
+
returnValue);
JITC_ADJUST(jitCoder, 1);
}
}
+ /* Restore the current method in the thread on return. */
+ _ILJitSetMethodInThread(jitCoder->jitFunction,
+
jit_value_get_param(jitCoder->jitFunction, 0),
+
jitCoder->currentMethod);
}
static void JITCoder_CallIndirect(ILCoder *coder, ILCoderMethodInfo *info,
@@ -177,6 +249,31 @@
ILMutexUnlock(globalTraceMutex);
}
#endif
+
+ if(!jitFunction)
+ {
+ /* We need to layout the class first. */
+ if(!_LayoutClass(ILExecThreadCurrent(),
ILMethod_Owner(methodInfo)))
+ {
+ return;
+ }
+ jitFunction = ILJitFunctionFromILMethod(methodInfo);
+ }
+
+#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS)
+ if (jitCoder->flags & IL_CODER_FLAG_STATS)
+ {
+ ILJitType signature = jit_function_get_signature(jitFunction);
+
+ ILMutexLock(globalTraceMutex);
+ fprintf(stdout,
+ "CallInfos: StackTop: %i, ArgCount: %i, Signature
argCount: %i\n",
+ jitCoder->stackTop,
+ argCount,
+ jit_type_num_params(signature));
+ ILMutexUnlock(globalTraceMutex);
+ }
+#endif
/* Output a call to the static constructor */
_ILJitCallStaticConstructor(jitCoder, ILMethod_Owner(methodInfo), 1);
@@ -202,6 +299,11 @@
jitCoder->jitStack[jitCoder->stackTop] = jitParams[1];
}
JITC_ADJUST(jitCoder, 1);
+
+ /* Restore the current method in the thread on return. */
+ _ILJitSetMethodInThread(jitCoder->jitFunction,
+
jit_value_get_param(jitCoder->jitFunction, 0),
+
jitCoder->currentMethod);
}
static void JITCoder_CallVirtual(ILCoder *coder, ILCoderMethodInfo *info,
@@ -211,9 +313,9 @@
ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
int argCount = info->numBaseArgs + info->numVarArgs;
- ILJitFunction func = methodInfo->userData;
+ ILJitFunction func = ILJitFunctionFromILMethod(methodInfo);
ILJitType signature;
- ILJitValue jitParams[argCount + 2];
+ ILJitValue jitParams[argCount + 1];
ILJitValue returnValue;
ILJitValue classPrivate;
ILJitValue vtable;
@@ -225,12 +327,24 @@
{
ILMutexLock(globalTraceMutex);
fprintf(stdout,
- "CallVirtual: %s.%s\n",
+ "CallVirtual: %s.%s at slot %i\n",
ILClass_Name(ILMethod_Owner(methodInfo)),
- ILMethod_Name(methodInfo));
+ ILMethod_Name(methodInfo),
+ methodInfo->index);
ILMutexUnlock(globalTraceMutex);
}
#endif
+
+ if(!func)
+ {
+ /* We might need to layout the class first. */
+ if(!_LayoutClass(ILExecThreadCurrent(),
ILMethod_Owner(methodInfo)))
+ {
+ return;
+ }
+ func = ILJitFunctionFromILMethod(methodInfo);
+ }
+
if(!func)
{
signature = _ILJitCreateMethodSignature(jitCoder, methodInfo);
@@ -239,6 +353,18 @@
{
signature = jit_function_get_signature(func);
}
+#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS)
+ if (jitCoder->flags & IL_CODER_FLAG_STATS)
+ {
+ ILMutexLock(globalTraceMutex);
+ fprintf(stdout,
+ "CallInfos: StackTop: %i, ArgCount: %i, Signature
argCount: %i\n",
+ jitCoder->stackTop,
+ argCount,
+ jit_type_num_params(signature));
+ ILMutexUnlock(globalTraceMutex);
+ }
+#endif
jitParams[0] = jit_value_get_param(jitCoder->jitFunction, 0);
_ILJitFillArguments(jitCoder, &(jitParams[1]), info);
/* TODO: handle varargs here and create a call signature. */
@@ -257,21 +383,26 @@
{
returnValue =
jit_insn_call_indirect_vtable(jitCoder->jitFunction,
jitFunction, signature,
-
jitParams, argCount,
+
jitParams, argCount + 1,
JIT_CALL_TAIL);
}
else
{
returnValue =
jit_insn_call_indirect_vtable(jitCoder->jitFunction,
jitFunction, signature,
-
jitParams, argCount,
+
jitParams, argCount + 1,
0);
}
if(returnItem->engineType != ILEngineType_Invalid)
{
- jitCoder->jitStack[jitCoder->stackTop] = returnValue;
+ jitCoder->jitStack[jitCoder->stackTop] =
+ _ILJitValueConvertToStackType(jitCoder->jitFunction,
returnValue);
JITC_ADJUST(jitCoder, 1);
}
+ /* Restore the current method in the thread on return. */
+ _ILJitSetMethodInThread(jitCoder->jitFunction,
+
jit_value_get_param(jitCoder->jitFunction, 0),
+
jitCoder->currentMethod);
}
static void JITCoder_CallInterface(ILCoder *coder, ILCoderMethodInfo *info,
@@ -282,7 +413,7 @@
int argCount = info->numBaseArgs + info->numVarArgs;
ILJitFunction func = methodInfo->userData;
ILJitType signature;
- ILJitValue jitParams[argCount + 2];
+ ILJitValue jitParams[argCount + 1];
ILJitValue returnValue;
ILJitValue classPrivate;
ILJitValue jitFunction;
@@ -291,6 +422,19 @@
ILJitValue args[3];
jit_label_t label = jit_label_undefined;
+#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS)
+ if (jitCoder->flags & IL_CODER_FLAG_STATS)
+ {
+ ILMutexLock(globalTraceMutex);
+ fprintf(stdout,
+ "CallInterface: %s.%s at slot %i\n",
+ ILClass_Name(ILMethod_Owner(methodInfo)),
+ ILMethod_Name(methodInfo),
+ methodInfo->index);
+ ILMutexUnlock(globalTraceMutex);
+ }
+#endif
+
if(!func)
{
signature = _ILJitCreateMethodSignature(jitCoder, methodInfo);
@@ -326,21 +470,26 @@
{
returnValue =
jit_insn_call_indirect_vtable(jitCoder->jitFunction,
jitFunction, signature,
-
jitParams, argCount,
+
jitParams, argCount + 1,
JIT_CALL_TAIL);
}
else
{
returnValue =
jit_insn_call_indirect_vtable(jitCoder->jitFunction,
jitFunction, signature,
-
jitParams, argCount,
+
jitParams, argCount + 1,
0);
}
if(returnItem->engineType != ILEngineType_Invalid)
{
- jitCoder->jitStack[jitCoder->stackTop] = returnValue;
+ jitCoder->jitStack[jitCoder->stackTop] =
+ _ILJitValueConvertToStackType(jitCoder->jitFunction,
returnValue);
JITC_ADJUST(jitCoder, 1);
}
+ /* Restore the current method in the thread on return. */
+ _ILJitSetMethodInThread(jitCoder->jitFunction,
+
jit_value_get_param(jitCoder->jitFunction, 0),
+
jitCoder->currentMethod);
}
static int JITCoder_CallInlineable(ILCoder *coder, int inlineType,
@@ -359,6 +508,15 @@
{
ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
+#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS)
+ if (jitCoder->flags & IL_CODER_FLAG_STATS)
+ {
+ ILMutexLock(globalTraceMutex);
+ fprintf(stdout,
+ "Return\n");
+ ILMutexUnlock(globalTraceMutex);
+ }
+#endif
if(engineType == ILEngineType_Invalid)
{
jit_insn_return(jitCoder->jitFunction, 0);
Index: pnet/engine/jitc_const.c
diff -u pnet/engine/jitc_const.c:1.3 pnet/engine/jitc_const.c:1.4
--- pnet/engine/jitc_const.c:1.3 Mon Jan 9 20:49:47 2006
+++ pnet/engine/jitc_const.c Sat Jan 28 15:07:10 2006
@@ -47,24 +47,18 @@
}
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);
+
(jit_nint)arg[0]);
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);
+
(jit_nint)IL_READ_UINT32(arg));
JITC_ADJUST(jitCoder, 1);
}
else if(opcode == IL_OP_LDC_R4)
Index: pnet/engine/jitc_except.c
diff -u pnet/engine/jitc_except.c:1.1 pnet/engine/jitc_except.c:1.2
--- pnet/engine/jitc_except.c:1.1 Mon Dec 19 18:00:35 2005
+++ pnet/engine/jitc_except.c Sat Jan 28 15:07:10 2006
@@ -26,6 +26,43 @@
static void JITCoder_SetupExceptions(ILCoder *_coder, ILException *exceptions,
int
hasRethrow)
{
+ ILJITCoder *jitCoder = _ILCoderToILJITCoder(_coder);
+
+#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS)
+ if (jitCoder->flags & IL_CODER_FLAG_STATS)
+ {
+ ILMutexLock(globalTraceMutex);
+ fprintf(stdout,
+ "SetupExceptions: hasRethrow: %i\n",
+ hasRethrow);
+ ILMutexUnlock(globalTraceMutex);
+ }
+#endif
+
+ /* We need to setup the filally labels first. */
+ while(exceptions != 0)
+ {
+ if((exceptions->flags & IL_META_EXCEPTION_FINALLY) != 0)
+ {
+ #if !defined(IL_CONFIG_REDUCE_CODE) &&
!defined(IL_WITHOUT_TOOLS)
+ if (jitCoder->flags & IL_CODER_FLAG_STATS)
+ {
+ ILMutexLock(globalTraceMutex);
+ fprintf(stdout,
+ "AddFinallyLabel for offset: %i\n",
+ exceptions->handlerOffset);
+ ILMutexUnlock(globalTraceMutex);
+ }
+ #endif
+ GetLabel(jitCoder, exceptions->handlerOffset,
+
_IL_JIT_LABEL_STARTFINALLY);
+ }
+ exceptions = exceptions->next;
+ }
+ /* Setup the jit function to handle exceptions. */
+
+ jit_insn_uses_catcher(jitCoder->jitFunction);
+
}
/*
@@ -33,6 +70,28 @@
*/
static void JITCoder_Throw(ILCoder *coder, int inCurrentMethod)
{
+ ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
+ ILJitValue exception = jitCoder->jitStack[jitCoder->stackTop - 1];;
+
+#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS)
+ if (jitCoder->flags & IL_CODER_FLAG_STATS)
+ {
+ ILMutexLock(globalTraceMutex);
+ fprintf(stdout,
+ "Throw: inCurrentMethod: %i\n",
+ inCurrentMethod);
+ ILMutexUnlock(globalTraceMutex);
+ }
+#endif
+ /*
+ if(inCurrentMethod == 1)
+ {
+ */
+ jit_insn_throw(jitCoder->jitFunction, exception);
+ JITC_ADJUST(jitCoder, -1);
+ /*
+ }
+ */
}
/*
@@ -47,6 +106,17 @@
*/
static void JITCoder_Rethrow(ILCoder *coder, ILException *exception)
{
+ ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
+
+#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS)
+ if (jitCoder->flags & IL_CODER_FLAG_STATS)
+ {
+ ILMutexLock(globalTraceMutex);
+ fprintf(stdout,
+ "Rethrow: \n");
+ ILMutexUnlock(globalTraceMutex);
+ }
+#endif
}
/*
@@ -54,6 +124,18 @@
*/
static void JITCoder_Jsr(ILCoder *coder, ILUInt32 dest)
{
+ ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
+
+#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS)
+ if (jitCoder->flags & IL_CODER_FLAG_STATS)
+ {
+ ILMutexLock(globalTraceMutex);
+ fprintf(stdout,
+ "Jsr: dest: %i\n",
+ dest);
+ ILMutexUnlock(globalTraceMutex);
+ }
+#endif
}
/*
@@ -61,6 +143,17 @@
*/
static void JITCoder_RetFromJsr(ILCoder *coder)
{
+ ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
+
+#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS)
+ if (jitCoder->flags & IL_CODER_FLAG_STATS)
+ {
+ ILMutexLock(globalTraceMutex);
+ fprintf(stdout,
+ "RetFromJsr: \n");
+ ILMutexUnlock(globalTraceMutex);
+ }
+#endif
}
/*
@@ -69,6 +162,42 @@
static void JITCoder_TryHandlerStart(ILCoder *_coder,
ILUInt32 start, ILUInt32 end)
{
+ ILJITCoder *jitCoder = _ILCoderToILJITCoder(_coder);
+ ILJitValue exception;
+
+#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS)
+ if (jitCoder->flags & IL_CODER_FLAG_STATS)
+ {
+ ILMutexLock(globalTraceMutex);
+ fprintf(stdout,
+ "TryHandlerStart: start: %i end: %i\n",
+ start,
+ end);
+ ILMutexUnlock(globalTraceMutex);
+ }
+#endif
+
+ if(!jitCoder->isInCatcher)
+ {
+ /* Tell libjit that we are in the catcher. */
+
+ jit_insn_start_catcher(jitCoder->jitFunction);
+
+ jitCoder->isInCatcher = 1;
+ }
+
+ /* We need the exception object on top of the stack. */
+ exception = jit_insn_thrown_exception(jitCoder->jitFunction);
+ jitCoder->jitStack[jitCoder->stackTop] = exception;
+ JITC_ADJUST(jitCoder, 1);
+
+ if(start == 0 && end == IL_MAX_UINT32)
+ {
+ /* This handler was the last one in the table */
+ /*
+ jit_insn_rethrow_unhandled(jitCoder->jitFunction);
+ */
+ }
}
/*
@@ -76,6 +205,17 @@
*/
static void JITCoder_TryHandlerEnd(ILCoder *coder)
{
+ ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
+
+#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS)
+ if (jitCoder->flags & IL_CODER_FLAG_STATS)
+ {
+ ILMutexLock(globalTraceMutex);
+ fprintf(stdout,
+ "TryHandlerEnd: \n");
+ ILMutexUnlock(globalTraceMutex);
+ }
+#endif
}
/*
@@ -84,14 +224,59 @@
static void JITCoder_Catch(ILCoder *_coder, ILException *exception,
ILClass *classInfo, int
hasRethrow)
{
+ ILJITCoder *jitCoder = _ILCoderToILJITCoder(_coder);
+
+#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS)
+ if (jitCoder->flags & IL_CODER_FLAG_STATS)
+ {
+ ILMutexLock(globalTraceMutex);
+ fprintf(stdout,
+ "Catch: %s hasRethrow: %i\n",
+ ILClass_Name(classInfo),
+ hasRethrow);
+ ILMutexUnlock(globalTraceMutex);
+ }
+#endif
}
static void JITCoder_EndCatchFinally(ILCoder *coder, ILException *exception)
{
+ ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
+
+#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS)
+ if (jitCoder->flags & IL_CODER_FLAG_STATS)
+ {
+ ILMutexLock(globalTraceMutex);
+ fprintf(stdout,
+ "EndCatchFinally: \n");
+ ILMutexUnlock(globalTraceMutex);
+ }
+#endif
+
+ jit_insn_return_from_finally(jitCoder->jitFunction);
}
+/*
+ * Handle the leave opcodes.
+ */
static void JITCoder_Finally(ILCoder *coder, ILException *exception, int dest)
{
+ ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
+ ILJITLabel *label = GetLabel(jitCoder, dest,
_IL_JIT_LABEL_STARTFINALLY);
+
+#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS)
+ if (jitCoder->flags & IL_CODER_FLAG_STATS)
+ {
+ ILMutexLock(globalTraceMutex);
+ fprintf(stdout,
+ "CallFinally: dest: %i\n",
+ dest);
+ ILMutexUnlock(globalTraceMutex);
+ }
+#endif
+ /*
+ jit_insn_call_finally(jitCoder->jitFunction, &(label->label));
+ */
}
/*
Index: pnet/engine/jitc_obj.c
diff -u pnet/engine/jitc_obj.c:1.8 pnet/engine/jitc_obj.c:1.9
--- pnet/engine/jitc_obj.c:1.8 Wed Jan 18 20:48:02 2006
+++ pnet/engine/jitc_obj.c Sat Jan 28 15:07:10 2006
@@ -269,7 +269,7 @@
}
#endif
/* Output a call to the static constructor */
- _ILJitCallStaticConstructor(jitCoder, ILField_Owner(field), 0);
+ _ILJitCallStaticConstructor(jitCoder, ILField_Owner(field), 1);
jitCoder->jitStack[jitCoder->stackTop] =
_ILJitLoadField(jitCoder, ptr, fieldType, field->offset, 0);
@@ -319,7 +319,7 @@
}
#endif
/* Output a call to the static constructor */
- _ILJitCallStaticConstructor(jitCoder, ILField_Owner(field), 0);
+ _ILJitCallStaticConstructor(jitCoder, ILField_Owner(field), 1);
jitCoder->jitStack[jitCoder->stackTop] =
_ILJitLoadFieldAddress(jitCoder, ptr, field->offset, 0);
@@ -371,7 +371,7 @@
}
#endif
/* Output a call to the static constructor */
- _ILJitCallStaticConstructor(jitCoder, ILField_Owner(field), 0);
+ _ILJitCallStaticConstructor(jitCoder, ILField_Owner(field), 1);
_ILJitStoreField(jitCoder, ptr, value, fieldType, field->offset, 1);
JITC_ADJUST(jitCoder, -1);
Index: pnet/engine/jitc_setup.c
diff -u pnet/engine/jitc_setup.c:1.7 pnet/engine/jitc_setup.c:1.8
--- pnet/engine/jitc_setup.c:1.7 Wed Jan 18 20:48:02 2006
+++ pnet/engine/jitc_setup.c Sat Jan 28 15:07:10 2006
@@ -119,14 +119,15 @@
/* Ensure that the evaluation stack can hold at least the methods
maxStack */
/* items. */
- if(code->maxStack > 0)
- {
- ALLOC_STACK(coder, code->maxStack);
- }
+ /* We need two additional slots for the ValueCtorArgs. */
+ ALLOC_STACK(coder, code->maxStack + 2);
/* And reset the stack top. */
coder->stackTop = 0;
+ /* Reset the isInCatcher flag. */
+ coder->isInCatcher = 0;
+
/* Set the current method in the thread. */
_ILJitSetMethodInThread(coder->jitFunction,
jit_value_get_param(coder->jitFunction, 0),
Index: pnet/engine/lib_type.c
diff -u pnet/engine/lib_type.c:1.51 pnet/engine/lib_type.c:1.52
--- pnet/engine/lib_type.c:1.51 Fri Sep 9 10:13:59 2005
+++ pnet/engine/lib_type.c Sat Jan 28 15:07:10 2006
@@ -2548,7 +2548,11 @@
*/
ILObject *_IL_Type_GetTypeFromHandle(ILExecThread *thread, void *handle)
{
+#ifdef IL_USE_JIT
+ ILClass *classInfo = (ILClass *)handle;
+#else
ILClass *classInfo = *((ILClass **)handle);
+#endif
if(classInfo)
{
return _ILGetClrType(thread, classInfo);