mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2025-12-06 02:40:26 -08:00
core: don't use gc allocator to allocate a runtime environment
When we don't use mprotect (nor guard page), we allocate the memory manually. This simplifies some code and makes the booting process less intervened with GC.
This commit is contained in:
parent
72af2d38b0
commit
868c3e4d31
2 changed files with 6 additions and 20 deletions
|
|
@ -1154,7 +1154,6 @@ update_bytes_consed () {
|
||||||
static void
|
static void
|
||||||
ecl_mark_env(struct cl_env_struct *env)
|
ecl_mark_env(struct cl_env_struct *env)
|
||||||
{
|
{
|
||||||
#if 1
|
|
||||||
if (env->stack) {
|
if (env->stack) {
|
||||||
GC_push_conditional((void *)env->stack, (void *)env->stack_top, 1);
|
GC_push_conditional((void *)env->stack, (void *)env->stack_top, 1);
|
||||||
GC_set_mark_bit((void *)env->stack);
|
GC_set_mark_bit((void *)env->stack);
|
||||||
|
|
@ -1167,16 +1166,8 @@ ecl_mark_env(struct cl_env_struct *env)
|
||||||
GC_push_conditional((void *)env->bds_org, (void *)(env->bds_top+1), 1);
|
GC_push_conditional((void *)env->bds_org, (void *)(env->bds_top+1), 1);
|
||||||
GC_set_mark_bit((void *)env->bds_org);
|
GC_set_mark_bit((void *)env->bds_org);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/*memset(env->values[env->nvalues], 0, (64-env->nvalues)*sizeof(cl_object));*/
|
|
||||||
#if defined(ECL_THREADS) && !defined(ECL_USE_MPROTECT) && !defined(ECL_USE_GUARD_PAGE)
|
|
||||||
/* When using threads, "env" is a pointer to memory allocated by ECL. */
|
|
||||||
GC_push_conditional((void *)env, (void *)(env + 1), 1);
|
|
||||||
GC_set_mark_bit((void *)env);
|
|
||||||
#else
|
|
||||||
/* When not using threads, "env" is mmaped or statically allocated. */
|
/* When not using threads, "env" is mmaped or statically allocated. */
|
||||||
GC_push_all((void *)env, (void *)(env + 1));
|
GC_push_all((void *)env, (void *)(env + 1));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
||||||
17
src/c/main.d
17
src/c/main.d
|
|
@ -222,24 +222,19 @@ ecl_init_env(cl_env_ptr env)
|
||||||
void
|
void
|
||||||
_ecl_dealloc_env(cl_env_ptr env)
|
_ecl_dealloc_env(cl_env_ptr env)
|
||||||
{
|
{
|
||||||
/*
|
/* Environment cleanup. This is required becauyse the environment is allocated
|
||||||
* Environment cleanup. This is only required when the environment is
|
* using mmap or some other method. We could do more cleaning here.*/
|
||||||
* allocated using mmap or some other method. We could do more, cleaning
|
|
||||||
* up stacks, etc, but we actually do not do it because that would need
|
|
||||||
* a lisp environment set up -- the allocator assumes one -- and we
|
|
||||||
* may have already cleaned up the value of ecl_process_env()
|
|
||||||
*/
|
|
||||||
#ifdef ECL_THREADS
|
#ifdef ECL_THREADS
|
||||||
ecl_mutex_destroy(&env->interrupt_struct->signal_queue_lock);
|
ecl_mutex_destroy(&env->interrupt_struct->signal_queue_lock);
|
||||||
#endif
|
#endif
|
||||||
#if defined(ECL_USE_MPROTECT)
|
#if defined(ECL_USE_MPROTECT)
|
||||||
if (munmap(env, sizeof(*env)))
|
if (munmap(env, sizeof(*env)))
|
||||||
ecl_internal_error("Unable to deallocate environment structure.");
|
ecl_internal_error("Unable to deallocate environment structure.");
|
||||||
#else
|
#elif defined(ECL_USE_GUARD_PAGE)
|
||||||
# if defined(ECL_USE_GUARD_PAGE)
|
|
||||||
if (!VirtualFree(env, 0, MEM_RELEASE))
|
if (!VirtualFree(env, 0, MEM_RELEASE))
|
||||||
ecl_internal_error("Unable to deallocate environment structure.");
|
ecl_internal_error("Unable to deallocate environment structure.");
|
||||||
# endif
|
#else
|
||||||
|
ecl_free_unsafe(env);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -270,7 +265,7 @@ _ecl_alloc_env(cl_env_ptr parent)
|
||||||
if (output == NULL)
|
if (output == NULL)
|
||||||
ecl_internal_error("Unable to allocate environment structure.");
|
ecl_internal_error("Unable to allocate environment structure.");
|
||||||
# else
|
# else
|
||||||
output = ecl_alloc(sizeof(*output));
|
output = ecl_malloc(sizeof(*output));
|
||||||
if (output == NULL)
|
if (output == NULL)
|
||||||
ecl_internal_error("Unable to allocate environment structure.");
|
ecl_internal_error("Unable to allocate environment structure.");
|
||||||
# endif
|
# endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue