Skip to content

Commit

Permalink
[profiler] Fix finding methods in other domains than the current one.
Browse files Browse the repository at this point in the history
In certain cross-domain scenarios, the method we're executing
is not necessarily emitted in the current domain. So we need
to scan all domains for it.
  • Loading branch information
Alex Rønne Petersen committed Mar 19, 2015
1 parent 73bd556 commit 954ddf4
Showing 1 changed file with 31 additions and 7 deletions.
38 changes: 31 additions & 7 deletions mono/profiler/proflog.c
Original file line number Diff line number Diff line change
Expand Up @@ -592,22 +592,46 @@ emit_method_inner (LogBuffer *logbuffer, void *method)
assert (logbuffer->data <= logbuffer->data_end);
}

typedef struct {
MonoMethod *method;
MonoJitInfo *found;
} MethodSearch;

static void
find_method (MonoDomain *domain, void *user_data)
{
MethodSearch *search = user_data;

if (search->found)
return;

MonoJitInfo *ji = mono_get_jit_info_from_method (domain, search->method);

// It could be AOT'd, so we need to force it to be loaded.
if (!ji) {
// Loads the method as a side effect.
mono_aot_get_method (domain, search->method);

ji = mono_get_jit_info_from_method (domain, search->method);
}

if (ji)
search->found = ji;
}

static void
register_method_local (MonoProfiler *prof, MonoDomain *domain, MonoMethod *method, MonoJitInfo *ji)
{
if (!domain)
g_assert (ji);

if (!mono_conc_hashtable_lookup (prof->method_table, method)) {
if (!ji)
ji = mono_get_jit_info_from_method (domain, method);

// It could be AOT'd, so we need to force it to be loaded.
if (!ji) {
// Loads the method as a side effect.
mono_aot_get_method (domain, method);
MethodSearch search = { method, NULL };

mono_domain_foreach (find_method, &search);

ji = mono_get_jit_info_from_method (domain, method);
ji = search.found;
}

g_assert (ji);
Expand Down

0 comments on commit 954ddf4

Please sign in to comment.