From: Zoltan Varga Date: Mon, 21 Dec 2015 22:06:53 +0000 (-0500) Subject: [aot] Add hooks which can be used by embedders to load the aot data for aot images... X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=b362500d857a4a03cbdc38a4dc7a3755d768afb9;p=mono.git [aot] Add hooks which can be used by embedders to load the aot data for aot images compiled with --aot=data-outfile=... --- diff --git a/mono/mini/aot-runtime.c b/mono/mini/aot-runtime.c index 1e28aaef20c..8586cf50eea 100644 --- a/mono/mini/aot-runtime.c +++ b/mono/mini/aot-runtime.c @@ -211,6 +211,11 @@ static mono_mutex_t aot_page_mutex; static MonoAotModule *mscorlib_aot_module; +/* Embedding API hooks to load the AOT data for AOT images compiled with MONO_AOT_FILE_FLAG_SEPARATE_DATA */ +static MonoLoadAotDataFunc aot_data_load_func; +static MonoFreeAotDataFunc aot_data_free_func; +static gpointer aot_data_func_user_data; + static void init_plt (MonoAotModule *info); @@ -1661,6 +1666,14 @@ find_symbol (MonoDl *module, gpointer *globals, const char *name, gpointer *valu } } +void +mono_install_load_aot_data_hook (MonoLoadAotDataFunc load_func, MonoFreeAotDataFunc free_func, gpointer user_data) +{ + aot_data_load_func = load_func; + aot_data_free_func = free_func; + aot_data_func_user_data = user_data; +} + /* Load the separate aot data file for ASSEMBLY */ static guint8* open_aot_data (MonoAssembly *assembly, MonoAotFileInfo *info, void **ret_handle) @@ -1669,13 +1682,19 @@ open_aot_data (MonoAssembly *assembly, MonoAotFileInfo *info, void **ret_handle) char *filename; guint8 *data; + if (aot_data_load_func) { + data = aot_data_load_func (assembly, info->datafile_size, aot_data_func_user_data, ret_handle); + g_assert (data); + return data; + } + /* * Use .aotdata as the default implementation if no callback is given */ filename = g_strdup_printf ("%s.aotdata", assembly->image->name); map = mono_file_map_open (filename); g_assert (map); - data = mono_file_map (info->datafile_size, MONO_MMAP_READ|MONO_MMAP_PRIVATE, mono_file_map_fd (map), 0, ret_handle); + data = mono_file_map (info->datafile_size, MONO_MMAP_READ, mono_file_map_fd (map), 0, ret_handle); g_assert (data); return data; diff --git a/mono/mini/mini.h b/mono/mini/mini.h index 9a7916000a0..8c6913add30 100644 --- a/mono/mini/mini.h +++ b/mono/mini/mini.h @@ -2430,6 +2430,16 @@ void mono_aot_init_gshared_method_rgctx (gpointer aot_module, guint32 metho /* This is an exported function */ MONO_API void mono_aot_register_module (gpointer *aot_info); +/* These are used to load the AOT data for aot images compiled with MONO_AOT_FILE_FLAG_SEPARATE_DATA */ +/* + * Return the AOT data for ASSEMBLY. SIZE is the size of the data. OUT_HANDLE should be set to a handle which is later + * passed to the free function. + */ +typedef unsigned char* (*MonoLoadAotDataFunc) (MonoAssembly *assembly, int size, gpointer user_data, void **out_handle); +/* Not yet used */ +typedef void (*MonoFreeAotDataFunc) (MonoAssembly *assembly, int size, gpointer user_data, void *handle); +MONO_API void mono_install_load_aot_data_hook (MonoLoadAotDataFunc load_func, MonoFreeAotDataFunc free_func, gpointer user_data); + void mono_xdebug_init (const char *xdebug_opts); void mono_save_xdebug_info (MonoCompile *cfg); void mono_save_trampoline_xdebug_info (MonoTrampInfo *info);