-
-/*
- * mini-runtime.c: Runtime code for the JIT
+/**
+ * \file
+ * Runtime code for the JIT
*
* Authors:
* Paolo Molaro (lupus@ximian.com)
/**
* mono_pmip:
- * @ip: an instruction pointer address
+ * \param ip an instruction pointer address
*
* This method is used from a debugger to get the name of the
- * method at address @ip. This routine is typically invoked from
+ * method at address \p ip. This routine is typically invoked from
* a debugger like this:
*
* (gdb) print mono_pmip ($pc)
*
- * Returns: the name of the method at address @ip.
+ * \returns the name of the method at address \p ip.
*/
G_GNUC_UNUSED char *
mono_pmip (void *ip)
}
/**
- * mono_print_method_from_ip
- * @ip: an instruction pointer address
+ * mono_print_method_from_ip:
+ * \param ip an instruction pointer address
*
* This method is used from a debugger to get the name of the
- * method at address @ip.
+ * method at address \p ip.
*
- * This prints the name of the method at address @ip in the standard
- * output. Unlike mono_pmip which returns a string, this routine
+ * This prints the name of the method at address \p ip in the standard
+ * output. Unlike \c mono_pmip which returns a string, this routine
* prints the value on the standard output.
*/
-#ifdef __GNUC__
-/* Prevent the linker from optimizing this away in embedding setups to help debugging */
- __attribute__ ((__used__))
-#endif
-void
+MONO_ATTR_USED void
mono_print_method_from_ip (void *ip)
{
MonoJitInfo *ji;
* INFO can be NULL.
* Frees INFO.
*/
-void
-mono_tramp_info_register (MonoTrampInfo *info, MonoDomain *domain)
+static void
+mono_tramp_info_register_internal (MonoTrampInfo *info, MonoDomain *domain, gboolean aot)
{
MonoTrampInfo *copy;
mono_lldb_save_trampoline_info (info);
#ifdef MONO_ARCH_HAVE_UNWIND_TABLE
- mono_arch_unwindinfo_install_tramp_unwind_info (info->unwind_ops, info->code, info->code_size);
+ if (!aot)
+ mono_arch_unwindinfo_install_tramp_unwind_info (info->unwind_ops, info->code, info->code_size);
#endif
/* Only register trampolines that have unwind infos */
mono_tramp_info_free (info);
}
+void
+mono_tramp_info_register (MonoTrampInfo *info, MonoDomain *domain)
+{
+ mono_tramp_info_register_internal (info, domain, FALSE);
+}
+
+void
+mono_aot_tramp_info_register (MonoTrampInfo *info, MonoDomain *domain)
+{
+ mono_tramp_info_register_internal (info, domain, TRUE);
+}
+
static void
mono_tramp_info_cleanup (void)
{
MonoLMF *
mono_get_lmf (void)
{
-#if defined(MONO_ARCH_ENABLE_MONO_LMF_VAR) && defined(HAVE_GET_TLS_ADDR)
- return (MonoLMF *)mono_tls_get_lmf ();
-#else
MonoJitTlsData *jit_tls;
if ((jit_tls = mono_tls_get_jit_tls ()))
* (the thread object allocation can trigger a collection).
*/
return NULL;
-#endif
}
MonoLMF **
void
mono_set_lmf (MonoLMF *lmf)
{
-#if defined(MONO_ARCH_ENABLE_MONO_LMF_VAR) && defined(HAVE_GET_TLS_ADDR)
- mono_tls_set_lmf (lmf);
-#else
(*mono_get_lmf_addr ()) = lmf;
-#endif
}
MonoJitTlsData*
/**
* mono_thread_abort:
- * @obj: exception object
- *
- * abort the thread, print exception information and stack trace
+ * \param obj exception object
+ * Abort the thread, print exception information and stack trace
*/
static void
mono_thread_abort (MonoObject *obj)
jit_tls->first_lmf = lmf;
- /*
- * We can have 2 configurations for accessing lmf.
- * We can use only the tls_lmf_addr variable, which will store the address of
- * jit_tls->lmf, or, if we have MONO_ARCH_ENABLE_MONO_LMF_VAR enabled, we can
- * use both tls_lmf_addr and tls_lmf variables (in this case we need to have
- * means of getting the address of a tls variable; this can be done always
- * when using __thread or, on osx, even when using pthread)
- */
-#if defined(MONO_ARCH_ENABLE_MONO_LMF_VAR) && defined(HAVE_GET_TLS_ADDR)
- /* jit_tls->lmf is unused */
- mono_tls_set_lmf (lmf);
- mono_set_lmf_addr (mono_tls_get_tls_addr (TLS_KEY_LMF));
-#else
mono_set_lmf_addr (&jit_tls->lmf);
jit_tls->lmf = lmf;
-#endif
#ifdef MONO_ARCH_HAVE_TLS_INIT
mono_arch_tls_init ();
}
static gpointer
-mono_jit_compile_method_with_opt (MonoMethod *method, guint32 opt, MonoError *error)
+mono_jit_compile_method_with_opt (MonoMethod *method, guint32 opt, gboolean jit_only, MonoError *error)
{
MonoDomain *target_domain, *domain = mono_domain_get ();
MonoJitInfo *info;
error_init (error);
#ifdef ENABLE_INTERPRETER
- if (mono_use_interpreter)
- return mono_interp_create_method_pointer (method, error);
+ if (mono_use_interpreter && !jit_only) {
+ code = mono_interp_create_method_pointer (method, error);
+ if (code)
+ return code;
+ }
#endif
if (mono_llvm_only)
{
gpointer code;
- code = mono_jit_compile_method_with_opt (method, mono_get_optimizations_for_method (method, default_opt), error);
+ code = mono_jit_compile_method_with_opt (method, mono_get_optimizations_for_method (method, default_opt), FALSE, error);
+ return code;
+}
+
+/*
+ * mono_jit_compile_method_jit_only:
+ *
+ * Compile METHOD using the JIT/AOT, even in interpreted mode.
+ */
+gpointer
+mono_jit_compile_method_jit_only (MonoMethod *method, MonoError *error)
+{
+ gpointer code;
+
+ code = mono_jit_compile_method_with_opt (method, mono_get_optimizations_for_method (method, default_opt), TRUE, error);
return code;
}
/**
* mono_jit_runtime_invoke:
- * @method: the method to invoke
- * @obj: this pointer
- * @params: array of parameter values.
- * @exc: Set to the exception raised in the managed method. If NULL, error is thrown instead.
- * If coop is enabled, this argument is ignored - all exceptoins are caught and propagated
- * through @error
- * @error: error or caught exception object
+ * \param method: the method to invoke
+ * \param obj: this pointer
+ * \param params: array of parameter values.
+ * \param exc: Set to the exception raised in the managed method.
+ * \param error: error or caught exception object
+ * If \p exc is NULL, \p error is thrown instead.
+ * If coop is enabled, \p exc argument is ignored -
+ * all exceptions are caught and propagated through \p error
*/
static MonoObject*
mono_jit_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObject **exc, MonoError *error)
}
if (callee) {
- compiled_method = mono_jit_compile_method_with_opt (callee, mono_get_optimizations_for_method (callee, default_opt), error);
+ compiled_method = mono_jit_compile_method (callee, error);
if (!compiled_method) {
g_assert (!mono_error_ok (error));
return NULL;
info->seq_points = g_hash_table_new_full (mono_aligned_addr_hash, NULL, NULL, mono_seq_point_info_free);
info->arch_seq_points = g_hash_table_new (mono_aligned_addr_hash, NULL);
info->jump_target_hash = g_hash_table_new (NULL, NULL);
+ mono_jit_code_hash_init (&info->interp_code_hash);
domain->runtime_info = info;
}
register_icall (mono_threads_state_poll, "mono_threads_state_poll", "void", FALSE);
#ifndef MONO_ARCH_NO_EMULATE_LONG_MUL_OPTS
- register_opcode_emulation (OP_LMUL, "__emul_lmul", "long long long", mono_llmult, "mono_llmult", TRUE);
+ register_opcode_emulation (OP_LMUL, "__emul_lmul", "long long long", mono_llmult, "mono_llmult", FALSE);
register_opcode_emulation (OP_LDIV, "__emul_ldiv", "long long long", mono_lldiv, "mono_lldiv", FALSE);
register_opcode_emulation (OP_LDIV_UN, "__emul_ldiv_un", "long long long", mono_lldiv_un, "mono_lldiv_un", FALSE);
register_opcode_emulation (OP_LREM, "__emul_lrem", "long long long", mono_llrem, "mono_llrem", FALSE);
register_icall_no_wrapper (mono_tls_get_thread, "mono_tls_get_thread", "ptr");
register_icall_no_wrapper (mono_tls_get_jit_tls, "mono_tls_get_jit_tls", "ptr");
register_icall_no_wrapper (mono_tls_get_domain, "mono_tls_get_domain", "ptr");
- register_icall_no_wrapper (mono_tls_get_lmf, "mono_tls_get_lmf", "ptr");
register_icall_no_wrapper (mono_tls_get_sgen_thread_info, "mono_tls_get_sgen_thread_info", "ptr");
register_icall_no_wrapper (mono_tls_get_lmf_addr, "mono_tls_get_lmf_addr", "ptr");
register_icall_no_wrapper (mono_tls_set_thread, "mono_tls_set_thread", "void ptr");
register_icall_no_wrapper (mono_tls_set_jit_tls, "mono_tls_set_jit_tls", "void ptr");
register_icall_no_wrapper (mono_tls_set_domain, "mono_tls_set_domain", "void ptr");
- register_icall_no_wrapper (mono_tls_set_lmf, "mono_tls_set_lmf", "void ptr");
register_icall_no_wrapper (mono_tls_set_sgen_thread_info, "mono_tls_set_sgen_thread_info", "void ptr");
register_icall_no_wrapper (mono_tls_set_lmf_addr, "mono_tls_set_lmf_addr", "void ptr");
}
/**
* mono_get_runtime_build_info:
- *
- * Return the runtime version + build date in string format.
* The returned string is owned by the caller. The returned string
- * format is "VERSION (FULL_VERSION BUILD_DATE)" and build date is optional.
+ * format is <code>VERSION (FULL_VERSION BUILD_DATE)</code> and build date is optional.
+ * \returns the runtime version + build date in string format.
*/
char*
mono_get_runtime_build_info (void)