- guint8 *code, *buf, *tramp;
-
- 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
- use r11 to keep that value, for instance. However, the generic part of
- the trampoline relies on r11 having the same value it had before coming
- here, so we must save it before. */
- mono_domain_lock (vtable->domain);
- code = buf = mono_code_manager_reserve (vtable->domain->code_mp, METHOD_TRAMPOLINE_SIZE);
- mono_domain_unlock (vtable->domain);
-
- //g_print ("mips_class_init_tramp buf=%p tramp=%p\n", buf, tramp);
-
- mips_addiu (code, mips_sp, mips_sp, -MIPS_MINIMAL_STACK_SIZE);
- mips_sw (code, mips_ra, mips_sp, MIPS_MINIMAL_STACK_SIZE + MIPS_RET_ADDR_OFFSET);
-
- /* Probably need to save/restore a0-a3 here */
-
- mips_load (code, mips_a0, vtable);
- mips_move (code, mips_a1, mips_ra);
- mips_move (code, mips_a2, mips_zero);
-
- mips_load (code, mips_t9, mips_class_init_trampoline);
- mips_jalr (code, mips_t9, mips_ra);
- mips_nop (code);
-
- mips_lw (code, mips_ra, mips_sp, MIPS_MINIMAL_STACK_SIZE + MIPS_RET_ADDR_OFFSET);
- mips_addiu (code, mips_sp, mips_sp, MIPS_MINIMAL_STACK_SIZE);
- mips_jr (code, mips_ra);
- mips_nop (code);
-
- /* Flush instruction cache, since we've generated code */
- mono_arch_flush_icache (buf, code - buf);
-
- /* Sanity check */
- g_assert ((code - buf) <= METHOD_TRAMPOLINE_SIZE);
- mono_jit_stats.method_trampolines++;
-
- return buf;