#include <mono/metadata/coree.h>
#include <mono/metadata/attach.h>
#include "mono/utils/mono-counters.h"
-#include <mono/utils/gc_wrapper.h>
#include "mini.h"
#include "jit.h"
NULL
};
+#ifdef __native_client_codegen__
+extern gint8 nacl_align_byte;
+#endif
+#ifdef __native_client__
+extern char *nacl_mono_path;
+#endif
#define DEFAULT_OPTIMIZATIONS ( \
MONO_OPT_PEEPHOLE | \
MONO_OPT_BRANCH | MONO_OPT_PEEPHOLE | MONO_OPT_LINEARS | MONO_OPT_CFOLD,
MONO_OPT_BRANCH | MONO_OPT_PEEPHOLE | MONO_OPT_LINEARS | MONO_OPT_COPYPROP | MONO_OPT_CONSPROP | MONO_OPT_DEADCE,
MONO_OPT_BRANCH | MONO_OPT_PEEPHOLE | MONO_OPT_LINEARS | MONO_OPT_COPYPROP | MONO_OPT_CONSPROP | MONO_OPT_DEADCE | MONO_OPT_LOOP | MONO_OPT_INLINE | MONO_OPT_INTRINS,
+ MONO_OPT_BRANCH | MONO_OPT_PEEPHOLE | MONO_OPT_LINEARS | MONO_OPT_COPYPROP | MONO_OPT_CONSPROP | MONO_OPT_DEADCE | MONO_OPT_LOOP | MONO_OPT_INLINE | MONO_OPT_INTRINS | MONO_OPT_TAILC,
MONO_OPT_BRANCH | MONO_OPT_PEEPHOLE | MONO_OPT_LINEARS | MONO_OPT_COPYPROP | MONO_OPT_CONSPROP | MONO_OPT_DEADCE | MONO_OPT_LOOP | MONO_OPT_INLINE | MONO_OPT_INTRINS | MONO_OPT_SSA,
MONO_OPT_BRANCH | MONO_OPT_PEEPHOLE | MONO_OPT_LINEARS | MONO_OPT_COPYPROP | MONO_OPT_CONSPROP | MONO_OPT_DEADCE | MONO_OPT_LOOP | MONO_OPT_INLINE | MONO_OPT_INTRINS | MONO_OPT_EXCEPTION,
MONO_OPT_BRANCH | MONO_OPT_PEEPHOLE | MONO_OPT_LINEARS | MONO_OPT_COPYPROP | MONO_OPT_CONSPROP | MONO_OPT_DEADCE | MONO_OPT_LOOP | MONO_OPT_INLINE | MONO_OPT_INTRINS | MONO_OPT_EXCEPTION | MONO_OPT_CMOV,
" --stats Print statistics about the JIT operations\n"
" --wapi=hps|semdel|seminfo IO-layer maintenance\n"
" --inject-async-exc METHOD OFFSET Inject an asynchronous exception at METHOD\n"
- " --verify-all Run the verifier on all methods\n"
+ " --verify-all Run the verifier on all assemblies and methods\n"
" --full-aot Avoid JITting any code\n"
" --agent=ASSEMBLY[:ARG] Loads the specific agent assembly and executes its Main method with the given argument before loading the main assembly.\n"
" --no-x86-stack-align Don't align stack on x86\n"
" --trace[=EXPR] Enable tracing, use --help-trace for details\n"
" --jitmap Output a jit method map to /tmp/perf-PID.map\n"
" --help-devel Shows more options available to developers\n"
+#ifdef __native_client_codegen__
+ " --nacl-align-mask-off Turn off Native Client 32-byte alignment mask (for debug only)\n"
+#endif
"\n"
"Runtime:\n"
" --config FILE Loads FILE as the Mono config\n"
" mode is one of cas, core-clr, verifiable or validil\n"
" --attach=OPTIONS Pass OPTIONS to the attach agent in the runtime.\n"
" Currently the only supported option is 'disable'.\n"
- " --llvm Controls whenever the runtime uses LLVM compiled code.\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"
);
}
#else
"\tTLS: normal\n"
#endif /* HAVE_KW_THREAD */
- "\tGC: " USED_GC_NAME "\n"
#ifdef MONO_ARCH_SIGSEGV_ON_ALTSTACK
"\tSIGSEGV: altstack\n"
#else
#endif
"\n"
#ifdef MONO_ARCH_LLVM_SUPPORTED
- "\tLLVM supported\n"
+#ifdef ENABLE_LLVM
+ "\tLLVM: yes(" LLVM_VERSION ")\n"
+#else
+ "\tLLVM: supported, not enabled.\n"
+#endif
#endif
"";
#ifdef HOST_WIN32
BOOL APIENTRY DllMain (HMODULE module_handle, DWORD reason, LPVOID reserved)
{
- if (!GC_DllMain (module_handle, reason, reserved))
+ if (!mono_gc_dllmain (module_handle, reason, reserved))
return FALSE;
switch (reason)
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;
}
}
+static void
+mono_set_use_smp (int use_smp)
+{
+#if HAVE_SCHED_SETAFFINITY
+ if (!use_smp) {
+ unsigned long proc_mask = 1;
+#ifdef GLIBC_BEFORE_2_3_4_SCHED_SETAFFINITY
+ sched_setaffinity (getpid(), (gpointer)&proc_mask);
+#else
+ sched_setaffinity (getpid(), sizeof (unsigned long), (gpointer)&proc_mask);
+#endif
+ }
+#endif
+}
+
+
+/**
+ * mono_main:
+ * @argc: number of arguments in the argv array
+ * @argv: array of strings containing the startup arguments
+ *
+ * Launches the Mono JIT engine and parses all the command line options
+ * in the same way that the mono command line VM would.
+ */
int
mono_main (int argc, char* argv[])
{
int test_jit_info_table = FALSE;
#endif
- setlocale (LC_ALL, "");
-
-#if HAVE_SCHED_SETAFFINITY
- if (getenv ("MONO_NO_SMP")) {
- unsigned long proc_mask = 1;
-#ifdef GLIBC_BEFORE_2_3_4_SCHED_SETAFFINITY
- sched_setaffinity (getpid(), (gpointer)&proc_mask);
-#else
- sched_setaffinity (getpid(), sizeof (unsigned long), (gpointer)&proc_mask);
+#ifdef MOONLIGHT
+#ifndef HOST_WIN32
+ /* stdout defaults to block buffering if it's not writing to a terminal, which
+ * happens with our test harness: we redirect stdout to capture it. Force line
+ * buffering in all cases. */
+ setlinebuf (stdout);
#endif
- }
#endif
+
+ setlocale (LC_ALL, "");
+
+ if (getenv ("MONO_NO_SMP"))
+ mono_set_use_smp (FALSE);
+
if (!g_thread_supported ())
g_thread_init (NULL);
mini_verbose++;
} else if (strcmp (argv [i], "--version") == 0 || strcmp (argv [i], "-V") == 0) {
char *build = mono_get_runtime_build_info ();
- g_print ("Mono JIT compiler version %s\nCopyright (C) 2002-2010 Novell, Inc and Contributors. www.mono-project.com\n", build);
+ char *gc_descr;
+
+ g_print ("Mono JIT compiler version %s\nCopyright (C) 2002-2011 Novell, Inc and Contributors. www.mono-project.com\n", build);
g_free (build);
g_print (info);
+ gc_descr = mono_gc_get_description ();
+ g_print ("\tGC: %s\n", gc_descr);
+ g_free (gc_descr);
if (mini_verbose) {
const char *cerror;
const char *clibpath;
opt = parse_optimizations (argv [i] + 11);
} else if (strncmp (argv [i], "-O=", 3) == 0) {
opt = parse_optimizations (argv [i] + 3);
+ } else if (strcmp (argv [i], "--gc=sgen") == 0) {
+ if (!strcmp (mono_gc_get_gc_name (), "boehm")) {
+ GString *path = g_string_new (argv [0]);
+ g_string_append (path, "-sgen");
+ argv [0] = path->str;
+#ifdef HAVE_EXECVP
+ execvp (path->str, argv);
+#else
+ fprintf (stderr, "Error: --gc=<NAME> option not supported on this platform.\n");
+#endif
+ }
+ } else if (strcmp (argv [i], "--gc=boehm") == 0) {
+ if (!strcmp (mono_gc_get_gc_name (), "sgen")) {
+ char *copy = g_strdup (argv [0]);
+ char *p = strstr (copy, "-sgen");
+ if (p == NULL){
+ fprintf (stderr, "Error, this process is not named mono-sgen and the command line option --boehm was passed");
+ exit (1);
+ }
+ *p = 0;
+ argv [0] = p;
+#ifdef HAVE_EXECVP
+ execvp (p, argv);
+#else
+ fprintf (stderr, "Error: --gc=<NAME> option not supported on this platform.\n");
+#endif
+ }
} else if (strcmp (argv [i], "--config") == 0) {
if (i +1 >= argc){
fprintf (stderr, "error: --config requires a filename argument\n");
return 1;
}
} else if (strcmp (argv [i], "--desktop") == 0) {
-#if defined (HAVE_BOEHM_GC)
- GC_dont_expand = 1;
-#endif
+ mono_gc_set_desktop_mode ();
/* Put desktop-specific optimizations here */
} else if (strcmp (argv [i], "--server") == 0){
/* Put server-specific optimizations here */
#endif
} else if (strcmp (argv [i], "--nollvm") == 0){
mono_use_llvm = FALSE;
+#ifdef __native_client_codegen__
+ } else if (strcmp (argv [i], "--nacl-align-mask-off") == 0){
+ nacl_align_byte = -1; /* 0xff */
+#endif
+#ifdef __native_client__
+ } else if (strcmp (argv [i], "--nacl-mono-path") == 0){
+ nacl_mono_path = g_strdup(argv[++i]);
+#endif
} else {
fprintf (stderr, "Unknown command line option: '%s'\n", argv [i]);
return 1;
}
}
+#ifdef __native_client_codegen__
+ if (getenv ("MONO_NACL_ALIGN_MASK_OFF"))
+ {
+ nacl_align_byte = -1; /* 0xff */
+ }
+#endif
+
if (!argv [i]) {
mini_usage ();
return 1;
}
#endif
- /*
- * This must be called before mono_debug_init(), because the
- * latter registers GC roots.
- */
- mono_gc_base_init ();
-
if (action == DO_DEBUGGER) {
enable_debugging = TRUE;