From fd4903870d93f44ffae042e10b5ec6975a2fe7b4 Mon Sep 17 00:00:00 2001 From: Lucas Meijer Date: Tue, 1 Jul 2014 13:07:15 +0200 Subject: Implement event callbacks to be used to profile the collector --- darwin_stop_world.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'darwin_stop_world.c') diff --git a/darwin_stop_world.c b/darwin_stop_world.c index a6b0a5c7..35a4ba7d 100644 --- a/darwin_stop_world.c +++ b/darwin_stop_world.c @@ -458,6 +458,8 @@ STATIC GC_bool GC_suspend_thread_list(thread_act_array_t act_list, int count, #endif /* !GC_NO_THREADS_DISCOVERY */ +extern GC_on_collection_event_proc GC_on_collection_event; + /* Caller holds allocation lock. */ GC_INNER void GC_stop_world(void) { @@ -540,6 +542,8 @@ GC_INNER void GC_stop_world(void) kern_result = thread_suspend(p->stop_info.mach_thread); if (kern_result != KERN_SUCCESS) ABORT("thread_suspend failed"); + if (GC_on_collection_event) + GC_on_collection_event(GC_EVENT_THREAD_UNSUSPENDED, (void *)p->stop_info.mach_thread); } } } @@ -654,6 +658,8 @@ GC_INNER void GC_start_world(void) if ((p->flags & FINISHED) == 0 && !p->thread_blocked && p->stop_info.mach_thread != my_thread) GC_thread_resume(p->stop_info.mach_thread); + if (GC_on_collection_event) + GC_on_collection_event(GC_EVENT_THREAD_UNSUSPENDED, (void *)p->stop_info.mach_thread); } } -- cgit v1.2.1 From 7cd987a1656fb2c9e38adc79027c1f0ef080f5df Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Sun, 17 May 2015 17:37:51 +0300 Subject: Fix logic/compile errors in "event callbacks" code (Darwin, Pthreads) * darwin_stop_world.c (GC_stop_world): Replace GC_EVENT_THREAD_UNSUSPENDED to GC_EVENT_THREAD_SUSPENDED. * pthread_stop_world.c (GC_on_collection_event): Declare. * pthread_stop_world.c (GC_suspend_all): Change type of "thread_id" local variable to pthread_t (or pid_t for Android) instead of int; fix "threadid" parameter to "thread_id" in GC_on_collection_event call; implement notification for NaCl target. * pthread_stop_world.c (GC_start_world): Declare "thread_id" local variable; implement notification for NaCl target. --- darwin_stop_world.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'darwin_stop_world.c') diff --git a/darwin_stop_world.c b/darwin_stop_world.c index 35a4ba7d..32b1ea64 100644 --- a/darwin_stop_world.c +++ b/darwin_stop_world.c @@ -543,7 +543,8 @@ GC_INNER void GC_stop_world(void) if (kern_result != KERN_SUCCESS) ABORT("thread_suspend failed"); if (GC_on_collection_event) - GC_on_collection_event(GC_EVENT_THREAD_UNSUSPENDED, (void *)p->stop_info.mach_thread); + GC_on_collection_event(GC_EVENT_THREAD_SUSPENDED, + (void *)p->stop_info.mach_thread); } } } -- cgit v1.2.1 From dcfbceb89f1d2dd9fa334467d19d5422fdc3e2ca Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Sun, 17 May 2015 18:23:52 +0300 Subject: Code refactoring of "event callbacks" functionality * alloc.c (GC_on_collection_event): Remove declaration (moved to gc_priv.h). * darwin_stop_world.c (GC_on_collection_event): Likewise. * pthread_stop_world.c (GC_on_collection_event): Likewise. * win32_threads.c (GC_on_collection_event): Likewise. * alloc.c (start_world): Rename to start_world_inner; inline it. * darwin_stop_world.c (GC_start_world): Wrap long code lines. * pthread_stop_world.c (GC_suspend_all, GC_start_world): Likewise. * win32_threads.c (GC_stop_world, GC_start_world): Likewise. * include/gc.h: Remove trailing space at EOLn. * include/private/gc_priv.h (GC_on_collection_event): Declare global variable (using GC_EXTERN). * misc.c (GC_on_collection_event): Add GC_INNER; replace NULL to 0. --- darwin_stop_world.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'darwin_stop_world.c') diff --git a/darwin_stop_world.c b/darwin_stop_world.c index 32b1ea64..2ef74af1 100644 --- a/darwin_stop_world.c +++ b/darwin_stop_world.c @@ -458,8 +458,6 @@ STATIC GC_bool GC_suspend_thread_list(thread_act_array_t act_list, int count, #endif /* !GC_NO_THREADS_DISCOVERY */ -extern GC_on_collection_event_proc GC_on_collection_event; - /* Caller holds allocation lock. */ GC_INNER void GC_stop_world(void) { @@ -660,7 +658,8 @@ GC_INNER void GC_start_world(void) p->stop_info.mach_thread != my_thread) GC_thread_resume(p->stop_info.mach_thread); if (GC_on_collection_event) - GC_on_collection_event(GC_EVENT_THREAD_UNSUSPENDED, (void *)p->stop_info.mach_thread); + GC_on_collection_event(GC_EVENT_THREAD_UNSUSPENDED, + (void *)p->stop_info.mach_thread); } } -- cgit v1.2.1