Author: zoltan
Date: 2005-03-13 07:10:38 -0500 (Sun, 13 Mar 2005)
New Revision: 41756

Modified:
   trunk/mono/mono/mini/ChangeLog
   trunk/mono/mono/mini/mini-amd64.c
   trunk/mono/mono/mini/mini-amd64.h
   trunk/mono/mono/mini/mini-x86.c
   trunk/mono/mono/mini/mini-x86.h
   trunk/mono/mono/mini/mini.c
   trunk/mono/mono/mini/mini.h
   trunk/mono/mono/mini/tramp-amd64.c
   trunk/mono/mono/mini/tramp-ppc.c
   trunk/mono/mono/mini/tramp-s390.c
   trunk/mono/mono/mini/tramp-s390x.c
   trunk/mono/mono/mini/tramp-sparc.c
   trunk/mono/mono/mini/tramp-x86.c
Log:
2005-03-13  Zoltan Varga  <[EMAIL PROTECTED]>

        * mini.h mini.c tramp-*.c: Move common trampoline code to mini.c.

        * mini-x86.h mini-x86.c mini-amd64.h mini-amd64.c: Get rid of the
        tramp_init functions as they are no longer needed.


Modified: trunk/mono/mono/mini/ChangeLog
===================================================================
--- trunk/mono/mono/mini/ChangeLog      2005-03-13 11:11:48 UTC (rev 41755)
+++ trunk/mono/mono/mini/ChangeLog      2005-03-13 12:10:38 UTC (rev 41756)
@@ -1,3 +1,10 @@
+2005-03-13  Zoltan Varga  <[EMAIL PROTECTED]>
+
+       * mini.h mini.c tramp-*.c: Move common trampoline code to mini.c.
+
+       * mini-x86.h mini-x86.c mini-amd64.h mini-amd64.c: Get rid of the
+       tramp_init functions as they are no longer needed.
+
 2005-03-12  Zoltan Varga  <[EMAIL PROTECTED]>
 
        * tramp-amd64.c (mono_amd64_tramp_init): Fix typo.

Modified: trunk/mono/mono/mini/mini-amd64.c
===================================================================
--- trunk/mono/mono/mini/mini-amd64.c   2005-03-13 11:11:48 UTC (rev 41755)
+++ trunk/mono/mono/mini/mini-amd64.c   2005-03-13 12:10:38 UTC (rev 41756)
@@ -667,8 +667,6 @@
        fpcw |= X86_FPCW_PREC_DOUBLE;
        __asm__  __volatile__ ("fldcw %0\n": : "m" (fpcw));
        __asm__  __volatile__ ("fnstcw %0\n": "=m" (fpcw));
-
-       mono_amd64_tramp_init ();
 }
 
 /*

Modified: trunk/mono/mono/mini/mini-amd64.h
===================================================================
--- trunk/mono/mono/mini/mini-amd64.h   2005-03-13 11:11:48 UTC (rev 41755)
+++ trunk/mono/mono/mini/mini-amd64.h   2005-03-13 12:10:38 UTC (rev 41756)
@@ -221,9 +221,6 @@
 #define MONO_ARCH_HAVE_CREATE_TRAMPOLINE_FROM_TOKEN 1
 #define MONO_ARCH_HAVE_CREATE_VARS 1
 
-void
-mono_amd64_tramp_init (void);
-
 gboolean
 mono_amd64_is_sse2 (void);
 

Modified: trunk/mono/mono/mini/mini-x86.c
===================================================================
--- trunk/mono/mono/mini/mini-x86.c     2005-03-13 11:11:48 UTC (rev 41755)
+++ trunk/mono/mono/mini/mini-x86.c     2005-03-13 12:10:38 UTC (rev 41756)
@@ -520,8 +520,6 @@
        fpcw |= X86_FPCW_PREC_DOUBLE;
        __asm__  __volatile__ ("fldcw %0\n": : "m" (fpcw));
        __asm__  __volatile__ ("fnstcw %0\n": "=m" (fpcw));
-
-       mono_x86_tramp_init ();
 }
 
 /*

Modified: trunk/mono/mono/mini/mini-x86.h
===================================================================
--- trunk/mono/mono/mini/mini-x86.h     2005-03-13 11:11:48 UTC (rev 41755)
+++ trunk/mono/mono/mini/mini-x86.h     2005-03-13 12:10:38 UTC (rev 41756)
@@ -159,8 +159,6 @@
 
 #endif
 
-void mono_x86_tramp_init (void);
-
 #define MONO_ARCH_BIGMUL_INTRINS 1
 #define MONO_ARCH_NEED_DIV_CHECK 1
 #define MONO_ARCH_HAVE_IS_INT_OVERFLOW 1

Modified: trunk/mono/mono/mini/mini.c
===================================================================
--- trunk/mono/mono/mini/mini.c 2005-03-13 11:11:48 UTC (rev 41755)
+++ trunk/mono/mono/mini/mini.c 2005-03-13 12:10:38 UTC (rev 41756)
@@ -147,6 +147,14 @@
 
 static GHashTable *jit_icall_name_hash = NULL;
 
+/*
+ * Address of the trampoline code.  This is used by the debugger to check
+ * whether a method is a trampoline.
+ */
+guint8 *mono_generic_trampoline_code = NULL;
+
+static guint8* trampoline_code [MONO_TRAMPOLINE_NUM];
+
 gboolean
 mono_running_on_valgrind (void)
 {
@@ -6783,6 +6791,25 @@
        return callinfo->wrapper;
 }
 
+static void
+mono_init_trampolines (void)
+{
+       trampoline_code [MONO_TRAMPOLINE_GENERIC] = 
mono_arch_create_trampoline_code (MONO_TRAMPOLINE_GENERIC);
+       trampoline_code [MONO_TRAMPOLINE_JUMP] = 
mono_arch_create_trampoline_code (MONO_TRAMPOLINE_JUMP);
+       trampoline_code [MONO_TRAMPOLINE_CLASS_INIT] = 
mono_arch_create_trampoline_code (MONO_TRAMPOLINE_CLASS_INIT);
+#ifdef MONO_ARCH_HAVE_PIC_AOT
+       trampoline_code [MONO_TRAMPOLINE_AOT] = 
mono_arch_create_trampoline_code (MONO_TRAMPOLINE_AOT);
+#endif
+
+       mono_generic_trampoline_code = trampoline_code 
[MONO_TRAMPOLINE_GENERIC];
+}
+
+guint8 *
+mono_get_trampoline_code (MonoTrampolineType tramp_type)
+{
+       return trampoline_code [tramp_type];
+}
+
 gpointer
 mono_create_class_init_trampoline (MonoVTable *vtable)
 {
@@ -9761,6 +9788,8 @@
 
        mono_arch_cpu_init ();
 
+       mono_init_trampolines ();
+
        if (!g_thread_supported ())
                g_thread_init (NULL);
        

Modified: trunk/mono/mono/mini/mini.h
===================================================================
--- trunk/mono/mono/mini/mini.h 2005-03-13 11:11:48 UTC (rev 41755)
+++ trunk/mono/mono/mini/mini.h 2005-03-13 12:10:38 UTC (rev 41756)
@@ -467,6 +467,14 @@
        } data;
 };
 
+typedef enum {
+       MONO_TRAMPOLINE_GENERIC,
+       MONO_TRAMPOLINE_JUMP,
+       MONO_TRAMPOLINE_CLASS_INIT,
+       MONO_TRAMPOLINE_AOT,
+       MONO_TRAMPOLINE_NUM
+} MonoTrampolineType;
+
 /* optimization flags: keep up to date with the name array in driver.c */
 enum {
        MONO_OPT_PEEPHOLE = 1 << 0,
@@ -804,6 +812,7 @@
 MonoJitICallInfo *mono_register_jit_icall      (gconstpointer func, const char 
*name, MonoMethodSignature *sig, gboolean is_save);
 gconstpointer     mono_icall_get_wrapper       (MonoJitICallInfo* callinfo);
 
+guint8 *          mono_get_trampoline_code (MonoTrampolineType tramp_type);
 gpointer          mono_create_jump_trampoline (MonoDomain *domain, 
                                                                                
           MonoMethod *method, 
                                                                                
           gboolean add_sync_wrapper);
@@ -811,6 +820,7 @@
 gpointer          mono_create_jit_trampoline (MonoMethod *method);
 gpointer          mono_create_jit_trampoline_from_token (MonoImage *image, 
guint32 token);
 MonoVTable*       mono_find_class_init_trampoline_by_addr (gconstpointer addr);
+
 gboolean          mono_running_on_valgrind (void);
 void*             mono_global_codeman_reserve (int size);
 gint32*           mono_allocate_stack_slots (MonoCompile *cfg, guint32 
*stack_size, guint32 *stack_align);
@@ -829,6 +839,7 @@
 gpointer  mono_arch_get_rethrow_exception       (void);
 gpointer  mono_arch_get_throw_exception_by_name (void);
 gpointer  mono_arch_get_throw_corlib_exception  (void);
+guchar*   mono_arch_create_trampoline_code      (MonoTrampolineType 
tramp_type);
 gpointer  mono_arch_create_jit_trampoline       (MonoMethod *method);
 gpointer  mono_arch_create_jit_trampoline_from_token (MonoImage *image, 
guint32 token);
 MonoJitInfo *mono_arch_create_jump_trampoline      (MonoMethod *method);

Modified: trunk/mono/mono/mini/tramp-amd64.c
===================================================================
--- trunk/mono/mono/mini/tramp-amd64.c  2005-03-13 11:11:48 UTC (rev 41755)
+++ trunk/mono/mono/mini/tramp-amd64.c  2005-03-13 12:10:38 UTC (rev 41756)
@@ -23,20 +23,7 @@
 #include "mini.h"
 #include "mini-amd64.h"
 
-typedef enum {
-       MONO_TRAMPOLINE_GENERIC,
-       MONO_TRAMPOLINE_JUMP,
-       MONO_TRAMPOLINE_CLASS_INIT,
-       MONO_TRAMPOLINE_AOT
-} MonoTrampolineType;
-
 /*
- * Address of the trampoline code.  This is used by the debugger to check
- * whether a method is a trampoline.
- */
-guint8 *mono_generic_trampoline_code = NULL;
-
-/*
  * get_unbox_trampoline:
  * @m: method pointer
  * @addr: pointer to native code for @m
@@ -234,17 +221,13 @@
        }
 }
 
-static guchar*
-create_trampoline_code (MonoTrampolineType tramp_type)
+guchar*
+mono_arch_create_trampoline_code (MonoTrampolineType tramp_type)
 {
        guint8 *buf, *code, *tramp;
        int i, lmf_offset, offset, method_offset, tramp_offset, 
saved_regs_offset, saved_fpregs_offset, framesize;
        gboolean has_caller;
-       static guint8 *trampoline_code [16];
 
-       if (trampoline_code [tramp_type])
-               return trampoline_code [tramp_type];
-
        if (tramp_type == MONO_TRAMPOLINE_JUMP)
                has_caller = FALSE;
        else
@@ -382,10 +365,6 @@
 
        mono_arch_flush_icache (buf, code - buf);
 
-       if (tramp_type == MONO_TRAMPOLINE_GENERIC)
-               mono_generic_trampoline_code = buf;
-       trampoline_code [tramp_type] = buf;
-
        return buf;
 }
 
@@ -397,7 +376,7 @@
        MonoJitInfo *ji;
        guint8 *code, *buf, *tramp;
 
-       tramp = create_trampoline_code (tramp_type);
+       tramp = mono_arch_create_trampoline_code (tramp_type);
 
        mono_domain_lock (domain);
        code = buf = mono_code_manager_reserve (domain->code_mp, 
TRAMPOLINE_SIZE);
@@ -538,12 +517,3 @@
 
        return ptr;
 }
-
-void
-mono_amd64_tramp_init (void)
-{
-       create_trampoline_code (MONO_TRAMPOLINE_GENERIC);
-       create_trampoline_code (MONO_TRAMPOLINE_JUMP);
-       create_trampoline_code (MONO_TRAMPOLINE_CLASS_INIT);
-       create_trampoline_code (MONO_TRAMPOLINE_AOT);
-}

Modified: trunk/mono/mono/mini/tramp-ppc.c
===================================================================
--- trunk/mono/mono/mini/tramp-ppc.c    2005-03-13 11:11:48 UTC (rev 41755)
+++ trunk/mono/mono/mini/tramp-ppc.c    2005-03-13 12:10:38 UTC (rev 41756)
@@ -21,22 +21,7 @@
 #include "mini.h"
 #include "mini-ppc.h"
 
-typedef enum {
-       MONO_TRAMPOLINE_GENERIC,
-       MONO_TRAMPOLINE_JUMP,
-       MONO_TRAMPOLINE_CLASS_INIT
-} MonoTrampolineType;
-
-/* adapt to mini later... */
-#define mono_jit_share_code (1)
-
 /*
- * Address of the x86 trampoline code.  This is used by the debugger to check
- * whether a method is a trampoline.
- */
-guint8 *mono_generic_trampoline_code = NULL;
-
-/*
  * get_unbox_trampoline:
  * @m: method pointer
  * @addr: pointer to native code for @m
@@ -241,29 +226,12 @@
  *  linkage area
  *  -------------------
  */
-static guchar*
-create_trampoline_code (MonoTrampolineType tramp_type)
+guchar*
+mono_arch_create_trampoline_code (MonoTrampolineType tramp_type)
 {
        guint8 *buf, *code = NULL;
-       static guint8* generic_jump_trampoline = NULL;
-       static guint8 *generic_class_init_trampoline = NULL;
        int i, offset;
 
-       switch (tramp_type) {
-       case MONO_TRAMPOLINE_GENERIC:
-               if (mono_generic_trampoline_code)
-                       return mono_generic_trampoline_code;
-               break;
-       case MONO_TRAMPOLINE_JUMP:
-               if (generic_jump_trampoline)
-                       return generic_jump_trampoline;
-               break;
-       case MONO_TRAMPOLINE_CLASS_INIT:
-               if (generic_class_init_trampoline)
-                       return generic_class_init_trampoline;
-               break;
-       }
-
        if(!code) {
                /* Now we'll create in 'buf' the PowerPC trampoline code. This
                 is the trampoline code common to all methods  */
@@ -416,18 +384,6 @@
                g_assert ((buf - code) <= 512);
        }
 
-       switch (tramp_type) {
-       case MONO_TRAMPOLINE_GENERIC:
-               mono_generic_trampoline_code = code;
-               break;
-       case MONO_TRAMPOLINE_JUMP:
-               generic_jump_trampoline = code;
-               break;
-       case MONO_TRAMPOLINE_CLASS_INIT:
-               generic_class_init_trampoline = code;
-               break;
-       }
-
        return code;
 }
 
@@ -474,7 +430,7 @@
        guint8 *tramp;
        MonoDomain* domain = mono_domain_get ();
        
-       tramp = create_trampoline_code (MONO_TRAMPOLINE_JUMP);
+       tramp = mono_get_trampoline_code (MONO_TRAMPOLINE_JUMP);
        return create_specific_tramp (method, tramp, domain);
 }
 
@@ -505,7 +461,7 @@
        MonoDomain* domain = mono_domain_get ();
        gpointer code_start;
 
-       tramp = create_trampoline_code (MONO_TRAMPOLINE_GENERIC);
+       tramp = mono_get_trampoline_code (MONO_TRAMPOLINE_GENERIC);
        /* FIXME: should pass the domain down to this function */
        ji = create_specific_tramp (method, tramp, domain);
        code_start = ji->code_start;
@@ -530,7 +486,7 @@
 {
        guint8 *code, *buf, *tramp;
 
-       tramp = create_trampoline_code (MONO_TRAMPOLINE_CLASS_INIT);
+       tramp = mono_get_trampoline_code (MONO_TRAMPOLINE_CLASS_INIT);
 
        /* This is the method-specific part of the trampoline. Its purpose is
        to provide the generic part with the MonoMethod *method pointer. We'll

Modified: trunk/mono/mono/mini/tramp-s390.c
===================================================================
--- trunk/mono/mono/mini/tramp-s390.c   2005-03-13 11:11:48 UTC (rev 41755)
+++ trunk/mono/mono/mini/tramp-s390.c   2005-03-13 12:10:38 UTC (rev 41756)
@@ -29,11 +29,6 @@
 #define METHOD_SAVE_OFFSET     S390_RET_ADDR_OFFSET-4
 
 /*------------------------------------------------------------------*/
-/* adapt to mini later...                                          */
-/*------------------------------------------------------------------*/
-#define mono_jit_share_code    (1)
-
-/*------------------------------------------------------------------*/
 /* Method-specific trampoline code fragment sizes                  */
 /*------------------------------------------------------------------*/
 #define METHOD_TRAMPOLINE_SIZE 64
@@ -64,24 +59,12 @@
 /*                 T y p e d e f s                                  */
 /*------------------------------------------------------------------*/
 
-typedef enum {
-       MONO_TRAMPOLINE_GENERIC,
-       MONO_TRAMPOLINE_JUMP,
-       MONO_TRAMPOLINE_CLASS_INIT
-} MonoTrampolineType;
-
 /*========================= End of Typedefs ========================*/
 
 /*------------------------------------------------------------------*/
 /*                   P r o t o t y p e s                            */
 /*------------------------------------------------------------------*/
 
-/*------------------------------------------------------------------*/
-/* Address of the generic trampoline code.  This is used by the     */
-/* debugger to check whether a method is a trampoline.             */
-/*------------------------------------------------------------------*/
-guint8 *mono_generic_trampoline_code = NULL;
-
 /*========================= End of Prototypes ======================*/
 
 /*------------------------------------------------------------------*/
@@ -251,37 +234,20 @@
 
 /*------------------------------------------------------------------*/
 /*                                                                  */
-/* Name                - create_trampoline_code                            */
+/* Name                - mono_arch_create_trampoline_code                      
      */
 /*                                                                  */
 /* Function    - Create the designated type of trampoline according*/
 /*                to the 'tramp_type' parameter.                    */
 /*                                                                  */
 /*------------------------------------------------------------------*/
 
-static guchar*
-create_trampoline_code (MonoTrampolineType tramp_type)
+guchar*
+mono_arch_create_trampoline_code (MonoTrampolineType tramp_type)
 {
 
        guint8 *buf, *code = NULL;
-       static guint8* generic_jump_trampoline = NULL;
-       static guint8 *generic_class_init_trampoline = NULL;
        int i, offset, lmfOffset;
 
-       switch (tramp_type) {
-       case MONO_TRAMPOLINE_GENERIC:
-               if (mono_generic_trampoline_code)
-                       return mono_generic_trampoline_code;
-               break;
-       case MONO_TRAMPOLINE_JUMP:
-               if (generic_jump_trampoline)
-                       return generic_jump_trampoline;
-               break;
-       case MONO_TRAMPOLINE_CLASS_INIT:
-               if (generic_class_init_trampoline)
-                       return generic_class_init_trampoline;
-               break;
-       }
-
        if(!code) {
                /* Now we'll create in 'buf' the S/390 trampoline code. This
                 is the trampoline code common to all methods  */
@@ -455,18 +421,6 @@
                g_assert ((buf - code) <= 512);
        }
 
-       switch (tramp_type) {
-       case MONO_TRAMPOLINE_GENERIC:
-               mono_generic_trampoline_code = code;
-               break;
-       case MONO_TRAMPOLINE_JUMP:
-               generic_jump_trampoline = code;
-               break;
-       case MONO_TRAMPOLINE_CLASS_INIT:
-               generic_class_init_trampoline = code;
-               break;
-       }
-
        return code;
 }
 
@@ -489,7 +443,7 @@
        MonoDomain *domain = mono_domain_get();
        gint32 displace;
 
-       tramp = create_trampoline_code (MONO_TRAMPOLINE_JUMP);
+       tramp = mono_get_trampoline_code (MONO_TRAMPOLINE_JUMP);
 
        mono_domain_lock (domain);
        code = buf = mono_code_manager_reserve (domain->code_mp, 
METHOD_TRAMPOLINE_SIZE);
@@ -553,7 +507,7 @@
        static guint8 *vc = NULL;
        gint32 displace;
 
-       vc = create_trampoline_code (MONO_TRAMPOLINE_GENERIC);
+       vc = mono_get_trampoline_code (MONO_TRAMPOLINE_GENERIC);
 
        /* This is the method-specific part of the trampoline. Its purpose is
        to provide the generic part with the MonoMethod *method pointer. We'll
@@ -601,7 +555,7 @@
 {
        guint8 *code, *buf, *tramp;
 
-       tramp = create_trampoline_code (MONO_TRAMPOLINE_CLASS_INIT);
+       tramp = mono_get_trampoline_code (MONO_TRAMPOLINE_CLASS_INIT);
 
        /*-----------------------------------------------------------*/
        /* This is the method-specific part of the trampoline. Its   */

Modified: trunk/mono/mono/mini/tramp-s390x.c
===================================================================
--- trunk/mono/mono/mini/tramp-s390x.c  2005-03-13 11:11:48 UTC (rev 41755)
+++ trunk/mono/mono/mini/tramp-s390x.c  2005-03-13 12:10:38 UTC (rev 41756)
@@ -29,11 +29,6 @@
 #define METHOD_SAVE_OFFSET     S390_RET_ADDR_OFFSET-8
 
 /*------------------------------------------------------------------*/
-/* adapt to mini later...                                          */
-/*------------------------------------------------------------------*/
-#define mono_jit_share_code    (1)
-
-/*------------------------------------------------------------------*/
 /* Method-specific trampoline code fragment sizes                  */
 /*------------------------------------------------------------------*/
 #define METHOD_TRAMPOLINE_SIZE 64
@@ -64,24 +59,12 @@
 /*                 T y p e d e f s                                  */
 /*------------------------------------------------------------------*/
 
-typedef enum {
-       MONO_TRAMPOLINE_GENERIC,
-       MONO_TRAMPOLINE_JUMP,
-       MONO_TRAMPOLINE_CLASS_INIT
-} MonoTrampolineType;
-
 /*========================= End of Typedefs ========================*/
 
 /*------------------------------------------------------------------*/
 /*                   P r o t o t y p e s                            */
 /*------------------------------------------------------------------*/
 
-/*------------------------------------------------------------------*/
-/* Address of the generic trampoline code.  This is used by the     */
-/* debugger to check whether a method is a trampoline.             */
-/*------------------------------------------------------------------*/
-guint8 *mono_generic_trampoline_code = NULL;
-
 /*========================= End of Prototypes ======================*/
 
 /*------------------------------------------------------------------*/
@@ -232,37 +215,20 @@
 
 /*------------------------------------------------------------------*/
 /*                                                                  */
-/* Name                - create_trampoline_code                            */
+/* Name                - mono_arch_create_trampoline_code                      
      */
 /*                                                                  */
 /* Function    - Create the designated type of trampoline according*/
 /*                to the 'tramp_type' parameter.                    */
 /*                                                                  */
 /*------------------------------------------------------------------*/
 
-static guchar*
-create_trampoline_code (MonoTrampolineType tramp_type)
+guchar*
+mono_arch_create_trampoline_code (MonoTrampolineType tramp_type)
 {
 
        guint8 *buf, *code = NULL;
-       static guint8* generic_jump_trampoline = NULL;
-       static guint8 *generic_class_init_trampoline = NULL;
        int i, offset;
 
-       switch (tramp_type) {
-       case MONO_TRAMPOLINE_GENERIC:
-               if (mono_generic_trampoline_code)
-                       return mono_generic_trampoline_code;
-               break;
-       case MONO_TRAMPOLINE_JUMP:
-               if (generic_jump_trampoline)
-                       return generic_jump_trampoline;
-               break;
-       case MONO_TRAMPOLINE_CLASS_INIT:
-               if (generic_class_init_trampoline)
-                       return generic_class_init_trampoline;
-               break;
-       }
-
        if(!code) {
                /* Now we'll create in 'buf' the S/390 trampoline code. This
                 is the trampoline code common to all methods  */
@@ -373,18 +339,6 @@
                g_assert ((buf - code) <= 512);
        }
 
-       switch (tramp_type) {
-       case MONO_TRAMPOLINE_GENERIC:
-               mono_generic_trampoline_code = code;
-               break;
-       case MONO_TRAMPOLINE_JUMP:
-               generic_jump_trampoline = code;
-               break;
-       case MONO_TRAMPOLINE_CLASS_INIT:
-               generic_class_init_trampoline = code;
-               break;
-       }
-
        return code;
 }
 
@@ -407,7 +361,7 @@
        MonoDomain *domain = mono_domain_get();
        gint32 displace;
 
-       tramp = create_trampoline_code (MONO_TRAMPOLINE_JUMP);
+       tramp = mono_get_trampoline_code (MONO_TRAMPOLINE_JUMP);
 
        mono_domain_lock (domain);
        code = buf = mono_code_manager_reserve (domain->code_mp, 
METHOD_TRAMPOLINE_SIZE);
@@ -471,7 +425,7 @@
        static guint8 *vc = NULL;
        gint32 displace;
 
-       vc = create_trampoline_code (MONO_TRAMPOLINE_GENERIC);
+       vc = mono_get_trampoline_code (MONO_TRAMPOLINE_GENERIC);
 
        /* This is the method-specific part of the trampoline. Its purpose is
        to provide the generic part with the MonoMethod *method pointer. We'll
@@ -521,7 +475,7 @@
 {
        guint8 *code, *buf, *tramp;
 
-       tramp = create_trampoline_code (MONO_TRAMPOLINE_CLASS_INIT);
+       tramp = mono_get_trampoline_code (MONO_TRAMPOLINE_CLASS_INIT);
 
        /* This is the method-specific part of the trampoline. Its purpose is
        to provide the generic part with the MonoMethod *method pointer. We'll

Modified: trunk/mono/mono/mini/tramp-sparc.c
===================================================================
--- trunk/mono/mono/mini/tramp-sparc.c  2005-03-13 11:11:48 UTC (rev 41755)
+++ trunk/mono/mono/mini/tramp-sparc.c  2005-03-13 12:10:38 UTC (rev 41756)
@@ -20,22 +20,7 @@
 #include "mini.h"
 #include "mini-sparc.h"
 
-typedef enum {
-       MONO_TRAMPOLINE_GENERIC,
-       MONO_TRAMPOLINE_JUMP,
-       MONO_TRAMPOLINE_CLASS_INIT
-} MonoTrampolineType;
-
-/* adapt to mini later... */
-#define mono_jit_share_code (1)
-
 /*
- * Address of the Sparc trampoline code.  This is used by the debugger to check
- * whether a method is a trampoline.
- */
-guint8 *mono_generic_trampoline_code = NULL;
-
-/*
  * get_unbox_trampoline:
  * @m: method pointer
  * @addr: pointer to native code for @m
@@ -133,29 +118,12 @@
 
 #define ALIGN_TO(val,align) (((val) + ((align) - 1)) & ~((align) - 1))
 
-static guchar*
-create_trampoline_code (MonoTrampolineType tramp_type)
+guchar*
+mono_arch_create_trampoline_code (MonoTrampolineType tramp_type)
 {
        guint8 *buf, *code, *tramp_addr;
        guint32 lmf_offset, method_reg, i;
-       static guint8* generic_jump_trampoline = NULL;
-       static guint8 *generic_class_init_trampoline = NULL;
 
-       switch (tramp_type) {
-       case MONO_TRAMPOLINE_GENERIC:
-               if (mono_generic_trampoline_code)
-                       return mono_generic_trampoline_code;
-               break;
-       case MONO_TRAMPOLINE_JUMP:
-               if (generic_jump_trampoline)
-                       return generic_jump_trampoline;
-               break;
-       case MONO_TRAMPOLINE_CLASS_INIT:
-               if (generic_class_init_trampoline)
-                       return generic_class_init_trampoline;
-               break;
-       }
-
        code = buf = mono_global_codeman_reserve (512);
 
        sparc_save_imm (code, sparc_sp, -608, sparc_sp);
@@ -257,18 +225,6 @@
 
        g_assert ((code - buf) <= 512);
 
-       switch (tramp_type) {
-       case MONO_TRAMPOLINE_GENERIC:
-               mono_generic_trampoline_code = buf;
-               break;
-       case MONO_TRAMPOLINE_JUMP:
-               generic_jump_trampoline = buf;
-               break;
-       case MONO_TRAMPOLINE_CLASS_INIT:
-               generic_class_init_trampoline = buf;
-               break;
-       }
-
        mono_arch_flush_icache (buf, code - buf);
 
        return buf;
@@ -282,7 +238,7 @@
        MonoJitInfo *ji;
        guint32 *code, *buf, *tramp;
 
-       tramp = create_trampoline_code (tramp_type);
+       tramp = mono_get_trampoline_code (tramp_type);
 
        mono_domain_lock (domain);
        code = buf = mono_code_manager_reserve (domain->code_mp, 
TRAMPOLINE_SIZE * 4);

Modified: trunk/mono/mono/mini/tramp-x86.c
===================================================================
--- trunk/mono/mono/mini/tramp-x86.c    2005-03-13 11:11:48 UTC (rev 41755)
+++ trunk/mono/mono/mini/tramp-x86.c    2005-03-13 12:10:38 UTC (rev 41756)
@@ -24,23 +24,7 @@
 #include "mini.h"
 #include "mini-x86.h"
 
-typedef enum {
-       MONO_TRAMPOLINE_GENERIC,
-       MONO_TRAMPOLINE_JUMP,
-       MONO_TRAMPOLINE_CLASS_INIT,
-       MONO_TRAMPOLINE_AOT
-} MonoTrampolineType;
-
-/* adapt to mini later... */
-#define mono_jit_share_code (1)
-
 /*
- * Address of the x86 trampoline code.  This is used by the debugger to check
- * whether a method is a trampoline.
- */
-guint8 *mono_generic_trampoline_code = NULL;
-
-/*
  * get_unbox_trampoline:
  * @m: method pointer
  * @addr: pointer to native code for @m
@@ -270,15 +254,11 @@
                }
 }
 
-static guchar*
-create_trampoline_code (MonoTrampolineType tramp_type)
+guchar*
+mono_arch_create_trampoline_code (MonoTrampolineType tramp_type)
 {
        guint8 *buf, *code;
-       static guint8 *trampoline_code [16];
 
-       if (trampoline_code [tramp_type])
-               return trampoline_code [tramp_type];
-
        code = buf = mono_global_codeman_reserve (256);
 
        /* save caller save regs because we need to do a call */ 
@@ -364,10 +344,6 @@
 
        g_assert ((buf - code) <= 256);
 
-       if (tramp_type == MONO_TRAMPOLINE_GENERIC)
-               mono_generic_trampoline_code = code;
-       trampoline_code [tramp_type] = code;
-
        return code;
 }
 
@@ -379,7 +355,7 @@
        guint8 *code, *buf, *tramp;
        MonoJitInfo *ji;
        
-       tramp = create_trampoline_code (tramp_type);
+       tramp = mono_get_trampoline_code (tramp_type);
 
        mono_domain_lock (domain);
        code = buf = mono_code_manager_reserve (domain->code_mp, 
TRAMPOLINE_SIZE);
@@ -507,11 +483,3 @@
 
        return ptr;
 }
-
-void
-mono_x86_tramp_init (void)
-{
-       create_trampoline_code (MONO_TRAMPOLINE_GENERIC);
-       create_trampoline_code (MONO_TRAMPOLINE_JUMP);
-       create_trampoline_code (MONO_TRAMPOLINE_CLASS_INIT);
-}

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to