[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_call.c
From: |
Klaus Treichel |
Subject: |
[dotgnu-pnet-commits] pnet ./ChangeLog engine/jitc.c engine/jitc_call.c |
Date: |
Sun, 02 Apr 2006 17:32:43 +0000 |
CVSROOT: /cvsroot/dotgnu-pnet
Module name: pnet
Branch:
Changes by: Klaus Treichel <address@hidden> 06/04/02 17:32:43
Modified files:
. : ChangeLog
engine : jitc.c jitc_call.c
Log message:
2006-03-25 Klaus Treichel <address@hidden>
* engine/jitc.c, engine/jitc_call.c: Call internal fuctions now directly
for normal calls and ctors.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/ChangeLog.diff?tr1=1.3310&tr2=1.3311&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc.c.diff?tr1=1.26&tr2=1.27&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnet/engine/jitc_call.c.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
Patches:
Index: pnet/ChangeLog
diff -u pnet/ChangeLog:1.3310 pnet/ChangeLog:1.3311
--- pnet/ChangeLog:1.3310 Sat Mar 25 07:06:54 2006
+++ pnet/ChangeLog Sun Apr 2 17:32:42 2006
@@ -3,6 +3,9 @@
* enjine/jitc_obj.c: Fix a bug in ILJITCoder_CastClass that caused a
segfault in IsInst when the object to cast was null.
+ * engine/jitc.c, engine/jitc_call.c: Call internal fuctions now directly
+ for normal calls and ctors.
+
2006-03-19 Rainer Größlinger <address@hidden>
* libgc/Makefile.am, libgc/Makefile.direct, libgc/Makefile.in,
Index: pnet/engine/jitc.c
diff -u pnet/engine/jitc.c:1.26 pnet/engine/jitc.c:1.27
--- pnet/engine/jitc.c:1.26 Sun Mar 19 11:29:11 2006
+++ pnet/engine/jitc.c Sun Apr 2 17:32:42 2006
@@ -45,13 +45,13 @@
* For dumping the jitted function before it is compiled uncomment the
* following define.
*/
-/* #define _IL_JIT_DUMP_FUNCTION 1 */
+#define _IL_JIT_DUMP_FUNCTION 1
/*
* For dumping the disassembled jitted function before after it is compiled
* uncomment the following define.
*/
-/* #define _IL_JIT_DISASSEMBLE_FUNCTION 1 */
+#define _IL_JIT_DISASSEMBLE_FUNCTION 1
/*
* To enable parameter / locals optimizations uncomment the following define.
@@ -1528,42 +1528,120 @@
}
/*
- * Generate the stub for calling an internal function.
+ * Check if a function is implemented by an internalcall.
+ * Returns 0 if the function is not implemented by an internal call,
+ * 1 if the function is implemented by an internal call and the function
+ * is not an allocating constructor (it doesn't allocate the new object)
+ * and 2 if the function is an allocating constructor.
*/
-static int _ILJitCompileInternal(jit_function_t func, ILMethod *method, void
*nativeFunction)
+static int _ILJitFunctionIsInternal(ILJITCoder *coder, ILMethod *method,
+
ILInternalInfo *fnInfo, int isConstructor)
+{
+ ILMethodCode code;
+
+ /* Get the method code */
+ if(!ILMethodGetCode(method, &code))
+ {
+ code.code = 0;
+ }
+ if(!(code.code))
+ {
+ 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:
+ {
+ /* 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;
+ }
+ }
+ return 0;
+}
+
+/*
+ * Generate the code to call an internal function.
+ */
+static ILJitValue _ILJitCallInternal(ILJitFunction func, ILMethod *method,
+ void *nativeFunction,
const char *methodName,
+ ILJitValue *args,
ILUInt32 numArgs)
{
-#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
ILType *ilSignature = ILMethod_Signature(method);
ILType *type = ILTypeGetEnumType(ILTypeGetParam(ilSignature, 0));
- ILJitType signature = jit_function_get_signature(func);
- unsigned int numParams = jit_type_num_params(signature);
- unsigned int totalParams = numParams;
+ /* Get the function to call. */
+ ILJitFunction jitFunction = ILJitFunctionFromILMethod(method);
ILJitValue thread = jit_value_get_param(func, 0);
- ILJitType returnType = jit_type_get_return(signature);;
+ jit_label_t label = jit_label_undefined;
+ ILJitType signature = 0;
+ ILJitType callSignature = 0;
+ ILJitType returnType = 0;
ILJitValue returnValue = 0;
+ unsigned int numParams = 0;
+ unsigned int totalParams = 0;
int hasStructReturn = 0;
- char *methodName = 0;
- jit_label_t label = jit_label_undefined;
ILJitValue thrownException = 0;
- ILUInt32 current;
+ ILUInt32 current = 0;
-#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS) &&
defined(_IL_JIT_ENABLE_DEBUG)
- methodName = _ILJitFunctionGetMethodName(func);
- if(jitCoder->flags & IL_CODER_FLAG_STATS)
+ if(!jitFunction)
{
- ILMutexLock(globalTraceMutex);
- fprintf(stdout, "CompileInternalMethod: %s\n", methodName);
- ILMutexUnlock(globalTraceMutex);
+ /* We need to layout the class first. */
+ if(!_LayoutClass(ILExecThreadCurrent(), ILMethod_Owner(method)))
+ {
+ return 0;
+ }
+ if(!(jitFunction = ILJitFunctionFromILMethod(method)))
+ {
+ return 0;
+ }
+ }
+
+ if(!(signature = jit_function_get_signature(jitFunction)))
+ {
+ return 0;
+ }
+ numParams = jit_type_num_params(signature);
+ totalParams = numParams;
+ returnType = jit_type_get_return(signature);;
+
+ if(numParams != (numArgs + 1))
+ {
+ printf("Number of args doesn't match: signature: %i - numArgs:
%i\n", numParams, numArgs);
}
-#endif
/* We need to set the method member in the ILExecThread == arg[0]. */
if(numParams > 0)
{
- ILJitValue paramValue;
ILJitType paramType;
ILJitType jitParamTypes[totalParams + 1];
ILJitValue jitParams[totalParams + 1];
@@ -1573,11 +1651,13 @@
/* an additional argument when the return value is a value type
*/
/* and pointers for structs. */
jitParamTypes[0] = jit_type_get_param(signature, 0);
+ jitParams[0] = jit_value_get_param(func, 0);
if(ILType_IsValueType(type))
{
++totalParams;
jitParamTypes[1] = _IL_JIT_TYPE_VPTR;
returnValue = jit_value_create(func, returnType);
+ jitParams[1] = jit_insn_address_of(func, returnValue);
returnType = _IL_JIT_TYPE_VOID;
hasStructReturn = 1;
++param;
@@ -1589,58 +1669,34 @@
if(jit_type_is_struct(paramType))
{
jitParamTypes[param] = _IL_JIT_TYPE_VPTR;
+ jitParams[param] = jit_insn_address_of(func,
args[current - 1]);
}
else
{
jitParamTypes[param] = paramType;
+ jitParams[param] = args[current - 1];
}
++param;
}
- signature = jit_type_create_signature(IL_JIT_CALLCONV_CDECL,
-
returnType,
-
jitParamTypes,
-
totalParams, 1);
-
- param = 1;
- jitParams[0] = jit_value_get_param(func, 0);
- if(hasStructReturn)
- {
- jitParams[1] = jit_insn_address_of(func, returnValue);
- ++param;
+ callSignature = jit_type_create_signature(IL_JIT_CALLCONV_CDECL,
+
returnType,
+
jitParamTypes,
+
totalParams, 1);
- }
- for(current = 1; current < numParams; ++current)
- {
- if(!(paramValue = jit_value_get_param(func, current)))
- {
- return JIT_RESULT_OUT_OF_MEMORY;
- }
- paramType = jit_value_get_type(paramValue);
- if(jit_type_is_struct(paramType))
- {
- jit_value_set_addressable(paramValue);
- jitParams[param] = jit_insn_address_of(func,
paramValue);
- }
- else
- {
- jitParams[param] = paramValue;
- }
- ++param;
- }
_ILJitSetMethodInThread(func, jitParams[0], method);
if(!hasStructReturn)
{
returnValue = jit_insn_call_native(func, methodName,
nativeFunction,
-
signature,
+
callSignature,
jitParams, numParams, 0);
}
else
{
jit_insn_call_native(func, methodName, nativeFunction,
- signature,
+ callSignature,
jitParams,
totalParams, 0);
}
- jit_type_free(signature);
+ jit_type_free(callSignature);
}
else
{
@@ -1650,14 +1706,67 @@
thrownException = jit_insn_load_relative(func, thread,
offsetof(ILExecThread, thrownException),
_IL_JIT_TYPE_VPTR);
- jit_insn_branch_if(func, thrownException, &label);
- jit_insn_return(func, returnValue);
- jit_insn_label(func, &label);
+ jit_insn_branch_if_not(func, thrownException, &label);
jit_insn_call_native(func, "jit_exception_clear_last",
jit_exception_clear_last,
_ILJitSignature_JitExceptionClearLast,
0, 0,
JIT_CALL_NOTHROW);
jit_insn_throw(func, thrownException);
+ jit_insn_label(func, &label);
+
+ return returnValue;
+}
+
+/*
+ * Generate the stub for calling an internal function.
+ */
+static int _ILJitCompileInternal(ILJitFunction func, ILMethod *method, void
*nativeFunction)
+{
+#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
+ ILJitType signature = jit_function_get_signature(func);
+ unsigned int numParams = jit_type_num_params(signature);
+ ILJitValue returnValue = 0;
+ char *methodName = 0;
+ ILUInt32 current;
+
+#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS) &&
defined(_IL_JIT_ENABLE_DEBUG)
+ methodName = _ILJitFunctionGetMethodName(func);
+ if(jitCoder->flags & IL_CODER_FLAG_STATS)
+ {
+ ILMutexLock(globalTraceMutex);
+ fprintf(stdout, "CompileInternalMethod: %s\n", methodName);
+ ILMutexUnlock(globalTraceMutex);
+ }
+#endif
+
+ if(numParams > 0)
+ {
+ ILJitValue paramValue;
+ ILJitValue jitParams[numParams - 1];
+
+ for(current = 1; current < numParams; ++current)
+ {
+ if(!(paramValue = jit_value_get_param(func, current)))
+ {
+ return JIT_RESULT_OUT_OF_MEMORY;
+ }
+ jitParams[current - 1] = paramValue;
+ }
+
+ returnValue = _ILJitCallInternal(func, method,
+
nativeFunction, methodName,
+
jitParams, numParams - 1);
+ }
+ else
+ {
+ returnValue = jit_insn_call_native(func, methodName,
nativeFunction,
+
signature, 0, 0, 0);
+ }
+ jit_insn_return(func, returnValue);
+
#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)
@@ -1880,8 +1989,12 @@
{
ILType *ownerType = ILType_FromClass(info);
ILType *synType = ILClassGetSynType(info);
-
- if(!(synType && ILType_IsArray(synType)) &&
!ILTypeIsStringClass(ownerType))
+ ILInternalInfo fnInfo;
+ int ctorType = _ILJitFunctionIsInternal(coder, method,
&fnInfo, 1);
+
+ if(!(synType && ILType_IsArray(synType)) &&
+ !ILTypeIsStringClass(ownerType) &&
+ !(ctorType == 2))
{
/* we need an other arg for this */
total++;
Index: pnet/engine/jitc_call.c
diff -u pnet/engine/jitc_call.c:1.11 pnet/engine/jitc_call.c:1.12
--- pnet/engine/jitc_call.c:1.11 Wed Mar 8 21:03:52 2006
+++ pnet/engine/jitc_call.c Sun Apr 2 17:32:43 2006
@@ -619,6 +619,7 @@
ILJitValue jitParams[argCount + 1];
ILJitValue returnValue;
char *methodName = 0;
+ ILInternalInfo fnInfo;
#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS)
if (jitCoder->flags & IL_CODER_FLAG_STATS)
@@ -659,15 +660,39 @@
/* Output a call to the static constructor */
_ILJitCallStaticConstructor(jitCoder, ILMethod_Owner(methodInfo), 0);
+#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS) &&
defined(_IL_JIT_ENABLE_DEBUG)
+ methodName = _ILJitFunctionGetMethodName(jitFunction);
+#endif
+
+ /* Check if the function is implemented in the engine. */
+ if(_ILJitFunctionIsInternal(jitCoder, methodInfo, &fnInfo, 0))
+ {
+ /* Call the engine function directly with the supplied args. */
+ if(info->hasParamArray)
+ {
+ ++argCount;
+ }
+ JITC_ADJUST(jitCoder, -argCount);
+ returnValue = _ILJitCallInternal(jitCoder->jitFunction,
methodInfo,
+
fnInfo.func, methodName,
+
&(jitCoder->jitStack[jitCoder->stackTop]),
+
argCount);
+ if(returnItem && returnItem->engineType != ILEngineType_Invalid)
+ {
+ jitCoder->jitStack[jitCoder->stackTop] =
+
_ILJitValueConvertToStackType(jitCoder->jitFunction,
+
returnValue);
+ JITC_ADJUST(jitCoder, 1);
+ }
+ return;
+ }
+
/* Set the ILExecThread argument. */
jitParams[0] = jit_value_get_param(jitCoder->jitFunction, 0);
_ILJitFillArguments(jitCoder, &(jitParams[1]), info);
/* TODO: create call signature for vararg calls. */
-#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS) &&
defined(_IL_JIT_ENABLE_DEBUG)
- methodName = _ILJitFunctionGetMethodName(jitFunction);
-#endif
if(info->tailCall == 1)
{
returnValue = jit_insn_call(jitCoder->jitFunction, methodName,
@@ -716,6 +741,8 @@
int argCount = info->numBaseArgs + info->numVarArgs;
ILJitValue jitParams[argCount + 2];
ILJitValue returnValue;
+ ILInternalInfo fnInfo;
+ int internalType = 0;
char *methodName = 0;
#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS)
@@ -764,6 +791,43 @@
/* Output a call to the static constructor */
_ILJitCallStaticConstructor(jitCoder, ILMethod_Owner(methodInfo), 1);
+ /* Check if the function is implemented in the engine. */
+ if((internalType = _ILJitFunctionIsInternal(jitCoder, methodInfo,
&fnInfo, 1)))
+ {
+ /* Call the engine function directly with the supplied args. */
+ if(internalType == 2)
+ {
+ /* This is an allocating constructor. */
+ if(info->hasParamArray)
+ {
+ ++argCount;
+ }
+ JITC_ADJUST(jitCoder, -argCount);
+ returnValue = _ILJitCallInternal(jitCoder->jitFunction,
methodInfo,
+
fnInfo.func, methodName,
+
&(jitCoder->jitStack[jitCoder->stackTop]),
+
argCount);
+ jitCoder->jitStack[jitCoder->stackTop] =
+
_ILJitValueConvertToStackType(jitCoder->jitFunction,
+
returnValue);
+ }
+ else
+ {
+ /* create a newobj and add it to the jitParams[0]. */
+ _ILJitNewObj(jitCoder, ILMethod_Owner(methodInfo),
&jitParams[0]);
+ _ILJitFillArguments(jitCoder, &(jitParams[1]), info);
+
+ returnValue = _ILJitCallInternal(jitCoder->jitFunction,
methodInfo,
+
fnInfo.func, methodName,
+
jitParams, argCount + 1);
+ jitCoder->jitStack[jitCoder->stackTop] =
+
_ILJitValueConvertToStackType(jitCoder->jitFunction,
+
jitParams[0]);
+ }
+ JITC_ADJUST(jitCoder, 1);
+ return;
+ }
+
/* Output a call to the constructor */
jitParams[0] = jit_value_get_param(jitCoder->jitFunction, 0); // we add
the current function thread as the first param
@@ -777,7 +841,8 @@
}
else
{
- _ILJitNewObj(jitCoder, ILMethod_Owner(methodInfo),
&jitParams[1]); // create a newobj and add it to the jitParams[1]
+ /* create a newobj and add it to the jitParams[1]. */
+ _ILJitNewObj(jitCoder, ILMethod_Owner(methodInfo),
&jitParams[1]);
_ILJitFillArguments(jitCoder, &(jitParams[2]), info);
// call the constructor with jitParams as input
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [dotgnu-pnet-commits] pnet ./ChangeLog engine/jitc.c engine/jitc_call.c,
Klaus Treichel <=