@@ -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
@@ -8556,13 +8559,15 @@ interp_mark_stack (gpointer thread_data, GcScanFunc func, gpointer gc_data, gboo
85568559 if (!context || !context - > stack_start )
85578560 return ;
85588561
8559- MonoLMF * * lmf_addr = (MonoLMF * * )info - > tls [TLS_KEY_LMF_ADDR ];
8560- if (lmf_addr )
8561- interp_mark_no_ref_slots (context , * lmf_addr );
8562+ if (mono_interp_opt & INTERP_OPT_PRECISE_GC ) {
8563+ MonoLMF * * lmf_addr = (MonoLMF * * )info - > tls [TLS_KEY_LMF_ADDR ];
8564+ if (lmf_addr )
8565+ interp_mark_no_ref_slots (context , * lmf_addr );
8566+ }
85628567
85638568 int slot_index = 0 ;
85648569 for (gpointer * p = (gpointer * )context - > stack_start ; p < (gpointer * )context - > stack_pointer ; p + + ) {
8565- if (context - > no_ref_slots [slot_index / 8 ] & (1 << (slot_index % 8 )))
8570+ if (context - > no_ref_slots && ( context - > no_ref_slots [slot_index / 8 ] & (1 << (slot_index % 8 ) )))
85668571 ;// This slot is marked as no ref, we don't scan it
85678572 else
85688573 func (p , gc_data );
0 commit comments