mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-01-05 08:50:49 -08:00
The garbage collector and the finalizer routines should not distort the lisp environment in which they were invoked.
This commit is contained in:
parent
19be68f9bc
commit
4dcf2dd604
3 changed files with 19 additions and 4 deletions
|
|
@ -32,9 +32,10 @@ struct typemanager tm_table[(int)t_end];
|
|||
static void
|
||||
finalize(cl_object o, cl_object data)
|
||||
{
|
||||
CL_NEWENV_BEGIN {
|
||||
switch (type_of(o)) {
|
||||
#ifdef ENABLE_DLOPEN
|
||||
case t_codeblock:
|
||||
case t_codeblock: {
|
||||
cl_mapc(2, @'si::unlink-symbol', o->cblock.links);
|
||||
if (o->cblock.handle != NULL) {
|
||||
printf("\n;;; Freeing library %s\n", o->cblock.name?
|
||||
|
|
@ -46,13 +47,14 @@ finalize(cl_object o, cl_object data)
|
|||
#endif
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
case t_stream:
|
||||
if (o->stream.file != NULL)
|
||||
fclose(o->stream.file);
|
||||
o->stream.file = NULL;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
default:}
|
||||
} CL_NEWENV_END;
|
||||
}
|
||||
|
||||
cl_object
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
#include "ecl.h"
|
||||
#include "page.h"
|
||||
#include "internal.h"
|
||||
#include "bytecodes.h"
|
||||
|
||||
#ifndef GBC_BOEHM
|
||||
|
||||
|
|
@ -331,7 +332,7 @@ BEGIN:
|
|||
mark_object(x->bytecodes.lex);
|
||||
mark_object(x->bytecodes.specials);
|
||||
mark_object(x->bytecodes.definition);
|
||||
mark_contblock(x->bytecodes.code, x->bytecodes.code_size);
|
||||
mark_contblock(x->bytecodes.code, x->bytecodes.code_size * sizeof(cl_opcode));
|
||||
p = x->bytecodes.data;
|
||||
i = x->bytecodes.data_size;
|
||||
goto MARK_DATA;
|
||||
|
|
@ -692,6 +693,8 @@ ecl_gc(cl_type t)
|
|||
if (!GC_enabled())
|
||||
return;
|
||||
|
||||
CL_SAVE_ENVIRONMENT;
|
||||
|
||||
if (SYM_VAL(@'si::*gc-verbose*') != Cnil) {
|
||||
printf("\n[GC ..");
|
||||
/* To use this should add entries in tm_table for reloc and contig.
|
||||
|
|
@ -827,6 +830,8 @@ ecl_gc(cl_type t)
|
|||
if (GC_exit_hook != NULL)
|
||||
(*GC_exit_hook)();
|
||||
|
||||
CL_RESTORE_ENVIRONMENT;
|
||||
|
||||
#ifdef THREADS
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -231,6 +231,14 @@ extern cl_object lex_env;
|
|||
* HIGH LEVEL CONTROL STRUCTURES *
|
||||
*********************************/
|
||||
|
||||
#define CL_NEWENV_BEGIN {\
|
||||
int __i = cl_stack_push_values(); \
|
||||
cl_object __env = lex_env;
|
||||
|
||||
#define CL_NEWENV_END \
|
||||
cl_stack_pop_values(__i); \
|
||||
lex_env = __env; }
|
||||
|
||||
#define CL_UNWIND_PROTECT_BEGIN {\
|
||||
bool __unwinding; frame_ptr __next_fr; \
|
||||
cl_index __nr; \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue