Skip to content

Commit 56a583e

Browse files
monojenkinsakoeplinger
authored andcommitted
[2019-10] [profiler] disable inlining when coverage profiler is used and fix allocation sizes (#17991)
* [profiler] let compiler decide about the size of an entry * [profiler] disable inlining when coverage profiler is used
1 parent 914ffea commit 56a583e

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

mono/metadata/profiler-private.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,14 @@ typedef struct {
9797

9898
extern MonoProfilerState mono_profiler_state;
9999

100+
typedef struct {
101+
guchar *cil_code;
102+
guint32 count;
103+
} MonoProfilerCoverageInfoEntry;
104+
100105
typedef struct {
101106
guint32 entries;
102-
struct {
103-
guchar *cil_code;
104-
guint32 count;
105-
} data [1];
107+
MonoProfilerCoverageInfoEntry data [MONO_ZERO_LEN_ARRAY];
106108
} MonoProfilerCoverageInfo;
107109

108110
void mono_profiler_started (void);

mono/metadata/profiler.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ mono_profiler_coverage_alloc (MonoMethod *method, guint32 entries)
435435

436436
coverage_lock ();
437437

438-
MonoProfilerCoverageInfo *info = g_malloc0 (sizeof (MonoProfilerCoverageInfo) + SIZEOF_VOID_P * 2 * entries);
438+
MonoProfilerCoverageInfo *info = g_malloc0 (sizeof (MonoProfilerCoverageInfo) + sizeof (MonoProfilerCoverageInfoEntry) * entries);
439439

440440
info->entries = entries;
441441

mono/mini/method-to-ir.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6004,6 +6004,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
60046004
gboolean emitted_funccall_seq_point = FALSE;
60056005

60066006
cfg->disable_inline = is_jit_optimizer_disabled (method);
6007+
cfg->current_method = method;
60076008

60086009
image = m_class_get_image (method->klass);
60096010

@@ -6048,6 +6049,8 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
60486049
if (cfg->compile_aot)
60496050
g_error ("Coverage profiling is not supported with AOT.");
60506051

6052+
INLINE_FAILURE ("coverage profiling");
6053+
60516054
cfg->coverage_info = mono_profiler_coverage_alloc (cfg->method, header->code_size);
60526055
}
60536056

@@ -6132,8 +6135,6 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
61326135
cfg->cil_offset_to_bb = (MonoBasicBlock **)mono_mempool_alloc0 (cfg->mempool, sizeof (MonoBasicBlock*) * header->code_size);
61336136
cfg->cil_offset_to_bb_len = header->code_size;
61346137

6135-
cfg->current_method = method;
6136-
61376138
if (cfg->verbose_level > 2)
61386139
printf ("method to IR %s\n", mono_method_full_name (method, TRUE));
61396140

0 commit comments

Comments
 (0)