summaryrefslogtreecommitdiff
path: root/libguile/gsubr.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2016-06-24 14:15:38 +0200
committerAndy Wingo <wingo@pobox.com>2016-06-24 14:15:38 +0200
commitd848af9a161b0c37964d582dfb8b52ed5112355f (patch)
tree6a5fb67950693dca72b61e0ed6872ec14b6fe47a /libguile/gsubr.c
parent5ca24b6ba1bc617e60a0a9b2ecad7f112e99ef9c (diff)
downloadguile-d848af9a161b0c37964d582dfb8b52ed5112355f.tar.gz
Parse bytecode to determine minimum arity
* libguile/programs.c (try_parse_arity): New helper, to parse bytecode to determine the minimum arity of a function in a cheaper way than grovelling through the debug info. Should speed up all thunk? checks and similar. (scm_i_program_arity): Simplify. * libguile/gsubr.h: * libguile/gsubr.c (scm_i_primitive_arity): * libguile/foreign.h: * libguile/foreign.c (scm_i_foreign_arity):
Diffstat (limited to 'libguile/gsubr.c')
-rw-r--r--libguile/gsubr.c31
1 files changed, 0 insertions, 31 deletions
diff --git a/libguile/gsubr.c b/libguile/gsubr.c
index d80e5dd42..b456b220a 100644
--- a/libguile/gsubr.c
+++ b/libguile/gsubr.c
@@ -262,37 +262,6 @@ scm_i_primitive_code_p (const scm_t_uint32 *code)
return 1;
}
-/* Given a program that is a primitive, determine its minimum arity.
- This is possible because each primitive's code is 4 32-bit words
- long, and they are laid out contiguously in an ordered pattern. */
-int
-scm_i_primitive_arity (SCM prim, int *req, int *opt, int *rest)
-{
- const scm_t_uint32 *code = SCM_PROGRAM_CODE (prim);
- unsigned idx, nargs, base, next;
-
- if (!scm_i_primitive_code_p (code))
- return 0;
-
- idx = (code - subr_stub_code) / 4;
-
- nargs = -1;
- next = 0;
- do
- {
- base = next;
- nargs++;
- next = (nargs + 1) * (nargs + 1);
- }
- while (idx >= next);
-
- *rest = (next - idx) < (idx - base);
- *req = *rest ? (next - 1) - idx : (base + nargs) - idx;
- *opt = *rest ? idx - (next - nargs) : idx - base;
-
- return 1;
-}
-
scm_t_uintptr
scm_i_primitive_call_ip (SCM subr)
{