[runtime] Adds AOTID
authorMarcos Henrich <marcos.henrich@xamarin.com>
Mon, 16 May 2016 16:08:39 +0000 (17:08 +0100)
committerMarcos Henrich <marcos.henrich@xamarin.com>
Fri, 8 Jul 2016 21:38:22 +0000 (22:38 +0100)
AOTID is a GUID generated by the AOT compiler and stored along with the
native code.

The AOTID uniquely identifies the generated native assembly.

The AOTID is required when we want to map native offsets to IL offsets
and the sequence points mapping those values need to be determined.

mono/metadata/metadata-internals.h
mono/mini/aot-compiler.c
mono/mini/aot-runtime.c
mono/mini/mini.h

index 96f6a5da7c90f3c924b02fe338f3a3eb4f728f95..a1b9eb841781775dcf0fdc3cc5d768ddcfde08e8 100644 (file)
@@ -271,6 +271,8 @@ struct _MonoImage {
 
        gpointer aot_module;
 
+       guint8 aotid[16];
+
        /*
         * The Assembly this image was loaded from.
         */
index 7c3fa351ccef1d807ab5e4d2c43863f7d1bb8aea..efb9e19fa44e2690b6ea2c225fe8e5dde46ce3ce 100644 (file)
@@ -51,6 +51,7 @@
 #include <mono/utils/mono-compiler.h>
 #include <mono/utils/mono-time.h>
 #include <mono/utils/mono-mmap.h>
+#include <mono/utils/mono-rand.h>
 #include <mono/utils/json.h>
 #include <mono/utils/mono-threads-coop.h>
 
@@ -8867,6 +8868,21 @@ emit_extra_methods (MonoAotCompile *acfg)
        emit_aot_data (acfg, MONO_AOT_TABLE_EXTRA_METHOD_INFO_OFFSETS, "extra_method_info_offsets", buf, p - buf);
 }      
 
+static void
+generate_aotid (guint8* aotid)
+{
+       gpointer *rand_handle;
+       MonoError error;
+
+       mono_rand_open ();
+       rand_handle = mono_rand_init (NULL, 0);
+
+       mono_rand_try_get_bytes (rand_handle, aotid, 16, &error);
+       mono_error_assert_ok (&error);
+
+       mono_rand_close (rand_handle);
+}
+
 static void
 emit_exception_info (MonoAotCompile *acfg)
 {
@@ -9360,6 +9376,8 @@ init_aot_file_info (MonoAotCompile *acfg, MonoAotFileInfo *info)
        info->nshared_got_entries = acfg->nshared_got_entries;
        for (i = 0; i < MONO_AOT_TRAMP_NUM; ++i)
                info->tramp_page_code_offsets [i] = acfg->tramp_page_code_offsets [i];
+
+       generate_aotid(&info->aotid);
 }
 
 static void
index d4eb786235ed89a7de1860e7c2be46fce9e9ecab..d60828b00275760042eed71237eb699886164971 100644 (file)
@@ -2002,6 +2002,9 @@ load_aot_module (MonoAssembly *assembly, gpointer user_data)
                find_symbol (sofile, globals, "mono_aot_file_info", (gpointer*)&info);
        }
 
+       // Copy aotid to MonoImage
+       memcpy(&assembly->image->aotid, info->aotid, 16);
+
        if (version_symbol) {
                /* Old file format */
                version = atoi (version_symbol);
index 25c208c8389efa27d5e2cc5b6e4ff02b3ea8f691..c55c89c0988924a3440afbee6b54d18dc0ec4f5b 100644 (file)
@@ -315,6 +315,8 @@ typedef struct MonoAotFileInfo
        guint32 trampoline_size [MONO_AOT_TRAMP_NUM];
        /* The offset where the trampolines begin on a trampoline page */
        guint32 tramp_page_code_offsets [MONO_AOT_TRAMP_NUM];
+       /* GUID of aot compilation */
+       guint8 aotid[16];
 } MonoAotFileInfo;
 
 /* Number of symbols in the MonoAotFileInfo structure */