- guint8 *code, *buf, *tramp;
-
- tramp = create_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. */
- //code = buf = g_malloc(METHOD_TRAMPOLINE_SIZE);
- mono_domain_lock (vtable->domain);
- code = buf = mono_code_manager_reserve (vtable->domain->code_mp, METHOD_TRAMPOLINE_SIZE);
- mono_domain_unlock (vtable->domain);
-
- ppc_mflr (buf, ppc_r4);
- ppc_stw (buf, ppc_r4, PPC_RET_ADDR_OFFSET, ppc_sp);
- ppc_stwu (buf, ppc_sp, -64, ppc_sp);
- ppc_load (buf, ppc_r3, vtable);
- ppc_load (buf, ppc_r5, 0);
-
- ppc_load (buf, ppc_r0, ppc_class_init_trampoline);
- ppc_mtlr (buf, ppc_r0);
- ppc_blrl (buf);
-
- ppc_lwz (buf, ppc_r0, 64 + PPC_RET_ADDR_OFFSET, ppc_sp);
- ppc_mtlr (buf, ppc_r0);
- ppc_addic (buf, ppc_sp, ppc_sp, 64);
- ppc_blr (buf);
-
- /* Flush instruction cache, since we've generated code */
- mono_arch_flush_icache (code, buf - code);
-
- /* Sanity check */
- g_assert ((buf - code) <= METHOD_TRAMPOLINE_SIZE);
-
- mono_jit_stats.method_trampolines++;
-
- return code;