summaryrefslogtreecommitdiff
path: root/libguile/smob.h
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2010-01-09 14:12:47 +0100
committerAndy Wingo <wingo@pobox.com>2010-01-09 14:21:03 +0100
commit75c3ed282029f4d2a80adf75f52ec1b9b34edcb7 (patch)
tree1167bd621a5dda0a9466f4c0f51d6b363445d73d /libguile/smob.h
parent9174596d5bfc456d06f4cf74a7a67e9b2b09aac3 (diff)
downloadguile-75c3ed282029f4d2a80adf75f52ec1b9b34edcb7.tar.gz
smobs are applied with vm trampoline procedures
* libguile/smob.c: Instead of having special evaluator support for applying smobs, we use the same strategy that gsubr uses, that smob application should happen via a trampoline VM procedure, which uses a special opcode (smob-apply). So statically allocate all of the desired trampoline procedures here. (scm_i_smob_apply_trampoline): Unfortunately there's no real place to put the trampoline, so instead use a weak-key hash. It's nasty, but I think the benefits of speeding up procedure calls in the general case are worth it. * libguile/smob.h (scm_smob_descriptor): Remove fields apply_0, apply_1, apply_2, and apply_3; these were never public. Also remove the gsubr_type field. Instead cache the trampoline objcode here. (SCM_SMOB_APPLY_0, SCM_SMOB_APPLY_1, SCM_SMOB_APPLY_2, SCM_SMOB_APPLY_3): Just go through scm_call_0, etc here. * libguile/vm-i-system.c (call, tail-call, mv-call): Simplify. All procedure calls are VM calls now. (smob-call): New instruction, used in smob trampoline procedures. * libguile/vm.c (apply_foreign): Remove. Yay! * libguile/procprop.c (scm_i_procedure_arity): Refactor a bit for the smob changes.
Diffstat (limited to 'libguile/smob.h')
-rw-r--r--libguile/smob.h16
1 files changed, 6 insertions, 10 deletions
diff --git a/libguile/smob.h b/libguile/smob.h
index a79c39c9c..07deebd27 100644
--- a/libguile/smob.h
+++ b/libguile/smob.h
@@ -41,11 +41,7 @@ typedef struct scm_smob_descriptor
int (*print) (SCM exp, SCM port, scm_print_state *pstate);
SCM (*equalp) (SCM, SCM);
SCM (*apply) ();
- SCM (*apply_0) (SCM);
- SCM (*apply_1) (SCM, SCM);
- SCM (*apply_2) (SCM, SCM, SCM);
- SCM (*apply_3) (SCM, SCM, SCM, SCM);
- int gsubr_type; /* Used in procprop.c */
+ SCM apply_trampoline_objcode;
} scm_smob_descriptor;
@@ -170,10 +166,10 @@ while (0)
#define SCM_SMOB_PREDICATE(tag, obj) SCM_TYP16_PREDICATE (tag, obj)
#define SCM_SMOB_DESCRIPTOR(x) (scm_smobs[SCM_SMOBNUM (x)])
#define SCM_SMOB_APPLICABLE_P(x) (SCM_SMOB_DESCRIPTOR (x).apply)
-#define SCM_SMOB_APPLY_0(x) (SCM_SMOB_DESCRIPTOR (x).apply_0 (x))
-#define SCM_SMOB_APPLY_1(x, a1) (SCM_SMOB_DESCRIPTOR (x).apply_1 (x, (a1)))
-#define SCM_SMOB_APPLY_2(x, a1, a2) (SCM_SMOB_DESCRIPTOR (x).apply_2 (x, (a1), (a2)))
-#define SCM_SMOB_APPLY_3(x, a1, a2, rst) (SCM_SMOB_DESCRIPTOR (x).apply_3 (x, (a1), (a2), (rst)))
+#define SCM_SMOB_APPLY_0(x) (scm_call_0 (x))
+#define SCM_SMOB_APPLY_1(x, a1) (scm_call_1 (x, a1))
+#define SCM_SMOB_APPLY_2(x, a1, a2) (scm_call_2 (x, a1, a2))
+#define SCM_SMOB_APPLY_3(x, a1, a2, rst) (scm_call_3 (x, a1, a2, a3))
/* Maximum number of SMOB types. */
#define SCM_I_MAX_SMOB_TYPE_COUNT 256
@@ -217,7 +213,7 @@ SCM_API void scm_assert_smob_type (scm_t_bits tag, SCM val);
SCM_API SCM scm_make_smob (scm_t_bits tc);
-SCM_INTERNAL int scm_i_smob_arity (SCM proc, int *req, int *opt, int *rest);
+SCM_INTERNAL SCM scm_i_smob_apply_trampoline (SCM smob);
SCM_API void scm_smob_prehistory (void);