smobs are applied with vm trampoline procedures
authorAndy Wingo <wingo@pobox.com>
Sat, 9 Jan 2010 13:12:47 +0000 (14:12 +0100)
committerAndy Wingo <wingo@pobox.com>
Sat, 9 Jan 2010 13:21:03 +0000 (14:21 +0100)
commit75c3ed282029f4d2a80adf75f52ec1b9b34edcb7
tree1167bd621a5dda0a9466f4c0f51d6b363445d73d
parent9174596d5bfc456d06f4cf74a7a67e9b2b09aac3
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.
libguile/procprop.c
libguile/smob.c
libguile/smob.h
libguile/vm-i-system.c
libguile/vm.c