mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-17 09:10:22 +02:00
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.
This commit is contained in:
parent
9174596d5b
commit
75c3ed2820
5 changed files with 399 additions and 479 deletions
|
@ -48,23 +48,27 @@ static scm_i_pthread_mutex_t props_lock = SCM_I_PTHREAD_MUTEX_INITIALIZER;
|
|||
int
|
||||
scm_i_procedure_arity (SCM proc, int *req, int *opt, int *rest)
|
||||
{
|
||||
if (SCM_IMP (proc))
|
||||
return 0;
|
||||
loop:
|
||||
switch (SCM_TYP7 (proc))
|
||||
while (!SCM_PROGRAM_P (proc))
|
||||
{
|
||||
case scm_tc7_program:
|
||||
return scm_i_program_arity (proc, req, opt, rest);
|
||||
case scm_tc7_smob:
|
||||
return scm_i_smob_arity (proc, req, opt, rest);
|
||||
case scm_tcs_struct:
|
||||
if (!SCM_STRUCT_APPLICABLE_P (proc))
|
||||
if (SCM_IMP (proc))
|
||||
return 0;
|
||||
proc = SCM_STRUCT_PROCEDURE (proc);
|
||||
goto loop;
|
||||
default:
|
||||
return 0;
|
||||
switch (SCM_TYP7 (proc))
|
||||
{
|
||||
case scm_tc7_smob:
|
||||
if (!SCM_SMOB_APPLICABLE_P (proc))
|
||||
return 0;
|
||||
proc = scm_i_smob_apply_trampoline (proc);
|
||||
break;
|
||||
case scm_tcs_struct:
|
||||
if (!SCM_STRUCT_APPLICABLE_P (proc))
|
||||
return 0;
|
||||
proc = SCM_STRUCT_PROCEDURE (proc);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return scm_i_program_arity (proc, req, opt, rest);
|
||||
}
|
||||
|
||||
/* FIXME: instead of the weak hash, perhaps for some kinds of procedures, use
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue