/* This points to the current acfg in LLVM mode */
static MonoAotCompile *llvm_acfg;
+static MonoAotCompile *current_acfg;
/* Cache of decoded method external icall symbol names. */
/* Owned by acfg, but kept in this static as well since it is */
return TRUE;
}
+gboolean
+mono_aot_can_enter_interp (MonoMethod *method)
+{
+ MonoAotCompile *acfg = current_acfg;
+
+ g_assert (acfg);
+ if (acfg->aot_opts.profile_only && !g_hash_table_lookup (acfg->profile_methods, method))
+ return TRUE;
+ return FALSE;
+}
+
static void
add_wrappers (MonoAotCompile *acfg)
{
if (method->wrapper_type == MONO_WRAPPER_COMINTEROP)
return;
- if (acfg->aot_opts.profile_only && !method->is_inflated && !g_hash_table_lookup (acfg->profile_methods, method))
- return;
+ if (acfg->aot_opts.profile_only && !g_hash_table_lookup (acfg->profile_methods, method)) {
+ if (acfg->aot_opts.llvm_only) {
+ /* Keep wrappers */
+ if (!method->wrapper_type)
+ return;
+ WrapperInfo *info = mono_marshal_get_wrapper_info (method);
+ switch (info->subtype) {
+ case WRAPPER_SUBTYPE_PTR_TO_STRUCTURE:
+ case WRAPPER_SUBTYPE_STRUCTURE_TO_PTR:
+ return;
+ default:
+ break;
+ }
+ } else {
+ if (!method->is_inflated)
+ return;
+ }
+ }
mono_atomic_inc_i32 (&acfg->stats.mcount);
acfg->plt_offset = 1;
add_preinit_got_slots (acfg);
+ current_acfg = acfg;
+
#ifdef ENABLE_LLVM
if (acfg->llvm) {
llvm_acfg = acfg;
/* We only collected methods from this assembly */
return 0;
+ current_acfg = NULL;
+
return emit_aot_image (acfg);
}
return 0;
}
+gboolean
+mono_aot_can_enter_interp (MonoMethod *method)
+{
+ return FALSE;
+}
+
#endif
int mono_aot_get_method_index (MonoMethod *method) MONO_LLVM_INTERNAL;
MonoJumpInfo* mono_aot_patch_info_dup (MonoJumpInfo* ji) MONO_LLVM_INTERNAL;
gboolean mono_aot_can_specialize (MonoMethod *method) MONO_LLVM_INTERNAL;
+gboolean mono_aot_can_enter_interp (MonoMethod *method) MONO_LLVM_INTERNAL;
#endif
-
-
-
-
#include "llvmonly-runtime.h"
#include "mini-llvm.h"
#include "jit-icalls.h"
+#include "aot-compiler.h"
#include <mono/metadata/abi-details.h>
#include <mono/metadata/class-abi-details.h>
#include <mono/utils/mono-utils-debug.h>
{
if (method->wrapper_type)
return FALSE;
- /* Virtual calls from corlib can go outside corlib */
- if ((m_class_get_image (method->klass) == m_class_get_image (cfg->method->klass)) && !virtual_)
- return FALSE;
+
+ if (m_class_get_image (method->klass) == m_class_get_image (cfg->method->klass)) {
+ /* When using AOT profiling, the method might not be AOTed */
+ if (cfg->compile_aot && mono_aot_can_enter_interp (method))
+ return TRUE;
+ /* Virtual calls from corlib can go outside corlib */
+ if (!virtual_)
+ return FALSE;
+ }
/* See needs_extra_arg () in mini-llvm.c */
if (method->string_ctor)