diff options
author | Andy Wingo <wingo@pobox.com> | 2010-01-06 20:11:33 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2010-01-07 23:49:25 +0100 |
commit | fd12a19a5e59afbd78ca67b1305c70bb1ecb724b (patch) | |
tree | 40e549e520e00d799afc8e3ee602b9dcc8f5bc5b /libguile/gsubr.h | |
parent | 97812f4d38b1077c87e8fde02b1d62da6a1a6a06 (diff) | |
download | guile-fd12a19a5e59afbd78ca67b1305c70bb1ecb724b.tar.gz |
subrs are now VM trampoline procedures
* libguile/_scm.h: Add foreign.h and programs.h to the private include
list, as snarfing subrs with static allocation now needs access to
some of their enums and macros.
* libguile/gsubr.c (create_gsubr): Instead of creating a tc7_gsubr
object, create a VM program with the call-subr opcode, so that the
representation of subrs is now gsubrs. CPP and elisp, together at
last.
(scm_subr_objcode_trampoline): New function, used by the SCM_DEFINE
snarf macro.
* libguile/gsubr.h (SCM_SUBR_META_INFO, SCM_SUBR_PROPS)
(SCM_SET_SUBR_GENERIC_LOC, SCM_SUBR_ARITY_TO_TYPE): Remove these
macros. They were never deprecated, but hopefully people aren't using
them.
(SCM_SUBRF, SCM_SUBR_NAME, SCM_SUBR_GENERIC, SCM_SET_SUBR_GENERIC):
Update to work on the new subr representation.
* libguile/objcodes.h (SCM_F_OBJCODE_IS_STATIC): New flag, indicates
that the "backing store" of the objcode is statically allocated.
* libguile/procprop.c (scm_sym_name): Define here instead of in gsubr.c.
* libguile/snarf.h (SCM_DEFINE): If we are doing static allocation,
statically allocate the foreign object, the object table, and the
program, and use some SCM_SNARF_INITtery to fix things up.
Unfortunately I have not been able to make this immutable. It might be
possible, though.
(SCM_IMMUTABLE_CELL, SCM_STATIC_DOUBLE_CELL, SCM_IMMUTABLE_FOREIGN):
(SCM_STATIC_SUBR_OBJVECT, SCM_STATIC_PROGRAM): New helper macros.
Diffstat (limited to 'libguile/gsubr.h')
-rw-r--r-- | libguile/gsubr.h | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/libguile/gsubr.h b/libguile/gsubr.h index 74a08a242..0f9d2acd9 100644 --- a/libguile/gsubr.h +++ b/libguile/gsubr.h @@ -3,7 +3,7 @@ #ifndef SCM_GSUBR_H #define SCM_GSUBR_H -/* Copyright (C) 1995,1996,1998,2000,2001, 2006, 2008, 2009 Free Software Foundation, Inc. +/* Copyright (C) 1995,1996,1998,2000,2001, 2006, 2008, 2009, 2010 Free Software Foundation, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -28,28 +28,24 @@ -/* Subrs - */ - -#define SCM_PRIMITIVE_P(x) (SCM_NIMP (x) && SCM_TYP7 (x) == scm_tc7_gsubr) -#define SCM_PRIMITIVE_GENERIC_P(x) (SCM_PRIMITIVE_P (x) && SCM_SUBR_GENERIC (x)) -#define SCM_SUBR_META_INFO(x) ((SCM *) SCM_CELL_WORD_3 (x)) -#define SCM_SUBR_NAME(x) (SCM_SUBR_META_INFO (x) [0]) -#define SCM_SUBRF(x) ((SCM (*)()) SCM_CELL_WORD_1 (x)) -#define SCM_SUBR_PROPS(x) (SCM_SUBR_META_INFO (x) [1]) -#define SCM_SUBR_GENERIC(x) ((SCM *) SCM_CELL_WORD_2 (x)) -#define SCM_SET_SUBR_GENERIC(x, g) (*((SCM *) SCM_CELL_WORD_2 (x)) = (g)) -#define SCM_SET_SUBR_GENERIC_LOC(x, g) (SCM_SET_CELL_WORD_2 (x, (scm_t_bits) g)) +SCM_API SCM scm_subr_objcode_trampoline (unsigned int nreq, + unsigned int nopt, + unsigned int rest); -/* Return the most suitable subr type for a subr with REQ required arguments, - OPT optional arguments, and REST (0 or 1) arguments. This has to be in - sync with `create_gsubr ()'. */ -#define SCM_SUBR_ARITY_TO_TYPE(req, opt, rest) \ - (scm_tc7_gsubr | (SCM_GSUBR_MAKTYPE (req, opt, rest) << 8U)) +/* Subrs + */ - +#define SCM_PRIMITIVE_P(x) (SCM_NIMP (x) && SCM_TYP7 (x) == scm_tc7_gsubr) +#define SCM_PRIMITIVE_GENERIC_P(x) (SCM_PROGRAM_P (x) && SCM_PROGRAM_IS_PRIMITIVE_GENERIC (x)) + +#define SCM_SUBRF(x) ((SCM (*)()) (SCM_FOREIGN_OBJECT (SCM_SIMPLE_VECTOR_REF (SCM_PROGRAM_OBJTABLE (x), 0), void*))) +#define SCM_SUBR_NAME(x) (SCM_SIMPLE_VECTOR_REF (SCM_PROGRAM_OBJTABLE (x), 1)) +#define SCM_SUBR_GENERIC(x) \ + (SCM_FOREIGN_OBJECT_REF (SCM_SIMPLE_VECTOR_REF (SCM_PROGRAM_OBJTABLE (x), 2), SCM*)) +#define SCM_SET_SUBR_GENERIC(x, g) \ + (*SCM_SUBR_GENERIC (x) = (g)) |