Skip to content

Commit

Permalink
[mono][sgen] Remove old code associated with domain unload (#84242)
Browse files Browse the repository at this point in the history
* [mono][sgen] Remove unused suspend finalizers functionality

* [mono][sgen] Remove threadpool shutdown logic

No longer used

* [mono][sgen] Remove logic associated with gc shutdown

* [mono][sgen] Remove logic for clearing handle stack during cleanup

* [mono][sgen] Remove code for xdomain checks

* [mono][sgen] Remove more code associated with finalization

* [mono][sgen] Remove code for freeing objects during domain unload

* [mono][sgen] Remove mono_gc_clear_domain

It is dead code
  • Loading branch information
BrzVlad authored Apr 4, 2023
1 parent e579ccb commit 25be848
Show file tree
Hide file tree
Showing 17 changed files with 15 additions and 696 deletions.
16 changes: 0 additions & 16 deletions src/mono/mono/metadata/boehm-gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,6 @@ mono_gc_base_init (void)
gc_initialized = TRUE;
}

void
mono_gc_base_cleanup (void)
{
GC_set_finalizer_notifier (NULL);
}

void
mono_gc_init_icalls (void)
{
Expand Down Expand Up @@ -893,16 +887,6 @@ mono_gc_wbarrier_object_copy_internal (MonoObject* obj, MonoObject *src)
m_class_get_instance_size (mono_object_class (obj)) - MONO_ABI_SIZEOF (MonoObject));
}

void
mono_gc_clear_domain (MonoDomain *domain)
{
}

void
mono_gc_suspend_finalizers (void)
{
}

int
mono_gc_get_suspend_signal (void)
{
Expand Down
5 changes: 0 additions & 5 deletions src/mono/mono/metadata/gc-internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ mono_object_register_finalizer_handle (MonoObjectHandle obj);

extern void mono_gc_init (void);
MONO_COMPONENT_API extern void mono_gc_base_init (void);
extern void mono_gc_base_cleanup (void);
extern void mono_gc_init_icalls (void);

/*
Expand Down Expand Up @@ -176,10 +175,6 @@ MONO_API int mono_gc_register_root (char *start, size_t size, MonoGCDescriptor
MONO_COMPONENT_API void mono_gc_deregister_root (char* addr);
void mono_gc_finalize_domain (MonoDomain *domain);
void mono_gc_run_finalize (void *obj, void *data);
void mono_gc_clear_domain (MonoDomain * domain);
/* Signal early termination of finalizer processing inside the gc */
void mono_gc_suspend_finalizers (void);


/*
* Register a root which can only be written using a write barrier.
Expand Down
30 changes: 0 additions & 30 deletions src/mono/mono/metadata/handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,36 +246,6 @@ mono_handle_stack_free (HandleStack *stack)
free_handle_stack (stack);
}

void
mono_handle_stack_free_domain (HandleStack *stack, MonoDomain *domain)
{
/* Called by the GC while clearing out objects of the given domain from the heap. */
/* If there are no handles-related bugs, there is nothing to do: if a
* thread accessed objects from the domain it was aborted, so any
* threads left alive cannot have any handles that point into the
* unloading domain. However if there is a handle leak, the handle stack is not */
if (!stack)
return;
/* Root domain only unloaded when mono is shutting down, don't need to check anything */
if (domain == mono_get_root_domain () || mono_runtime_is_shutting_down ())
return;
HandleChunk *cur = stack->bottom;
HandleChunk *last = stack->top;
if (!cur)
return;
while (cur) {
for (int idx = 0; idx < cur->size; ++idx) {
HandleChunkElem *elem = &cur->elems[idx];
if (!elem->o)
continue;
g_assert (mono_object_domain (elem->o) != domain);
}
if (cur == last)
break;
cur = cur->next;
}
}

static void
check_handle_stack_monotonic (HandleStack *stack)
{
Expand Down
1 change: 0 additions & 1 deletion src/mono/mono/metadata/handle.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ HandleStack* mono_handle_stack_alloc (void);
void mono_handle_stack_free (HandleStack *handlestack);
MonoRawHandle mono_stack_mark_pop_value (MonoThreadInfo *info, HandleStackMark *stackmark, MonoRawHandle value);
MONO_COMPONENT_API MonoThreadInfo* mono_stack_mark_record_size (MonoThreadInfo *info, HandleStackMark *stackmark, const char *func_name);
void mono_handle_stack_free_domain (HandleStack *stack, MonoDomain *domain);

#ifdef MONO_HANDLE_TRACK_SP
void mono_handle_chunk_leak_check (HandleStack *handles);
Expand Down
14 changes: 0 additions & 14 deletions src/mono/mono/metadata/monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -1108,20 +1108,6 @@ mono_monitor_exit (MonoObject *obj)
MONO_EXTERNAL_ONLY_VOID (mono_monitor_exit_internal (obj));
}

MonoGCHandle
mono_monitor_get_object_monitor_gchandle (MonoObject *object)
{
LockWord lw;

lw.sync = object->synchronisation;

if (lock_word_is_inflated (lw)) {
MonoThreadsSync *mon = lock_word_get_inflated_lock (lw);
return (MonoGCHandle)mon->data;
}
return NULL;
}

/*
* mono_monitor_threads_sync_member_offset:
* @status_offset: returns size and offset of the "status" member
Expand Down
3 changes: 0 additions & 3 deletions src/mono/mono/metadata/monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,6 @@ ICALL_EXPORT
guint32
mono_monitor_enter_v4_fast (MonoObject *obj, MonoBoolean *lock_taken);

MonoGCHandle
mono_monitor_get_object_monitor_gchandle (MonoObject *object);

void
mono_monitor_threads_sync_members_offset (int *status_offset, int *nest_offset);
#define MONO_THREADS_SYNC_MEMBER_OFFSET(o) ((o)>>8)
Expand Down
23 changes: 0 additions & 23 deletions src/mono/mono/metadata/sgen-client-mono.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,28 +205,6 @@ sgen_client_update_copied_object (char *destination, GCVTable gc_vtable, void *o
mono_sgen_register_moved_object (obj, destination);
}

#ifdef XDOMAIN_CHECKS_IN_WBARRIER
extern gboolean sgen_mono_xdomain_checks;

#define sgen_client_wbarrier_generic_nostore_check(ptr) do { \
/* FIXME: ptr_in_heap must be called with the GC lock held */ \
if (sgen_mono_xdomain_checks && *(MonoObject**)ptr && ptr_in_heap (ptr)) { \
char *start = find_object_for_ptr (ptr); \
MonoObject *value = *(MonoObject**)ptr; \
LOCK_GC; \
SGEN_ASSERT (0, start, "Write barrier outside an object?"); \
if (start) { \
MonoObject *obj = (MonoObject*)start; \
if (obj->vtable->domain != value->vtable->domain) \
SGEN_ASSERT (0, is_xdomain_ref_allowed (ptr, start, obj->vtable->domain), "Cross-domain ref not allowed"); \
} \
UNLOCK_GC; \
} \
} while (0)
#else
#define sgen_client_wbarrier_generic_nostore_check(ptr)
#endif

static gboolean G_GNUC_UNUSED
sgen_client_object_has_critical_finalizer (GCObject *obj)
{
Expand Down Expand Up @@ -738,7 +716,6 @@ gboolean sgen_is_managed_allocator (MonoMethod *method);
gboolean sgen_has_managed_allocator (void);
void sgen_disable_native_stack_scan (void);

void sgen_scan_for_registered_roots_in_domain (MonoDomain *domain, int root_type);
void sgen_null_links_for_domain (MonoDomain *domain);

#endif
Loading

0 comments on commit 25be848

Please sign in to comment.