Add some debug code to help diagnose a buildbot failure.
[mono.git] / mono / mini / tramp-alpha.c
index 2f2882422b6bcaa19570054230013cc71bcf99c7..03b69988788a998f26912740c36c31c5f8dc122e 100644 (file)
@@ -18,9 +18,6 @@
 /*------------------------------------------------------------------*/
 /*                 D e f i n e s                                    */
 /*------------------------------------------------------------------*/
-#define NOT_IMPLEMENTED(x) \
-        g_error ("FIXME: %s is not yet implemented.", x);
-
 #define ALPHA_DEBUG(x) \
        if (mini_alpha_verbose_level) \
                g_debug ("ALPHA_DEBUG: %s is called.", x);
@@ -184,7 +181,7 @@ mono_arch_create_trampoline_code (MonoTrampolineType tramp_type)
       }
     
     // alpha_at points to start of this method !!!
-    alpha_ldq(code, alpha_r0, alpha_at, off);
+    alpha_ldq(code, alpha_pv, alpha_at, off);
     alpha_br(code, alpha_zero, 2);
     
     *code = (unsigned int)(((unsigned long)mono_get_lmf_addr) & 0xFFFFFFFF);
@@ -196,7 +193,7 @@ mono_arch_create_trampoline_code (MonoTrampolineType tramp_type)
      * The call might clobber argument registers, but they are already
      * saved to the stack/global regs.
      */
-    alpha_jsr(code, alpha_ra, alpha_r0, 0);
+    alpha_jsr(code, alpha_ra, alpha_pv, 0);
     
     // Save lmf_addr
     alpha_stq(code, alpha_r0, alpha_sp,
@@ -383,7 +380,7 @@ mono_arch_create_jump_trampoline (MonoMethod *method)
 {
        ALPHA_DEBUG("mono_arch_create_jump_trampoline");
 
-       NOT_IMPLEMENTED("mono_arch_create_jump_trampoline");
+       NOT_IMPLEMENTED;
        
         return 0;
 }
@@ -475,14 +472,12 @@ mono_arch_create_specific_trampoline (gpointer arg1,
   alpha_jmp(code, alpha_zero, alpha_at, 0);
   
   g_assert (((char *)code - (char *)buf) <= TRAMPOLINE_SIZE);
-  mono_domain_lock (domain);
   /*
    * FIXME: Changing the size to code - buf causes strange crashes during
    * mcs bootstrap.
    */
-  real_code = mono_code_manager_reserve (domain->code_mp, TRAMPOLINE_SIZE);
+  real_code = mono_domain_code_reserve (domain, TRAMPOLINE_SIZE);
   size = (char *)code - (char *)buf;
-  mono_domain_unlock (domain);
   
   memcpy (real_code, buf, size);
  
@@ -525,89 +520,8 @@ mono_arch_nullify_class_init_trampoline (guint8 *code, gssize *regs)
       g_assert_not_reached ();
 }
 
-/*
-** This method is called after delegate method is compiled.
-** We need to patch call site to call compiled method directly
-** (not via trampoline stub)
-** Determine address to patch using fp reg
-** 
-*/
-
 void
-mono_arch_patch_delegate_trampoline (guint8 *code, guint8 *tramp,
-                                    gssize *regs, guint8 *addr)
-{
-  unsigned int *pcode = (unsigned int *)code;
-  int reg;
-  short fp_disp, obj_disp;
-  unsigned long *pobj, obj;
-
-  ALPHA_DEBUG("mono_arch_patch_delegate_trampoline");
-
-  // The call signature for now is
-  // -4 - ldq     v0,24(fp)
-  // -3 - ldq     v0,40(v0)
-  // -2 - mov     v0,t12
-  // -1 - jsr     ra,(t12),0x200041476e4
-  //  0 - ldah    gp,0(ra)
-  if (((pcode[-4] & 0xFC000000) == 0xA4000000) &&
-      ((pcode[-3] & 0xFC000000) == 0xA4000000) &&
-      ((pcode[-2] & 0xFC000FE0) == 0x44000400) &&
-      ((pcode[-1] & 0xFFFF0000) == 0x6B5B0000))
-    {
-      fp_disp = (pcode[-4] & 0xFFFF);
-      obj_disp = (pcode[-3] & 0xFFFF);
-
-      pobj = regs[15] + fp_disp;
-      obj = *pobj;
-      reg = 0;
-    }
-    // The non-optimized call signature for now is
-    // -5 - ldq     v0,24(fp)
-    // -4 - mov     v0,v0
-    // -3 - ldq     v0,40(v0)
-    // -2 - mov     v0,t12
-    // -1 - jsr     ra,(t12),0x200041476e4
-    //  0 - ldah    gp,0(ra)
-  else if (((pcode[-5] & 0xFC000000) == 0xA4000000) &&
-          ((pcode[-4] & 0xFC000FE0) == 0x44000400) &&
-          ((pcode[-3] & 0xFC000000) == 0xA4000000) &&
-          ((pcode[-2] & 0xFC000FE0) == 0x44000400) &&
-          ((pcode[-1] & 0xFFFF0000) == 0x6B5B0000))
-    {
-      fp_disp = (pcode[-5] & 0xFFFF);
-      obj_disp = (pcode[-3] & 0xFFFF);
-
-      pobj = regs[15] + fp_disp;
-      obj = *pobj;
-      reg = 0;
-    }
-      // Code with linears optimization
-      // -4 - mov     reg,v0
-      // -3 - ldq     v0,40(v0)
-      // -2 - mov     v0,t12
-      // -1 - jsr     ra,(t12)
-      //  0 - ldah    gp,0(ra)
-  else if (((pcode[-4] & 0xFC000FE0) == 0x44000400) &&
-          ((pcode[-3] & 0xFC000000) == 0xA4000000) &&
-          ((pcode[-2] & 0xFC000FE0) == 0x44000400) &&
-          ((pcode[-1] & 0xFFFF0000) == 0x6B5B0000))
-    {
-      fp_disp = (pcode[-4] >> AXP_REG2_SHIFT) & AXP_REG_MASK;
-      obj_disp = (pcode[-3] & 0xFFFF);
-
-      obj = regs[fp_disp];
-      //obj = *pobj;
-      reg = 0;
-    }
-  else
-    g_assert_not_reached ();
-
-  *((gpointer*)(obj + obj_disp)) = addr;
-}
-
-void
-mono_arch_patch_callsite (guint8 *code, guint8 *addr)
+mono_arch_patch_callsite (guint8 *method_start, guint8 *code, guint8 *addr)
 {
   unsigned long *p = (unsigned int *)(code-12);
   
@@ -654,6 +568,7 @@ mono_arch_patch_callsite (guint8 *code, guint8 *addr)
 
 /*
  * mono_arch_get_unbox_trampoline:
+ * @gsctx: the generic sharing context
  * @m: method pointer
  * @addr: pointer to native code for @m
  *
@@ -662,7 +577,7 @@ mono_arch_patch_callsite (guint8 *code, guint8 *addr)
  * unboxing before calling the method
  */
 gpointer
-mono_arch_get_unbox_trampoline (MonoMethod *m, gpointer addr)
+mono_arch_get_unbox_trampoline (MonoGenericSharingContext *gsctx, MonoMethod *m, gpointer addr)
 {
   unsigned int *code, *start_code;
   int this_reg = 16; //R16
@@ -671,13 +586,10 @@ mono_arch_get_unbox_trampoline (MonoMethod *m, gpointer addr)
 
   ALPHA_DEBUG("mono_arch_get_unbox_trampoline");
 
-  if (!mono_method_signature (m)->ret->byref &&
-      MONO_TYPE_ISSTRUCT (mono_method_signature (m)->ret))
+  if (MONO_TYPE_ISSTRUCT (mono_method_signature (m)->ret))
     this_reg = 17; //R17
 
-  mono_domain_lock (domain);
-  start_code = code = (unsigned int *)mono_code_manager_reserve (domain->code_mp, 32);
-  mono_domain_unlock (domain);
+  start_code = code = (unsigned int *)mono_domain_code_reserve (domain, 32);
 
   // Adjust this by size of MonoObject
   alpha_addq_(code, this_reg, sizeof(MonoObject), this_reg);  // 0
@@ -713,25 +625,10 @@ mono_arch_patch_plt_entry (guint8 *code, guint8 *addr)
         g_assert_not_reached ();
 }
 
-/*
- * This method is only called when running in the Mono Debugger.
- */
 gpointer
-mono_debugger_create_notification_function (void)
+mono_arch_create_rgctx_lazy_fetch_trampoline (guint32 encoded_offset)
 {
-  guint8 *code;
-  unsigned int *buf;
-
-  code = mono_global_codeman_reserve (16);
-  buf = (unsigned int *)code;
-
-  *buf = 0;
-
-  alpha_call_pal(buf, 0x80);
-  alpha_ret(buf, alpha_ra, 1);
-  //x86_breakpoint (buf);
-  //x86_ret (buf);
-
-  return code;
+       /* FIXME: implement! */
+       g_assert_not_reached ();
+       return NULL;
 }
-