2006-06-21 Zoltan Varga <vargaz@gmail.com>
[mono.git] / mono / mini / tramp-s390.c
1 /*------------------------------------------------------------------*/
2 /*                                                                  */
3 /* Name        - tramp-s390.c                                       */
4 /*                                                                  */
5 /* Function    - JIT trampoline code for S/390.                     */
6 /*                                                                  */
7 /* Name        - Neale Ferguson (Neale.Ferguson@SoftwareAG-usa.com) */
8 /*                                                                  */
9 /* Date        - January, 2004                                      */
10 /*                                                                  */
11 /* Derivation  - From exceptions-x86 & exceptions-ppc               */
12 /*               Paolo Molaro (lupus@ximian.com)                    */
13 /*               Dietmar Maurer (dietmar@ximian.com)                */
14 /*                                                                  */
15 /* Copyright   - 2001 Ximian, Inc.                                  */
16 /*                                                                  */
17 /*------------------------------------------------------------------*/
18
19 /*------------------------------------------------------------------*/
20 /*                 D e f i n e s                                    */
21 /*------------------------------------------------------------------*/
22
23 #define GR_SAVE_SIZE            4*sizeof(long)
24 #define FP_SAVE_SIZE            16*sizeof(double)
25 #define METHOD_SAVE_OFFSET      S390_MINIMAL_STACK_SIZE
26 #define CREATE_GR_OFFSET        METHOD_SAVE_OFFSET+sizeof(gpointer)
27 #define CREATE_FP_OFFSET        CREATE_GR_OFFSET+GR_SAVE_SIZE
28 #define CREATE_LMF_OFFSET       CREATE_FP_OFFSET+FP_SAVE_SIZE
29 #define CREATE_STACK_SIZE       (CREATE_LMF_OFFSET+2*sizeof(long)+sizeof(MonoLMF))
30
31 /*------------------------------------------------------------------*/
32 /* Method-specific trampoline code fragment sizes                   */
33 /*------------------------------------------------------------------*/
34 #define METHOD_TRAMPOLINE_SIZE  64
35 #define JUMP_TRAMPOLINE_SIZE    64
36
37 /*========================= End of Defines =========================*/
38
39 /*------------------------------------------------------------------*/
40 /*                 I n c l u d e s                                  */
41 /*------------------------------------------------------------------*/
42
43 #include <config.h>
44 #include <glib.h>
45 #include <string.h>
46
47 #include <mono/metadata/appdomain.h>
48 #include <mono/metadata/marshal.h>
49 #include <mono/metadata/tabledefs.h>
50 #include <mono/arch/s390/s390-codegen.h>
51
52 #include "mini.h"
53 #include "mini-s390.h"
54
55 /*========================= End of Includes ========================*/
56
57 /*------------------------------------------------------------------*/
58 /*                 T y p e d e f s                                  */
59 /*------------------------------------------------------------------*/
60
61 /*========================= End of Typedefs ========================*/
62
63 /*------------------------------------------------------------------*/
64 /*                   P r o t o t y p e s                            */
65 /*------------------------------------------------------------------*/
66
67 /*========================= End of Prototypes ======================*/
68
69 /*------------------------------------------------------------------*/
70 /*                 G l o b a l   V a r i a b l e s                  */
71 /*------------------------------------------------------------------*/
72
73
74 /*====================== End of Global Variables ===================*/
75
76 /*------------------------------------------------------------------*/
77 /*                                                                  */
78 /* Name         - get_unbox_trampoline                              */
79 /*                                                                  */
80 /* Function     - Return a pointer to a trampoline which does the   */
81 /*                unboxing before calling the method.               */
82 /*                                                                  */
83 /*                When value type methods are called through the    */
84 /*                vtable we need to unbox the 'this' argument.      */
85 /*                                                                  */
86 /* Parameters   - method - Methd pointer                            */
87 /*                addr   - Pointer to native code for method        */
88 /*                                                                  */
89 /*------------------------------------------------------------------*/
90
91 static gpointer
92 get_unbox_trampoline (MonoMethod *method, gpointer addr)
93 {
94         guint8 *code, *start;
95         int this_pos = s390_r2;
96
97         start = addr;
98         if ((!mono_method_signature (method)->ret->byref) && 
99             (MONO_TYPE_ISSTRUCT (mono_method_signature (method)->ret)))
100                 this_pos = s390_r3;
101     
102         start = code = mono_global_codeman_reserve (28);
103
104         s390_basr (code, s390_r13, 0);
105         s390_j    (code, 4);
106         s390_word (code, addr);
107         s390_l    (code, s390_r1, 0, s390_r13, 4);
108         s390_ahi  (code, this_pos, sizeof(MonoObject));
109         s390_br   (code, s390_r1);
110
111         g_assert ((code - start) <= 28);
112
113         return start;
114 }
115
116 /*========================= End of Function ========================*/
117
118 /*------------------------------------------------------------------*/
119 /*                                                                  */
120 /* Name         - s390_magic_trampoline                             */
121 /*                                                                  */
122 /* Function     - This method is called by the function             */
123 /*                "arch_create_jit_trampoline", which in turn is    */
124 /*                called by the trampoline functions for virtual    */
125 /*                methods. After having called the JIT compiler to  */
126 /*                compile the method, it inspects the caller code   */
127 /*                to find the address of the method-specific part   */
128 /*                of the trampoline vtable slot for this method,    */
129 /*                updates it with a fragment that calls the newly   */
130 /*                compiled code and returns this address. The calls */
131 /*                generated by mono for S/390 will look like either:*/
132 /*                1. l     %r1,xxx(%rx)                             */
133 /*                   bras  %r14,%r1                                 */
134 /*                2. brasl %r14,xxxxxx                              */
135 /*                                                                  */
136 /* Parameters   - code   - Pointer into caller code                 */
137 /*                method - The method to compile                    */
138 /*                sp     - Stack pointer                            */
139 /*                                                                  */
140 /*------------------------------------------------------------------*/
141
142 static gpointer
143 s390_magic_trampoline (MonoMethod *method, guchar *code, char *sp)
144 {
145         gpointer addr;
146         gint32 displace;
147         int reg;
148         guchar* base;
149         unsigned short opcode;
150         char *fname;
151         MonoJitInfo *codeJi, 
152                     *addrJi;
153
154         addr = mono_compile_method(method);
155         g_assert(addr);
156
157
158         if (code) {
159
160                 /* The top bit needs to be ignored on S/390 */
161                 code = (guchar*)((guint32)code & 0x7fffffff);
162
163                 fname  = mono_method_full_name (method, TRUE);
164                 codeJi = mono_jit_info_table_find (mono_domain_get(), code);
165                 addrJi = mono_jit_info_table_find (mono_domain_get(), addr);
166                 if (mono_method_same_domain (codeJi, addrJi)) {
167
168                         opcode = *((unsigned short *) (code - 6));
169                         switch (opcode) {
170                         case 0x5810 :
171                                 /* This is a bras r14,r1 instruction */
172                                 code    -= 4;
173                                 reg      = *code >> 4;
174                                 displace = *((short *)code) & 0x0fff;
175                                 if (reg > 5) 
176                                         base = *((guchar **) (sp + S390_REG_SAVE_OFFSET+
177                                                                sizeof(int)*(reg-6)));
178                                 else
179                                         base = *((guchar **) ((sp - CREATE_STACK_SIZE) + 
180                                                                CREATE_GR_OFFSET +
181                                                                sizeof(int)*(reg-2)));
182
183                                 if ((method->klass->valuetype) && 
184                                     (!mono_aot_is_got_entry(code, base))) 
185                                         addr = get_unbox_trampoline(method, addr);
186
187                                 code = base + displace;
188                                 if (mono_domain_owns_vtable_slot(mono_domain_get(), 
189                                                                  code))
190                                         s390_patch(code, addr);
191                                 break;
192                         case 0xc0e5 :
193                                 /* This is the 'brasl' instruction */
194                                 code    -= 4;
195                                 displace = ((gint32) addr - (gint32) (code - 2)) / 2;
196                                 if (mono_method_same_domain (codeJi, addrJi)) {
197                                         s390_patch (code, displace);
198                                         mono_arch_flush_icache (code, 4);
199                                 }
200                                 break;
201                         default :
202                                 g_error("Unable to patch instruction prior to %p",code);
203                         }
204                 }
205         }
206
207
208         return addr;
209 }
210
211 /*========================= End of Function ========================*/
212
213 /*------------------------------------------------------------------*/
214 /*                                                                  */
215 /* Name         - s390_class_init_trampoline                        */
216 /*                                                                  */
217 /* Function     - Initialize a class and then no-op the call to     */
218 /*                the trampoline.                                   */
219 /*                                                                  */
220 /*------------------------------------------------------------------*/
221
222 static void
223 s390_class_init_trampoline (void *vtable, guchar *code, char *sp)
224 {
225         char patch[6] = {0x47, 0x00, 0x00, 0x00, 0x07, 0x00};
226
227         mono_runtime_class_init (vtable);
228
229         code = code - 6;
230
231         memcpy(code, patch, sizeof(patch));
232 }
233
234 /*========================= End of Function ========================*/
235
236 /*------------------------------------------------------------------*/
237 /*                                                                  */
238 /* Name         - mono_arch_create_trampoline_code                            */
239 /*                                                                  */
240 /* Function     - Create the designated type of trampoline according*/
241 /*                to the 'tramp_type' parameter.                    */
242 /*                                                                  */
243 /*------------------------------------------------------------------*/
244
245 guchar*
246 mono_arch_create_trampoline_code (MonoTrampolineType tramp_type)
247 {
248
249         guint8 *buf, *code = NULL;
250         int i, offset, lmfOffset;
251
252         if(!code) {
253                 /* Now we'll create in 'buf' the S/390 trampoline code. This
254                  is the trampoline code common to all methods  */
255                 
256                 code = buf = mono_global_codeman_reserve(512);
257                 
258                 /*-----------------------------------------------------------
259                 STEP 0: First create a non-standard function prologue with a
260                 stack size big enough to save our registers.
261                 -----------------------------------------------------------*/
262                 
263                 s390_stm  (buf, s390_r6, s390_r14, STK_BASE, S390_REG_SAVE_OFFSET);
264                 s390_lr   (buf, s390_r11, s390_r15);
265                 s390_ahi  (buf, STK_BASE, -CREATE_STACK_SIZE);
266                 s390_st   (buf, s390_r11, 0, STK_BASE, 0);
267                 s390_st   (buf, s390_r1, 0, STK_BASE, METHOD_SAVE_OFFSET);
268                 s390_stm  (buf, s390_r2, s390_r5, STK_BASE, CREATE_GR_OFFSET);
269
270                 /* Save the FP registers */
271                 offset = CREATE_FP_OFFSET;
272                 for (i = s390_f0; i <= s390_f15; ++i) {
273                         s390_std  (buf, i, 0, STK_BASE, offset);
274                         offset += 8;
275                 }
276
277                 /*----------------------------------------------------------
278                 STEP 1: call 'mono_get_lmf_addr()' to get the address of our
279                 LMF. We'll need to restore it after the call to
280                 's390_magic_trampoline' and before the call to the native
281                 method.
282                 ----------------------------------------------------------*/
283                                 
284                 s390_basr (buf, s390_r13, 0);
285                 s390_j    (buf, 4);
286                 s390_word (buf, mono_get_lmf_addr);
287                 s390_l    (buf, s390_r1, 0, s390_r13, 4);
288                 s390_basr (buf, s390_r14, s390_r1);
289
290                 /*---------------------------------------------------------------*/
291                 /* we build the MonoLMF structure on the stack - see mini-s390.h */
292                 /* Keep in sync with the code in mono_arch_emit_prolog           */
293                 /*---------------------------------------------------------------*/
294                 lmfOffset = CREATE_STACK_SIZE - sizeof(MonoLMF);
295                                                                                         
296                 s390_lr    (buf, s390_r13, STK_BASE);
297                 s390_ahi   (buf, s390_r13, lmfOffset);  
298                                                                                         
299                 /*---------------------------------------------------------------*/     
300                 /* Set lmf.lmf_addr = jit_tls->lmf                               */     
301                 /*---------------------------------------------------------------*/     
302                 s390_st    (buf, s390_r2, 0, s390_r13,                          
303                             G_STRUCT_OFFSET(MonoLMF, lmf_addr));                        
304                                                                                         
305                 /*---------------------------------------------------------------*/     
306                 /* Get current lmf                                               */     
307                 /*---------------------------------------------------------------*/     
308                 s390_l     (buf, s390_r0, 0, s390_r2, 0);                               
309                                                                                         
310                 /*---------------------------------------------------------------*/     
311                 /* Set our lmf as the current lmf                                */     
312                 /*---------------------------------------------------------------*/     
313                 s390_st    (buf, s390_r13, 0, s390_r2, 0);                              
314                                                                                         
315                 /*---------------------------------------------------------------*/     
316                 /* Have our lmf.previous_lmf point to the last lmf               */     
317                 /*---------------------------------------------------------------*/     
318                 s390_st    (buf, s390_r0, 0, s390_r13,                          
319                             G_STRUCT_OFFSET(MonoLMF, previous_lmf));                    
320                                                                                         
321                 /*---------------------------------------------------------------*/     
322                 /* save method info                                              */     
323                 /*---------------------------------------------------------------*/     
324                 s390_l     (buf, s390_r1, 0, STK_BASE, METHOD_SAVE_OFFSET);
325                 s390_st    (buf, s390_r1, 0, s390_r13,                          
326                             G_STRUCT_OFFSET(MonoLMF, method));                          
327                                                                         
328                 /*---------------------------------------------------------------*/     
329                 /* save the current SP                                           */     
330                 /*---------------------------------------------------------------*/     
331                 s390_l     (buf, s390_r1, 0, STK_BASE, 0);
332                 s390_st    (buf, s390_r1, 0, s390_r13, G_STRUCT_OFFSET(MonoLMF, ebp));  
333                                                                         
334                 /*---------------------------------------------------------------*/     
335                 /* save the current IP                                           */     
336                 /*---------------------------------------------------------------*/     
337                 if (tramp_type == MONO_TRAMPOLINE_JUMP) {
338                         s390_lhi   (buf, s390_r1, 0);
339                 } else {
340                         s390_l     (buf, s390_r1, 0, s390_r1, S390_RET_ADDR_OFFSET);
341                         s390_la    (buf, s390_r1, 0, s390_r1, 0);
342                 }
343                 s390_st    (buf, s390_r1, 0, s390_r13, G_STRUCT_OFFSET(MonoLMF, eip));  
344                                                                                         
345                 /*---------------------------------------------------------------*/     
346                 /* Save general and floating point registers                     */     
347                 /*---------------------------------------------------------------*/     
348                 s390_stm   (buf, s390_r2, s390_r12, s390_r13,                           
349                             G_STRUCT_OFFSET(MonoLMF, gregs[2]));                        
350                 for (i = 0; i < 16; i++) {                                              
351                         s390_std  (buf, i, 0, s390_r13,                                 
352                                    G_STRUCT_OFFSET(MonoLMF, fregs[i]));                 
353                 }                                                                       
354
355                 /*---------------------------------------------------------------*/
356                 /* STEP 2: call 's390_magic_trampoline()', who will compile the  */
357                 /* code and fix the method vtable entry for us                   */
358                 /*---------------------------------------------------------------*/
359                                 
360                 /* Set arguments */
361                 
362                 /* Arg 1: MonoMethod *method. It was put in r1 by the
363                 method-specific trampoline code, and then saved before the call
364                 to mono_get_lmf_addr()'. */
365                 s390_l  (buf, s390_r2, 0, STK_BASE, METHOD_SAVE_OFFSET);
366                 
367                 /* Arg 2: code (next address to the instruction that called us) */
368                 if (tramp_type == MONO_TRAMPOLINE_JUMP) {
369                         s390_lhi (buf, s390_r3, 0);
370                 } else {
371                         s390_l  (buf, s390_r3, 0, s390_r11, S390_RET_ADDR_OFFSET);
372                 }
373                 
374                 /* Arg 3: stack pointer */
375                 s390_lr   (buf, s390_r4, STK_BASE);
376                 s390_ahi  (buf, s390_r4, CREATE_STACK_SIZE);
377                 
378                 /* Calculate call address and call
379                 's390_magic_trampoline'. Return value will be in r2 */
380                 s390_basr (buf, s390_r13, 0);
381                 s390_j    (buf, 4);
382                 if (tramp_type == MONO_TRAMPOLINE_CLASS_INIT) {
383                         s390_word (buf, s390_class_init_trampoline);
384                 } else {
385                         s390_word (buf, s390_magic_trampoline);
386                 }
387                 s390_l    (buf, s390_r1, 0, s390_r13, 4);
388                 s390_basr (buf, s390_r14, s390_r1);
389                 
390                 /* OK, code address is now on r2. Move it to r1, so that we
391                 can restore r2 and use it from r1 later */
392                 s390_lr   (buf, s390_r1, s390_r2);
393
394                 /*----------------------------------------------------------
395                 STEP 3: Restore the LMF
396                 ----------------------------------------------------------*/
397                 restoreLMF(buf, STK_BASE, CREATE_STACK_SIZE);
398         
399                 /*----------------------------------------------------------
400                 STEP 4: call the compiled method
401                 ----------------------------------------------------------*/
402                 
403                 /* Restore registers */
404
405                 s390_lm   (buf, s390_r2, s390_r5, STK_BASE, CREATE_GR_OFFSET);
406                 
407                 /* Restore the FP registers */
408                 offset = CREATE_FP_OFFSET;
409                 for (i = s390_f0; i <= s390_f15; ++i) {
410                         s390_ld  (buf, i, 0, STK_BASE, offset);
411                         offset += 8;
412                 }
413
414                 /* Restore stack pointer and jump to the code - 
415                    R14 contains the return address to our caller */
416                 s390_lr   (buf, STK_BASE, s390_r11);
417                 s390_lm   (buf, s390_r6, s390_r14, STK_BASE, S390_REG_SAVE_OFFSET);
418                 s390_br   (buf, s390_r1);
419
420                 /* Flush instruction cache, since we've generated code */
421                 mono_arch_flush_icache (code, buf - code);
422         
423                 /* Sanity check */
424                 g_assert ((buf - code) <= 512);
425         }
426
427         return code;
428 }
429
430 /*========================= End of Function ========================*/
431
432 /*------------------------------------------------------------------*/
433 /*                                                                  */
434 /* Name         - mono_arch_create_jump_trampoline                  */
435 /*                                                                  */
436 /* Function     - Create the designated type of trampoline according*/
437 /*                to the 'tramp_type' parameter.                    */
438 /*                                                                  */
439 /*------------------------------------------------------------------*/
440
441 MonoJitInfo *
442 mono_arch_create_jump_trampoline (MonoMethod *method)
443 {
444         guint8 *code, *buf, *tramp = NULL;
445         MonoJitInfo *ji;
446         MonoDomain *domain = mono_domain_get();
447         gint32 displace;
448
449         tramp = mono_get_trampoline_code (MONO_TRAMPOLINE_JUMP);
450
451         mono_domain_lock (domain);
452         code = buf = mono_code_manager_reserve (domain->code_mp, METHOD_TRAMPOLINE_SIZE);
453         mono_domain_unlock (domain);
454
455         s390_basr (buf, s390_r1, 0);
456         s390_j    (buf, 4);
457         s390_word (buf, method);
458         s390_l    (buf, s390_r1, 0, s390_r1, 4);
459         displace = (tramp - buf) / 2;
460         s390_jcl  (buf, S390_CC_UN, displace);
461
462         mono_arch_flush_icache (code, buf-code);
463
464         g_assert ((buf - code) <= JUMP_TRAMPOLINE_SIZE);
465         
466         ji              = g_new0 (MonoJitInfo, 1);
467         ji->method      = method;
468         ji->code_start  = code;
469         ji->code_size   = buf - code;
470         
471         mono_jit_stats.method_trampolines++;
472
473         return ji;
474 }
475
476 /*========================= End of Function ========================*/
477
478 /*------------------------------------------------------------------*/
479 /*                                                                  */
480 /* Name         - mono_arch_create_jit_trampoline                   */
481 /*                                                                  */
482 /* Function     - Creates a trampoline function for virtual methods.*/
483 /*                If the created code is called it first starts JIT */
484 /*                compilation and then calls the newly created      */
485 /*                method. It also replaces the corresponding vtable */
486 /*                entry (see s390_magic_trampoline).                */
487 /*                                                                  */
488 /*                A trampoline consists of two parts: a main        */
489 /*                fragment, shared by all method trampolines, and   */
490 /*                and some code specific to each method, which      */
491 /*                hard-codes a reference to that method and then    */
492 /*                calls the main fragment.                          */
493 /*                                                                  */
494 /*                The main fragment contains a call to              */
495 /*                's390_magic_trampoline', which performs a call    */
496 /*                to the JIT compiler and substitutes the method-   */
497 /*                specific fragment with some code that directly    */
498 /*                calls the JIT-compiled method.                    */
499 /*                                                                  */
500 /* Parameter    - method - Pointer to the method information        */
501 /*                                                                  */
502 /* Returns      - A pointer to the newly created code               */
503 /*                                                                  */
504 /*------------------------------------------------------------------*/
505
506 gpointer
507 mono_arch_create_jit_trampoline (MonoMethod *method)
508 {
509         guint8 *code, *buf;
510         static guint8 *vc = NULL;
511         gint32 displace;
512
513         vc = mono_get_trampoline_code (MONO_TRAMPOLINE_GENERIC);
514
515         /*----------------------------------------------------------*/
516         /* This is the method-specific part of the trampoline. Its  */
517         /* purpose is to provide the generic part with the          */
518         /* MonoMethod *method pointer. We'll use r1 to keep it.     */
519         /*----------------------------------------------------------*/
520         code = buf = mono_global_codeman_reserve(METHOD_TRAMPOLINE_SIZE);
521
522         s390_basr (buf, s390_r1, 0);
523         s390_j    (buf, 4);
524         s390_word (buf, method);
525         s390_l    (buf, s390_r1, 0, s390_r1, 4);
526         displace = (vc - buf) / 2;
527         s390_jcl  (buf, S390_CC_UN, displace);
528
529         /* Flush instruction cache, since we've generated code */
530         mono_arch_flush_icache (code, buf - code);
531                 
532         /* Sanity check */
533         g_assert ((buf - code) <= METHOD_TRAMPOLINE_SIZE);
534         
535         return code;
536 }
537
538 /*========================= End of Function ========================*/
539
540 /*------------------------------------------------------------------*/
541 /*                                                                  */
542 /* Name         - mono_arch_create_class_init_trampoline            */
543 /*                                                                  */
544 /* Function     - Creates a trampoline function to run a type init- */
545 /*                ializer. If the trampoline is called, it calls    */
546 /*                mono_runtime_class_init with the given vtable,    */
547 /*                then patches the caller code so it does not get   */
548 /*                called any more.                                  */
549 /*                                                                  */
550 /* Parameter    - vtable - The type to initialize                   */
551 /*                                                                  */
552 /* Returns      - A pointer to the newly created code               */
553 /*                                                                  */
554 /*------------------------------------------------------------------*/
555
556 gpointer
557 mono_arch_create_class_init_trampoline (MonoVTable *vtable)
558 {
559         guint8 *code, *buf, *tramp;
560
561         tramp = mono_get_trampoline_code (MONO_TRAMPOLINE_CLASS_INIT);
562
563         /*-----------------------------------------------------------*/
564         /* This is the method-specific part of the trampoline. Its   */
565         /* purpose is to provide the generic part with the MonoMethod*/
566         /* *method pointer. We'll use r11 to keep that value, for    */
567         /* instance. However, the generic part of the trampoline     */
568         /* relies on r11 having the same value it had before coming  */
569         /* here, so we must save it before.                          */
570         /*-----------------------------------------------------------*/
571         code = buf = mono_global_codeman_reserve(METHOD_TRAMPOLINE_SIZE);
572
573         s390_st   (buf, s390_r14, 0, STK_BASE, S390_RET_ADDR_OFFSET);
574         s390_ahi  (buf, STK_BASE, -S390_MINIMAL_STACK_SIZE);
575
576         s390_basr (buf, s390_r1, 0);
577         s390_j    (buf, 6);
578         s390_word (buf, vtable);
579         s390_word (buf, s390_class_init_trampoline);
580         s390_lr   (buf, s390_r3, s390_r14);
581         s390_l    (buf, s390_r2, 0, s390_r1, 4);
582         s390_lhi  (buf, s390_r4, 0);
583         s390_l    (buf, s390_r1, 0, s390_r1, 8);
584         s390_basr (buf, s390_r14, s390_r1);
585
586         s390_ahi  (buf, STK_BASE, S390_MINIMAL_STACK_SIZE);
587         s390_l    (buf, s390_r14, 0, STK_BASE, S390_RET_ADDR_OFFSET);
588         s390_br   (buf, s390_r14);
589
590         /* Flush instruction cache, since we've generated code */
591         mono_arch_flush_icache (code, buf - code);
592                 
593         /* Sanity check */
594         g_assert ((buf - code) <= METHOD_TRAMPOLINE_SIZE);
595
596         mono_jit_stats.method_trampolines++;
597
598         return code;
599 }
600
601 /*========================= End of Function ========================*/
602
603 /*------------------------------------------------------------------*/
604 /*                                                                  */
605 /* Name         - mono_debuger_create_notification_function         */
606 /*                                                                  */
607 /* Function     - This method is only called when running in the    */
608 /*                Mono debugger. It returns a pointer to the        */
609 /*                arch specific notification function.              */
610 /*                                                                  */
611 /*------------------------------------------------------------------*/
612
613 gpointer
614 mono_debugger_create_notification_function (MonoCodeManager *codeman)
615 {
616         guint8 *ptr, *buf;
617
618         ptr = buf = mono_code_manager_reserve (codeman, 16);
619         s390_break (buf);
620         s390_br (buf, s390_r14);
621
622         return ptr;
623 }
624
625 /*========================= End of Function ========================*/