2 * tramp-ppc.c: JIT trampoline code for PowerPC
5 * Dietmar Maurer (dietmar@ximian.com)
6 * Paolo Molaro (lupus@ximian.com)
7 * Carlos Valiente <yo@virutass.net>
8 * Andreas Faerber <andreas.faerber@web.de>
10 * (C) 2001 Ximian, Inc.
11 * (C) 2007-2008 Andreas Faerber
17 #include <mono/metadata/appdomain.h>
18 #include <mono/metadata/marshal.h>
19 #include <mono/metadata/tabledefs.h>
20 #include <mono/arch/ppc/ppc-codegen.h>
25 static guint8* nullified_class_init_trampoline;
27 /* Same as mono_create_ftnptr, but doesn't require a domain */
29 mono_ppc_create_ftnptr (guint8 *code)
31 #ifdef PPC_USES_FUNCTION_DESCRIPTOR
32 MonoPPCFunctionDescriptor *ftnptr = mono_global_codeman_reserve (sizeof (MonoPPCFunctionDescriptor));
45 * Return the instruction to jump from code to target, 0 if not
46 * reachable with a single instruction
49 branch_for_target_reachable (guint8 *branch, guint8 *target)
51 gint diff = target - branch;
52 g_assert ((diff & 3) == 0);
55 return (18 << 26) | (diff);
57 /* diff between 0 and -33554432 */
58 if (diff >= -33554432)
59 return (18 << 26) | (diff & ~0xfc000000);
65 * get_unbox_trampoline:
66 * @gsctx: the generic sharing context
68 * @addr: pointer to native code for @m
70 * when value type methods are called through the vtable we need to unbox the
71 * this argument. This method returns a pointer to a trampoline which does
72 * unboxing before calling the method
75 mono_arch_get_unbox_trampoline (MonoGenericSharingContext *gsctx, MonoMethod *m, gpointer addr)
80 MonoDomain *domain = mono_domain_get ();
81 int size = MONO_PPC_32_64_CASE (20, 32) + PPC_FTNPTR_SIZE;
83 addr = mono_get_addr_from_ftnptr (addr);
85 if (MONO_TYPE_ISSTRUCT (mono_method_signature (m)->ret))
88 mono_domain_lock (domain);
89 start = code = mono_domain_code_reserve (domain, size);
90 code = mono_ppc_create_pre_code_ftnptr (code);
91 short_branch = branch_for_target_reachable (code + 4, addr);
93 mono_domain_code_commit (domain, code, size, 8);
94 mono_domain_unlock (domain);
97 ppc_addi (code, this_pos, this_pos, sizeof (MonoObject));
98 ppc_emit32 (code, short_branch);
100 ppc_load (code, ppc_r0, addr);
101 ppc_mtctr (code, ppc_r0);
102 ppc_addi (code, this_pos, this_pos, sizeof (MonoObject));
103 ppc_bcctr (code, 20, 0);
105 mono_arch_flush_icache (start, code - start);
106 g_assert ((code - start) <= size);
107 /*g_print ("unbox trampoline at %d for %s:%s\n", this_pos, m->klass->name, m->name);
108 g_print ("unbox code is at %p for method at %p\n", start, addr);*/
114 * mono_arch_get_static_rgctx_trampoline:
116 * Create a trampoline which sets RGCTX_REG to MRGCTX, then jumps to ADDR.
119 mono_arch_get_static_rgctx_trampoline (MonoMethod *m, MonoMethodRuntimeGenericContext *mrgctx, gpointer addr)
121 guint8 *code, *start, *p;
122 guint8 imm_buf [128];
123 guint32 short_branch;
124 MonoDomain *domain = mono_domain_get ();
126 int size = MONO_PPC_32_64_CASE (24, (PPC_LOAD_SEQUENCE_LENGTH * 2) + 8) + PPC_FTNPTR_SIZE;
128 addr = mono_get_addr_from_ftnptr (addr);
130 /* Compute size of code needed to emit mrgctx */
132 ppc_load (p, MONO_ARCH_RGCTX_REG, mrgctx);
133 imm_size = p - imm_buf;
135 mono_domain_lock (domain);
136 start = code = mono_domain_code_reserve (domain, size);
137 code = mono_ppc_create_pre_code_ftnptr (code);
138 short_branch = branch_for_target_reachable (code + imm_size, addr);
140 mono_domain_code_commit (domain, code, size, imm_size + 4);
141 mono_domain_unlock (domain);
144 ppc_load (code, MONO_ARCH_RGCTX_REG, mrgctx);
145 ppc_emit32 (code, short_branch);
147 ppc_load (code, ppc_r0, addr);
148 ppc_mtctr (code, ppc_r0);
149 ppc_load (code, MONO_ARCH_RGCTX_REG, mrgctx);
150 ppc_bcctr (code, 20, 0);
152 mono_arch_flush_icache (start, code - start);
153 g_assert ((code - start) <= size);
159 mono_arch_patch_callsite (guint8 *method_start, guint8 *code_ptr, guint8 *addr)
161 guint32 *code = (guint32*)code_ptr;
163 addr = mono_get_addr_from_ftnptr (addr);
165 /* This is the 'blrl' instruction */
169 * Note that methods are called also with the bl opcode.
171 if (((*code) >> 26) == 18) {
172 /*g_print ("direct patching\n");*/
173 ppc_patch ((guint8*)code, addr);
174 mono_arch_flush_icache ((guint8*)code, 4);
179 g_assert (mono_ppc_is_direct_call_sequence (code));
181 ppc_patch ((guint8*)code, addr);
185 mono_arch_patch_plt_entry (guint8 *code, gpointer *got, gssize *regs, guint8 *addr)
187 g_assert_not_reached ();
191 mono_arch_nullify_class_init_trampoline (guint8 *code, gssize *regs)
193 mono_arch_patch_callsite (NULL, code, nullified_class_init_trampoline);
197 mono_arch_nullify_plt_entry (guint8 *code, gssize *regs)
199 g_assert_not_reached ();
202 /* Stack size for trampoline function
203 * PPC_MINIMAL_STACK_SIZE + 16 (args + alignment to ppc_magic_trampoline)
204 * + MonoLMF + 14 fp regs + 13 gregs + alignment
205 * #define STACK (PPC_MINIMAL_STACK_SIZE + 4 * sizeof (gulong) + sizeof (MonoLMF) + 14 * sizeof (double) + 13 * (sizeof (gulong)))
206 * STACK would be 444 for 32 bit darwin
208 #ifdef __mono_ppc64__
209 #define STACK (PPC_MINIMAL_STACK_SIZE + 4 * sizeof (gulong) + sizeof (MonoLMF) + 14 * sizeof (double) + 13 * sizeof (gulong))
214 /* Method-specific trampoline code fragment size */
215 #define METHOD_TRAMPOLINE_SIZE 64
217 /* Jump-specific trampoline code fragment size */
218 #define JUMP_TRAMPOLINE_SIZE 64
220 #ifdef PPC_USES_FUNCTION_DESCRIPTOR
221 #define PPC_TOC_REG ppc_r2
223 #define PPC_TOC_REG -1
227 mono_arch_create_trampoline_code (MonoTrampolineType tramp_type)
232 GSList *unwind_ops, *l;
234 code = mono_arch_create_trampoline_code_full (tramp_type, &code_size, &ji, &unwind_ops, FALSE);
236 //mono_save_trampoline_xdebug_info ("<generic_trampoline>", code, code_size, unwind_ops);
238 for (l = unwind_ops; l; l = l->next)
240 g_slist_free (unwind_ops);
246 * Stack frame description when the generic trampoline is called.
248 * --------------------
250 * -------------------
251 * Saved FP registers 0-13
252 * -------------------
253 * Saved general registers 0-30
254 * -------------------
255 * param area for 3 args to ppc_magic_trampoline
256 * -------------------
258 * -------------------
261 mono_arch_create_trampoline_code_full (MonoTrampolineType tramp_type, guint32 *code_size, MonoJumpInfo **ji, GSList **out_unwind_ops, gboolean aot)
263 guint8 *buf, *code = NULL;
265 gconstpointer tramp_handler;
266 int size = MONO_PPC_32_64_CASE (600, 800);
268 /* Now we'll create in 'buf' the PowerPC trampoline code. This
269 is the trampoline code common to all methods */
271 code = buf = mono_global_codeman_reserve (size);
274 *out_unwind_ops = NULL;
276 ppc_store_reg_update (buf, ppc_r1, -STACK, ppc_r1);
278 /* start building the MonoLMF on the stack */
279 offset = STACK - sizeof (double) * MONO_SAVED_FREGS;
280 for (i = 14; i < 32; i++) {
281 ppc_stfd (buf, i, offset, ppc_r1);
282 offset += sizeof (double);
285 * now the integer registers.
287 offset = STACK - sizeof (MonoLMF) + G_STRUCT_OFFSET (MonoLMF, iregs);
288 ppc_store_multiple_regs (buf, ppc_r13, offset, ppc_r1);
290 /* Now save the rest of the registers below the MonoLMF struct, first 14
291 * fp regs and then the 31 gregs.
293 offset = STACK - sizeof (MonoLMF) - (14 * sizeof (double));
294 for (i = 0; i < 14; i++) {
295 ppc_stfd (buf, i, offset, ppc_r1);
296 offset += sizeof (double);
298 #define GREGS_OFFSET (STACK - sizeof (MonoLMF) - (14 * sizeof (double)) - (31 * sizeof (gulong)))
299 offset = GREGS_OFFSET;
300 for (i = 0; i < 31; i++) {
301 ppc_store_reg (buf, i, offset, ppc_r1);
302 offset += sizeof (gulong);
305 /* we got here through a jump to the ctr reg, we must save the lr
306 * in the parent frame (we do it here to reduce the size of the
307 * method-specific trampoline)
309 ppc_mflr (buf, ppc_r0);
310 ppc_store_reg (buf, ppc_r0, STACK + PPC_RET_ADDR_OFFSET, ppc_r1);
312 /* ok, now we can continue with the MonoLMF setup, mostly untouched
313 * from emit_prolog in mini-ppc.c
316 buf = mono_arch_emit_load_aotconst (code, buf, ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_get_lmf_addr");
317 #ifdef PPC_USES_FUNCTION_DESCRIPTOR
318 ppc_load_reg (buf, ppc_r2, sizeof (gpointer), ppc_r11);
319 ppc_load_reg (buf, ppc_r11, 0, ppc_r11);
321 ppc_mtlr (buf, ppc_r11);
324 ppc_load_func (buf, ppc_r0, mono_get_lmf_addr);
325 ppc_mtlr (buf, ppc_r0);
328 /* we build the MonoLMF structure on the stack - see mini-ppc.h
329 * The pointer to the struct is put in ppc_r11.
331 ppc_addi (buf, ppc_r11, ppc_sp, STACK - sizeof (MonoLMF));
332 ppc_store_reg (buf, ppc_r3, G_STRUCT_OFFSET(MonoLMF, lmf_addr), ppc_r11);
333 /* new_lmf->previous_lmf = *lmf_addr */
334 ppc_load_reg (buf, ppc_r0, G_STRUCT_OFFSET(MonoLMF, previous_lmf), ppc_r3);
335 ppc_store_reg (buf, ppc_r0, G_STRUCT_OFFSET(MonoLMF, previous_lmf), ppc_r11);
336 /* *(lmf_addr) = r11 */
337 ppc_store_reg (buf, ppc_r11, G_STRUCT_OFFSET(MonoLMF, previous_lmf), ppc_r3);
338 /* save method info (it's stored on the stack, so get it first and put it
339 * in r5 as it's the third argument to the function)
341 if (tramp_type == MONO_TRAMPOLINE_GENERIC_CLASS_INIT)
342 ppc_load_reg (buf, ppc_r5, GREGS_OFFSET + PPC_FIRST_ARG_REG * sizeof (gpointer), ppc_r1);
344 ppc_load_reg (buf, ppc_r5, GREGS_OFFSET, ppc_r1);
345 if ((tramp_type == MONO_TRAMPOLINE_JIT) || (tramp_type == MONO_TRAMPOLINE_JUMP))
346 ppc_store_reg (buf, ppc_r5, G_STRUCT_OFFSET(MonoLMF, method), ppc_r11);
347 /* store the frame pointer of the calling method */
348 ppc_addi (buf, ppc_r0, ppc_sp, STACK);
349 ppc_store_reg (buf, ppc_r0, G_STRUCT_OFFSET(MonoLMF, ebp), ppc_r11);
350 /* save the IP (caller ip) */
351 if (tramp_type == MONO_TRAMPOLINE_JUMP) {
352 ppc_li (buf, ppc_r0, 0);
354 ppc_load_reg (buf, ppc_r0, STACK + PPC_RET_ADDR_OFFSET, ppc_r1);
356 ppc_store_reg (buf, ppc_r0, G_STRUCT_OFFSET(MonoLMF, eip), ppc_r11);
359 * Now we're ready to call trampoline (gssize *regs, guint8 *code, gpointer value, guint8 *tramp)
360 * Note that the last argument is unused.
362 /* Arg 1: a pointer to the registers */
363 ppc_addi (buf, ppc_r3, ppc_r1, GREGS_OFFSET);
365 /* Arg 2: code (next address to the instruction that called us) */
366 if (tramp_type == MONO_TRAMPOLINE_JUMP)
367 ppc_li (buf, ppc_r4, 0);
369 ppc_load_reg (buf, ppc_r4, STACK + PPC_RET_ADDR_OFFSET, ppc_r1);
371 /* Arg 3: MonoMethod *method. It was put in r5 already above */
372 /*ppc_mr (buf, ppc_r5, ppc_r5);*/
375 buf = mono_arch_emit_load_aotconst (code, buf, ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, g_strdup_printf ("trampoline_func_%d", tramp_type));
376 #ifdef PPC_USES_FUNCTION_DESCRIPTOR
377 ppc_load_reg (buf, ppc_r2, sizeof (gpointer), ppc_r11);
378 ppc_load_reg (buf, ppc_r11, 0, ppc_r11);
380 ppc_mtlr (buf, ppc_r11);
383 tramp_handler = mono_get_trampoline_func (tramp_type);
384 ppc_load_func (buf, ppc_r0, tramp_handler);
385 ppc_mtlr (buf, ppc_r0);
389 /* OK, code address is now on r3. Move it to the counter reg
390 * so it will be ready for the final jump: this is safe since we
391 * won't do any more calls.
393 if (!MONO_TRAMPOLINE_TYPE_MUST_RETURN (tramp_type)) {
394 #ifdef PPC_USES_FUNCTION_DESCRIPTOR
395 ppc_load_reg (buf, ppc_r2, sizeof (gpointer), ppc_r3);
396 ppc_load_reg (buf, ppc_r3, 0, ppc_r3);
398 ppc_mtctr (buf, ppc_r3);
402 * Now we restore the MonoLMF (see emit_epilogue in mini-ppc.c)
403 * and the rest of the registers, so the method called will see
404 * the same state as before we executed.
405 * The pointer to MonoLMF is in ppc_r11.
407 ppc_addi (buf, ppc_r11, ppc_r1, STACK - sizeof (MonoLMF));
408 /* r5 = previous_lmf */
409 ppc_load_reg (buf, ppc_r5, G_STRUCT_OFFSET(MonoLMF, previous_lmf), ppc_r11);
411 ppc_load_reg (buf, ppc_r6, G_STRUCT_OFFSET(MonoLMF, lmf_addr), ppc_r11);
412 /* *(lmf_addr) = previous_lmf */
413 ppc_store_reg (buf, ppc_r5, G_STRUCT_OFFSET(MonoLMF, previous_lmf), ppc_r6);
415 ppc_load_multiple_regs (buf, ppc_r13, G_STRUCT_OFFSET(MonoLMF, iregs), ppc_r11);
417 for (i = 14; i < 32; i++)
418 ppc_lfd (buf, i, G_STRUCT_OFFSET(MonoLMF, fregs) + ((i-14) * sizeof (gdouble)), ppc_r11);
420 /* restore the volatile registers, we skip r1, of course */
421 offset = STACK - sizeof (MonoLMF) - (14 * sizeof (double));
422 for (i = 0; i < 14; i++) {
423 ppc_lfd (buf, i, offset, ppc_r1);
424 offset += sizeof (double);
426 offset = STACK - sizeof (MonoLMF) - (14 * sizeof (double)) - (31 * sizeof (gulong));
427 ppc_load_reg (buf, ppc_r0, offset, ppc_r1);
428 offset += 2 * sizeof (gulong);
429 for (i = 2; i < 13; i++) {
430 if (i != PPC_TOC_REG && (i != 3 || tramp_type != MONO_TRAMPOLINE_RGCTX_LAZY_FETCH))
431 ppc_load_reg (buf, i, offset, ppc_r1);
432 offset += sizeof (gulong);
435 /* Non-standard function epilogue. Instead of doing a proper
436 * return, we just jump to the compiled code.
438 /* Restore stack pointer and LR and jump to the code */
439 ppc_load_reg (buf, ppc_r1, 0, ppc_r1);
440 ppc_load_reg (buf, ppc_r11, PPC_RET_ADDR_OFFSET, ppc_r1);
441 ppc_mtlr (buf, ppc_r11);
442 if (MONO_TRAMPOLINE_TYPE_MUST_RETURN (tramp_type))
445 ppc_bcctr (buf, 20, 0);
447 /* Flush instruction cache, since we've generated code */
448 mono_arch_flush_icache (code, buf - code);
450 *code_size = buf - code;
453 g_assert ((buf - code) <= size);
455 if (tramp_type == MONO_TRAMPOLINE_CLASS_INIT) {
458 /* Initialize the nullified class init trampoline */
459 nullified_class_init_trampoline = mono_ppc_create_ftnptr (mono_arch_get_nullified_class_init_trampoline (&code_len));
465 #define TRAMPOLINE_SIZE (MONO_PPC_32_64_CASE (24, (5+5+1+1)*4))
467 mono_arch_create_specific_trampoline (gpointer arg1, MonoTrampolineType tramp_type, MonoDomain *domain, guint32 *code_len)
469 guint8 *code, *buf, *tramp;
470 guint32 short_branch;
472 tramp = mono_get_trampoline_code (tramp_type);
474 mono_domain_lock (domain);
475 code = buf = mono_domain_code_reserve_align (domain, TRAMPOLINE_SIZE, 4);
476 short_branch = branch_for_target_reachable (code + MONO_PPC_32_64_CASE (8, 5*4), tramp);
477 #ifdef __mono_ppc64__
478 /* FIXME: make shorter if possible */
481 mono_domain_code_commit (domain, code, TRAMPOLINE_SIZE, 12);
483 mono_domain_unlock (domain);
486 ppc_load_sequence (buf, ppc_r0, (gulong) arg1);
487 ppc_emit32 (buf, short_branch);
489 /* Prepare the jump to the generic trampoline code.*/
490 ppc_load (buf, ppc_r0, (gulong) tramp);
491 ppc_mtctr (buf, ppc_r0);
493 /* And finally put 'arg1' in r0 and fly! */
494 ppc_load (buf, ppc_r0, (gulong) arg1);
495 ppc_bcctr (buf, 20, 0);
498 /* Flush instruction cache, since we've generated code */
499 mono_arch_flush_icache (code, buf - code);
501 g_assert ((buf - code) <= TRAMPOLINE_SIZE);
503 *code_len = buf - code;
509 emit_trampoline_jump (guint8 *code, guint8 *tramp)
511 guint32 short_branch = branch_for_target_reachable (code, tramp);
513 /* FIXME: we can save a few bytes here by committing if the
514 short branch is possible */
516 ppc_emit32 (code, short_branch);
518 ppc_load (code, ppc_r0, tramp);
519 ppc_mtctr (code, ppc_r0);
520 ppc_bcctr (code, 20, 0);
527 mono_arch_create_rgctx_lazy_fetch_trampoline (guint32 slot)
532 return mono_arch_create_rgctx_lazy_fetch_trampoline_full (slot, &code_size, &ji, FALSE);
536 mono_arch_create_rgctx_lazy_fetch_trampoline_full (guint32 slot, guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
538 #ifdef MONO_ARCH_VTABLE_REG
541 guint8 **rgctx_null_jumps;
549 mrgctx = MONO_RGCTX_SLOT_IS_MRGCTX (slot);
550 index = MONO_RGCTX_SLOT_INDEX (slot);
552 index += sizeof (MonoMethodRuntimeGenericContext) / sizeof (gpointer);
553 for (depth = 0; ; ++depth) {
554 int size = mono_class_rgctx_get_array_size (depth, mrgctx);
556 if (index < size - 1)
561 tramp_size = MONO_PPC_32_64_CASE (40, 52) + 12 * depth;
569 code = buf = mono_global_codeman_reserve (tramp_size);
571 rgctx_null_jumps = g_malloc (sizeof (guint8*) * (depth + 2));
575 ppc_mr (code, ppc_r4, PPC_FIRST_ARG_REG);
577 /* load rgctx ptr from vtable */
578 ppc_load_reg (code, ppc_r4, G_STRUCT_OFFSET (MonoVTable, runtime_generic_context), PPC_FIRST_ARG_REG);
579 /* is the rgctx ptr null? */
580 ppc_compare_reg_imm (code, 0, ppc_r4, 0);
581 /* if yes, jump to actual trampoline */
582 rgctx_null_jumps [0] = code;
583 ppc_bc (code, PPC_BR_TRUE, PPC_BR_EQ, 0);
586 for (i = 0; i < depth; ++i) {
587 /* load ptr to next array */
588 if (mrgctx && i == 0)
589 ppc_load_reg (code, ppc_r4, sizeof (MonoMethodRuntimeGenericContext), ppc_r4);
591 ppc_load_reg (code, ppc_r4, 0, ppc_r4);
592 /* is the ptr null? */
593 ppc_compare_reg_imm (code, 0, ppc_r4, 0);
594 /* if yes, jump to actual trampoline */
595 rgctx_null_jumps [i + 1] = code;
596 ppc_bc (code, PPC_BR_TRUE, PPC_BR_EQ, 0);
600 ppc_load_reg (code, ppc_r4, sizeof (gpointer) * (index + 1), ppc_r4);
601 /* is the slot null? */
602 ppc_compare_reg_imm (code, 0, ppc_r4, 0);
603 /* if yes, jump to actual trampoline */
604 rgctx_null_jumps [depth + 1] = code;
605 ppc_bc (code, PPC_BR_TRUE, PPC_BR_EQ, 0);
606 /* otherwise return r4 */
607 /* FIXME: if we use r3 as the work register we can avoid this copy */
608 ppc_mr (code, ppc_r3, ppc_r4);
611 for (i = mrgctx ? 1 : 0; i <= depth + 1; ++i)
612 ppc_patch (rgctx_null_jumps [i], code);
614 g_free (rgctx_null_jumps);
616 /* move the rgctx pointer to the VTABLE register */
617 ppc_mr (code, MONO_ARCH_VTABLE_REG, ppc_r3);
620 code = mono_arch_emit_load_aotconst (buf, code, ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, g_strdup_printf ("specific_trampoline_lazy_fetch_%u", slot));
621 /* Branch to the trampoline */
622 #ifdef PPC_USES_FUNCTION_DESCRIPTOR
623 ppc_load_reg (code, ppc_r11, 0, ppc_r11);
625 ppc_mtctr (code, ppc_r11);
626 ppc_bcctr (code, PPC_BR_ALWAYS, 0);
628 tramp = mono_arch_create_specific_trampoline (GUINT_TO_POINTER (slot),
629 MONO_TRAMPOLINE_RGCTX_LAZY_FETCH, mono_get_root_domain (), NULL);
631 /* jump to the actual trampoline */
632 code = emit_trampoline_jump (code, tramp);
635 mono_arch_flush_icache (buf, code - buf);
637 g_assert (code - buf <= tramp_size);
639 *code_size = code - buf;
643 g_assert_not_reached ();
648 mono_arch_create_generic_class_init_trampoline (void)
653 return mono_arch_create_generic_class_init_trampoline_full (&code_size, &ji, FALSE);
657 mono_arch_create_generic_class_init_trampoline_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
661 static int byte_offset = -1;
662 static guint8 bitmask;
666 tramp_size = MONO_PPC_32_64_CASE (32, 44);
670 code = buf = mono_global_codeman_reserve (tramp_size);
675 mono_marshal_find_bitfield_offset (MonoVTable, initialized, &byte_offset, &bitmask);
677 ppc_lbz (code, ppc_r4, byte_offset, PPC_FIRST_ARG_REG);
678 ppc_andid (code, ppc_r4, ppc_r4, bitmask);
680 ppc_bc (code, PPC_BR_TRUE, PPC_BR_EQ, 0);
684 ppc_patch (jump, code);
687 code = mono_arch_emit_load_aotconst (buf, code, ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, "specific_trampoline_generic_class_init");
688 /* Branch to the trampoline */
689 #ifdef PPC_USES_FUNCTION_DESCRIPTOR
690 ppc_load_reg (code, ppc_r11, 0, ppc_r11);
692 ppc_mtctr (code, ppc_r11);
693 ppc_bcctr (code, PPC_BR_ALWAYS, 0);
695 tramp = mono_arch_create_specific_trampoline (NULL, MONO_TRAMPOLINE_GENERIC_CLASS_INIT,
696 mono_get_root_domain (), NULL);
698 /* jump to the actual trampoline */
699 code = emit_trampoline_jump (code, tramp);
702 mono_arch_flush_icache (buf, code - buf);
704 *code_size = code - buf;
706 g_assert (code - buf <= tramp_size);
712 mono_arch_get_nullified_class_init_trampoline (guint32 *code_len)
715 guint32 tramp_size = 64;
717 code = buf = mono_global_codeman_reserve (tramp_size);
720 mono_arch_flush_icache (buf, code - buf);
722 *code_len = code - buf;
724 g_assert (code - buf <= tramp_size);