#include <mono/utils/mono-path.h>
#include <mono/utils/mono-mmap.h>
#include <mono/utils/mono-io-portability.h>
+#include <mono/utils/atomic.h>
#include <mono/metadata/class-internals.h>
#include <mono/metadata/assembly.h>
#include <mono/metadata/object-internals.h>
for (i = 0; i < top; i++){
if ((addr >= tables->st_virtual_address) &&
(addr < tables->st_virtual_address + tables->st_raw_data_size)){
-#ifdef ENABLE_COREE
+#ifdef HOST_WIN32
if (image->is_module_handle)
return addr;
#endif
if (!mono_image_ensure_section_idx (image, i))
return NULL;
}
-#ifdef ENABLE_COREE
+#ifdef HOST_WIN32
if (image->is_module_handle)
return image->raw_data + addr;
#endif
if (sect->st_raw_data_ptr + sect->st_raw_data_size > image->raw_data_len)
return FALSE;
-#ifdef ENABLE_COREE
+#ifdef HOST_WIN32
if (image->is_module_handle)
iinfo->cli_sections [section] = image->raw_data + sect->st_virtual_address;
else
if (image->modules [idx - 1]) {
mono_image_addref (image->modules [idx - 1]);
image->modules [idx - 1]->assembly = image->assembly;
-#ifdef ENABLE_COREE
+#ifdef HOST_WIN32
if (image->modules [idx - 1]->is_module_handle)
mono_image_fixup_vtable (image->modules [idx - 1]);
#endif
{
MonoDotNetHeader64 header64;
-#ifdef ENABLE_COREE
+#ifdef HOST_WIN32
if (!image->is_module_handle)
#endif
if (offset + sizeof (MonoDotNetHeader32) > image->raw_data_len)
SWAPPDE (header->datadir.pe_cli_header);
SWAPPDE (header->datadir.pe_reserved);
-#ifdef ENABLE_COREE
+#ifdef HOST_WIN32
if (image->is_module_handle)
image->raw_data_len = header->nt.pe_image_size;
#endif
iinfo = image->image_info;
header = &iinfo->cli_header;
-#ifdef ENABLE_COREE
+#ifdef HOST_WIN32
if (!image->is_module_handle)
#endif
if (offset + sizeof (msdos) > image->raw_data_len)
image->raw_buffer_used = TRUE;
image->raw_data_len = mono_file_map_size (filed);
image->raw_data = mono_file_map (image->raw_data_len, MONO_MMAP_READ|MONO_MMAP_PRIVATE, mono_file_map_fd (filed), 0, &image->raw_data_handle);
+#if defined(HAVE_MMAP) && !defined (HOST_WIN32)
+ if (!image->raw_data) {
+ image->fileio_used = TRUE;
+ image->raw_data = mono_file_map_fileio (image->raw_data_len, MONO_MMAP_READ|MONO_MMAP_PRIVATE, mono_file_map_fd (filed), 0, &image->raw_data_handle);
+ }
+#endif
if (!image->raw_data) {
mono_file_map_close (filed);
g_free (image);
return mono_image_open_from_data_full (data, data_len, need_copy, status, FALSE);
}
-#ifdef ENABLE_COREE
+#ifdef HOST_WIN32
/* fname is not duplicated. */
MonoImage*
mono_image_open_from_module_handle (HMODULE module_handle, char* fname, gboolean has_entry_point, MonoImageOpenStatus* status)
g_return_val_if_fail (fname != NULL, NULL);
-#ifdef ENABLE_COREE
+#ifdef HOST_WIN32
/* Load modules using LoadLibrary. */
if (!refonly && coree_module_handle) {
HMODULE module_handle;
void
mono_image_fixup_vtable (MonoImage *image)
{
-#ifdef ENABLE_COREE
+#ifdef HOST_WIN32
MonoCLIImageInfo *iinfo;
MonoPEDirEntry *de;
MonoVTableFixup *vtfixup;
mono_images_unlock ();
-#ifdef ENABLE_COREE
+#ifdef HOST_WIN32
if (image->is_module_handle && image->has_entry_point) {
mono_images_lock ();
if (image->ref_count == 0) {
}
}
-#ifdef ENABLE_COREE
+#ifdef HOST_WIN32
mono_images_lock ();
if (image->is_module_handle && !image->has_entry_point)
FreeLibrary ((HMODULE) image->raw_data);
#endif
if (image->raw_buffer_used) {
- if (image->raw_data != NULL)
- mono_file_unmap (image->raw_data, image->raw_data_handle);
+ if (image->raw_data != NULL) {
+#ifndef HOST_WIN32
+ if (image->fileio_used)
+ mono_file_unmap_fileio (image->raw_data, image->raw_data_handle);
+ else
+#endif
+ mono_file_unmap (image->raw_data, image->raw_data_handle);
+ }
}
if (image->raw_data_allocated) {
free_hash (image->delegate_invoke_cache);
free_hash (image->delegate_abstract_invoke_cache);
free_hash (image->delegate_bound_static_invoke_cache);
+ free_hash (image->delegate_invoke_generic_cache);
+ free_hash (image->delegate_begin_invoke_generic_cache);
+ free_hash (image->delegate_end_invoke_generic_cache);
free_hash (image->remoting_invoke_cache);
free_hash (image->runtime_invoke_cache);
free_hash (image->runtime_invoke_direct_cache);
free_hash (image->thunk_invoke_cache);
free_hash (image->var_cache_slow);
free_hash (image->mvar_cache_slow);
+ free_hash (image->wrapper_param_names);
+ free_hash (image->native_wrapper_aot_cache);
+ free_hash (image->pinvoke_scopes);
+ free_hash (image->pinvoke_scope_filenames);
/* The ownership of signatures is not well defined */
//g_hash_table_foreach (image->memberref_signatures, free_mr_signatures, NULL);
if (image->modules)
g_free (image->modules);
+#ifndef DISABLE_PERFCOUNTERS
mono_perfcounters->loader_bytes -= mono_mempool_get_allocated (image->mempool);
+#endif
if (!image->dynamic) {
if (debug_assembly_unload)
}
image->files [fileidx - 1] = res;
-#ifdef ENABLE_COREE
+#ifdef HOST_WIN32
if (res->is_module_handle)
mono_image_fixup_vtable (res);
#endif
{
gpointer res;
+#ifndef DISABLE_PERFCOUNTERS
mono_perfcounters->loader_bytes += size;
+#endif
mono_image_lock (image);
res = mono_mempool_alloc (image->mempool, size);
mono_image_unlock (image);
{
gpointer res;
+#ifndef DISABLE_PERFCOUNTERS
mono_perfcounters->loader_bytes += size;
+#endif
mono_image_lock (image);
res = mono_mempool_alloc0 (image->mempool, size);
mono_image_unlock (image);
{
char *res;
+#ifndef DISABLE_PERFCOUNTERS
mono_perfcounters->loader_bytes += strlen (s);
+#endif
mono_image_lock (image);
res = mono_mempool_strdup (image->mempool, s);
mono_image_unlock (image);