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

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

[Dotgnu-pnet-commits] CVS: pnet/engine gen_marshal.tc, NONE, 1.1 .cvsign


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnet/engine gen_marshal.tc, NONE, 1.1 .cvsignore, 1.3, 1.4 Makefile.am, 1.63, 1.64 cvmc.c, 1.41, 1.42 cvmc_ptr.c, 1.10, 1.11 cvmc_setup.c, 1.35, 1.36 null_coder.c, 1.22, 1.23 verify.c, 1.43, 1.44
Date: Sun, 27 Jul 2003 23:56:26 -0400

Update of /cvsroot/dotgnu-pnet/pnet/engine
In directory subversions:/tmp/cvs-serv26273/engine

Modified Files:
        .cvsignore Makefile.am cvmc.c cvmc_ptr.c cvmc_setup.c 
        null_coder.c verify.c 
Added Files:
        gen_marshal.tc 
Log Message:


Start adding support for a treecc-based marshalling system,
to eventually replace the "CVMCoder_SetupExtern" mess.


--- NEW FILE ---
%both %{
/*
 * gen_marshal.tc - Generate marshalling code from PInvoke/internalcall's.
 *
 * Copyright (C) 2003  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
[...1053 lines suppressed...]

        /* Generate the code */
        ILM_GenValue(node, &context);

        /* Reset for the constructor form of the method */
        ILM_ClearLocals(node, &context);
        context.isConstructor = 1;
        ILM_AllocLocals(node, &context);

        /* Generate the constructor code */
        ILM_GenValue(node, &context);

        /* TODO: method footer code */

        /* Clean up and exit */
        ShutdownNativeMethod(&(state.state));
        return 0;
}

%}

Index: .cvsignore
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/.cvsignore,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** .cvsignore  12 May 2002 06:59:45 -0000      1.3
--- .cvsignore  28 Jul 2003 03:56:24 -0000      1.4
***************
*** 9,10 ****
--- 9,12 ----
  cvm_opt.s.tmp
  cvm_labels.h
+ gen_marshal.c
+ gen_marshal.h

Index: Makefile.am
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/Makefile.am,v
retrieving revision 1.63
retrieving revision 1.64
diff -C2 -r1.63 -r1.64
*** Makefile.am 22 Jul 2003 11:10:31 -0000      1.63
--- Makefile.am 28 Jul 2003 03:56:24 -0000      1.64
***************
*** 12,15 ****
--- 12,16 ----
                                                cvmc.c \
                                                dumpconfig.c \
+                                               gen_marshal.c \
                                                heap.c \
                                                internal.c \
***************
*** 102,104 ****
        $(SHELL) $(srcdir)/mklabel.sh "$(AWK)" $(srcdir)/cvm.h >cvm_labels.h
  
! CLEANFILES = cvm_opt.s cvm_opt.s.tmp asmfix ilrun_opt cvm_labels.h
--- 103,109 ----
        $(SHELL) $(srcdir)/mklabel.sh "$(AWK)" $(srcdir)/cvm.h >cvm_labels.h
  
! $(srcdir)/gen_marshal.c: $(srcdir)/gen_marshal.tc
!       $(TREECC) -f -o $(srcdir)/gen_marshal.c -h $(srcdir)/gen_marshal.h \
!                       $(srcdir)/gen_marshal.tc
! 
! CLEANFILES = cvm_labels.h $(srcdir)/gen_marshal.c $(srcdir)/gen_marshal.h

Index: cvmc.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/cvmc.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -C2 -r1.41 -r1.42
*** cvmc.c      22 Jun 2003 17:16:44 -0000      1.41
--- cvmc.c      28 Jul 2003 03:56:24 -0000      1.42
***************
*** 80,83 ****
--- 80,85 ----
        int                             debugEnabled;
        int                             flags;
+       long                    nativeArgPosn;
+       long                    nativeArgHeight;
  };
  
***************
*** 162,165 ****
--- 164,170 ----
        coder->debugEnabled = 0;
        coder->flags = 0;
+       coder->nativeArgPosn = 0;
+       coder->nativeArgHeight = 0;
+ 
        /* Call the interpreter to export the label tables for
           use in code generation for direct threading */
***************
*** 440,443 ****
--- 445,456 ----
        CVMCoder_MarkEnd,
        CVMCoder_SetFlags,
+       CVMCoder_AllocExtraLocal,
+       CVMCoder_PushThread,
+       CVMCoder_LoadNativeArgAddr,
+       CVMCoder_LoadNativeLocalAddr,
+       CVMCoder_StartFfiArgs,
+       CVMCoder_PushRawArgPointer,
+       CVMCoder_CallFfi,
+       CVMCoder_CheckNull,
        "sentinel"
  };

Index: cvmc_ptr.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/cvmc_ptr.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** cvmc_ptr.c  29 Jun 2002 11:26:03 -0000      1.10
--- cvmc_ptr.c  28 Jul 2003 03:56:24 -0000      1.11
***************
*** 628,630 ****
--- 628,638 ----
  }
  
+ /*
+  * Check the top of stack value for NULL.
+  */
+ static void CVMCoder_CheckNull(ILCoder *coder)
+ {
+       CVM_OUT_NONE(COP_CKNULL);
+ }
+ 
  #endif        /* IL_CVMC_CODE */

Index: cvmc_setup.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/cvmc_setup.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -C2 -r1.35 -r1.36
*** cvmc_setup.c        21 Jul 2003 07:31:55 -0000      1.35
--- cvmc_setup.c        28 Jul 2003 03:56:24 -0000      1.36
***************
*** 1365,1367 ****
--- 1365,1489 ----
  }
  
+ /*
+  * Allocate an extra local variable in the current method frame.
+  * Returns the local variable index.
+  */
+ static ILUInt32 CVMCoder_AllocExtraLocal(ILCoder *coder, ILType *type)
+ {
+       /* TODO */
+       return 0;
+ }
+ 
+ /*
+  * Push a thread value onto the stack for an internalcall.
+  */
+ static void CVMCoder_PushThread(ILCoder *_coder, int useRawCalls)
+ {
+       ILCVMCoder *coder = (ILCVMCoder *)_coder;
+       if(useRawCalls)
+       {
+               CVM_OUT_NONE(COP_PUSH_THREAD_RAW);
+               CVM_ADJUST(1);
+       }
+       else
+       {
+               CVM_OUT_NONE(COP_PUSH_THREAD);
+               ++(coder->nativeArgPosn);
+       }
+ }
+ 
+ /*
+  * Load the address of an argument onto the native argument stack.
+  */
+ static void CVMCoder_LoadNativeArgAddr(ILCoder *_coder, ILUInt32 num)
+ {
+       ILCVMCoder *coder = (ILCVMCoder *)_coder;
+       ILUInt32 offset = ((ILCVMCoder *)coder)->argOffsets[num];
+       if(coder->nativeArgPosn < 8)
+       {
+               CVM_OUT_WIDE(COP_WADDR_NATIVE_0 + coder->nativeArgPosn, offset);
+       }
+       else
+       {
+               CVMP_OUT_WORD2(COP_PREFIX_WADDR_NATIVE_N,
+                                          
(ILUInt32)(ILInt32)(coder->nativeArgPosn),
+                                          offset);
+       }
+       ++(coder->nativeArgPosn);
+ }
+ 
+ /*
+  * Load the address of a local onto the native argument stack.
+  */
+ static void CVMCoder_LoadNativeLocalAddr(ILCoder *_coder, ILUInt32 num)
+ {
+       ILCVMCoder *coder = (ILCVMCoder *)_coder;
+       ILUInt32 offset = ((ILCVMCoder *)coder)->localOffsets[num];
+       if(coder->nativeArgPosn < 8)
+       {
+               CVM_OUT_WIDE(COP_WADDR_NATIVE_0 + coder->nativeArgPosn, offset);
+       }
+       else
+       {
+               CVMP_OUT_WORD2(COP_PREFIX_WADDR_NATIVE_N,
+                                          
(ILUInt32)(ILInt32)(coder->nativeArgPosn),
+                                          offset);
+       }
+       ++(coder->nativeArgPosn);
+ }
+ 
+ /*
+  * Start pushing arguments for a "libffi" call onto the stack.
+  */
+ static void CVMCoder_StartFfiArgs(ILCoder *_coder)
+ {
+       ILCVMCoder *coder = (ILCVMCoder *)_coder;
+       coder->nativeArgPosn = -1;
+       coder->nativeArgHeight = coder->height;
+ }
+ 
+ /*
+  * Push the address of the raw argument block onto the stack.
+  */
+ static void CVMCoder_PushRawArgPointer(ILCoder *_coder)
+ {
+       ILCVMCoder *coder = (ILCVMCoder *)_coder;
+       ILUInt32 height = (ILUInt32)(coder->height - coder->nativeArgHeight);
+       CVM_OUT_WIDE(COP_MADDR, height);
+       CVM_ADJUST(1);
+ }
+ 
+ /*
+  * Perform a function call using "libffi".
+  */
+ static void CVMCoder_CallFfi(ILCoder *coder, void *fn, void *cif,
+                                                        int useRawCalls, int 
hasReturn)
+ {
+       if(useRawCalls)
+       {
+               if(hasReturn)
+               {
+                       CVM_OUT_PTR2(COP_CALL_NATIVE_RAW, fn, cif);
+                       CVM_ADJUST(-2);
+               }
+               else
+               {
+                       CVM_OUT_PTR2(COP_CALL_NATIVE_VOID_RAW, fn, cif);
+                       CVM_ADJUST(-1);
+               }
+       }
+       else
+       {
+               if(hasReturn)
+               {
+                       CVM_OUT_PTR2(COP_CALL_NATIVE, fn, cif);
+                       CVM_ADJUST(-1);
+               }
+               else
+               {
+                       CVM_OUT_PTR2(COP_CALL_NATIVE_VOID, fn, cif);
+               }
+       }
+ }
+ 
  #endif        /* IL_CVMC_CODE */

Index: null_coder.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/null_coder.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -r1.22 -r1.23
*** null_coder.c        22 Jun 2003 17:16:44 -0000      1.22
--- null_coder.c        28 Jul 2003 03:56:24 -0000      1.23
***************
*** 373,376 ****
--- 373,402 ----
  {
  }
+ static ILUInt32 Coder_AllocExtraLocal(ILCoder *coder, ILType *type)
+ {
+       return 0;
+ }
+ static void Coder_PushThread(ILCoder *coder, int useRawCalls)
+ {
+ }
+ static void Coder_LoadNativeArgAddr(ILCoder *coder, ILUInt32 num)
+ {
+ }
+ static void Coder_LoadNativeLocalAddr(ILCoder *coder, ILUInt32 num)
+ {
+ }
+ static void Coder_StartFfiArgs(ILCoder *coder)
+ {
+ }
+ static void Coder_PushRawArgPointer(ILCoder *coder)
+ {
+ }
+ static void Coder_CallFfi(ILCoder *coder, void *fn, void *cif,
+                                                 int useRawCalls, int 
hasReturn)
+ {
+ }
+ static void Coder_CheckNull(ILCoder *coder)
+ {
+ }
  
  /*
***************
*** 470,473 ****
--- 496,507 ----
        Coder_MarkEnd,
        Coder_SetFlags,
+       Coder_AllocExtraLocal,
+       Coder_PushThread,
+       Coder_LoadNativeArgAddr,
+       Coder_LoadNativeLocalAddr,
+       Coder_StartFfiArgs,
+       Coder_PushRawArgPointer,
+       Coder_CallFfi,
+       Coder_CheckNull,
        "sentinel"
  };

Index: verify.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/verify.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -C2 -r1.43 -r1.44
*** verify.c    19 Jun 2003 12:19:40 -0000      1.43
--- verify.c    28 Jul 2003 03:56:24 -0000      1.44
***************
*** 243,246 ****
--- 243,250 ----
        return ILEngineType_O;
  }
+ ILEngineType _ILTypeToEngineType(ILType *type)
+ {
+       return TypeToEngineType(type);
+ }
  
  /*





reply via email to

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