diff options
author | Andy Wingo <wingo@pobox.com> | 2008-09-09 07:15:01 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2008-09-09 07:15:01 +0200 |
commit | 8e3670748f86ae78cc59a628d9262ad165c1fae4 (patch) | |
tree | 0d8664dc797d21c0ee8f0dd945c5044efe576bdb /libguile/programs.c | |
parent | 7618201efd35d653b98d3c1036d65e36b2c6db53 (diff) | |
download | guile-8e3670748f86ae78cc59a628d9262ad165c1fae4.tar.gz |
rework late binding resolution to be simpler and more efficient
* libguile/programs.h (struct scm_program):
* libguile/programs.c (scm_c_make_program): Record the current module
when making a program. This replaces the per-late binding recorded
module in the generated code, which should be more efficient, both in
terms of garbage, and in not calling resolve-module.
(program-module): New accessor.
* module/system/vm/program.scm: Add program-module to exports.
* libguile/vm-i-loader.c (link-later): Remove this instruction, since now
the entry in the object table is just a symbol, and can be loaded with
load-symbol.
* libguile/vm-i-system.c (late-variable-ref, late-variable-set): Rework
so as to look up in the module of the current program. The logic could
be condensed quite a bit if scm_module_lookup () knew what to do with
mod==#f.
* module/system/vm/assemble.scm (dump-object!): Dump <vlink-later> just
as load-symbol, as mentioned in the note on link-later.
* module/system/il/ghil.scm: Update comment to reflect the new reality.
Diffstat (limited to 'libguile/programs.c')
-rw-r--r-- | libguile/programs.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libguile/programs.c b/libguile/programs.c index 436e2b863..1b3895ba2 100644 --- a/libguile/programs.c +++ b/libguile/programs.c @@ -46,6 +46,7 @@ #include <string.h> #include "vm-bootstrap.h" #include "instructions.h" +#include "modules.h" #include "programs.h" #include "vm.h" @@ -69,6 +70,7 @@ scm_c_make_program (void *addr, size_t size, SCM holder) p->objs = zero_vector; p->external = SCM_EOL; p->holder = holder; + p->module = scm_current_module (); /* If nobody holds bytecode's address, then allocate a new memory */ if (SCM_FALSEP (holder)) @@ -99,6 +101,7 @@ program_mark (SCM obj) scm_gc_mark (p->meta); scm_gc_mark (p->objs); scm_gc_mark (p->external); + scm_gc_mark (p->module); return p->holder; } @@ -184,6 +187,16 @@ SCM_DEFINE (scm_program_objects, "program-objects", 1, 0, 0, } #undef FUNC_NAME +SCM_DEFINE (scm_program_module, "program-module", 1, 0, 0, + (SCM program), + "") +#define FUNC_NAME s_scm_program_module +{ + SCM_VALIDATE_PROGRAM (1, program); + return SCM_PROGRAM_DATA (program)->module; +} +#undef FUNC_NAME + SCM_DEFINE (scm_program_external, "program-external", 1, 0, 0, (SCM program), "") |