dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[dotgnu-pnet-commits] pnet ChangeLog engine/jitc.c engine/Makefile.am...


From: Klaus Treichel
Subject: [dotgnu-pnet-commits] pnet ChangeLog engine/jitc.c engine/Makefile.am...
Date: Sun, 18 Jun 2006 13:09:36 +0000

CVSROOT:        /sources/dotgnu-pnet
Module name:    pnet
Changes by:     Klaus Treichel <ktreichel>      06/06/18 13:09:36

Modified files:
        .              : ChangeLog 
        engine         : jitc.c Makefile.am 
Added files:
        engine         : jitc_pinvoke.c 

Log message:
        2006-06-18  Kirill Kononenko  <address@hidden>
        
                * engine/jitc.c: Add signatures for ILStringToUTF8 and 
ILStringCreate.
                Move _ILJitCompilePinvoke to jitc_pinvoke.c.
        
                * engine/jitc_pinvoke.c: Added.
        
                * engine/Makefile.am: Add jitc_pinvoke.c to the jit coder 
sources.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pnet/ChangeLog?cvsroot=dotgnu-pnet&r1=1.3327&r2=1.3328
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/jitc.c?cvsroot=dotgnu-pnet&r1=1.39&r2=1.40
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/Makefile.am?cvsroot=dotgnu-pnet&r1=1.86&r2=1.87
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/jitc_pinvoke.c?cvsroot=dotgnu-pnet&rev=1.1

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/ChangeLog,v
retrieving revision 1.3327
retrieving revision 1.3328
diff -u -b -r1.3327 -r1.3328
--- ChangeLog   17 Jun 2006 09:24:38 -0000      1.3327
+++ ChangeLog   18 Jun 2006 13:09:35 -0000      1.3328
@@ -1,3 +1,12 @@
+2006-06-18  Kirill Kononenko  <address@hidden>
+
+       * engine/jitc.c: Add signatures for ILStringToUTF8 and ILStringCreate.
+       Move _ILJitCompilePinvoke to jitc_pinvoke.c.
+
+       * engine/jitc_pinvoke.c: Added.
+
+       * engine/Makefile.am: Add jitc_pinvoke.c to the jit coder sources.
+
 2006-06-17  Klaus Treichel  <address@hidden>
 
        * engine/cvm.c: Move the globalTraceMutex to system.c. Wrap the rest in

Index: engine/jitc.c
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/engine/jitc.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -b -r1.39 -r1.40
--- engine/jitc.c       17 Jun 2006 09:24:38 -0000      1.39
+++ engine/jitc.c       18 Jun 2006 13:09:35 -0000      1.40
@@ -221,6 +221,16 @@
 static ILJitType _ILJitSignature_ILGetClrType = 0;
 
 /*
+ * char *ILStringToUTF8(ILExecThread *thread, ILString *str)
+ */
+static ILJitType _ILJitSignature_ILStringToUTF8 = 0;
+
+/* 
+ * ILString *ILStringCreate(ILExecThread *thread, const char *str)
+ */
+static ILJitType _ILJitSignature_ILStringCreate = 0;
+
+/*
  * Define offsetof macro if not present.
  */
 #ifndef offsetof
@@ -2039,6 +2049,24 @@
                return 0;
        }
 
+       args[0] = _IL_JIT_TYPE_VPTR;
+       args[1] = _IL_JIT_TYPE_VPTR;
+       returnType = _IL_JIT_TYPE_VPTR;
+       if(!(_ILJitSignature_ILStringToUTF8 =
+               jit_type_create_signature(IL_JIT_CALLCONV_CDECL, returnType, 
args, 2, 1)))
+       {
+               return 0;
+       }
+       
+       args[0] = _IL_JIT_TYPE_VPTR;
+       args[1] = _IL_JIT_TYPE_VPTR;
+       returnType = _IL_JIT_TYPE_VPTR;
+       if(!(_ILJitSignature_ILStringCreate =
+               jit_type_create_signature(IL_JIT_CALLCONV_CDECL, returnType, 
args, 2, 1)))
+       {
+               return 0;
+       }
+
        return 1;
 }
 /*
@@ -2573,55 +2601,6 @@
 }
 
 /*
- * On demand code generator.for functions implemented in IL code.
- */
-static int _ILJitCompilePinvoke(jit_function_t func)
-{
-       ILMethod *method = (ILMethod *)jit_function_get_meta(func, 
IL_JIT_META_METHOD);
-#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS) && 
defined(_IL_JIT_ENABLE_DEBUG)
-       ILClass *info = ILMethod_Owner(method);
-       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, "CompilePinvoke: %s\n", methodName);
-               ILMutexUnlock(globalTraceMutex);
-       }
-#endif
-
-       /* TODO */
-
-#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;
-}
-
-/*
  * Check if the given method is abstract (should have no implementation).
  */
 static int _ILJitMethodIsAbstract(ILMethod *method)
@@ -2642,6 +2621,7 @@
 
 #include "jitc_alloc.c"
 #include "jitc_delegate.c"
+#include "jitc_pinvoke.c"
 
 /*
  * Create the signature type for an ILMethod.

Index: engine/Makefile.am
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/engine/Makefile.am,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -b -r1.86 -r1.87
--- engine/Makefile.am  17 Jun 2006 09:24:38 -0000      1.86
+++ engine/Makefile.am  18 Jun 2006 13:09:36 -0000      1.87
@@ -26,6 +26,7 @@
                                jitc_labels.c \
                                jitc_locals.c \
                                jitc_obj.c \
+                               jitc_pinvoke.c \
                                jitc_ptr.c \
                                jitc_setup.c \
                                jitc_stack.c \

Index: engine/jitc_pinvoke.c
===================================================================
RCS file: engine/jitc_pinvoke.c
diff -N engine/jitc_pinvoke.c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ engine/jitc_pinvoke.c       18 Jun 2006 13:09:36 -0000      1.1
@@ -0,0 +1,162 @@
+/*
+ * jitc_pinvoke.c - Handle pinvokes and marshaling within the JIT.
+ *
+ * Copyright (C) 2006  Southern Storm Software, Pty Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+/*
+ * On demand code generator.for functions implemented in IL code.
+ */
+static int _ILJitCompilePinvoke(jit_function_t func)
+{
+       ILMethod *method = (ILMethod *)jit_function_get_meta(func, 
IL_JIT_META_METHOD);
+       ILPInvoke *pinv = ILPInvokeFind(method);
+       jit_abi_t jitAbi;
+#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS) && 
defined(_IL_JIT_ENABLE_DEBUG)
+       ILClass *info = ILMethod_Owner(method);
+       ILClassPrivate *classPrivate = (ILClassPrivate *)info->userData;
+       ILJITCoder *jitCoder = (ILJITCoder *)(classPrivate->process->coder);
+       char *methodName = _ILJitFunctionGetMethodName(func);
+#endif
+       ILJitMethodInfo *jitMethodInfo = (ILJitMethodInfo *)(method->userData);
+       ILJitType signature = jit_function_get_signature(func);
+       ILJitType returnType = jit_type_get_return(signature);
+       unsigned int numParams = jit_type_num_params(signature);
+       ILJitType callSignature;
+       ILJitValue returnValue;
+       ILUInt32 current;
+#ifdef IL_JIT_THREAD_IN_SIGNATURE
+       unsigned int totalParams = numParams - 1;
+#else
+       unsigned int totalParams = numParams;
+#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, "CompilePinvoke: %s\n", methodName);
+               ILMutexUnlock(globalTraceMutex);
+       }
+#endif
+
+       /* TODO */
+       if(!pinv)
+       {
+               /* The pinvoke record could not be found. */
+               return JIT_RESULT_COMPILE_ERROR;
+       }
+
+       /* determine which calling convention to use. */
+       switch(pinv->member.attributes & IL_META_PINVOKE_CALL_CONV_MASK)
+       {
+               case IL_META_PINVOKE_CALL_CONV_WINAPI:
+               {
+                       /* TODO: There is no winapi calling convention in 
libjit. */
+                       jitAbi = IL_JIT_CALLCONV_STDCALL;
+               }
+               break;
+
+               case IL_META_PINVOKE_CALL_CONV_CDECL:
+               {
+                       jitAbi = IL_JIT_CALLCONV_CDECL;
+               }
+               break;
+
+               case IL_META_PINVOKE_CALL_CONV_STDCALL:
+               {
+                       jitAbi = IL_JIT_CALLCONV_STDCALL;
+               }
+               break;
+
+               case IL_META_PINVOKE_CALL_CONV_FASTCALL:
+               {
+                       jitAbi = IL_JIT_CALLCONV_FASTCALL;
+               }
+               break;
+
+               default:
+               {
+                       /* There is an invalid calling convention inthe 
metadata. */
+                       return JIT_RESULT_COMPILE_ERROR;
+               }
+       }
+
+       if(totalParams > 0)
+       {
+               ILJitType paramType;
+               ILJitType jitParamTypes[totalParams];
+               ILJitValue jitParams[totalParams];
+               ILUInt32 param = 0;
+
+#ifdef IL_JIT_THREAD_IN_SIGNATURE
+               for(current = 1; current < numParams; ++current)
+#else
+               for(current = 0; current < numParams; ++current)
+#endif
+               {
+                       paramType = jit_type_get_param(signature, current);
+                       jitParams[param] = jit_value_get_param(func, current);
+                       jitParamTypes[param] = paramType;
+                       ++param;
+               }
+               callSignature = jit_type_create_signature(jitAbi,
+                                                                               
                  returnType,
+                                                                               
                  jitParamTypes,
+                                                                               
                  totalParams, 1);
+
+               returnValue = jit_insn_call_native(func, 0, 
jitMethodInfo->fnInfo.func,
+                                                                               
   callSignature,
+                                                                               
   jitParams, totalParams, 0);
+       }
+       else
+       {
+               callSignature = jit_type_create_signature(jitAbi,
+                                                                               
                  returnType,
+                                                                               
                  0, 0, 1);
+
+               returnValue = jit_insn_call_native(func, 0, 
jitMethodInfo->fnInfo.func,
+                                                                               
   callSignature, 0, 0, 0);
+       }
+       jit_type_free(callSignature);
+       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)
+       {
+               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;
+}
+




reply via email to

[Prev in Thread] Current Thread [Next in Thread]