mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-10 15:50:50 +02:00
More API-ification
This commit is contained in:
parent
4ccb489869
commit
d8bcbf2d74
5 changed files with 30 additions and 25 deletions
8
bdw.h
8
bdw.h
|
@ -211,7 +211,7 @@ static int gc_init(int argc, struct gc_option argv[],
|
|||
return 1;
|
||||
}
|
||||
|
||||
static struct mutator* initialize_gc_for_thread(uintptr_t *stack_base,
|
||||
static struct mutator* gc_init_for_thread(uintptr_t *stack_base,
|
||||
struct heap *heap) {
|
||||
pthread_mutex_lock(&heap->lock);
|
||||
if (!heap->multithreaded) {
|
||||
|
@ -224,13 +224,11 @@ static struct mutator* initialize_gc_for_thread(uintptr_t *stack_base,
|
|||
GC_register_my_thread(&base);
|
||||
return add_mutator(heap);
|
||||
}
|
||||
static void finish_gc_for_thread(struct mutator *mut) {
|
||||
static void gc_finish_for_thread(struct mutator *mut) {
|
||||
GC_unregister_my_thread();
|
||||
}
|
||||
|
||||
static void* call_without_gc(struct mutator *mut, void* (*f)(void*),
|
||||
void *data) NEVER_INLINE;
|
||||
static void* call_without_gc(struct mutator *mut,
|
||||
static void* gc_call_without_gc(struct mutator *mut,
|
||||
void* (*f)(void*),
|
||||
void *data) {
|
||||
return GC_do_blocking(f, data);
|
||||
|
|
11
gc-api.h
11
gc-api.h
|
@ -7,6 +7,9 @@
|
|||
#define GC_DEBUG 0
|
||||
#endif
|
||||
|
||||
#define GC_ALWAYS_INLINE __attribute__((always_inline))
|
||||
#define GC_NEVER_INLINE __attribute__((noinline))
|
||||
|
||||
#define GC_UNLIKELY(e) __builtin_expect(e, 0)
|
||||
#define GC_LIKELY(e) __builtin_expect(e, 1)
|
||||
|
||||
|
@ -52,7 +55,7 @@ struct gc_edge {
|
|||
static inline struct gc_edge gc_edge(void* addr) {
|
||||
return (struct gc_edge){addr};
|
||||
}
|
||||
static struct gc_ref gc_edge_ref(struct gc_edge edge) {
|
||||
static inline struct gc_ref gc_edge_ref(struct gc_edge edge) {
|
||||
return *edge.dst;
|
||||
}
|
||||
static inline void gc_edge_update(struct gc_edge edge, struct gc_ref ref) {
|
||||
|
@ -82,4 +85,10 @@ GC_API_ int gc_option_from_string(const char *str);
|
|||
GC_API_ int gc_init(int argc, struct gc_option argv[],
|
||||
struct heap **heap, struct mutator **mutator);
|
||||
|
||||
GC_API_ struct mutator* gc_init_for_thread(uintptr_t *stack_base,
|
||||
struct heap *heap);
|
||||
GC_API_ void gc_finish_for_thread(struct mutator *mut);
|
||||
GC_API_ void* gc_call_without_gc(struct mutator *mut, void* (*f)(void*),
|
||||
void *data) GC_NEVER_INLINE;
|
||||
|
||||
#endif // GC_API_H_
|
||||
|
|
|
@ -307,9 +307,9 @@ struct call_with_gc_data {
|
|||
};
|
||||
static void* call_with_gc_inner(uintptr_t *stack_base, void *arg) {
|
||||
struct call_with_gc_data *data = arg;
|
||||
struct mutator *mut = initialize_gc_for_thread(stack_base, data->heap);
|
||||
struct mutator *mut = gc_init_for_thread(stack_base, data->heap);
|
||||
void *ret = data->f(mut);
|
||||
finish_gc_for_thread(mut);
|
||||
gc_finish_for_thread(mut);
|
||||
return ret;
|
||||
}
|
||||
static void* call_with_gc(void* (*f)(struct mutator *),
|
||||
|
@ -434,7 +434,7 @@ int main(int argc, char *argv[]) {
|
|||
run_one_test(mut);
|
||||
for (size_t i = 1; i < nthreads; i++) {
|
||||
struct join_data data = { 0, threads[i] };
|
||||
call_without_gc(mut, join_thread, &data);
|
||||
gc_call_without_gc(mut, join_thread, &data);
|
||||
if (data.status) {
|
||||
errno = data.status;
|
||||
perror("Failed to join thread");
|
||||
|
|
6
semi.h
6
semi.h
|
@ -370,16 +370,16 @@ static int gc_init(int argc, struct gc_option argv[],
|
|||
return 1;
|
||||
}
|
||||
|
||||
static struct mutator* initialize_gc_for_thread(uintptr_t *stack_base,
|
||||
static struct mutator* gc_init_for_thread(uintptr_t *stack_base,
|
||||
struct heap *heap) {
|
||||
fprintf(stderr,
|
||||
"Semispace copying collector not appropriate for multithreaded use.\n");
|
||||
exit(1);
|
||||
}
|
||||
static void finish_gc_for_thread(struct mutator *space) {
|
||||
static void gc_finish_for_thread(struct mutator *space) {
|
||||
}
|
||||
|
||||
static void* call_without_gc(struct mutator *mut, void* (*f)(void*),
|
||||
static void* gc_call_without_gc(struct mutator *mut, void* (*f)(void*),
|
||||
void *data) {
|
||||
// Can't be threads, then there won't be collection.
|
||||
return f(data);
|
||||
|
|
|
@ -2079,7 +2079,7 @@ static int gc_init(int argc, struct gc_option argv[],
|
|||
return 1;
|
||||
}
|
||||
|
||||
static struct mutator* initialize_gc_for_thread(uintptr_t *stack_base,
|
||||
static struct mutator* gc_init_for_thread(uintptr_t *stack_base,
|
||||
struct heap *heap) {
|
||||
struct mutator *ret = calloc(1, sizeof(struct mutator));
|
||||
if (!ret)
|
||||
|
@ -2088,7 +2088,7 @@ static struct mutator* initialize_gc_for_thread(uintptr_t *stack_base,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static void finish_gc_for_thread(struct mutator *mut) {
|
||||
static void gc_finish_for_thread(struct mutator *mut) {
|
||||
remove_mutator(mutator_heap(mut), mut);
|
||||
mutator_mark_buf_destroy(&mut->mark_buf);
|
||||
free(mut);
|
||||
|
@ -2118,9 +2118,7 @@ static void reactivate_mutator(struct heap *heap, struct mutator *mut) {
|
|||
heap_unlock(heap);
|
||||
}
|
||||
|
||||
static void* call_without_gc(struct mutator *mut, void* (*f)(void*),
|
||||
void *data) NEVER_INLINE;
|
||||
static void* call_without_gc(struct mutator *mut,
|
||||
static void* gc_call_without_gc(struct mutator *mut,
|
||||
void* (*f)(void*),
|
||||
void *data) {
|
||||
struct heap *heap = mutator_heap(mut);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue