Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions gc/mmtk/mmtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ struct objspace {
pthread_cond_t cond_world_started;
size_t start_the_world_count;

pthread_mutex_t event_hook_mutex;

struct {
bool gc_thread_crashed;
char crash_msg[256];
Expand Down Expand Up @@ -338,9 +340,9 @@ rb_mmtk_call_obj_free(MMTk_ObjectReference object)
struct objspace *objspace = rb_gc_get_objspace();

if (RB_UNLIKELY(rb_gc_event_hook_required_p(RUBY_INTERNAL_EVENT_FREEOBJ))) {
rb_gc_worker_thread_set_vm_context(&objspace->vm_context);
pthread_mutex_lock(&objspace->event_hook_mutex);
rb_gc_event_hook(obj, RUBY_INTERNAL_EVENT_FREEOBJ);
rb_gc_worker_thread_unset_vm_context(&objspace->vm_context);
pthread_mutex_unlock(&objspace->event_hook_mutex);
}

rb_gc_obj_free(objspace, obj);
Expand Down Expand Up @@ -579,6 +581,8 @@ rb_gc_impl_objspace_init(void *objspace_ptr)
objspace->mutex = (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER;
objspace->cond_world_stopped = (pthread_cond_t)PTHREAD_COND_INITIALIZER;
objspace->cond_world_started = (pthread_cond_t)PTHREAD_COND_INITIALIZER;

objspace->event_hook_mutex = (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER;
}

void
Expand Down
Loading