inline call to scm_make_program when making closures
* libguile/programs.c (scm_make_program): Add a comment. * libguile/vm-engine.h (INIT_ARGS): Add a couple of UNLIKELY notes. * libguile/vm-i-system.c (make-closure): Inline the call to scm_make_program, which avoids some redundant checks.
This commit is contained in:
parent
6d14383e86
commit
7edf200127
3 changed files with 10 additions and 5 deletions
|
|
@ -69,6 +69,12 @@ SCM_DEFINE (scm_make_program, "make-program", 1, 2, 0,
|
|||
if (SCM_UNLIKELY (SCM_UNBNDP (external)))
|
||||
external = SCM_EOL;
|
||||
else
|
||||
/* FIXME: currently this test is quite expensive (can be 2-3% of total
|
||||
execution time in programs that make many closures). We could remove it,
|
||||
yes, but we'd get much better gains if we used some other method, like
|
||||
just capturing the variables that we need instead of all heap-allocated
|
||||
variables. Dunno. Keeping the check for now, as it's a user-callable
|
||||
function, and inlining the op in the vm's make-closure operation. */
|
||||
SCM_VALIDATE_LIST (3, external);
|
||||
|
||||
SCM_RETURN_NEWSMOB3 (scm_tc16_program, objcode, objtable, external);
|
||||
|
|
|
|||
|
|
@ -363,7 +363,7 @@ do { \
|
|||
|
||||
#define INIT_ARGS() \
|
||||
{ \
|
||||
if (bp->nrest) \
|
||||
if (SCM_UNLIKELY (bp->nrest)) \
|
||||
{ \
|
||||
int n = nargs - (bp->nargs - 1); \
|
||||
if (n < 0) \
|
||||
|
|
@ -374,7 +374,7 @@ do { \
|
|||
} \
|
||||
else \
|
||||
{ \
|
||||
if (nargs != bp->nargs) \
|
||||
if (SCM_UNLIKELY (nargs != bp->nargs)) \
|
||||
goto vm_error_wrong_num_args; \
|
||||
} \
|
||||
}
|
||||
|
|
|
|||
|
|
@ -473,9 +473,8 @@ VM_DEFINE_INSTRUCTION (37, br_if_not_null, "br-if-not-null", 2, 0, 0)
|
|||
VM_DEFINE_INSTRUCTION (38, make_closure, "make-closure", 0, 1, 1)
|
||||
{
|
||||
SYNC_BEFORE_GC ();
|
||||
*sp = scm_make_program (SCM_PROGRAM_OBJCODE (*sp),
|
||||
SCM_PROGRAM_OBJTABLE (*sp),
|
||||
external);
|
||||
SCM_NEWSMOB3 (*sp, scm_tc16_program, SCM_PROGRAM_OBJCODE (*sp),
|
||||
SCM_PROGRAM_OBJTABLE (*sp), external);
|
||||
NEXT;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue