2007-12-07 Zoltan Varga <vargaz@gmail.com>
authorZoltan Varga <vargaz@gmail.com>
Fri, 7 Dec 2007 15:47:37 +0000 (15:47 -0000)
committerZoltan Varga <vargaz@gmail.com>
Fri, 7 Dec 2007 15:47:37 +0000 (15:47 -0000)
* mini.h mini-amd64.c mini-x86.c: Get rid of the mono_arch_find_vtable ()
function.

* tramp-x86.c tramp-amd64.c mini-trampolines.c: Pass the vtable argument to
mono_generic_class_init_trampoline () the same as it is done with the other
trampolines.

svn path=/trunk/mono/; revision=90946

mono/mini/ChangeLog
mono/mini/mini-amd64.c
mono/mini/mini-trampolines.c
mono/mini/mini-x86.c
mono/mini/mini.h
mono/mini/tramp-amd64.c
mono/mini/tramp-x86.c

index b5a2fbfe9d395ceeb8513a6e7de7a2fe67eb65bc..ba753045cd17ec496131a4a0e74b84246eba5eb5 100644 (file)
@@ -1,5 +1,12 @@
 2007-12-07  Zoltan Varga  <vargaz@gmail.com>
 
+       * mini.h mini-amd64.c mini-x86.c: Get rid of the mono_arch_find_vtable () 
+       function.
+
+       * tramp-x86.c tramp-amd64.c mini-trampolines.c: Pass the vtable argument to
+       mono_generic_class_init_trampoline () the same as it is done with the other
+       trampolines.
+
        * mini-arm.h mini-arm.c tramp-arm.c inssel-arm.brg cpu-arm.md 
        aot-runtime.c aot-compiler.c: Implement AOT support.    
 
index 43c2e2cd9000f143f4d20fb9264ed4cfcf18140a..324e0f6b971aab61b766a15ecf8689a514d41d84 100644 (file)
@@ -5772,12 +5772,6 @@ mono_arch_find_this_argument (gpointer *regs, MonoMethod *method)
 }
 #endif
 
-MonoVTable*
-mono_arch_find_vtable (gpointer *regs, guint8 *code)
-{
-       return (MonoVTable*) regs [MONO_ARCH_VTABLE_REG];
-}
-
 MonoInst*
 mono_arch_get_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsig, MonoInst **args)
 {
index 961a554fc3fa01d7e7cc925996918e922029fdbe..ab02b56c4a952ba4073180508e1162da03b73849 100644 (file)
@@ -296,22 +296,16 @@ mono_class_init_trampoline (gssize *regs, guint8 *code, MonoVTable *vtable, guin
  * mono_generic_class_init_trampoline:
  *
  * This method calls mono_runtime_class_init () to run the static constructor
- * for the type, then patches the caller code so it is not called again.
+ * for the type.
  */
 void
-mono_generic_class_init_trampoline (gssize *regs, guint8 *code, gpointer dummy, guint8 *tramp)
+mono_generic_class_init_trampoline (gssize *regs, guint8 *code, MonoVTable *vtable, guint8 *tramp)
 {
-#ifdef MONO_ARCH_VTABLE_REG
-       MonoVTable *vtable = mono_arch_find_vtable ((gpointer*)regs, code);
-
-       //g_print ("generic class init for class %s.%s\n", vtable->klass->name_space, vtable->klass->name);
+       g_print ("generic class init for class %s.%s\n", vtable->klass->name_space, vtable->klass->name);
 
        mono_runtime_class_init (vtable);
 
        //g_print ("done initing generic\n");
-#else
-       g_assert_not_reached ();
-#endif
 }
 
 #ifdef MONO_ARCH_HAVE_CREATE_DELEGATE_TRAMPOLINE
index db64d448cf648c94abd448fc057d287c3ef8cf69..d2f154658ae0c348b7d7c6b124686ec000087859 100644 (file)
@@ -4371,12 +4371,6 @@ mono_arch_find_this_argument (gpointer *regs, MonoMethod *method)
 }
 #endif
 
-MonoVTable*
-mono_arch_find_vtable (gpointer *regs, guint8 *code)
-{
-       return (MonoVTable*) regs [MONO_ARCH_VTABLE_REG];
-}
-
 MonoInst*
 mono_arch_get_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsig, MonoInst **args)
 {
index a10f58dfd364f4cb8c38dd83392ac46e28915e3b..670774f2743b3ab9d0b633c84729569dc9393cf8 100644 (file)
@@ -964,7 +964,7 @@ gpointer          mono_aot_trampoline (gssize *regs, guint8 *code, guint8 *token
 gpointer          mono_aot_plt_trampoline (gssize *regs, guint8 *code, guint8 *token_info, 
                                                                                   guint8* tramp) MONO_INTERNAL;
 void              mono_class_init_trampoline (gssize *regs, guint8 *code, MonoVTable *vtable, guint8 *tramp) MONO_INTERNAL;
-void              mono_generic_class_init_trampoline (gssize *regs, guint8 *code, gpointer dummy, guint8 *tramp) MONO_INTERNAL;
+void              mono_generic_class_init_trampoline (gssize *regs, guint8 *code, MonoVTable *vtable, guint8 *tramp) MONO_INTERNAL;
 gconstpointer     mono_get_trampoline_func (MonoTrampolineType tramp_type);
 gpointer          mini_get_vtable_trampoline (void) MONO_INTERNAL;
 gpointer          mono_debugger_create_notification_function (void) MONO_INTERNAL;
@@ -1063,7 +1063,6 @@ gpointer mono_arch_create_specific_trampoline   (gpointer arg1, MonoTrampolineTy
 void        mono_arch_emit_imt_argument         (MonoCompile *cfg, MonoCallInst *call) MONO_INTERNAL;
 MonoMethod* mono_arch_find_imt_method           (gpointer *regs, guint8 *code) MONO_INTERNAL;
 MonoObject* mono_arch_find_this_argument        (gpointer *regs, MonoMethod *method) MONO_INTERNAL;
-MonoVTable* mono_arch_find_vtable              (gpointer *regs, guint8 *code) MONO_INTERNAL;
 gpointer    mono_arch_build_imt_thunk           (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem **imt_entries, int count) MONO_INTERNAL;
 
 /* Exception handling */
index acc21fee792faa0864e9d5e24717d033b4ae8c5d..71338d0e96f1b7d0d540fc545e9e2ee22cc79966 100644 (file)
@@ -202,18 +202,16 @@ mono_arch_create_trampoline_code (MonoTrampolineType tramp_type)
        amd64_mov_reg_reg (code, AMD64_RBP, AMD64_RSP, 8);
        amd64_alu_reg_imm (code, X86_SUB, AMD64_RSP, framesize);
 
-       if (tramp_type != MONO_TRAMPOLINE_GENERIC_CLASS_INIT) {
-               offset += 8;
-               tramp_offset = - offset;
+       offset += 8;
+       tramp_offset = - offset;
 
-               offset += 8;
-               method_offset = - offset;
+       offset += 8;
+       method_offset = - offset;
 
-               /* Compute the trampoline address from the return address */
-               /* 5 = length of amd64_call_membase () */
-               amd64_alu_reg_imm (code, X86_SUB, AMD64_R11, 5);
-               amd64_mov_membase_reg (code, AMD64_RBP, tramp_offset, AMD64_R11, 8);
-       }
+       /* Compute the trampoline address from the return address */
+       /* 5 = length of amd64_call_membase () */
+       amd64_alu_reg_imm (code, X86_SUB, AMD64_R11, 5);
+       amd64_mov_membase_reg (code, AMD64_RBP, tramp_offset, AMD64_R11, 8);
 
        /* Save all registers */
 
@@ -243,6 +241,8 @@ mono_arch_create_trampoline_code (MonoTrampolineType tramp_type)
                amd64_mov_reg_membase (code, AMD64_R11, AMD64_R11, 6, 8);
                mono_amd64_patch (br [1], code);
                amd64_mov_membase_reg (code, AMD64_RBP, method_offset, AMD64_R11, 8);
+       } else {
+               amd64_mov_membase_reg (code, AMD64_RBP, method_offset, MONO_ARCH_VTABLE_REG, 8);
        }
 
        /* Save LMF begin */
@@ -263,11 +263,9 @@ mono_arch_create_trampoline_code (MonoTrampolineType tramp_type)
        amd64_mov_reg_reg (code, AMD64_R11, AMD64_RSP, 8);
        amd64_alu_reg_imm (code, X86_ADD, AMD64_R11, framesize + 16);
        amd64_mov_membase_reg (code, AMD64_RBP, lmf_offset + G_STRUCT_OFFSET (MonoLMF, rsp), AMD64_R11, 8);
-       if (tramp_type != MONO_TRAMPOLINE_GENERIC_CLASS_INIT) {
-               /* Save method */
-               amd64_mov_reg_membase (code, AMD64_R11, AMD64_RBP, method_offset, 8);
-               amd64_mov_membase_reg (code, AMD64_RBP, lmf_offset + G_STRUCT_OFFSET (MonoLMF, method), AMD64_R11, 8);
-       }
+       /* Save method */
+       amd64_mov_reg_membase (code, AMD64_R11, AMD64_RBP, method_offset, 8);
+       amd64_mov_membase_reg (code, AMD64_RBP, lmf_offset + G_STRUCT_OFFSET (MonoLMF, method), AMD64_R11, 8);
        /* Save callee saved regs */
 #ifdef PLATFORM_WIN32
        amd64_mov_membase_reg (code, AMD64_RBP, lmf_offset + G_STRUCT_OFFSET (MonoLMF, rdi), AMD64_RDI, 8);
@@ -302,11 +300,8 @@ mono_arch_create_trampoline_code (MonoTrampolineType tramp_type)
        else
                amd64_mov_reg_imm (code, AMD64_ARG_REG2, 0);
 
-       /* Arg3 is the method ptr / dummy */
-       if (tramp_type == MONO_TRAMPOLINE_GENERIC_CLASS_INIT)
-               amd64_mov_reg_imm (code, AMD64_ARG_REG3, 0);
-       else
-               amd64_mov_reg_membase (code, AMD64_ARG_REG3, AMD64_RBP, method_offset, 8);
+       /* Arg3 is the method/vtable ptr */
+       amd64_mov_reg_membase (code, AMD64_ARG_REG3, AMD64_RBP, method_offset, 8);
 
        /* Arg4 is the trampoline address */
        if (tramp_type == MONO_TRAMPOLINE_GENERIC_CLASS_INIT)
index f789e6756554d54d4b364c9c9445e42785fbb391..5b903583673a55e701ed840705adda8b37e86f31 100644 (file)
@@ -192,13 +192,10 @@ mono_arch_create_trampoline_code (MonoTrampolineType tramp_type)
         */
 
        /* If this is a generic class init the argument is not on the
-        * stack yet but in MONO_ARCH_VTABLE_REG and is accessed by
-        * the callee via the register array.  As a dummy argument we
-        * pass it NULL, which we push here, and then everything that
-        * follows works the same way.
+        * stack yet but in MONO_ARCH_VTABLE_REG.
         */
        if (tramp_type == MONO_TRAMPOLINE_GENERIC_CLASS_INIT)
-               x86_push_imm (buf, 0);
+               x86_push_reg (buf, MONO_ARCH_VTABLE_REG);
 
        /* Put all registers into an array on the stack
         * If this code is changed, make sure to update the offset value in