Skip to content

Commit

Permalink
Replace ENABLE_COREE with a runtime switch.
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Povirk authored and gonzalop committed Mar 25, 2011
1 parent 3d67797 commit e439067
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 27 deletions.
2 changes: 1 addition & 1 deletion mono/metadata/assembly.c
Expand Up @@ -1634,7 +1634,7 @@ mono_assembly_load_from_full (MonoImage *image, const char*fname,
loaded_assemblies = g_list_prepend (loaded_assemblies, ass);
mono_assemblies_unlock ();

#ifdef ENABLE_COREE
#ifdef HOST_WIN32
if (image->is_module_handle)
mono_image_fixup_vtable (image);
#endif
Expand Down
7 changes: 0 additions & 7 deletions mono/metadata/coree.c
Expand Up @@ -33,14 +33,10 @@
#include "environment.h"
#include "coree.h"

#ifdef ENABLE_COREE

HMODULE coree_module_handle = NULL;

static gboolean init_from_coree = FALSE;

#endif

gchar*
mono_get_module_file_name (HMODULE module_handle)
{
Expand Down Expand Up @@ -73,7 +69,6 @@ mono_get_module_file_name (HMODULE module_handle)
return file_name_utf8;
}

#ifdef ENABLE_COREE
/* Entry point called by LdrLoadDll of ntdll.dll after _CorValidateImage. */
BOOL STDMETHODCALLTYPE _CorDllMain(HINSTANCE hInst, DWORD dwReason, LPVOID lpReserved)
{
Expand Down Expand Up @@ -928,6 +923,4 @@ mono_fixup_exe_image (MonoImage* image)
MonoFixupExe ((HMODULE) image->raw_data);
}

#endif /* ENABLE_COREE */

#endif /* HOST_WIN32 */
5 changes: 1 addition & 4 deletions mono/metadata/domain.c
Expand Up @@ -1242,9 +1242,6 @@ mono_init_internal (const char *filename, const char *exe_filename, const char *
#ifdef HOST_WIN32
/* Avoid system error message boxes. */
SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
#ifdef ENABLE_COREE
mono_load_coree (exe_filename);
#endif
#endif

mono_perfcounters_init ();
Expand Down Expand Up @@ -1283,7 +1280,7 @@ mono_init_internal (const char *filename, const char *exe_filename, const char *
* exe_image, and close it during shutdown.
*/
get_runtimes_from_exe (exe_filename, &exe_image, runtimes);
#ifdef ENABLE_COREE
#ifdef HOST_WIN32
if (!exe_image) {
exe_image = mono_assembly_open_from_bundle (exe_filename, NULL, FALSE);
if (!exe_image)
Expand Down
26 changes: 13 additions & 13 deletions mono/metadata/image.c
Expand Up @@ -121,7 +121,7 @@ mono_cli_rva_image_map (MonoImage *image, guint32 addr)
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
Expand Down Expand Up @@ -158,7 +158,7 @@ mono_image_rva_map (MonoImage *image, guint32 addr)
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
Expand Down Expand Up @@ -239,7 +239,7 @@ mono_image_ensure_section_idx (MonoImage *image, int section)

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
Expand Down Expand Up @@ -628,7 +628,7 @@ mono_image_load_module (MonoImage *image, int idx)
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
Expand Down Expand Up @@ -702,7 +702,7 @@ do_load_header (MonoImage *image, MonoDotNetHeader *header, int offset)
{
MonoDotNetHeader64 header64;

#ifdef ENABLE_COREE
#ifdef HOST_WIN32
if (!image->is_module_handle)
#endif
if (offset + sizeof (MonoDotNetHeader32) > image->raw_data_len)
Expand Down Expand Up @@ -823,7 +823,7 @@ do_load_header (MonoImage *image, MonoDotNetHeader *header, int offset)
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
Expand All @@ -842,7 +842,7 @@ mono_image_load_pe_data (MonoImage *image)
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)
Expand Down Expand Up @@ -1178,7 +1178,7 @@ mono_image_open_from_data (char *data, guint32 data_len, gboolean need_copy, Mon
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)
Expand Down Expand Up @@ -1212,7 +1212,7 @@ mono_image_open_full (const char *fname, MonoImageOpenStatus *status, gboolean r

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;
Expand Down Expand Up @@ -1364,7 +1364,7 @@ mono_image_open_raw (const char *fname, MonoImageOpenStatus *status)
void
mono_image_fixup_vtable (MonoImage *image)
{
#ifdef ENABLE_COREE
#ifdef HOST_WIN32
MonoCLIImageInfo *iinfo;
MonoPEDirEntry *de;
MonoVTableFixup *vtfixup;
Expand Down Expand Up @@ -1502,7 +1502,7 @@ mono_image_close_except_pools (MonoImage *image)

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) {
Expand Down Expand Up @@ -1545,7 +1545,7 @@ mono_image_close_except_pools (MonoImage *image)
}
}

#ifdef ENABLE_COREE
#ifdef HOST_WIN32
mono_images_lock ();
if (image->is_module_handle && !image->has_entry_point)
FreeLibrary ((HMODULE) image->raw_data);
Expand Down Expand Up @@ -2000,7 +2000,7 @@ mono_image_load_file_for_image (MonoImage *image, int fileidx)
}

image->files [fileidx - 1] = res;
#ifdef ENABLE_COREE
#ifdef HOST_WIN32
if (res->is_module_handle)
mono_image_fixup_vtable (res);
#endif
Expand Down
17 changes: 15 additions & 2 deletions mono/mini/driver.c
Expand Up @@ -1143,6 +1143,9 @@ mini_usage (void)
" Currently the only supported option is 'disable'.\n"
" --llvm, --nollvm Controls whenever the runtime uses LLVM to compile code.\n"
" --gc=[sgen,boehm] Select SGen or Boehm GC (runs mono or mono-sgen)\n"
#ifdef HOST_WIN32
" --mixed-mode Enable mixed-mode image support.\n"
#endif
);
}

Expand Down Expand Up @@ -1250,10 +1253,8 @@ BOOL APIENTRY DllMain (HMODULE module_handle, DWORD reason, LPVOID reserved)
mono_install_runtime_load (mini_init);
break;
case DLL_PROCESS_DETACH:
#ifdef ENABLE_COREE
if (coree_module_handle)
FreeLibrary (coree_module_handle);
#endif
break;
}
return TRUE;
Expand Down Expand Up @@ -1345,6 +1346,9 @@ mono_main (int argc, char* argv[])
#ifdef MONO_JIT_INFO_TABLE_TEST
int test_jit_info_table = FALSE;
#endif
#ifdef HOST_WIN32
int mixed_mode = FALSE;
#endif

#ifdef MOONLIGHT
#ifndef HOST_WIN32
Expand Down Expand Up @@ -1473,6 +1477,10 @@ mono_main (int argc, char* argv[])
return 1;
}
config_file = argv [++i];
#ifdef HOST_WIN32
} else if (strcmp (argv [i], "--mixed-mode") == 0) {
mixed_mode = TRUE;
#endif
} else if (strcmp (argv [i], "--ncompile") == 0) {
if (i + 1 >= argc){
fprintf (stderr, "error: --ncompile requires an argument\n");
Expand Down Expand Up @@ -1737,6 +1745,11 @@ mono_main (int argc, char* argv[])
}
#endif

#ifdef HOST_WIN32
if (mixed_mode)
mono_load_coree (argv [i]);
#endif

mono_set_defaults (mini_verbose, opt);
domain = mini_init (argv [i], forced_version);

Expand Down

0 comments on commit e439067

Please sign in to comment.