diff options
author | Andy Wingo <wingo@pobox.com> | 2010-01-09 16:42:27 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2010-01-09 16:43:26 +0100 |
commit | 6f16379e9a8d1f2d10c648793582a10772f29e32 (patch) | |
tree | 895e04e9865e359245c7c372ab5b9e7d4afad9f7 /libguile/programs.h | |
parent | 75c3ed282029f4d2a80adf75f52ec1b9b34edcb7 (diff) | |
download | guile-6f16379e9a8d1f2d10c648793582a10772f29e32.tar.gz |
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.
Diffstat (limited to 'libguile/programs.h')
-rw-r--r-- | libguile/programs.h | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/libguile/programs.h b/libguile/programs.h index 61b76a9bf..15457344c 100644 --- a/libguile/programs.h +++ b/libguile/programs.h @@ -33,7 +33,10 @@ #define SCM_PROGRAM_P(x) (!SCM_IMP (x) && SCM_TYP7(x) == scm_tc7_program) #define SCM_PROGRAM_OBJCODE(x) (SCM_CELL_OBJECT_1 (x)) #define SCM_PROGRAM_OBJTABLE(x) (SCM_CELL_OBJECT_2 (x)) -#define SCM_PROGRAM_FREE_VARIABLES(x) (SCM_CELL_OBJECT_3 (x)) +#define SCM_PROGRAM_FREE_VARIABLES(x) (SCM_CELL_OBJECT_LOC (x, 3)) +#define SCM_PROGRAM_FREE_VARIABLE_REF(x,i) (SCM_PROGRAM_FREE_VARIABLES (x)[i]) +#define SCM_PROGRAM_FREE_VARIABLE_SET(x,i,v) (SCM_PROGRAM_FREE_VARIABLES (x)[i]=(v)) +#define SCM_PROGRAM_NUM_FREE_VARIABLES(x) (SCM_CELL_WORD_0 (x) >> 16) #define SCM_PROGRAM_DATA(x) (SCM_OBJCODE_DATA (SCM_PROGRAM_OBJCODE (x))) #define SCM_VALIDATE_PROGRAM(p,x) SCM_MAKE_VALIDATE (p, x, PROGRAM_P) #define SCM_PROGRAM_IS_BOOT(x) (SCM_CELL_WORD_0 (x) & SCM_F_PROGRAM_IS_BOOT) @@ -53,7 +56,9 @@ SCM_API SCM scm_program_properties (SCM program); SCM_API SCM scm_program_name (SCM program); SCM_API SCM scm_program_objects (SCM program); SCM_API SCM scm_program_module (SCM program); -SCM_API SCM scm_program_free_variables (SCM program); +SCM_API SCM scm_program_num_free_variables (SCM program); +SCM_API SCM scm_program_free_variable_ref (SCM program, SCM i); +SCM_API SCM scm_program_free_variable_set_x (SCM program, SCM i, SCM x); SCM_API SCM scm_program_objcode (SCM program); SCM_API SCM scm_c_program_source (SCM program, size_t ip); |