diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2022-01-30 18:48:03 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2022-01-30 18:48:03 +0300 |
commit | e1bd7face3efbd1631e869ae87c4bbcc01c80862 (patch) | |
tree | a4784eb151f04857ca3cb36aa847f3b9d7ac5ed9 | |
parent | e3071e5b42ffdff14b37638dec4d73bcbc6ef381 (diff) | |
download | bdwgc-e1bd7face3efbd1631e869ae87c4bbcc01c80862.tar.gz |
Revert "Support malloc redirection on E2K (single-threaded mode only)"
This reverts commit 9027a0b429ad3f2f3f0eb77210f22c4a1d21ee4a.
There is a simpler solution (which also works for the multi-threaded case) - allocate the buffers on the stack.
-rw-r--r-- | include/private/gc_priv.h | 8 | ||||
-rw-r--r-- | include/private/gcconfig.h | 10 | ||||
-rw-r--r-- | mach_dep.c | 43 |
3 files changed, 10 insertions, 51 deletions
diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h index 70741b0b..25aa8175 100644 --- a/include/private/gc_priv.h +++ b/include/private/gc_priv.h @@ -1471,14 +1471,6 @@ struct _GC_arrays { # define GC_trace_addr GC_arrays._trace_addr ptr_t _trace_addr; # endif -# ifdef E2K_USE_SCRATCH -# define GC_e2k_ps_buffer GC_arrays._e2k_ps_buffer -# define GC_e2k_ps_capacity GC_arrays._e2k_ps_capacity - ptr_t _e2k_ps_buffer; - size_t _e2k_ps_capacity; - /* A buffer allocated by GC_scratch_alloc() and used repeatedly */ - /* by GC_get_procedure_stack() in the single-threaded mode. */ -# endif # define GC_capacity_heap_sects GC_arrays._capacity_heap_sects size_t _capacity_heap_sects; # define GC_n_heap_sects GC_arrays._n_heap_sects diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h index a0d13845..0a337dc5 100644 --- a/include/private/gcconfig.h +++ b/include/private/gcconfig.h @@ -2061,15 +2061,9 @@ EXTERN_C_BEGIN # ifdef LINUX extern int __dso_handle[]; # define DATASTART ((ptr_t)__dso_handle) -# ifdef REDIRECT_MALLOC -# if !defined(GC_LINUX_THREADS) -# define E2K_USE_SCRATCH -# elif !defined(CPPCHECK) -# error malloc redirection with threads is not supported on E2K yet -# endif -# elif !defined(THREAD_LOCAL_ALLOC) +# if !defined(REDIRECT_MALLOC) && !defined(THREAD_LOCAL_ALLOC) # define MPROTECT_VDB -# endif /* !REDIRECT_MALLOC && !THREAD_LOCAL_ALLOC */ +# endif # endif # endif /* E2K */ @@ -67,29 +67,15 @@ } while (0) GC_INNER void GC_free_procedure_stack(ptr_t buf) { -# ifdef E2K_USE_SCRATCH - GC_ASSERT(buf != NULL); - GC_ASSERT(NULL == GC_e2k_ps_buffer); - GC_e2k_ps_buffer = buf; /* the buffer could be reused */ -# else - free(buf); -# endif + free(buf); } GC_INNER size_t GC_get_procedure_stack(ptr_t *buf_ptr) { word ps; - ptr_t buf; - word buf_sz; + ptr_t buf = NULL; + word buf_sz = 0; word new_sz = 0; -# ifdef E2K_USE_SCRATCH - buf = GC_e2k_ps_buffer; - buf_sz = (word)GC_e2k_ps_capacity; - GC_e2k_ps_buffer = NULL; /* indicate the buffer is in use */ -# else - buf = NULL; - buf_sz = 0; -# endif get_stack_index(&ps); for (;;) { int res = syscall(__NR_access_hw_stacks, E2K_READ_PROCEDURE_STACK, @@ -97,22 +83,9 @@ if (res != -1) break; if (ENOMEM == errno && buf_sz != new_sz) { -# ifdef LOG_E2K_ALLOCS - GC_log_printf("GC_get_procedure_stack(): free/alloc %lu/%lu bytes," - " GC #%lu\n", - (unsigned long)buf_sz, (unsigned long)new_sz, - (unsigned long)GC_gc_no); -# endif -# ifdef E2K_USE_SCRATCH - GC_ASSERT(new_sz > (word)GC_e2k_ps_capacity); - GC_scratch_recycle_no_gww(buf, GC_e2k_ps_capacity); - buf = GC_scratch_alloc((size_t)new_sz); - GC_e2k_ps_capacity = (size_t)new_sz; - /* TODO: support malloc redirection if multi-threaded */ -# else - free(buf); - buf = malloc((size_t)new_sz); -# endif + /* FIXME: use GC_scratch_alloc to support malloc redirection? */ + free(buf); + buf = malloc((size_t)new_sz); if (NULL == buf) ABORT_ARG1("Could not allocate memory for procedure stack", ", %lu bytes requested", (unsigned long)new_sz); @@ -127,13 +100,13 @@ get_stack_index(&ps); } - if (buf_sz < new_sz) + if (buf_sz != new_sz) ABORT_ARG2("Buffer size mismatch while reading procedure stack", ": buf_sz= %lu, new_sz= %lu", (unsigned long)buf_sz, (unsigned long)new_sz); GC_ASSERT(buf != NULL); *buf_ptr = buf; - return (size_t)new_sz; + return (size_t)buf_sz; } ptr_t GC_save_regs_in_stack(void) { |