summaryrefslogtreecommitdiff
path: root/libguile/gsubr.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2013-10-18 17:41:33 +0200
committerAndy Wingo <wingo@pobox.com>2013-10-18 17:41:33 +0200
commitb0ca878cae82ebb2028783aff6e27352b70810d8 (patch)
tree8988b37ea611a6f748edf164f45b4968f1ac1e05 /libguile/gsubr.c
parentd724a36562357c86f2b4c21b46992abf9598b4d1 (diff)
downloadguile-b0ca878cae82ebb2028783aff6e27352b70810d8.tar.gz
Foreign procedures are RTL programs
* libguile/foreign.c: Convert to using RTL stubs. Because RTL code has different GC characteristics than objcode -- it's mostly assumed that RTL code will never go away -- we go ahead and pre-generate code for 100 arguments. This is actually less memory than the stack VM code, and doesn't require any relocations at load-time: bonus! We'll cross the >=100 args bridge if we ever come to it. (get_foreign_stub_code) New function. (scm_i_foreign_arity): New helper, like scm_i_primitive_arity. (cif_to_procedure): Rework to make RTL programs. * libguile/foreign.h: Declare scm_pointer_to_scm and scm_scm_to_pointer. Declare new internal helpers. * libguile/gsubr.c (create_subr): Refactor to set the flags when the object is allocated. * libguile/instructions.h: Define SCM_PACK_RTL_12_12. * libguile/programs.c (scm_i_rtl_program_minimum_arity): Dispatch to scm_i_foreign_arity if the procedure has the FOREIGN flag. * libguile/programs.h (SCM_F_PROGRAM_IS_FOREIGN) (SCM_PROGRAM_IS_FOREIGN): New interfaces. * test-suite/tests/foreign.test ("procedure->pointer"): Add a test for foreign arities.
Diffstat (limited to 'libguile/gsubr.c')
-rw-r--r--libguile/gsubr.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libguile/gsubr.c b/libguile/gsubr.c
index 4e061e340..5dd767df7 100644
--- a/libguile/gsubr.c
+++ b/libguile/gsubr.c
@@ -236,10 +236,10 @@ create_subr (int define, const char *name,
sname = scm_from_utf8_symbol (name);
- ret = scm_words (scm_tc7_rtl_program | (nfree << 16), nfree + 2);
flags = SCM_F_PROGRAM_IS_PRIMITIVE;
flags |= generic_loc ? SCM_F_PROGRAM_IS_PRIMITIVE_GENERIC : 0;
- SCM_SET_CELL_WORD_0 (ret, SCM_CELL_WORD_0 (ret) | flags);
+
+ ret = scm_words (scm_tc7_rtl_program | (nfree << 16) | flags, nfree + 2);
SCM_SET_CELL_WORD_1 (ret, get_subr_stub_code (nreq, nopt, rest));
SCM_RTL_PROGRAM_FREE_VARIABLE_SET (ret, 0, scm_from_pointer (fcn, NULL));
SCM_RTL_PROGRAM_FREE_VARIABLE_SET (ret, 1, sname);