summaryrefslogtreecommitdiff
path: root/pthread_stop_world.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2015-06-23 14:39:29 +0300
committerIvan Maidanski <ivmai@mail.ru>2015-06-23 14:39:29 +0300
commit9aaeaa329b4c6eb28b259b28887f8f779fc28591 (patch)
tree46e3701d493185b8b132be5af82ec6173b9baa1b /pthread_stop_world.c
parentda3c476ec9dfd1961d99d0066b226c62233bd37d (diff)
downloadbdwgc-9aaeaa329b4c6eb28b259b28887f8f779fc28591.tar.gz
Standalone profiling callback for threads suspend/resume
* alloc.c (GC_on_collection_event, GC_set_on_collection_event, GC_get_on_collection_event): Move from misc.c. * alloc.c (GC_on_collection_event): Make STATIC. * include/private/gc_priv.h (GC_on_collection_event): Remove declaration. * include/gc.h (GC_on_collection_event_proc): Remove 2nd argument of the callback. * alloc.c (GC_try_to_collect_inner, GC_stopped_mark): Likewise. * darwin_stop_world.c (GC_suspend_thread_list, GC_stop_world, GC_thread_resume): Use GC_on_thread_event instead of GC_on_collection_event. * pthread_stop_world.c (GC_suspend_all, GC_start_world): Likewise. * win32_threads.c (GC_suspend, GC_start_world): Likewise. * include/gc.h (GC_on_collection_event_proc): Update comment. * include/gc.h (GC_set_on_collection_event, GC_get_on_collection_event): Add comment. * include/gc.h (GC_on_thread_event_proc): New callback type (only if GC_THREADS). * include/gc.h (GC_set_on_thread_event, GC_get_on_thread_event): New API function declaration (only if GC_THREADS). * include/private/gc_priv.h (GC_on_thread_event): New variable declaration (only if THREADS). * misc.c (GC_on_thread_event): New global variable (only if THREADS). * misc.c (GC_set_on_thread_event, GC_get_on_thread_event): New API function (only if THREADS).
Diffstat (limited to 'pthread_stop_world.c')
-rw-r--r--pthread_stop_world.c33
1 files changed, 15 insertions, 18 deletions
diff --git a/pthread_stop_world.c b/pthread_stop_world.c
index 873b575f..9d046b4f 100644
--- a/pthread_stop_world.c
+++ b/pthread_stop_world.c
@@ -503,10 +503,9 @@ STATIC int GC_suspend_all(void)
if (pthread_stackseg_np(p->id, &stack))
ABORT("pthread_stackseg_np failed");
p -> stop_info.stack_ptr = (ptr_t)stack.ss_sp - stack.ss_size;
-
- if (GC_on_collection_event)
- GC_on_collection_event(GC_EVENT_THREAD_SUSPENDED,
- (void *)p->id);
+ if (GC_on_thread_event)
+ GC_on_thread_event(GC_EVENT_THREAD_SUSPENDED,
+ (void *)p->id);
}
# else
# ifndef PLATFORM_ANDROID
@@ -522,9 +521,9 @@ STATIC int GC_suspend_all(void)
n_live_threads--;
break;
case 0:
- if (GC_on_collection_event)
- GC_on_collection_event(GC_EVENT_THREAD_SUSPENDED,
- (void *)thread_id);
+ if (GC_on_thread_event)
+ GC_on_thread_event(GC_EVENT_THREAD_SUSPENDED,
+ (void *)thread_id);
break;
default:
ABORT_ARG1("pthread_kill failed at suspend",
@@ -565,9 +564,8 @@ STATIC int GC_suspend_all(void)
num_used++;
if (GC_nacl_thread_parked[i] == 1) {
num_threads_parked++;
- if (GC_on_collection_event)
- GC_on_collection_event(GC_EVENT_THREAD_SUSPENDED,
- (void *)(word)i);
+ if (GC_on_thread_event)
+ GC_on_thread_event(GC_EVENT_THREAD_SUSPENDED, (void *)(word)i);
}
}
}
@@ -844,9 +842,8 @@ GC_INNER void GC_start_world(void)
# ifdef GC_OPENBSD_UTHREADS
if (pthread_resume_np(p -> id) != 0)
ABORT("pthread_resume_np failed");
- if (GC_on_collection_event)
- GC_on_collection_event(GC_EVENT_THREAD_UNSUSPENDED,
- (void *)p->id);
+ if (GC_on_thread_event)
+ GC_on_thread_event(GC_EVENT_THREAD_UNSUSPENDED, (void *)p->id);
# else
# ifndef PLATFORM_ANDROID
thread_id = p -> id;
@@ -861,9 +858,9 @@ GC_INNER void GC_start_world(void)
n_live_threads--;
break;
case 0:
- if (GC_on_collection_event)
- GC_on_collection_event(GC_EVENT_THREAD_UNSUSPENDED,
- (void *)thread_id);
+ if (GC_on_thread_event)
+ GC_on_thread_event(GC_EVENT_THREAD_UNSUSPENDED,
+ (void *)thread_id);
break;
default:
ABORT_ARG1("pthread_kill failed at resume",
@@ -891,8 +888,8 @@ GC_INNER void GC_start_world(void)
GC_log_printf("World starting...\n");
# endif
GC_nacl_park_threads_now = 0;
- if (GC_on_collection_event)
- GC_on_collection_event(GC_EVENT_THREAD_UNSUSPENDED, NULL);
+ if (GC_on_thread_event)
+ GC_on_thread_event(GC_EVENT_THREAD_UNSUSPENDED, NULL);
/* TODO: Send event for every unsuspended thread. */
# endif
}