Skip to content

Commit 076a17e

Browse files
committed
[mono][interp] Add option to disable precise scanning of stack
1 parent 08a4289 commit 076a17e

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

src/mono/mono/mini/interp/interp.c

+10-5
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,8 @@ get_context (void)
413413
context = g_new0 (ThreadContext, 1);
414414
context->stack_start = (guchar*)mono_valloc_aligned (INTERP_STACK_SIZE, MINT_STACK_ALIGNMENT, MONO_MMAP_READ | MONO_MMAP_WRITE, MONO_MEM_ACCOUNT_INTERP_STACK);
415415
// A bit for every pointer sized slot in the stack. FIXME don't allocate whole bit array
416-
context->no_ref_slots = (guchar*)mono_valloc (NULL, INTERP_STACK_SIZE / (8 * sizeof (gpointer)), MONO_MMAP_READ | MONO_MMAP_WRITE, MONO_MEM_ACCOUNT_INTERP_STACK);
416+
if (mono_interp_opt & INTERP_OPT_PRECISE_GC)
417+
context->no_ref_slots = (guchar*)mono_valloc (NULL, INTERP_STACK_SIZE / (8 * sizeof (gpointer)), MONO_MMAP_READ | MONO_MMAP_WRITE, MONO_MEM_ACCOUNT_INTERP_STACK);
417418
context->stack_end = context->stack_start + INTERP_STACK_SIZE - INTERP_REDZONE_SIZE;
418419
context->stack_real_end = context->stack_start + INTERP_STACK_SIZE;
419420
/* We reserve a stack slot at the top of the interp stack to make temp objects visible to GC */
@@ -8013,6 +8014,8 @@ interp_parse_options (const char *options)
80138014
#endif
80148015
else if (strncmp (arg, "ssa", 3) == 0)
80158016
opt = INTERP_OPT_SSA;
8017+
else if (strncmp (arg, "precise", 7) == 0)
8018+
opt = INTERP_OPT_PRECISE_GC;
80168019
else if (strncmp (arg, "all", 3) == 0)
80178020
opt = ~INTERP_OPT_NONE;
80188021

@@ -8558,13 +8561,15 @@ interp_mark_stack (gpointer thread_data, GcScanFunc func, gpointer gc_data, gboo
85588561
if (!context || !context->stack_start)
85598562
return;
85608563

8561-
MonoLMF **lmf_addr = (MonoLMF**)info->tls [TLS_KEY_LMF_ADDR];
8562-
if (lmf_addr)
8563-
interp_mark_no_ref_slots (context, *lmf_addr);
8564+
if (mono_interp_opt & INTERP_OPT_PRECISE_GC) {
8565+
MonoLMF **lmf_addr = (MonoLMF**)info->tls [TLS_KEY_LMF_ADDR];
8566+
if (lmf_addr)
8567+
interp_mark_no_ref_slots (context, *lmf_addr);
8568+
}
85648569

85658570
int slot_index = 0;
85668571
for (gpointer *p = (gpointer*)context->stack_start; p < (gpointer*)context->stack_pointer; p++) {
8567-
if (context->no_ref_slots [slot_index / 8] & (1 << (slot_index % 8)))
8572+
if (context->no_ref_slots && (context->no_ref_slots [slot_index / 8] & (1 << (slot_index % 8))))
85688573
;// This slot is marked as no ref, we don't scan it
85698574
else
85708575
func (p, gc_data);

src/mono/mono/mini/interp/interp.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ enum {
4242
INTERP_OPT_JITERPRETER = 64,
4343
#endif
4444
INTERP_OPT_SSA = 128,
45-
INTERP_OPT_DEFAULT = INTERP_OPT_INLINE | INTERP_OPT_CPROP | INTERP_OPT_SUPER_INSTRUCTIONS | INTERP_OPT_BBLOCKS | INTERP_OPT_TIERING | INTERP_OPT_SIMD | INTERP_OPT_SSA
45+
INTERP_OPT_PRECISE_GC = 256,
46+
INTERP_OPT_DEFAULT = INTERP_OPT_INLINE | INTERP_OPT_CPROP | INTERP_OPT_SUPER_INSTRUCTIONS | INTERP_OPT_BBLOCKS | INTERP_OPT_TIERING | INTERP_OPT_SIMD | INTERP_OPT_SSA | INTERP_OPT_PRECISE_GC
4647
#if HOST_BROWSER
4748
| INTERP_OPT_JITERPRETER
4849
#endif

src/mono/mono/mini/interp/transform.c

+3
Original file line numberDiff line numberDiff line change
@@ -8547,6 +8547,9 @@ interp_mark_ref_slots_for_vt (TransformData *td, int base_offset, MonoClass *kla
85478547
void
85488548
interp_mark_ref_slots_for_var (TransformData *td, int var)
85498549
{
8550+
if (!(mono_interp_opt & INTERP_OPT_PRECISE_GC))
8551+
return;
8552+
85508553
g_assert (td->vars [var].offset != -1);
85518554

85528555
gsize max_index = (td->vars [var].offset + td->vars [var].size) / sizeof (gpointer);

0 commit comments

Comments
 (0)