* 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
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;
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 */
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 */
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 */
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);
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)