summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libguile/vm.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/libguile/vm.c b/libguile/vm.c
index 8ca2ada6e..9e5e9dbe6 100644
--- a/libguile/vm.c
+++ b/libguile/vm.c
@@ -268,7 +268,7 @@ static SCM make_u8vector (const scm_t_uint8 *bytes, size_t len)
}
static SCM
-vm_make_boot_program (long nargs)
+really_make_boot_program (long nargs)
{
scm_byte_t bytes[] = {0, 0, 0, 0,
0, 0, 0, 0,
@@ -280,6 +280,24 @@ vm_make_boot_program (long nargs)
return scm_make_program (scm_bytecode_to_objcode (make_u8vector (bytes, sizeof(bytes))),
SCM_BOOL_F, SCM_EOL);
}
+#define NUM_BOOT_PROGS 8
+static SCM
+vm_make_boot_program (long nargs)
+{
+ static SCM programs[NUM_BOOT_PROGS] = { 0, };
+
+ if (SCM_UNLIKELY (!programs[0]))
+ {
+ int i;
+ for (i = 0; i < NUM_BOOT_PROGS; i++)
+ programs[i] = scm_permanent_object (really_make_boot_program (i));
+ }
+
+ if (SCM_LIKELY (nargs < NUM_BOOT_PROGS))
+ return programs[nargs];
+ else
+ return really_make_boot_program (nargs);
+}
/*