[jit] Add a new MONO_RGCTX_INFO_ELEMENT_KLASS info type and use it instead of MONO_RG...
[mono.git] / mono / mini / tramp-s390x.c
index d694c70f01db531db14c953ada975f3bd12c622e..e6bbe8ccb7eea82ff0a57b974d5da42086ef6408 100644 (file)
 #include <glib.h>
 #include <string.h>
 
+#include <mono/metadata/abi-details.h>
 #include <mono/metadata/appdomain.h>
 #include <mono/metadata/marshal.h>
 #include <mono/metadata/tabledefs.h>
+#include <mono/metadata/profiler-private.h>
 #include <mono/arch/s390x/s390x-codegen.h>
 
 #include "mini.h"
@@ -107,6 +109,7 @@ mono_arch_get_unbox_trampoline (MonoMethod *method, gpointer addr)
        g_assert ((code - start) <= 28);
 
        mono_arch_flush_icache (start, code - start);
+       mono_profiler_code_buffer_new (start, code - start, MONO_PROFILER_CODE_BUFFER_UNBOX_TRAMPOLINE, method);
 
        return start;
 }
@@ -133,9 +136,6 @@ mono_arch_patch_callsite (guint8 *method_start, guint8 *orig_code, guint8 *addr)
                S390_EMIT_CALL((orig_code - 14), addr);
                mono_arch_flush_icache (orig_code - 14, 12);
        } else {
-fprintf(stderr, "%p %02x %02x %02x %02x\n",
-&orig_code[-14], orig_code[-12], orig_code[-11], orig_code[-6], orig_code[-5]);
-fflush(stderr);
                /* This is the 'brasl' instruction */
                orig_code    -= 4;
                displace = ((gssize) addr - (gssize) (orig_code - 2)) / 2;
@@ -199,6 +199,9 @@ mono_arch_get_nullified_class_init_trampoline (MonoTrampInfo **info)
 
        s390_br (code, s390_r14);
 
+       mono_arch_flush_icache (buf, code - buf);
+       mono_profiler_code_buffer_new (buf, code - buf, MONO_PROFILER_CODE_BUFFER_HELPER, NULL);
+
        if (info)
                *info = mono_tramp_info_create ("nullified_class_init_trampoline", 
                                                buf, code - buf, NULL, NULL);
@@ -401,6 +404,7 @@ mono_arch_create_generic_trampoline (MonoTrampolineType tramp_type, MonoTrampInf
 
        /* Flush instruction cache, since we've generated code */
        mono_arch_flush_icache (code, buf - code);
+       mono_profiler_code_buffer_new (buf, code - buf, MONO_PROFILER_CODE_BUFFER_GENERICS_TRAMPOLINE, NULL);
        
        if (info) {
                tramp_name = mono_get_generic_trampoline_name (tramp_type);
@@ -467,6 +471,8 @@ mono_arch_create_specific_trampoline (gpointer arg1, MonoTrampolineType tramp_ty
 
        /* Flush instruction cache, since we've generated code */
        mono_arch_flush_icache (code, buf - code);
+       mono_profiler_code_buffer_new (buf, code - buf, MONO_PROFILER_CODE_BUFFER_SPECIFIC_TRAMPOLINE, 
+                                      (void *) mono_get_generic_trampoline_simple_name (tramp_type));
 
        /* Sanity check */
        g_assert ((buf - code) <= SPECIFIC_TRAMPOLINE_SIZE);
@@ -533,7 +539,7 @@ mono_arch_create_rgctx_lazy_fetch_trampoline (guint32 slot, MonoTrampInfo **info
                s390_lgr (code, s390_r1, s390_r2);
        } else {
                /* load rgctx ptr from vtable */
-               s390_lg (code, s390_r1, 0, s390_r2, G_STRUCT_OFFSET(MonoVTable, runtime_generic_context));
+               s390_lg (code, s390_r1, 0, s390_r2, MONO_STRUCT_OFFSET(MonoVTable, runtime_generic_context));
                /* is the rgctx ptr null? */
                s390_ltgr (code, s390_r1, s390_r1);
                /* if yes, jump to actual trampoline */
@@ -582,6 +588,7 @@ mono_arch_create_rgctx_lazy_fetch_trampoline (guint32 slot, MonoTrampInfo **info
        s390_jg (code, displace);
 
        mono_arch_flush_icache (buf, code - buf);
+       mono_profiler_code_buffer_new (buf, code - buf, MONO_PROFILER_CODE_BUFFER_GENERICS_TRAMPOLINE, NULL);
 
        g_assert (code - buf <= tramp_size);
 
@@ -630,6 +637,7 @@ mono_arch_get_static_rgctx_trampoline (MonoMethod *m,
        g_assert ((code - start) < buf_len);
 
        mono_arch_flush_icache (start, code - start);
+       mono_profiler_code_buffer_new (start, code - start, MONO_PROFILER_CODE_BUFFER_HELPER, NULL);
 
        return(start);
 }      
@@ -700,6 +708,7 @@ mono_arch_create_handler_block_trampoline (MonoTrampInfo **info, gboolean aot)
        }
 
        mono_arch_flush_icache (buf, code - buf);
+       mono_profiler_code_buffer_new (buf, code - buf, MONO_PROFILER_CODE_BUFFER_HELPER, NULL);
        g_assert (code - buf <= tramp_size);
 
        if (info)