mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-14 15:40:19 +02:00
allocate free variables inline to closures
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump. * libguile/programs.h (SCM_PROGRAM_FREE_VARIABLES) (SCM_PROGRAM_FREE_VARIABLE_REF, SCM_PROGRAM_FREE_VARIABLE_SET) (SCM_PROGRAM_NUM_FREE_VARIABLES): * libguile/programs.c (scm_make_program, scm_program_num_free_variables) (scm_program_free_variable_ref, scm_program_free_variable_set_x): Allocate free variables inline with programs, instead of being in a vect. Should improve locality, and require fewer local variables in the VM. * libguile/vm-engine.c (vm_engine): Remove free_vars and free_vars_count variables. * libguile/vm-engine.h (CACHE_PROGRAM): No need to muck with free_vars and free_vars_count. (CHECK_FREE_VARIABLE): Update for inline free vars. * libguile/vm-i-system.c (FREE_VARIABLE_REF): Update for inline free vars. (make-closure, fix-closure): Take the closure vals as separate stack args, and copy or fix them inline into the appropriate closure. * module/language/objcode/spec.scm (program-free-variables): Define a local version of this removed function. * module/language/tree-il/compile-glil.scm (flatten): Adjust to not make a vector when making closures. * module/system/vm/program.scm: Export program-num-free-variables, program-free-variable-ref, program-free-variable-set!, and remove program-free-variables. * test-suite/tests/tree-il.test ("lambda"): Update to not make vectors when making closures.
This commit is contained in:
parent
75c3ed2820
commit
6f16379e9a
10 changed files with 114 additions and 56 deletions
|
@ -154,19 +154,6 @@
|
|||
object_count = 0; \
|
||||
} \
|
||||
} \
|
||||
{ \
|
||||
SCM c = SCM_PROGRAM_FREE_VARIABLES (program); \
|
||||
if (SCM_I_IS_VECTOR (c)) \
|
||||
{ \
|
||||
free_vars = SCM_I_VECTOR_WELTS (c); \
|
||||
free_vars_count = SCM_I_VECTOR_LENGTH (c); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
free_vars = NULL; \
|
||||
free_vars_count = 0; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#define SYNC_BEFORE_GC() \
|
||||
|
@ -193,8 +180,11 @@
|
|||
#endif
|
||||
|
||||
#if VM_CHECK_FREE_VARIABLES
|
||||
#define CHECK_FREE_VARIABLE(_num) \
|
||||
do { if (SCM_UNLIKELY ((_num) >= free_vars_count)) goto vm_error_free_variable; } while (0)
|
||||
#define CHECK_FREE_VARIABLE(_num) \
|
||||
do { \
|
||||
if (SCM_UNLIKELY ((_num) >= SCM_PROGRAM_NUM_FREE_VARIABLES (program))) \
|
||||
goto vm_error_free_variable; \
|
||||
} while (0)
|
||||
#else
|
||||
#define CHECK_FREE_VARIABLE(_num)
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue